6 Commits
Author SHA1 Message Date
timi 5f4c35cdd3 Merge pull request 'v1.1.1' (#8) from dev into master
Reviewed-on: #8
2026-11-11 17:27:20 +00:00
timi 35885b6e9d Merge pull request 'v1.1.0' (#7) from dev into master
Reviewed-on: #7
2026-11-11 16:18:39 +00:00
timi a0a978f58b Merge pull request 'v1.0.3' (#6) from dev into master
Reviewed-on: #6
2026-11-10 09:30:55 +00:00
timi 986f8c75db Merge pull request 'v1.0.2' (#5) from dev into master
Reviewed-on: #5
2026-11-07 17:59:18 +00:00
timi 13db8077f4 Merge pull request 'v1.0.2' (#4) from dev into master
Reviewed-on: #4
2026-11-07 17:50:22 +00:00
timi 7c8d2566d7 Merge pull request 'v1.0.1' (#3) from dev into master
Reviewed-on: #3
2026-11-06 09:33:01 +00:00
26 changed files with 52 additions and 438 deletions
-8
View File
@@ -35,14 +35,6 @@ export interface ComponentMeta {
} }
export const COMPONENT_LIST: ComponentMeta[] = [ export const COMPONENT_LIST: ComponentMeta[] = [
{
name: "TTimeline",
title: "Timeline 时间轴",
description: "按时间顺序展示事件。",
category: "布局组件",
entry: "src/components/timeline/index.vue",
slug: "timeline"
},
// ---------- 布局组件 ---------- // ---------- 布局组件 ----------
{ {
name: "PageTransition", name: "PageTransition",
-2
View File
@@ -61,8 +61,6 @@ async function onChangeTab(value: string) {
`AppShell` 只负责导航形态与容器尺寸,不接管路由。`v-model` 与 `change` 都只是把点击结果交回业务,跳不跳、跳去哪里由业务决定。 `AppShell` 只负责导航形态与容器尺寸,不接管路由。`v-model` 与 `change` 都只是把点击结果交回业务,跳不跳、跳去哪里由业务决定。
点击未禁用的左侧导航项时,`rail-click` 会传出该项的值,包括已激活的导航项。该事件表示点击,不受 `before-change` 控制;切换是否被允许仍由 `before-change` 和 `change` 决定。
## 平板布局 ## 平板布局
`tablet` 默认 `true`——引入 `AppShell` 就意味着要手机和平板两端。真有项目只需要容器能力、暂不响应式,传 `:tablet="false"` 即可退回纯手机布局。 `tablet` 默认 `true`——引入 `AppShell` 就意味着要手机和平板两端。真有项目只需要容器能力、暂不响应式,传 `:tablet="false"` 即可退回纯手机布局。
-36
View File
@@ -74,30 +74,6 @@ demo-preview=../demos/master-detail-page/sub.vue
第三层只在分栏形态下成立:`split` 为 false 时 `sub` 被忽略, 第三层只在分栏形态下成立:`split` 为 false 时 `sub` 被忽略,
子页要走整页路由,由详情页自己判断(`usePane().openSub()` 会返回 false)。 子页要走整页路由,由详情页自己判断(`usePane().openSub()` 会返回 false)。
### 列表要留着的时候:`sub-mode="cover"`
上面那种是「同一条记录继续往下钻」,列表可以不要了。但如果从详情跳进的是**另一个模块**
的页面,用户还得对着列表核对,`shift` 把列表推走就错了。
传 `sub-mode="cover"`:主栏不动、子页直接盖住详情栏,详情原地保活(返回时滚动位置和状态都在)。
```vue
<master-detail-page :split="isWide" :selected="!!selectedId" :sub="!!subView" sub-mode="cover">
<template #master><!-- 资金流水列表 --></template>
<template #detail><fund-record-detail :record-id="selectedId" /></template>
<template #sub><sales-order-detail :order-id="orderPane.orderId" /></template>
</master-detail-page>
```
| 状态 | 主栏 | 右栏 |
| --- | --- | --- |
| 选中 | 列表 | 详情 |
| `sub` 为 true | 列表(不动) | 子页 |
两种模式共用同一套 `sub` / `subView` 状态,层级、历史和 `pane.close()` 的行为完全一致,
只影响布局。子页里再换一层(订单详情 → 取消订单)仍然是给 `#sub` 里的内容换 `:key`,
外层 `PaneTransition` 自动接上。
### 谁来决定子页 ### 谁来决定子页
详情页发起,列表页编排: 详情页发起,列表页编排:
@@ -124,18 +100,6 @@ const { selectedId, subView } = useMasterDetailPane({
子页里的返回调 `usePane().close()`,会关掉最上面一层;`pane.close(true)` 表示 子页里的返回调 `usePane().close()`,会关掉最上面一层;`pane.close(true)` 表示
子页里改过数据,回到详情时宿主会重新拉一次。 子页里改过数据,回到详情时宿主会重新拉一次。
宿主需要给子页标识补前缀(例如标明"叠在哪一单上")时,用 `providePane` 在页面最外层
换一套派生上下文,别在中间塞容器组件——那会切断栏内骨架的直系选择器:
```ts
const { selectedId, subView, openSub, close } = useMasterDetailPane({ … });
providePane({
close: saved => close(saved),
openSub: view => openSub(buildView(orderPane.value.orderId, view))
});
```
子页内部不要再套一层 `MasterDetailPage` 分栏——右栏本来就不宽, 子页内部不要再套一层 `MasterDetailPage` 分栏——右栏本来就不宽,
需要列表就用单栏形态(`split` 传 false)。 需要列表就用单栏形态(`split` 传 false)。
-49
View File
@@ -244,55 +244,6 @@ function openSub(view: string): boolean {
用 `useMasterDetailPane` 的话这些它都包了,把 `:sub="!!subView"` 接上即可。 用 `useMasterDetailPane` 的话这些它都包了,把 `:sub="!!subView"` 接上即可。
### 第三层的两种呈现
同样是第三层,用户要不要继续看列表,决定了完全不同的排布:
| `sub-mode` | 主栏 | 右栏 | 用在什么场景 |
| --- | --- | --- | --- |
| `shift`(默认) | 详情 | 子页 | 同一条记录继续往下钻,列表已经不用看了 |
| `cover` | 列表(不动) | 子页 | 从详情跳进**另一个模块**的页面,列表要一直在眼前 |
`cover` 的典型例子:资金流水列表 → 某条流水的详情 → 点「交易订单详情」。
这时订单是另一个模块的整页,但用户还在按资金流水核对,列表必须留着。
`shift` 会把列表整列推走,正好相反。
```vue
<master-detail :split="isWide" :detail-empty="!selectedId" :sub="!!subView" sub-mode="cover">
<template #master><!-- 资金流水列表 --></template>
<template #detail>
<fund-record-detail :record-id="selectedId" />
</template>
<template #sub>
<sales-order-detail :order-id="orderPane.orderId" />
</template>
</master-detail>
```
`cover` 下详情不参与位移,只原地淡出——**保活**,返回时滚动位置和内部表单状态都还在,
不会像 `v-if` 重建那样重新拉一次接口。
两种模式共用同一套 `sub` / `subView` 状态,只是布局不同:层级、历史和 `pane.close()` 的行为完全一致。
### 右栏里的页面怎么带上前缀
子页标识由内容页发起(`pane.openSub("payment")`),但宿主可能需要在前面补上"叠在哪一条上",
例如 `sales-order:<订单 id>:payment`。别在中间塞一层容器组件去改写——容器会切断
`.detail > .tui-page-layout` / `.sub > .tui-page-layout` 这些直系选择器,栏内导航栏会退回 `fixed`
飘到视口顶上。用 `providePane` 在页面最外层换一套派生上下文:
```ts
const { selectedId, subView, openSub, close } = useMasterDetailPane({ … });
providePane({
close: saved => close(saved),
// 订单页发的是 `payment`,补上订单 id 后宿主的 #sub 才知道渲染谁
openSub: view => openSub(isOrderView(view) ? view : buildView(orderId, view))
});
```
它只在当前组件的后代里生效,并会遮蔽上层的同一套上下文,所以 `close` 要原样转发。
### 切换动画 ### 切换动画
右栏换视图没有路由变化,所以不能用 `PageTransition`,改用 `PaneTransition`(只做效果,不绑定路由): 右栏换视图没有路由变化,所以不能用 `PageTransition`,改用 `PaneTransition`(只做效果,不绑定路由):
-39
View File
@@ -1,39 +0,0 @@
# Timeline 时间轴
按时间顺序展示事件,使用 `Timeline` 和 `TimelineItem` 组合。
:::preview 基础用法
demo-preview=../demos/timeline/basic.vue
:::
容器支持 `layout`(`vertical`、`horizontal`)和 `reverse`。节点支持 `label`、`content`、`dot-color`,以及默认、`label`、`content`、`dot` 插槽。点击节点触发 `click`,参数包含事件 `e` 和节点属性 `item`。
这是基础实现,暂不支持 PC 端的全部属性和布局。
## 样式变量
可在时间轴或其祖先元素上覆盖以下 CSS 变量。圆点颜色使用节点的 `dot-color` 属性设置。
| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| `--t-timeline-dot-size` | `.5rem` | 圆点宽高 |
| `--t-timeline-dot-border-width` | `2px` | 圆点边框宽度 |
| `--t-timeline-dot-background` | `var(--td-bg-color-container, #fff)` | 圆点背景 |
| `--t-timeline-line-width` | `2px` | 连接线粗细 |
| `--t-timeline-line-color` | `var(--td-component-border, #ddd)` | 连接线颜色 |
| `--t-timeline-line-gap` | `.25rem` | 连接线与圆点的间隙 |
| `--t-timeline-item-gap` | `1rem` | 纵向节点底部间距 |
| `--t-timeline-content-offset` | `1rem` | 纵向内容左侧偏移 |
| `--t-timeline-horizontal-offset` | `1.5rem` | 横向内容顶部偏移 |
| `--t-timeline-horizontal-gap` | `.75rem` | 横向节点右侧间距 |
| `--t-timeline-label-color` | `var(--td-text-color-secondary, #777)` | 时间标签颜色 |
```css
.my-timeline {
--t-timeline-dot-size: .625rem;
--t-timeline-line-color: #aaa;
--t-timeline-item-gap: 1.5rem;
}
```
-10
View File
@@ -1,10 +0,0 @@
<template>
<t-timeline>
<t-timeline-item label="2026-11-11" content="提交订单" />
<t-timeline-item label="2026-11-12" dot-color="warning">正在配送</t-timeline-item>
<t-timeline-item label="2026-11-13" dot-color="default">等待签收</t-timeline-item>
</t-timeline>
</template>
<script setup lang="ts">
import { Timeline as TTimeline, TimelineItem as TTimelineItem } from "timi-tdesign-mobile";
</script>
+1 -1
View File
@@ -5,7 +5,7 @@
"module": "./dist/timi-tdesign-mobile.mjs", "module": "./dist/timi-tdesign-mobile.mjs",
"style": "./dist/timi-tdesign-mobile.css", "style": "./dist/timi-tdesign-mobile.css",
"private": false, "private": false,
"version": "1.4.0", "version": "1.1.1",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"dev": "pnpm run -C docs dev", "dev": "pnpm run -C docs dev",
+6 -24
View File
@@ -6,19 +6,6 @@
*/ */
:root { :root {
--tui-split-duration: 320ms; --tui-split-duration: 320ms;
/**
* 安全区统一入口,四个方向都从这里取。
*
* --safe-area-inset-* 由 Capacitor 原生层按 WindowInsets 注入:Android WebView
* 不实现 env(safe-area-inset-*),恒返回 0,只有原生注入的变量才是真实值。
* iOS / 浏览器没有这套变量,回退到 env()。
* 使用方要自己接管安全区时,覆盖这几个 --tui-safe-* 即可。
*/
--tui-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
--tui-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
--tui-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
--tui-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
} }
/** /**
@@ -31,11 +18,6 @@
* *
* .tui-page-content 使用绝对定位铺满上级容器,因此上级必须是 * .tui-page-content 使用绝对定位铺满上级容器,因此上级必须是
* PageTransition 渲染出的定位容器,不要在普通 div 中直接使用。 * PageTransition 渲染出的定位容器,不要在普通 div 中直接使用。
*
* 顶部安全区从 --tui-safe-top 取(定义在 :root,Capacitor 注入优先、env() 兜底)。
* 这个取值能成立的前提是窗口真的 edge-to-edge:Android 15+ 由系统强制,
* Android 15 以下需要在 MainActivity 里调 WindowCompat.setDecorFitsSystemWindows(false)。
* 窗口没全屏却按全屏补安全区,顶部就会多出一条状态栏高度的空白。
*/ */
/** /**
@@ -50,7 +32,7 @@
box-sizing: border-box; box-sizing: border-box;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding-top: var(--tui-detail-empty-inset, calc(var(--tui-safe-top, 0px) + 48px)); padding-top: var(--tui-detail-empty-inset, calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px));
// 必须有不透明背景:切换视图时它和旧内容同时在场, // 必须有不透明背景:切换视图时它和旧内容同时在场,
// 透明的话提示文字会浮在还在滑出的页面上,看起来像重影。 // 透明的话提示文字会浮在还在滑出的页面上,看起来像重影。
background: var(--tui-detail-empty-background, var(--td-bg-color-page)); background: var(--tui-detail-empty-background, var(--td-bg-color-page));
@@ -72,8 +54,8 @@
position: absolute; position: absolute;
min-height: 0; min-height: 0;
box-sizing: border-box; box-sizing: border-box;
padding-top: calc(var(--tui-safe-top, 0px) + 48px + 1rem); padding-top: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px + 1rem);
padding-bottom: calc(var(--tui-safe-bottom, 0px) + 1rem); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
flex-direction: column; flex-direction: column;
&.scroll { &.scroll {
@@ -93,8 +75,8 @@
} }
&.tui-navbar { &.tui-navbar {
--tui-nav-height: calc(var(--tui-safe-top, 0px) + 48px); --tui-nav-height: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 48px);
--td-navbar-padding-top: var(--tui-safe-top, 0px); --td-navbar-padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
.t-navbar__content, .t-navbar__content,
.t-navbar__placeholder { .t-navbar__placeholder {
@@ -128,7 +110,7 @@
.tui-app-shell.is-rail { .tui-app-shell.is-rail {
.rail { .rail {
padding-top: var(--tui-safe-top, 0px); padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
} }
.t-navbar--fixed .t-navbar__content { .t-navbar--fixed .t-navbar__content {
+1 -1
View File
@@ -173,7 +173,7 @@ defineExpose({
flex: none; flex: none;
height: 100%; height: 100%;
display: flex; display: flex;
padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + var(--tui-safe-bottom, 0px)); padding: var(--ai-msg-padding-top, .5rem) 1rem calc(var(--ai-chat-bottom-area-height, 4.5rem) + 1.5rem + env(safe-area-inset-bottom, 0px));
min-width: 0; min-width: 0;
min-height: 0; min-height: 0;
box-sizing: border-box; box-sizing: border-box;
+1 -1
View File
@@ -215,7 +215,7 @@ defineExpose({
flex-direction: column; flex-direction: column;
.bottom-area { .bottom-area {
inset: auto 1rem calc(1rem + var(--tui-safe-bottom, 0px)); inset: auto 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
width: auto; width: auto;
margin: 0 auto; margin: 0 auto;
z-index: 2; z-index: 2;
+3 -5
View File
@@ -90,7 +90,6 @@ const props = withDefaults(defineProps<AppShellProps>(), {
const emit = defineEmits<{ const emit = defineEmits<{
"update:modelValue": [value: AppShellValue]; "update:modelValue": [value: AppShellValue];
"change": [value: AppShellValue]; "change": [value: AppShellValue];
"rail-click": [value: AppShellValue];
}>(); }>();
defineSlots<{ defineSlots<{
@@ -165,7 +164,6 @@ function onSelect(item: AppShellItem): void {
return; return;
} }
emit("rail-click", item.value);
void requestChange(item.value); void requestChange(item.value);
} }
@@ -211,7 +209,7 @@ function onTabChange(value: AppShellValue): void {
position: relative; position: relative;
overflow-y: auto; overflow-y: auto;
flex-direction: column; flex-direction: column;
padding-left: var(--tui-safe-left, 0); padding-left: env(safe-area-inset-left, 0);
border-right: 1px solid var(--td-component-border); border-right: 1px solid var(--td-component-border);
background: var(--tui-rail-background, var(--td-bg-color-container)); background: var(--tui-rail-background, var(--td-bg-color-container));
@@ -262,7 +260,7 @@ function onTabChange(value: AppShellValue): void {
.rail-extra { .rail-extra {
margin-top: auto; margin-top: auto;
padding-bottom: calc(.75rem + var(--tui-safe-bottom, 0)); padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0));
} }
} }
@@ -272,7 +270,7 @@ function onTabChange(value: AppShellValue): void {
flex: none; flex: none;
border-top: 1px solid var(--td-component-border); border-top: 1px solid var(--td-component-border);
padding-bottom: var(--tui-safe-bottom, 0); padding-bottom: env(safe-area-inset-bottom, 0);
background: var(--tui-tabbar-background, var(--td-bg-color-container)); background: var(--tui-tabbar-background, var(--td-bg-color-container));
:deep(.t-tab-bar-item) { :deep(.t-tab-bar-item) {
+1 -1
View File
@@ -135,7 +135,7 @@ defineSlots<BottomPopupSlots>();
.body { .body {
flex: 1; flex: 1;
padding: 0 0 var(--tui-safe-bottom, 0); padding: 0 0 env(safe-area-inset-bottom, 0);
overflow: auto; overflow: auto;
min-height: 0; min-height: 0;
} }
+1 -6
View File
@@ -16,7 +16,6 @@ import NotifyView from "./notify-view";
import BottomPopup from "./bottom-popup"; import BottomPopup from "./bottom-popup";
import AttachmentSelector from "./attachment-selector"; import AttachmentSelector from "./attachment-selector";
import Space from "./space"; import Space from "./space";
import { Timeline, TimelineItem } from "./timeline";
import CardContainer from "./card-container"; import CardContainer from "./card-container";
import { import {
AiChatComposer, AiChatComposer,
@@ -43,8 +42,6 @@ export default [
BottomPopup, BottomPopup,
AttachmentSelector, AttachmentSelector,
Space, Space,
Timeline,
TimelineItem,
CardContainer, CardContainer,
AiChatComposer, AiChatComposer,
AiChatMessageList, AiChatMessageList,
@@ -70,8 +67,6 @@ export {
BottomPopup, BottomPopup,
AttachmentSelector, AttachmentSelector,
Space, Space,
Timeline,
TimelineItem,
CardContainer, CardContainer,
AiChatComposer, AiChatComposer,
AiChatMessageList, AiChatMessageList,
@@ -80,7 +75,7 @@ export {
}; };
export { createLayoutContext, provideLayout, useLayout } from "./app-shell"; export { createLayoutContext, provideLayout, useLayout } from "./app-shell";
export { useExpandToMaster, useMasterDetail, useMasterDetailPane, usePane, providePane } from "../composables/use-master-detail"; export { useExpandToMaster, useMasterDetail, useMasterDetailPane, usePane } from "../composables/use-master-detail";
export type { ExpandToMasterOptions, PaneContext, PaneDirection, UseMasterDetailOptions, UseMasterDetailPaneOptions, UseMasterDetailPaneReturn, UseMasterDetailReturn } from "../composables/use-master-detail"; export type { ExpandToMasterOptions, PaneContext, PaneDirection, UseMasterDetailOptions, UseMasterDetailPaneOptions, UseMasterDetailPaneReturn, UseMasterDetailReturn } from "../composables/use-master-detail";
export type { export type {
+1 -3
View File
@@ -6,7 +6,6 @@
:top-inset="topInset" :top-inset="topInset"
:detail-empty="!selected" :detail-empty="!selected"
:sub="sub" :sub="sub"
:sub-mode="subMode"
> >
<template #master> <template #master>
<div class="tui-master-wrap"> <div class="tui-master-wrap">
@@ -55,8 +54,7 @@ const props = withDefaults(defineProps<MasterDetailPageProps>(), {
direction: "forward", direction: "forward",
masterWidth: 380, masterWidth: 380,
topInset: "", topInset: "",
sub: false, sub: false
subMode: "shift"
}); });
defineSlots<{ defineSlots<{
+2 -9
View File
@@ -19,16 +19,9 @@ export interface MasterDetailPageProps {
/** /**
* 是否进入第三层:主栏换成详情内容,右栏显示 `#sub` 槽。 * 是否进入第三层:主栏换成详情内容,右栏显示 `#sub` 槽。
* *
* 三层依次是:列表 → 详情 → 子页。只有分栏形态下有效, * 三层依次是:列表 → 详情 → 子页。进入时列表整列滑出左侧、详情退到主栏,
* 返回时反向还原成「列表 + 详情」。只有分栏形态下有效,
* 窄屏请让子页走整页路由(`usePane().openSub()` 会返回 false)。 * 窄屏请让子页走整页路由(`usePane().openSub()` 会返回 false)。
*/ */
sub?: boolean; sub?: boolean;
/**
* 第三层的呈现方式,默认 `shift`。
*
* - `shift`:列表整列滑出、详情退到主栏,适合同一条记录继续往下钻;
* - `cover`:主栏不动、子页盖住详情栏,适合从详情跳进另一个模块的页面,
* 列表要一直留在眼前(详情原地保活,返回时滚动位置和状态都在)。
*/
subMode?: "shift" | "cover";
} }
+2 -33
View File
@@ -4,8 +4,7 @@
:class="{ :class="{
split: isSplit, split: isSplit,
'is-collapsed': isSplit && detailEmpty, 'is-collapsed': isSplit && detailEmpty,
'has-sub': isSplit && showSub, 'has-sub': isSplit && showSub
'is-sub-cover': isSplit && showSub && subMode === 'cover'
}" }"
:style="rootStyle" :style="rootStyle"
> >
@@ -45,8 +44,7 @@ const props = withDefaults(defineProps<MasterDetailProps>(), {
emptyText: "", emptyText: "",
topInset: "", topInset: "",
detailEmpty: false, detailEmpty: false,
sub: false, sub: false
subMode: "shift"
}); });
defineSlots<{ defineSlots<{
@@ -233,35 +231,6 @@ const rootStyle = computed<StyleValue>(() => ({
right: 0; right: 0;
} }
} }
/**
* 第三层的 cover 形态:右栏换人,主栏不动。
*
* shift 是"整条轨道左移",用户已经不看列表了;cover 针对的相反——
* 从详情跳进别的模块,列表本身要一直留在眼前。
* 详情不参与位移,只原地淡出(保活,返回时滚动位置和内部状态都还在),
* 子页像换班一样滑进右栏。
*/
&.has-sub.is-sub-cover {
.master {
left: 0;
right: calc(100% - var(--tui-master-width));
border-right-color: var(--td-component-border, rgba(0, 0, 0, .08));
}
.detail {
left: var(--tui-master-width);
right: 0;
opacity: 0;
pointer-events: none;
}
.sub {
left: var(--tui-master-width);
right: 0;
}
}
} }
} }
</style> </style>
-11
View File
@@ -31,15 +31,4 @@ export interface MasterDetailProps {
* 只有分栏形态下有效,窄屏请让子页走整页路由。 * 只有分栏形态下有效,窄屏请让子页走整页路由。
*/ */
sub?: boolean; sub?: boolean;
/**
* 第三层的呈现方式,默认 `shift`。
*
* - `shift`:整条轨道左移,列表滑出、详情退到主栏。适合同一条记录继续往下钻,
* 用户已经不需要再看列表了。
* - `cover`:主栏不动,子页直接盖住详情栏(详情原地保活,返回时滚动位置和内部状态都在)。
* 适合从详情跳进**另一个模块**的页面——列表本身是用户要一直看的东西。
*
* 两种方式共用同一套 `sub` / `subView` 状态,切换只影响布局,不影响层级和历史的处理。
*/
subMode?: "shift" | "cover";
} }
-6
View File
@@ -1,6 +0,0 @@
import { WebToolkit } from "timi-web";
import timeline from "./index.vue";
import item from "./item.vue";
export const Timeline = WebToolkit.withInstall(timeline);
export const TimelineItem = WebToolkit.withInstall(item);
-73
View File
@@ -1,73 +0,0 @@
<template>
<div class="t-timeline" :class="{ horizontal: layout === 'horizontal', reverse }">
<slot />
</div>
</template>
<script setup lang="ts">
defineOptions({ name: "TTimeline" });
withDefaults(defineProps<{ layout?: "vertical" | "horizontal"; reverse?: boolean }>(), {
layout: "vertical",
reverse: false
});
</script>
<style lang="less">
.t-timeline {
display: flex;
flex-direction: column;
&.reverse {
flex-direction: column-reverse;
}
&.horizontal {
flex-direction: row;
&.reverse {
flex-direction: row-reverse;
}
.t-timeline-item {
flex: 1;
padding: var(--t-timeline-horizontal-offset, 1.5rem) var(--t-timeline-horizontal-gap, .75rem) 0 0;
}
.t-timeline-item::before {
top: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
left: calc(var(--t-timeline-dot-size, .5rem) + var(--t-timeline-line-gap, .25rem));
width: calc(100% - var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-gap, .25rem) - var(--t-timeline-line-gap, .25rem));
height: var(--t-timeline-line-width, 2px);
}
.t-timeline-item .dot {
top: 0;
}
}
.t-timeline-item {
position: relative;
padding: 0 0 var(--t-timeline-item-gap, 1rem) var(--t-timeline-content-offset, 1rem);
&::before {
position: absolute;
top: calc(1lh / 2 + var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem));
bottom: calc(var(--t-timeline-dot-size, .5rem) / 2 + var(--t-timeline-line-gap, .25rem) - 1lh / 2);
left: calc((var(--t-timeline-dot-size, .5rem) - var(--t-timeline-line-width, 2px)) / 2);
width: var(--t-timeline-line-width, 2px);
content: "";
background: var(--t-timeline-line-color, var(--td-component-border, #ddd));
}
&:last-child::before {
display: none;
}
}
&.reverse .t-timeline-item:last-child::before {
display: block;
}
&.reverse .t-timeline-item:first-child::before {
display: none;
}
}
</style>
-58
View File
@@ -1,58 +0,0 @@
<template>
<div class="t-timeline-item" @click="onClick">
<span class="dot" :style="{ color: color }">
<slot name="dot" />
</span>
<div v-if="label || $slots.label" class="label">
<slot name="label">
<span v-text="label" />
</slot>
</div>
<div>
<slot name="content">
<slot>
<span v-text="content" />
</slot>
</slot>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from "vue";
defineOptions({ name: "TTimelineItem" });
const props = withDefaults(defineProps<{
label?: string;
content?: string;
dotColor?: string
}>(), { dotColor: "primary" });
const emit = defineEmits<{ click: [context: { e: MouseEvent; item: typeof props }] }>();
const colors: Record<string, string> = {
primary: "var(--td-brand-color, #0052d9)",
warning: "#ed7b2f",
error: "#d54941",
default: "#bbb"
};
const color = computed(() => colors[props.dotColor] ?? props.dotColor);
function onClick(e: MouseEvent): void {
emit("click", { e, item: props });
}
</script>
<style lang="less" scoped>
.dot {
position: absolute;
top: calc((1lh - var(--t-timeline-dot-size, .5rem)) / 2);
left: 0;
width: var(--t-timeline-dot-size, .5rem);
height: var(--t-timeline-dot-size, .5rem);
border: var(--t-timeline-dot-border-width, 2px) solid currentColor;
box-sizing: border-box;
background: var(--t-timeline-dot-background, var(--td-bg-color-container, #fff));
border-radius: 50%;
}
.label {
color: var(--t-timeline-label-color, var(--td-text-color-secondary, #777));
}
</style>
@@ -142,7 +142,7 @@ async function onConfirm() {
<style lang="less" scoped> <style lang="less" scoped>
.popup { .popup {
margin: 0; margin: 0;
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px)); padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
.field { .field {
@@ -101,7 +101,7 @@ function onConfirm() {
<style lang="less" scoped> <style lang="less" scoped>
.link-form { .link-form {
gap: .75rem; gap: .75rem;
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px)); padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
@@ -231,7 +231,7 @@ async function onConfirm() {
<style lang="less" scoped> <style lang="less" scoped>
.popup { .popup {
margin: 0; margin: 0;
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px)); padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
overflow-y: auto; overflow-y: auto;
background: var(--td-bg-color-container); background: var(--td-bg-color-container);
@@ -136,7 +136,7 @@ watch(() => props.active, (active) => {
<style lang="less" scoped> <style lang="less" scoped>
.table-picker { .table-picker {
padding: 0 1rem calc(1rem + var(--tui-safe-bottom, 0px)); padding: 0 1rem calc(1rem + env(safe-area-inset-bottom));
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
background: var(--td-bg-color-container, #fff); background: var(--td-bg-color-container, #fff);
@@ -520,7 +520,7 @@ function confirmColor() {
.heading-picker { .heading-picker {
width: min(22rem, calc(100vw - 2rem)); width: min(22rem, calc(100vw - 2rem));
padding: .5rem .75rem calc(.5rem + var(--tui-safe-bottom, 0px)); padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom));
} }
.color-picker-popup { .color-picker-popup {
+28 -57
View File
@@ -86,24 +86,6 @@ export function usePane(): PaneContext | null {
return inject(PANE_KEY, null); return inject(PANE_KEY, null);
} }
/**
* 把一套栏内上下文提供给后代。
*
* 用在"页面要改写子页标识"的场合:列表页在最外层 provide 一套派生上下文,
* 右栏里的页面调 `openSub()` 时标识先经过它,不必在中间塞一层容器组件。
*
* 不要用容器组件代替它:栏内页面的骨架样式(导航栏退化成栏内头部、内容区铺满)
* 挂在 `.detail > .tui-page-layout` 这类直系选择器上,多包一层就全落空。
*
* 注意 provide 只在当前组件的后代里生效,且会遮蔽上层的同一套上下文,
* 所以派生时要把 `close` / `openSub` 转发给宿主,别自己重写一套。
*
* @param context 派生出来的上下文,通常转发 `usePane()` 拿到的宿主上下文
*/
export function providePane(context: PaneContext): void {
provide(PANE_KEY, context);
}
/** /**
* 主从布局的选中态管理。 * 主从布局的选中态管理。
* *
@@ -117,7 +99,7 @@ export function useMasterDetail(options: UseMasterDetailOptions = {}): UseMaster
const isWide = layout.isWide; const isWide = layout.isWide;
// 右栏里的页面通过 usePane().close() 把控制权交回来 // 右栏里的页面通过 usePane().close() 把控制权交回来
providePane({ provide(PANE_KEY, {
close: (saved = false) => options.onClose?.(saved), close: (saved = false) => options.onClose?.(saved),
openSub: view => options.onOpenSub?.(view) ?? false openSub: view => options.onOpenSub?.(view) ?? false
}); });
@@ -244,13 +226,6 @@ export interface UseMasterDetailPaneReturn {
openSub: (view: string) => boolean; openSub: (view: string) => boolean;
/** 关闭子页面,回到详情层。 */ /** 关闭子页面,回到详情层。 */
closeSub: () => void; closeSub: () => void;
/**
* 关闭右栏最上面一层:有子页先关子页,其次关编辑,最后关详情。
*
* 和 `usePane().close()` 是同一套逻辑,给"页面要派生一套栏内上下文"时转发用
* (见 `providePane`)。
*/
close: (saved?: boolean) => void;
} }
/** /**
@@ -338,37 +313,34 @@ export function useMasterDetailPane(options: UseMasterDetailPaneOptions): UseMas
? options.edit(id) ? options.edit(id)
: options.detail(id)), : options.detail(id)),
onOpenSub: requestSub, onOpenSub: requestSub,
onClose: saved => closePane(saved) onClose: saved => {
}); if (popPane(saved)) {
return;
/** 关闭右栏最上面一层;页面派生上下文时原样转发这一个。 */
function closePane(saved = false): void {
if (popPane(saved)) {
return;
}
// 降级:没有可回退的层级,只改 query
pendingNav.value = "replace";
paneDirection.value = "back";
// 有子页先关子页,回到详情
if (subView.value) {
subView.value = "";
return;
}
// 取消/保存编辑:回到详情,保存过就让详情重新加载
if (editing.value) {
editing.value = false;
if (saved) {
detailVersion.value++;
} }
return;
}
// 关闭详情:右滑出,回到空栏 // 降级:没有可回退的层级,只改 query
selectedId.value = ""; pendingNav.value = "replace";
} paneDirection.value = "back";
// 有子页先关子页,回到详情
if (subView.value) {
subView.value = "";
return;
}
// 取消/保存编辑:回到详情,保存过就让详情重新加载
if (editing.value) {
editing.value = false;
if (saved) {
detailVersion.value++;
}
return;
}
// 关闭详情:右滑出,回到空栏
selectedId.value = "";
}
});
function openDetail(id: string): void { function openDetail(id: string): void {
// 正在编辑时直接点列表里另一项:栈顶是编辑层,就地改成新客户的详情的话, // 正在编辑时直接点列表里另一项:栈顶是编辑层,就地改成新客户的详情的话,
@@ -522,8 +494,7 @@ export function useMasterDetailPane(options: UseMasterDetailPaneOptions): UseMas
openDetail, openDetail,
openEdit, openEdit,
openSub: requestSub, openSub: requestSub,
closeSub, closeSub
close: closePane
}; };
} }