Skip to content

Commit

Permalink
fix: sidebar menu items issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Nov 24, 2024
1 parent 8979bca commit e65380f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/layouts/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ onBeforeMount(async () => {
if (isPro()) {
await store.dispatch('system/getCustomize');
}
console.debug(menuItems.value);
});
defineOptions({ name: 'ClSidebar' });
Expand Down Expand Up @@ -146,7 +147,7 @@ defineOptions({ name: 'ClSidebar' });
:default-openeds="openedIndexes"
@select="onMenuItemClick"
>
<template v-for="(item, index) in menuItems" :key="index">
<template v-for="item in menuItems">
<cl-sidebar-item :item="item" />
</template>
</el-menu>
Expand Down
1 change: 1 addition & 0 deletions src/layouts/components/TabsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ defineOptions({ name: 'ClTabsView' });
&:deep(.el-tabs__header.is-top) {
border-bottom: none;
margin: 0;
}
&:deep(.el-tabs__new-tab) {
Expand Down
9 changes: 5 additions & 4 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export function getDefaultSidebarMenuItems(): MenuItem[] {
},
],
},
{
path: '/users',
title: 'router.menuItems.users',
icon: getIconByRouteConcept('user'),
},
{
path: '/users',
title: 'router.menuItems.usersManagement.title',
Expand Down Expand Up @@ -184,10 +189,6 @@ export function getDefaultHiddenMenuItems(): MenuItem[] {
});
}

export function getDefaultMenuItems(): MenuItem[] {
return [...getDefaultSidebarMenuItems(), ...getDefaultHiddenMenuItems()];
}

export function getRootRoute(
routes: Array<ExtendedRouterRecord>
): ExtendedRouterRecord | undefined {
Expand Down
34 changes: 19 additions & 15 deletions src/store/modules/layout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { plainClone } from '@/utils/object';
import { normalizeTree } from '@/utils/tree';
import { getDefaultMenuItems } from '@/router';
import { getDefaultSidebarMenuItems } from '@/router';
import { isAllowedRoutePath, isPro } from '@/utils';
import { saveLocalStorage } from '@/utils/storage';

Expand Down Expand Up @@ -45,7 +45,7 @@ export default {
state: {
// sidebar
sidebarCollapsed: getDefaultSidebarCollapsed(),
menuItems: getDefaultMenuItems(),
menuItems: getDefaultSidebarMenuItems(),

// tabs view
activeTabId: getDefaultActiveTabId(),
Expand Down Expand Up @@ -91,22 +91,26 @@ export default {
// skip if no path
if (!d.path) return false;

// skip some items if pro
if (isPro()) {
// skip some items if pro
return !['router.menuItems.users'].includes(d.title);
} else {
// skip some items if not pro
switch (d.path) {
case '/notifications':
case '/environments':
case '/system':
case '/deps':
case '/gits':
case '/databases':
case '/dependencies':
return false;
default:
return ['usersManagement'].every(
key => !d.title.includes(key)
);
}
}

// skip some items if not pro
return (
![
'/notifications',
'/environments',
'/system',
'/deps',
'/gits',
'/databases',
].includes(d.path) || !['userManagement'].includes(d.title)
);
})
// filter items by navVisibleFn
.filter(d => {
Expand Down

0 comments on commit e65380f

Please sign in to comment.