bug修复
This commit is contained in:
@@ -109,8 +109,11 @@ const router = createRouter({
|
||||
router.beforeEach((to, from, next) => {
|
||||
document.title = to.meta.title ? `${to.meta.title} - 博客系统` : '博客系统'
|
||||
const token = localStorage.getItem('access_token')
|
||||
const userInfo = JSON.parse(localStorage.getItem('user_info') || 'null')
|
||||
if (to.meta.requiresAuth && !token) {
|
||||
next({ name: 'Login', query: { redirect: to.fullPath } })
|
||||
} else if (to.meta.requiresAdmin && userInfo?.role !== 'ADMIN') {
|
||||
next({ name: 'Home' })
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user