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';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
const SUPPORTED_ADMIN_MENU_NAMES = new Set([
|
const SUPPORTED_ADMIN_MENU_NAMES = new Set([
|
||||||
|
'Analytics',
|
||||||
'Blog',
|
'Blog',
|
||||||
'BlogArticle',
|
'BlogArticle',
|
||||||
'BlogArticleCreate',
|
'BlogArticleCreate',
|
||||||
@ -20,6 +21,7 @@ const SUPPORTED_ADMIN_MENU_NAMES = new Set([
|
|||||||
'BlogTheme',
|
'BlogTheme',
|
||||||
'BlogThemeImport',
|
'BlogThemeImport',
|
||||||
'BlogThemeSave',
|
'BlogThemeSave',
|
||||||
|
'Dashboard',
|
||||||
'Profile',
|
'Profile',
|
||||||
'QqBot',
|
'QqBot',
|
||||||
'QqBotAccount',
|
'QqBotAccount',
|
||||||
@ -81,6 +83,7 @@ const SUPPORTED_ADMIN_MENU_NAMES = new Set([
|
|||||||
'SystemUserCreate',
|
'SystemUserCreate',
|
||||||
'SystemUserDelete',
|
'SystemUserDelete',
|
||||||
'SystemUserEdit',
|
'SystemUserEdit',
|
||||||
|
'Workspace',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function isSupportedAdminMenuName(name?: null | string | symbol) {
|
export function isSupportedAdminMenuName(name?: null | string | symbol) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user