@@ -12,6 +12,8 @@ const userStore = useUserStore()
1212const { wsCache } = useCache ( )
1313const whiteList = [ '/login' , '/admin-login' ]
1414const assistantWhiteList = [ '/assistant' , '/embeddedPage' , '/embeddedCommon' , '/401' ]
15+
16+ const wsAdminRouterList = [ '/ds/index' , '/as/index' ]
1517export const watchRouter = ( router : Router ) => {
1618 router . beforeEach ( async ( to : any , from : any , next : any ) => {
1719 await loadXpackStatic ( )
@@ -35,14 +37,15 @@ export const watchRouter = (router: Router) => {
3537 next ( toLoginPage ( to . fullPath ) )
3638 return
3739 }
38- let isFirstDynamicPath = false
3940 if ( ! userStore . getUid ) {
4041 await userStore . info ( )
4142 generateDynamicRouters ( router )
42- isFirstDynamicPath = to ?. path && [ '/ds/index' , '/as/index' ] . includes ( to . path )
43+ const isFirstDynamicPath = to ?. path && [ '/ds/index' , '/as/index' ] . includes ( to . path )
4344 if ( isFirstDynamicPath ) {
44- next ( { ...to , replace : true } )
45- return
45+ if ( userStore . isSpaceAdmin ) {
46+ next ( { ...to , replace : true } )
47+ return
48+ }
4649 }
4750 }
4851 if ( to . path === '/' || accessCrossPermission ( to ) ) {
@@ -62,9 +65,14 @@ const accessCrossPermission = (to: any) => {
6265 if ( ! to ?. path ) return false
6366 return (
6467 ( to . path . startsWith ( '/system' ) && ! userStore . isAdmin ) ||
65- ( to . path . startsWith ( '/set' ) && ! userStore . isSpaceAdmin )
68+ ( to . path . startsWith ( '/set' ) && ! userStore . isSpaceAdmin ) ||
69+ ( isWsAdminRouter ( to ) && ! userStore . isSpaceAdmin )
6670 )
6771}
72+
73+ const isWsAdminRouter = ( to ?: any ) => {
74+ return wsAdminRouterList . some ( ( item : string ) => to ?. path ?. startsWith ( item ) )
75+ }
6876const loadXpackStatic = ( ) => {
6977 if ( document . getElementById ( 'sqlbot_xpack_static' ) ) {
7078 return Promise . resolve ( )
0 commit comments