浏览代码

关闭标签的问题

lighter 1 年之前
父节点
当前提交
8d7e004760
共有 1 个文件被更改,包括 6 次插入15 次删除
  1. 6 15
      src/pinia/use-tabs.ts

+ 6 - 15
src/pinia/use-tabs.ts

@@ -80,35 +80,26 @@ function useTabs() {
     }
 
     function closeRight(index: number) {
-        const currentRouterIndex = tabsKeys.value.indexOf(router.currentRoute.value.name)
-        if (currentRouterIndex > -1 && index < currentRouterIndex) {
-            routerPush(index)
-        }
         tabs.value.splice(index + 1, tabsKeys.value.length - 1);
+        router.push(tabs.value[tabs.value.length - 1].path)
     }
 
     function closeLeft(index: number) {
-        const currentRouterIndex = tabsKeys.value.indexOf(router.currentRoute.value.name)
-        if (currentRouterIndex > -1 && index > currentRouterIndex) {
-            routerPush(index)
-        }
-        tabs.value.splice(0, index - 1);
+        tabs.value.splice(0, index);
+        router.push(tabs.value[0].path)
     }
 
     function closeAll() {
-        router.push("/").then(() => {
-        })
-        tabs.value.splice(0, tabsKeys.value.length - 1);
+        router.push("/").then(() => {})
+        tabs.value = []
     }
 
-
     function isActive(name: string) {
         return name === router.currentRoute.value.name
     }
 
     function closeOther(index: number) {
-        routerPush(index)
-        tabs.value = tabsKeys.value[index]
+        tabs.value = []
     }
 
     return {