Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(projects): fix tab fixedIndex as null case #414

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/store/modules/tab/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/typings/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/typings/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;
}
Expand Down
Loading