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