mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-12 19:40:41 +08:00
fix router
This commit is contained in:
@@ -10,46 +10,64 @@ const router = createRouter({
|
||||
children: [
|
||||
{
|
||||
path: 'dashboard',
|
||||
component: () => import('../pages/dashboard.vue')
|
||||
component: () => import('../pages/dashboard.vue'),
|
||||
},
|
||||
{
|
||||
path: 'ranking',
|
||||
component: () => import('../pages/ranking.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'resources',
|
||||
component: () => import('../pages/resources.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'subscribe-movie',
|
||||
component: () => import('../pages/subscribe-movie.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'subscribe-tv',
|
||||
component: () => import('../pages/subscribe-tv.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'downloading',
|
||||
component: () => import('../pages/downloading.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'history',
|
||||
component: () => import('../pages/history.vue'),
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
{
|
||||
path: 'sites',
|
||||
component: () => import('../pages/sites.vue'),
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
}
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'account-settings',
|
||||
component: () => import('../pages/account-settings.vue'),
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
}
|
||||
}
|
||||
requiresAuth: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -79,7 +97,8 @@ router.beforeEach((to, from, next) => {
|
||||
if (to.meta.requiresAuth && !isAuthenticated) {
|
||||
// 如果路由需要登录权限且用户未登录,则跳转到登录页面
|
||||
next('/login')
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// 否则,允许继续进行路由导航
|
||||
next()
|
||||
}
|
||||
@@ -89,6 +108,7 @@ router.beforeEach((to, from, next) => {
|
||||
function checkLoginStatus() {
|
||||
// 在此处检查用户的登录状态,例如从本地存储中读取令牌或其他登录相关的信息
|
||||
const token = localStorage.getItem('token')
|
||||
|
||||
return !!token // 返回一个布尔值,表示用户是否已登录
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user