diff --git a/package.json b/package.json index bc276d4..538360b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tdesign-vue-next-starter", - "version": "0.7.1", + "version": "0.7.2", "scripts": { "dev:mock": "vite --open --mode mock", "dev": "vite --open --mode development", diff --git a/src/layouts/components/LayoutContent.vue b/src/layouts/components/LayoutContent.vue index 77ef192..0c9fea9 100644 --- a/src/layouts/components/LayoutContent.vue +++ b/src/layouts/components/LayoutContent.vue @@ -2,12 +2,14 @@ { if (ctx.trigger === 'document') activeTabPath.value = null; if (visible) activeTabPath.value = path; }; + +const handleDragend = (options: { currentIndex: number; targetIndex: number }) => { + const { tabRouters } = tabsRouterStore; + + [tabRouters[options.currentIndex], tabRouters[options.targetIndex]] = [ + tabRouters[options.targetIndex], + tabRouters[options.currentIndex], + ]; +}; diff --git a/src/store/modules/tabs-router.ts b/src/store/modules/tabs-router.ts index 00092a5..d8d1f38 100644 --- a/src/store/modules/tabs-router.ts +++ b/src/store/modules/tabs-router.ts @@ -49,17 +49,28 @@ export const useTabsRouterStore = defineStore('tabsRouter', { // 处理关闭右侧 subtractTabRouterBehind(newRoute: TRouterInfo) { const { routeIdx } = newRoute; - this.tabRouterList = this.tabRouterList.slice(0, routeIdx + 1); + const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome); + let tabRouterList: Array = this.tabRouterList.slice(0, routeIdx + 1); + if (routeIdx < homeIdx) { + tabRouterList = tabRouterList.concat(homeRoute); + } + this.tabRouterList = tabRouterList; }, // 处理关闭左侧 subtractTabRouterAhead(newRoute: TRouterInfo) { const { routeIdx } = newRoute; - this.tabRouterList = homeRoute.concat(this.tabRouterList.slice(routeIdx)); + const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome); + let tabRouterList: Array = this.tabRouterList.slice(routeIdx); + if (routeIdx > homeIdx) { + tabRouterList = homeRoute.concat(tabRouterList); + } + this.tabRouterList = tabRouterList; }, // 处理关闭其他 subtractTabRouterOther(newRoute: TRouterInfo) { const { routeIdx } = newRoute; - this.tabRouterList = routeIdx === 0 ? homeRoute : homeRoute.concat([this.tabRouterList?.[routeIdx]]); + const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome); + this.tabRouterList = routeIdx === homeIdx ? homeRoute : homeRoute.concat([this.tabRouterList?.[routeIdx]]); }, removeTabRouterList() { this.tabRouterList = [];