Commit dad5847d by 赵月辉

修改系统路由不需要登录的白名单

parent 11ede501
......@@ -9,9 +9,9 @@ import useUserStore from '@/store/modules/user'
import useSettingsStore from '@/store/modules/settings'
import usePermissionStore from '@/store/modules/permission'
NProgress.configure({ showSpinner: false });
NProgress.configure({showSpinner: false})
const whiteList = ['/login', '/register','/index','/computingResource/resourceList'];
const whiteList = ['/login', '/register', '/index', '/computingResource/resourceList']
router.beforeEach((to, from, next) => {
NProgress.start()
......@@ -19,9 +19,11 @@ router.beforeEach((to, from, next) => {
to.meta.title && useSettingsStore().setTitle(to.meta.title)
/* has token*/
if (to.path === '/login') {
next({ path: '/' })
next({path: '/'})
NProgress.done()
} else if (whiteList.indexOf(to.path) !== -1) {
useUserStore().getInfo().then(res => {
})
next()
} else {
if (useUserStore().roles.length === 0) {
......@@ -36,12 +38,12 @@ router.beforeEach((to, from, next) => {
router.addRoute(route) // 动态添加可访问路由表
}
})
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
next({...to, replace: true}) // hack方法 确保addRoutes已完成
})
}).catch(err => {
useUserStore().logOut().then(() => {
ElMessage.error(err)
next({ path: '/' })
next({path: '/'})
})
})
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment