提交登录跳转问题

This commit is contained in:
limengnan 2025-06-20 10:00:15 +08:00
parent 1c07580224
commit 81d74a4cfe
2 changed files with 2 additions and 10 deletions

View File

@ -139,18 +139,11 @@ router.beforeEach((to, from, next) => {
// 设置页面标题 // 设置页面标题
document.title = to.meta.title ? `${to.meta.title} - StdProject` : 'StdProject' document.title = to.meta.title ? `${to.meta.title} - StdProject` : 'StdProject'
const token = localStorage.getItem('token') || ''
debugger
console.log(userStore.isAuthenticated) console.log(userStore.isAuthenticated)
// 检查是否需要认证 // 检查是否需要认证
if (to.meta.requiresAuth) { if (to.meta.requiresAuth) {
// next() if (!!token) {
// if (userStore.isAuthenticated) {
// next()
// } else {
// next('/login')
// }
if (userStore.isAuthenticated) {
next() next()
} else { } else {
next('/UserLogin') // 未认证重定向到登录页 next('/UserLogin') // 未认证重定向到登录页

View File

@ -5,7 +5,6 @@ import { ElMessage } from 'element-plus'
export const useUserStore = defineStore('user', () => { export const useUserStore = defineStore('user', () => {
// 状态 // 状态
debugger
const token = ref(localStorage.getItem('token') || '') const token = ref(localStorage.getItem('token') || '')
const userInfo = ref(JSON.parse(localStorage.getItem('userInfo') || 'null')) const userInfo = ref(JSON.parse(localStorage.getItem('userInfo') || 'null'))
const permissions = ref(JSON.parse(localStorage.getItem('permissions') || '[]')) const permissions = ref(JSON.parse(localStorage.getItem('permissions') || '[]'))