fix(projects): fix repeat home tab

This commit is contained in:
Soybean
2024-03-02 11:08:14 +08:00
parent a17d68eb11
commit bccd6cb3c3
2 changed files with 11 additions and 7 deletions

View File

@@ -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);