From 3d9dba965f6501cb41526fe1ecf392d49f9c23c6 Mon Sep 17 00:00:00 2001 From: ming4762 Date: Sun, 18 May 2025 10:33:02 +0800 Subject: [PATCH] perf: perf the control logic of Tab (#6220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: perf the control logic of Tab * 每个标签页Tab使用唯一的key来控制关闭打开等逻辑 * 统一函数获取tab的key * 通过3种方式设置tab key:1、使用router query参数pageKey 2、使用路由meta参数fullPathKey设置使用fullPath或path作为key * 单个路由可以打开多个标签页 * 如果设置fullPathKey为false,则query变更不会打开新的标签(这很实用) * perf: perf the control logic of Tab * perf: perf the control logic of Tab * 测试用例适配 * perf: perf the control logic of Tab * 解决AI提示的警告 --- docs/src/guide/essentials/route.md | 40 ++++ packages/@core/base/typings/src/tabs.ts | 7 +- .../@core/base/typings/src/vue-router.d.ts | 4 + .../src/components/tabs-chrome/tabs.vue | 4 +- .../tabs-ui/src/components/tabs/tabs.vue | 4 +- .../layouts/src/basic/content/content.vue | 10 +- .../layouts/src/basic/tabbar/tabbar.vue | 2 +- .../layouts/src/basic/tabbar/use-tabbar.ts | 12 +- packages/stores/src/modules/tabbar.test.ts | 39 ++-- packages/stores/src/modules/tabbar.ts | 181 +++++++++++------- 10 files changed, 199 insertions(+), 104 deletions(-) diff --git a/docs/src/guide/essentials/route.md b/docs/src/guide/essentials/route.md index d8a938dd..985c48a9 100644 --- a/docs/src/guide/essentials/route.md +++ b/docs/src/guide/essentials/route.md @@ -339,6 +339,10 @@ interface RouteMeta { | 'success' | 'warning' | string; + /** + * 路由的完整路径作为key(默认true) + */ + fullPathKey?: boolean; /** * 当前路由的子级在菜单中不展现 * @default false @@ -502,6 +506,13 @@ interface RouteMeta { 用于配置页面的徽标颜色。 +### fullPathKey + +- 类型:`boolean` +- 默认值:`true` + +是否将路由的完整路径作为tab key(默认true) + ### activePath - 类型:`string` @@ -602,3 +613,32 @@ const { refresh } = useRefresh(); refresh(); ``` + +## 标签页与路由控制 + +在某些场景下,需要单个路由打开多个标签页,或者修改路由的query不打开新的标签页 + +每个标签页Tab使用唯一的key标识,设置Tab key有三种方式,优先级由高到低: + +- 使用路由query参数pageKey + +```vue +