From 4b7d732ec7401123f7f2b4874c9e833b29fac254 Mon Sep 17 00:00:00 2001 From: sunlei Date: Tue, 16 Jun 2026 13:27:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8DDashboard=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antdv-next/src/api/core/menu.spec.ts | 66 +++++++++++++++++++ apps/web-antdv-next/src/api/core/menu.ts | 3 + 2 files changed, 69 insertions(+) create mode 100644 apps/web-antdv-next/src/api/core/menu.spec.ts diff --git a/apps/web-antdv-next/src/api/core/menu.spec.ts b/apps/web-antdv-next/src/api/core/menu.spec.ts new file mode 100644 index 0000000..c770d6e --- /dev/null +++ b/apps/web-antdv-next/src/api/core/menu.spec.ts @@ -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', + }, + ], + }, + ]); + }); +}); diff --git a/apps/web-antdv-next/src/api/core/menu.ts b/apps/web-antdv-next/src/api/core/menu.ts index 0783d4b..0b708e1 100644 --- a/apps/web-antdv-next/src/api/core/menu.ts +++ b/apps/web-antdv-next/src/api/core/menu.ts @@ -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) {