From 487213b64853765e2bd186474e4607572624a33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E5=8D=9A=E6=96=87?= <349952469@qq.com> Date: Tue, 14 Jun 2022 15:42:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(projects):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BD=93=E5=89=8DTab=E9=A1=B5=E7=AD=BE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/tab/index.ts | 12 ++++++++++++ src/views/function/tab/index.vue | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index f590f3de..2c9b8bbc 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -1,3 +1,5 @@ +import { unref } from 'vue'; +import type { Ref } from 'vue'; import type { Router, RouteLocationNormalizedLoaded } from 'vue-router'; import { defineStore } from 'pinia'; import { useRouterPush } from '@/composables'; @@ -50,6 +52,16 @@ export const useTabStore = defineStore('tab-store', { setActiveTab(fullPath: string) { this.activeTab = fullPath; }, + /** + * 设置当前路由对应的页签title + * @param title - tab名称 + */ + setActiveTabTitle(title: string | Ref) { + const item = this.tabs.find(tab => tab.fullPath === this.activeTab); + if (item) { + Object.assign(item, { meta: { title: unref(title) } }); + } + }, /** * 初始化首页页签路由 * @param routeHomeName - 路由首页的name diff --git a/src/views/function/tab/index.vue b/src/views/function/tab/index.vue index cafdeb65..6bd81a15 100644 --- a/src/views/function/tab/index.vue +++ b/src/views/function/tab/index.vue @@ -5,16 +5,24 @@ 跳转Tab Detail 跳转Tab Multi Detail 1 跳转Tab Multi Detail 2 + + + 设置当前Tab页标题 + From efcfa576d52a7eab644f3b4c65af153442887fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E5=8D=9A=E6=96=87?= <349952469@qq.com> Date: Tue, 14 Jun 2022 16:09:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(projects):=20=E8=AE=BE=E7=BD=AEtab?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=AF=BC=E8=87=B4meta=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/tab/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index 2c9b8bbc..d0be48e5 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -1,5 +1,3 @@ -import { unref } from 'vue'; -import type { Ref } from 'vue'; import type { Router, RouteLocationNormalizedLoaded } from 'vue-router'; import { defineStore } from 'pinia'; import { useRouterPush } from '@/composables'; @@ -56,10 +54,10 @@ export const useTabStore = defineStore('tab-store', { * 设置当前路由对应的页签title * @param title - tab名称 */ - setActiveTabTitle(title: string | Ref) { + setActiveTabTitle(title: string) { const item = this.tabs.find(tab => tab.fullPath === this.activeTab); if (item) { - Object.assign(item, { meta: { title: unref(title) } }); + item.meta.title = title; } }, /**