Commit e4d60eca authored by 李苏's avatar 李苏 💬

路由进度条

parent a7654d57
...@@ -11,14 +11,14 @@ NProgress.configure({ showSpinner: false }) ...@@ -11,14 +11,14 @@ NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
console.log(store.state.user.token) // console.log(store.state.user.token)
NProgress.start() // NProgress.start()
if (getToken()) { if (getToken()) {
to.meta.title && store.dispatch('settings/setTitle', to.meta.title) to.meta.title && store.dispatch('settings/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 { } else {
if (store.state.app.isInit==false) { if (store.state.app.isInit==false) {
store.commit('app/changeInit') store.commit('app/changeInit')
...@@ -40,11 +40,11 @@ router.beforeEach((to, from, next) => { ...@@ -40,11 +40,11 @@ router.beforeEach((to, from, next) => {
next() next()
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
NProgress.done() // NProgress.done()
} }
} }
}) })
router.afterEach(() => { router.afterEach(() => {
NProgress.done() // NProgress.done()
}) })
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 to comment