From 5e440a7dc434c43eb828fa62cf9c12b0078b8565 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期一, 20 一月 2025 11:36:18 +0800
Subject: [PATCH] !173 发布 5.3.0-BETA 公测版本 Merge pull request !173 from 疯狂的狮子Li/dev

---
 src/plugins/tab.ts |   73 +++++++++++++++++++++++++-----------
 1 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts
index a310154..4b44dc6 100644
--- a/src/plugins/tab.ts
+++ b/src/plugins/tab.ts
@@ -1,25 +1,43 @@
-import { useTagsViewStore } from '@/store/modules/tagsView';
 import router from '@/router';
-import { TagView, RouteLocationRaw } from 'vue-router';
+import { RouteLocationMatched, RouteLocationNormalized, RouteLocationRaw } from 'vue-router';
+import useTagsViewStore from '@/store/modules/tagsView';
 
 export default {
-  // 鍒锋柊褰撳墠tab椤电
-  async refreshPage(obj: TagView): Promise<void> {
+  /**
+   * 鍒锋柊褰撳墠tab椤电
+   * @param obj 鏍囩瀵硅薄
+   */
+  async refreshPage(obj?: RouteLocationNormalized): Promise<void> {
     const { path, query, matched } = router.currentRoute.value;
     if (obj === undefined) {
-      matched.forEach((m) => {
+      matched.forEach((m: RouteLocationMatched) => {
         if (m.components && m.components.default && m.components.default.name) {
           if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
-            obj = { name: m.components.default.name, path: path, query: query };
+            obj = {
+              name: m.components.default.name,
+              path: path,
+              query: query,
+              matched: undefined,
+              fullPath: undefined,
+              hash: undefined,
+              params: undefined,
+              redirectedFrom: undefined,
+              meta: undefined
+            };
           }
         }
       });
     }
-    // prettier-ignore
-    await useTagsViewStore().delCachedView(obj)
-    router.replace({
-      path: '/redirect' + obj.path,
-      query: obj.query
+    let query1: undefined | {} = {};
+    let path1: undefined | string = '';
+    if (obj) {
+      query1 = obj.query;
+      path1 = obj.path;
+    }
+    await useTagsViewStore().delCachedView(obj);
+    await router.replace({
+      path: '/redirect' + path1,
+      query: query1
     });
   },
   // 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛�
@@ -30,13 +48,13 @@
     }
   },
   // 鍏抽棴鎸囧畾tab椤电
-  async closePage(obj?: TagView): Promise<{ visitedViews: TagView[]; cachedViews: string[] } | any> {
+  async closePage(obj?: RouteLocationNormalized): Promise<{ visitedViews: RouteLocationNormalized[]; cachedViews: string[] } | any> {
     if (obj === undefined) {
       // prettier-ignore
-      const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value) as any
-      const latestView = visitedViews.slice(-1)[0]
+      const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value)
+      const latestView = visitedViews.slice(-1)[0];
       if (latestView) {
-        return router.push(latestView.fullPath)
+        return router.push(latestView.fullPath);
       }
       return router.push('/');
     }
@@ -47,23 +65,32 @@
     return useTagsViewStore().delAllViews();
   },
   // 鍏抽棴宸︿晶tab椤电
-  closeLeftPage(obj: TagView) {
+  closeLeftPage(obj?: RouteLocationNormalized) {
     return useTagsViewStore().delLeftTags(obj || router.currentRoute.value);
   },
   // 鍏抽棴鍙充晶tab椤电
-  closeRightPage(obj: TagView) {
+  closeRightPage(obj?: RouteLocationNormalized) {
     return useTagsViewStore().delRightTags(obj || router.currentRoute.value);
   },
   // 鍏抽棴鍏朵粬tab椤电
-  closeOtherPage(obj: TagView) {
+  closeOtherPage(obj?: RouteLocationNormalized) {
     return useTagsViewStore().delOthersViews(obj || router.currentRoute.value);
   },
-  // 鎵撳紑tab椤电
-  openPage(url: RouteLocationRaw) {
-    return router.push(url);
+  /**
+   * 鎵撳紑tab椤电
+   * @param url 璺敱鍦板潃
+   * @param title 鏍囬
+   * @param query 鍙傛暟
+   */
+  openPage(url: string, title?: string, query?: any) {
+    const obj = { path: url, query: { ...query, title } };
+    return router.push(obj);
   },
-  // 淇敼tab椤电
-  updatePage(obj: TagView) {
+  /**
+   * 淇敼tab椤电
+   * @param obj 鏍囩瀵硅薄
+   */
+  updatePage(obj: RouteLocationNormalized) {
     return useTagsViewStore().updateVisitedView(obj);
   }
 };

--
Gitblit v1.9.3