mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 09:17:06 +08:00
fix: Fixed white screen issue when regular users access restricted menus
This commit is contained in:
committed by
fit2cloud-chenyw
parent
175138758a
commit
a2c1ec0e25
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user