fix(projects): fix repeat home tab
This commit is contained in:
parent
a17d68eb11
commit
bccd6cb3c3
@ -9,7 +9,7 @@ import { localStg } from '@/utils/storage';
|
|||||||
import { useRouteStore } from '@/store/modules/route';
|
import { useRouteStore } from '@/store/modules/route';
|
||||||
import { useThemeStore } from '../theme';
|
import { useThemeStore } from '../theme';
|
||||||
import {
|
import {
|
||||||
filterTabsByAllRoutes,
|
extractTabsByAllRoutes,
|
||||||
filterTabsById,
|
filterTabsById,
|
||||||
filterTabsByIds,
|
filterTabsByIds,
|
||||||
findTabByRouteName,
|
findTabByRouteName,
|
||||||
@ -63,8 +63,8 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
|||||||
const storageTabs = localStg.get('globalTabs');
|
const storageTabs = localStg.get('globalTabs');
|
||||||
|
|
||||||
if (themeStore.tab.cache && storageTabs) {
|
if (themeStore.tab.cache && storageTabs) {
|
||||||
const filteredTabs = filterTabsByAllRoutes(router, storageTabs);
|
const extractedTabs = extractTabsByAllRoutes(router, storageTabs);
|
||||||
tabs.value = updateTabsByI18nKey(filteredTabs);
|
tabs.value = updateTabsByI18nKey(extractedTabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
addTab(currentRoute);
|
addTab(currentRoute);
|
||||||
|
@ -14,9 +14,13 @@ export function getAllTabs(tabs: App.Global.Tab[], homeTab?: App.Global.Tab) {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const fixedTabs = tabs.filter(tab => tab.fixedIndex !== undefined).sort((a, b) => a.fixedIndex! - b.fixedIndex!);
|
const filterHomeTabs = tabs.filter(tab => tab.id !== homeTab.id);
|
||||||
|
|
||||||
const remainTabs = tabs.filter(tab => tab.fixedIndex === undefined);
|
const fixedTabs = filterHomeTabs
|
||||||
|
.filter(tab => tab.fixedIndex !== undefined)
|
||||||
|
.sort((a, b) => a.fixedIndex! - b.fixedIndex!);
|
||||||
|
|
||||||
|
const remainTabs = filterHomeTabs.filter(tab => tab.fixedIndex === undefined);
|
||||||
|
|
||||||
const allTabs = [homeTab, ...fixedTabs, ...remainTabs];
|
const allTabs = [homeTab, ...fixedTabs, ...remainTabs];
|
||||||
|
|
||||||
@ -154,12 +158,12 @@ export function filterTabsByIds(tabIds: string[], tabs: App.Global.Tab[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter tabs by all routes
|
* extract tabs by all routes
|
||||||
*
|
*
|
||||||
* @param router
|
* @param router
|
||||||
* @param tabs
|
* @param tabs
|
||||||
*/
|
*/
|
||||||
export function filterTabsByAllRoutes(router: Router, tabs: App.Global.Tab[]) {
|
export function extractTabsByAllRoutes(router: Router, tabs: App.Global.Tab[]) {
|
||||||
const routes = router.getRoutes();
|
const routes = router.getRoutes();
|
||||||
|
|
||||||
const routeNames = routes.map(route => route.name);
|
const routeNames = routes.map(route => route.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user