diff --git a/src/api/system/menu/types.ts b/src/api/system/menu/types.ts index ca19840..d566fbe 100644 --- a/src/api/system/menu/types.ts +++ b/src/api/system/menu/types.ts @@ -44,6 +44,8 @@ export interface MenuVO extends BaseEntity { visible: string; status: string; icon: string; + activeMenu: string; + ext: string; remark: string; } @@ -63,6 +65,8 @@ export interface MenuForm { visible?: string; status?: string; icon?: string; + activeMenu?: string; + ext?: string; remark?: string; query?: string; perms?: string; diff --git a/src/components/TopNav/index.vue b/src/components/TopNav/index.vue index 80e1ee5..26c79b5 100644 --- a/src/components/TopNav/index.vue +++ b/src/components/TopNav/index.vue @@ -97,8 +97,9 @@ const childrenMenus = computed(() => { // 默认激活的菜单 const activeMenu = computed(() => { - let path = route.path; - if (path === '/index') { + const { meta } = route; + let path = meta.activeMenu || route.path; + if (path === '/index' || route.path === '/index') { path = '/system/user'; } let activePath = path; diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index bca0688..706cbf8 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -47,8 +47,8 @@ export const usePermissionStore = defineStore('permission', () => { }; const generateRoutes = async (): Promise => { const res = await getRouters(); - const { data } = res; - let text = JSON.stringify(data); + const data = Array.isArray(res.data) ? res.data : []; + const text = JSON.stringify(data); const sdata = JSON.parse(text); const rdata = JSON.parse(text); const defaultData = JSON.parse(text); @@ -65,7 +65,7 @@ export const usePermissionStore = defineStore('permission', () => { setTopbarRoutes(defaultRoutes); // 路由name重复检查 duplicateRouteChecker(asyncRoutes, sidebarRoutes); - return new Promise(resolve => resolve(rewriteRoutes)); + return rewriteRoutes; }; /** diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue index 4b31a80..3616017 100644 --- a/src/views/system/menu/index.vue +++ b/src/views/system/menu/index.vue @@ -313,7 +313,7 @@ - + - + + + + + + @@ -398,7 +403,9 @@ const initFormData = { isFrame: 'N', isCache: 'Y', visible: '0', - status: '0' + status: '0', + activeMenu: '', + remark: '' }; const data = reactive>({ form: { ...initFormData },