mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-28 19:47:49 +08:00
fix bugs
This commit is contained in:
+7
-6
@@ -1,5 +1,5 @@
|
||||
import store from '@/store';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import store from '@/store'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
@@ -105,13 +105,14 @@ const router = createRouter({
|
||||
// 导航守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
// 通过 Vuex Store 检查用户是否已登录
|
||||
const isAuthenticated = store.state.auth.token !== null;
|
||||
const isAuthenticated = store.state.auth.token !== null
|
||||
if (to.meta.requiresAuth && !isAuthenticated) {
|
||||
// 如果路由需要登录权限且用户未登录,则跳转到登录页面
|
||||
next('/login');
|
||||
} else {
|
||||
next('/login')
|
||||
}
|
||||
else {
|
||||
// 否则,允许继续进行路由导航
|
||||
next();
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user