fix: 恢复Dashboard菜单路由

This commit is contained in:
sunlei 2026-06-16 13:27:44 +08:00
parent c95ac9df9e
commit 4b7d732ec7
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,66 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
const requestClientGet = vi.fn();
vi.mock('#/api/request', () => ({
requestClient: {
get: requestClientGet,
},
}));
describe('core menu api', () => {
beforeEach(() => {
requestClientGet.mockReset();
});
it('keeps supported dashboard routes from backend menus', async () => {
requestClientGet.mockResolvedValue([
{
name: 'Dashboard',
path: '/dashboard',
redirect: '/analytics',
children: [
{
name: 'Analytics',
path: '/analytics',
component: '/dashboard/analytics/index',
},
{
name: 'Workspace',
path: '/workspace',
component: '/dashboard/workspace/index',
},
],
},
{
name: 'Unsupported',
path: '/unsupported',
component: '/unsupported/index',
},
]);
const { getAllMenusApi } = await import('./menu');
const menus = await getAllMenusApi();
expect(requestClientGet).toHaveBeenCalledWith('/menu/all');
expect(menus).toEqual([
{
name: 'Dashboard',
path: '/dashboard',
redirect: '/analytics',
children: [
{
name: 'Analytics',
path: '/analytics',
component: '/dashboard/analytics/index',
},
{
name: 'Workspace',
path: '/workspace',
component: '/dashboard/workspace/index',
},
],
},
]);
});
});

View File

@ -3,6 +3,7 @@ import type { RouteRecordStringComponent } from '@vben/types';
import { requestClient } from '#/api/request';
const SUPPORTED_ADMIN_MENU_NAMES = new Set([
'Analytics',
'Blog',
'BlogArticle',
'BlogArticleCreate',
@ -20,6 +21,7 @@ const SUPPORTED_ADMIN_MENU_NAMES = new Set([
'BlogTheme',
'BlogThemeImport',
'BlogThemeSave',
'Dashboard',
'Profile',
'QqBot',
'QqBotAccount',
@ -81,6 +83,7 @@ const SUPPORTED_ADMIN_MENU_NAMES = new Set([
'SystemUserCreate',
'SystemUserDelete',
'SystemUserEdit',
'Workspace',
]);
export function isSupportedAdminMenuName(name?: null | string | symbol) {