Skip to content

Commit 9cf2a51

Browse files
committed
fix(projects): Fix homepage mount error under dynamic routing
1 parent 0123c37 commit 9cf2a51

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/store/modules/tab/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { RouteKey } from '@elegant-router/types';
66
import { SetupStoreId } from '@/enum';
77
import { useRouterPush } from '@/hooks/common/router';
88
import { localStg } from '@/utils/storage';
9+
import { useRouteStore } from '@/store/modules/route';
910
import { useThemeStore } from '../theme';
1011
import {
1112
filterTabsByAllRoutes,
@@ -23,6 +24,7 @@ import {
2324

2425
export const useTabStore = defineStore(SetupStoreId.Tab, () => {
2526
const router = useRouter();
27+
const routeStore = useRouteStore();
2628
const themeStore = useThemeStore();
2729
const { routerPush } = useRouterPush(false);
2830

@@ -34,7 +36,7 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
3436

3537
/** Init home tab */
3638
function initHomeTab() {
37-
homeTab.value = getDefaultHomeTab(router);
39+
homeTab.value = getDefaultHomeTab(router, routeStore.routeHome);
3840
}
3941

4042
/** Get all tabs */

src/store/modules/tab/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ export function getRouteIcons(route: App.Global.TabRoute) {
100100
* Get default home tab
101101
*
102102
* @param router
103+
* @param homeRouteName routeHome in useRouteStore
103104
*/
104-
export function getDefaultHomeTab(router: Router) {
105-
const homeRouteName = import.meta.env.VITE_ROUTE_HOME;
105+
export function getDefaultHomeTab(router: Router, homeRouteName: LastLevelRouteKey) {
106106
const homeRoutePath = getRoutePath(homeRouteName);
107107
const i18nLabel = $t(`route.${homeRouteName}`);
108108

0 commit comments

Comments
 (0)