Commit dad5847d by 赵月辉

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

parent 11ede501
...@@ -9,9 +9,9 @@ import useUserStore from '@/store/modules/user' ...@@ -9,9 +9,9 @@ import useUserStore from '@/store/modules/user'
import useSettingsStore from '@/store/modules/settings' import useSettingsStore from '@/store/modules/settings'
import usePermissionStore from '@/store/modules/permission' 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) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
...@@ -19,9 +19,11 @@ router.beforeEach((to, from, next) => { ...@@ -19,9 +19,11 @@ router.beforeEach((to, from, next) => {
to.meta.title && useSettingsStore().setTitle(to.meta.title) to.meta.title && useSettingsStore().setTitle(to.meta.title)
/* has token*/ /* has token*/
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }) next({path: '/'})
NProgress.done() NProgress.done()
} else if (whiteList.indexOf(to.path) !== -1) { } else if (whiteList.indexOf(to.path) !== -1) {
useUserStore().getInfo().then(res => {
})
next() next()
} else { } else {
if (useUserStore().roles.length === 0) { if (useUserStore().roles.length === 0) {
...@@ -36,12 +38,12 @@ router.beforeEach((to, from, next) => { ...@@ -36,12 +38,12 @@ router.beforeEach((to, from, next) => {
router.addRoute(route) // 动态添加可访问路由表 router.addRoute(route) // 动态添加可访问路由表
} }
}) })
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 next({...to, replace: true}) // hack方法 确保addRoutes已完成
}) })
}).catch(err => { }).catch(err => {
useUserStore().logOut().then(() => { useUserStore().logOut().then(() => {
ElMessage.error(err) ElMessage.error(err)
next({ path: '/' }) next({path: '/'})
}) })
}) })
} else { } 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