diff --git a/ui/src/router/admin/index.ts b/ui/src/router/admin/index.ts index ab91806f4f1..f9457e10faf 100644 --- a/ui/src/router/admin/index.ts +++ b/ui/src/router/admin/index.ts @@ -11,6 +11,7 @@ import { loginRoutes } from './login' import { systemRoutes } from './system' import { workspaceRoutes } from './workspace' import { workflowRoutes } from './workflow' +import { getChildRouteList } from './utils' const ADMIN_BASE_PATH = window.MaxKB?.prefix || import.meta.env.VITE_BASE_PATH || '/admin/' NProgress.configure({ minimum: 0.3, showSpinner: false, speed: 500, trickleSpeed: 200 }) @@ -61,6 +62,15 @@ router.beforeEach(async (to, from) => { } } +const workspaceList = user.userInfo?.workspace_list ?? [] +if (to.name === 'workspace-home' && workspaceList.length === 0) { + const hasSystemAccess = getChildRouteList('system').some((item) => (item.permission ? item.permission() : true)) + if (hasSystemAccess) { + return { name: 'system-home', replace: true } + } + // 没有任何工作空间、也没有系统权限:不做额外处理,保持原有行为 +} + // 当前路由有权限,放行 if (!to.meta?.permission || (to.meta.permission as (route: RouteLocationNormalizedLoaded) => boolean)(to)) { return true