From 4708eded4c7765eec77f0c90f58980f393353a73 Mon Sep 17 00:00:00 2001 From: paynezhuang Date: Sat, 27 Apr 2024 00:25:56 +0800 Subject: [PATCH] fix(projects): fix tab fixedIndex as null case --- src/store/modules/tab/shared.ts | 6 +++--- src/typings/app.d.ts | 2 +- src/typings/router.d.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/store/modules/tab/shared.ts b/src/store/modules/tab/shared.ts index 2d4b6d526..a6acbf017 100644 --- a/src/store/modules/tab/shared.ts +++ b/src/store/modules/tab/shared.ts @@ -17,10 +17,10 @@ export function getAllTabs(tabs: App.Global.Tab[], homeTab?: App.Global.Tab) { const filterHomeTabs = tabs.filter(tab => tab.id !== homeTab.id); const fixedTabs = filterHomeTabs - .filter(tab => tab.fixedIndex !== undefined) + .filter(tab => tab.fixedIndex !== undefined && tab.fixedIndex !== null) .sort((a, b) => a.fixedIndex! - b.fixedIndex!); - const remainTabs = filterHomeTabs.filter(tab => tab.fixedIndex === undefined); + const remainTabs = filterHomeTabs.filter(tab => tab.fixedIndex === undefined || tab.fixedIndex === null); const allTabs = [homeTab, ...fixedTabs, ...remainTabs]; @@ -177,7 +177,7 @@ export function extractTabsByAllRoutes(router: Router, tabs: App.Global.Tab[]) { * @param tabs */ export function getFixedTabs(tabs: App.Global.Tab[]) { - return tabs.filter(tab => tab.fixedIndex !== undefined); + return tabs.filter(tab => tab.fixedIndex !== undefined && tab.fixedIndex !== null); } /** diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index 13cc492ff..f9efe69b5 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -198,7 +198,7 @@ declare namespace App { /** The tab route full path */ fullPath: string; /** The tab fixed index */ - fixedIndex?: number; + fixedIndex?: number | null; /** * Tab icon * diff --git a/src/typings/router.d.ts b/src/typings/router.d.ts index ffa804c53..13dc4f242 100644 --- a/src/typings/router.d.ts +++ b/src/typings/router.d.ts @@ -58,7 +58,7 @@ declare module 'vue-router' { /** By default, the same route path will use one tab, if set to true, it will use multiple tabs */ multiTab?: boolean; /** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */ - fixedIndexInTab?: number; + fixedIndexInTab?: number | null; /** if set query parameters, it will be automatically carried when entering the route */ query?: Record; }