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 { useThemeStore } from '../theme';
|
||||
import {
|
||||
filterTabsByAllRoutes,
|
||||
extractTabsByAllRoutes,
|
||||
filterTabsById,
|
||||
filterTabsByIds,
|
||||
findTabByRouteName,
|
||||
@ -63,8 +63,8 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
||||
const storageTabs = localStg.get('globalTabs');
|
||||
|
||||
if (themeStore.tab.cache && storageTabs) {
|
||||
const filteredTabs = filterTabsByAllRoutes(router, storageTabs);
|
||||
tabs.value = updateTabsByI18nKey(filteredTabs);
|
||||
const extractedTabs = extractTabsByAllRoutes(router, storageTabs);
|
||||
tabs.value = updateTabsByI18nKey(extractedTabs);
|
||||
}
|
||||
|
||||
addTab(currentRoute);
|
||||
|
@ -14,9 +14,13 @@ export function getAllTabs(tabs: App.Global.Tab[], homeTab?: App.Global.Tab) {
|
||||
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];
|
||||
|
||||
@ -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 tabs
|
||||
*/
|
||||
export function filterTabsByAllRoutes(router: Router, tabs: App.Global.Tab[]) {
|
||||
export function extractTabsByAllRoutes(router: Router, tabs: App.Global.Tab[]) {
|
||||
const routes = router.getRoutes();
|
||||
|
||||
const routeNames = routes.map(route => route.name);
|
||||
|
Loading…
Reference in New Issue
Block a user