From 6b988bd582bfcd17fee48c476a5a6e5cc172b0d5 Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期三, 12 三月 2025 10:08:33 +0800
Subject: [PATCH] dev-2

---
 src/plugins/tab.ts |   55 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts
index 1c0ab7a..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)
+    let query1: undefined | {} = {};
+    let path1: undefined | string = '';
+    if (obj) {
+      query1 = obj.query;
+      path1 = obj.path;
+    }
+    await useTagsViewStore().delCachedView(obj);
     await router.replace({
-      path: '/redirect' + obj.path,
-      query: obj.query
+      path: '/redirect' + path1,
+      query: query1
     });
   },
   // 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛�
@@ -30,10 +48,10 @@
     }
   },
   // 鍏抽棴鎸囧畾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 { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value)
       const latestView = visitedViews.slice(-1)[0];
       if (latestView) {
         return router.push(latestView.fullPath);
@@ -47,15 +65,15 @@
     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);
   },
   /**
@@ -68,8 +86,11 @@
     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