feat: master-detail third pane
- MasterDetail / MasterDetailPage: add `sub` prop and `#sub` slot. The three columns share one container and are placed by left/right, so the detail pane moves between columns without remounting and keeps its scroll position. - useMasterDetailPane: add subView / openSub / closeSub, keep the sub view in query and browser history alongside detail and view. - page-layout: sub pane reuses the in-pane navbar rules; the list navbar slides out on the third level instead of being hidden. - docs: demos for the third pane, the layered navbars and PaneTransition; restore transition durations in demo previews under prefers-reduced-motion, where VitePress zeroes them. Fix the missing `split` ref in the master-detail demo and the incorrect note about the back arrow.
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div class="demo">
|
||||
<div class="bar">
|
||||
<button type="button" class="chip" :disabled="view !== 'list'" @click="go('detail', 'forward')">
|
||||
<span>进入详情</span>
|
||||
</button>
|
||||
<button type="button" class="chip" :disabled="view !== 'detail'" @click="go('edit', 'forward')">
|
||||
<span>进入编辑</span>
|
||||
</button>
|
||||
<button type="button" class="chip" :disabled="view !== 'edit'" @click="go('detail', 'back')">
|
||||
<span>编辑 → 详情</span>
|
||||
</button>
|
||||
<button type="button" class="chip" :disabled="view === 'list'" @click="go('list', 'back')">
|
||||
<span>返回列表</span>
|
||||
</button>
|
||||
<button type="button" class="chip" :disabled="view === 'list'" @click="go('list', 'none')">
|
||||
<span>直接替换</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="frame">
|
||||
<pane-transition :direction="direction">
|
||||
<div v-if="view === 'list'" key="list" class="pane">
|
||||
<h4 class="title" v-text="'客户列表'" />
|
||||
<p class="row" v-text="'当前在列表层,按「进入详情」看 forward 推入。'" />
|
||||
</div>
|
||||
<div v-else-if="view === 'detail'" key="detail" class="pane">
|
||||
<h4 class="title" v-text="'客户详情'" />
|
||||
<p class="row" v-text="'forward:新内容从右侧推过来,旧内容左移让位。'" />
|
||||
<p class="row" v-text="'back:新内容从左侧覆盖回来,旧内容滑出右侧。'" />
|
||||
</div>
|
||||
<div v-else key="edit" class="pane">
|
||||
<h4 class="title" v-text="'编辑客户'" />
|
||||
<p class="row" v-text="'编辑层。按「编辑 → 详情」看 back 反向播放。'" />
|
||||
</div>
|
||||
</pane-transition>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import { PaneTransition, type PaneDirection } from "timi-tdesign-mobile";
|
||||
|
||||
type ViewName = "list" | "detail" | "edit";
|
||||
|
||||
const view = ref<ViewName>("list");
|
||||
const direction = ref<PaneDirection>("forward");
|
||||
|
||||
function go(next: ViewName, nextDirection: PaneDirection): void {
|
||||
direction.value = nextDirection;
|
||||
view.value = next;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.demo {
|
||||
.bar {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
margin-bottom: .75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.chip {
|
||||
padding: .375rem .875rem;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: .8125rem;
|
||||
background: var(--td-bg-color-container);
|
||||
border-radius: 99rem;
|
||||
border: 1px solid var(--td-component-border);
|
||||
cursor: pointer;
|
||||
|
||||
&:disabled {
|
||||
opacity: .4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.frame {
|
||||
height: 220px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: .75rem;
|
||||
border: 1px solid var(--td-component-border);
|
||||
background: var(--td-bg-color-page);
|
||||
}
|
||||
|
||||
.pane {
|
||||
height: 100%;
|
||||
padding: 1rem;
|
||||
box-sizing: border-box;
|
||||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0 0 .75rem;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin: 0 0 .5rem;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: .8125rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user