From 6b87db103119db1cabc31fa1c0222470c76da6b2 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 3 Feb 2026 14:00:11 +0800 Subject: [PATCH] fix: Fixed white screen issue when regular users access restricted menus --- frontend/src/router/watch.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/router/watch.ts b/frontend/src/router/watch.ts index 524ec576..e34418d7 100644 --- a/frontend/src/router/watch.ts +++ b/frontend/src/router/watch.ts @@ -12,6 +12,8 @@ const userStore = useUserStore() const { wsCache } = useCache() const whiteList = ['/login', '/admin-login'] const assistantWhiteList = ['/assistant', '/embeddedPage', '/embeddedCommon', '/401'] + +const wsAdminRouterList = ['/ds/index', '/as/index'] export const watchRouter = (router: Router) => { router.beforeEach(async (to: any, from: any, next: any) => { await loadXpackStatic() @@ -35,14 +37,15 @@ export const watchRouter = (router: Router) => { next(toLoginPage(to.fullPath)) return } - let isFirstDynamicPath = false if (!userStore.getUid) { await userStore.info() generateDynamicRouters(router) - isFirstDynamicPath = to?.path && ['/ds/index', '/as/index'].includes(to.path) + const isFirstDynamicPath = to?.path && ['/ds/index', '/as/index'].includes(to.path) if (isFirstDynamicPath) { - next({ ...to, replace: true }) - return + if (userStore.isSpaceAdmin) { + next({ ...to, replace: true }) + return + } } } if (to.path === '/' || accessCrossPermission(to)) { @@ -62,9 +65,14 @@ const accessCrossPermission = (to: any) => { if (!to?.path) return false return ( (to.path.startsWith('/system') && !userStore.isAdmin) || - (to.path.startsWith('/set') && !userStore.isSpaceAdmin) + (to.path.startsWith('/set') && !userStore.isSpaceAdmin) || + (isWsAdminRouter(to) && !userStore.isSpaceAdmin) ) } + +const isWsAdminRouter = (to?: any) => { + return wsAdminRouterList.some((item: string) => to?.path?.startsWith(item)) +} const loadXpackStatic = () => { if (document.getElementById('sqlbot_xpack_static')) { return Promise.resolve()