fix: 恢复Dashboard菜单路由
This commit is contained in:
parent
c95ac9df9e
commit
4b7d732ec7
66
apps/web-antdv-next/src/api/core/menu.spec.ts
Normal file
66
apps/web-antdv-next/src/api/core/menu.spec.ts
Normal 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',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user