feat: 系统功能更新 - 添加错误统计、数据初始化、订单调度等功能
This commit is contained in:
@@ -190,6 +190,12 @@ const routes = [
|
||||
component: () => import('@/views/ApiManagement.vue'),
|
||||
meta: { title: 'API管理', requiresAuth: true, requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: '/admin/error-statistics',
|
||||
name: 'ErrorStatistics',
|
||||
component: () => import('@/views/ErrorStatistics.vue'),
|
||||
meta: { title: '错误统计', requiresAuth: true, requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: '/hello',
|
||||
name: 'HelloWorld',
|
||||
@@ -246,6 +252,13 @@ router.beforeEach(async (to, from, next) => {
|
||||
try {
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 检查localStorage中的token是否被清除(例如JWT过期后被request.js清除)
|
||||
// 如果token被清除但store中仍有用户信息,则同步清除store
|
||||
const storedToken = localStorage.getItem('token')
|
||||
if (!storedToken && userStore.isAuthenticated) {
|
||||
userStore.clearUserData()
|
||||
}
|
||||
|
||||
// 优化:只在首次访问时初始化用户状态
|
||||
if (!userStore.initialized) {
|
||||
await userStore.init()
|
||||
|
||||
Reference in New Issue
Block a user