This commit is contained in:
jxxghp
2024-06-13 19:52:31 +08:00
parent 9aa2de526e
commit 7eacaf8fc5
5 changed files with 19 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import { configureNProgress, doneNProgress, startNProgress } from '@/api/nprogress'
import { configureNProgress } from '@/api/nprogress'
import store from '@/store'
// Nprogress
@@ -168,17 +168,11 @@ router.beforeEach((to, from, next) => {
// 总是记录非login路由
if (to.fullPath != '/login') store.state.auth.originalPath = to.fullPath
const isAuthenticated = store.state.auth.token !== null
if (to.meta.requiresAuth && !isAuthenticated) {
next('/login')
} else {
startNProgress()
next()
}
})
router.afterEach(() => {
doneNProgress()
})
export default router