xto-fronted 0.4.59 → 0.4.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,173 +1,173 @@
1
- /**
2
- * 动态路由模板
3
- */
4
-
5
- import type { RouteRecordRaw } from 'vue-router'
6
-
7
- // 布局路由(包含默认子路由和 catch-all 404)
8
- export const layoutRoute: RouteRecordRaw = {
9
- path: '/',
10
- name: 'Layout',
11
- component: () => import('@/components/Layout/index.vue'),
12
- redirect: '/dashboard',
13
- children: [
14
- {
15
- path: '/dashboard',
16
- name: 'Dashboard',
17
- component: () => import('@/views/dashboard/index.vue'),
18
- meta: {
19
- title: '仪表盘',
20
- icon: 'dashboard',
21
- keepAlive: true,
22
- affix: true
23
- }
24
- },
25
- {
26
- path: '/system/user',
27
- name: 'SystemUser',
28
- component: () => import('@/views/system/user/index.vue'),
29
- meta: {
30
- title: '用户管理',
31
- icon: 'user',
32
- keepAlive: true
33
- }
34
- },
35
- {
36
- path: '/system/role',
37
- name: 'SystemRole',
38
- component: () => import('@/views/system/role/index.vue'),
39
- meta: {
40
- title: '角色管理',
41
- icon: 'role',
42
- keepAlive: true
43
- }
44
- },
45
- {
46
- path: '/system/menu',
47
- name: 'SystemMenu',
48
- component: () => import('@/views/system/menu/index.vue'),
49
- meta: {
50
- title: '菜单管理',
51
- icon: 'menu',
52
- keepAlive: true
53
- }
54
- },
55
- // catch-all 路由:让 404 在 Layout 内部渲染,保持左侧菜单显示
56
- {
57
- path: '/:pathMatch(.*)*',
58
- name: 'CatchAll',
59
- component: () => import('@/views/error/404.vue'),
60
- meta: {
61
- title: '404',
62
- hidden: true
63
- }
64
- }
65
- ]
66
- }
67
-
68
- // 默认路由(用于开发,后续由后端返回)
69
- export const defaultDynamicRoutes: RouteRecordRaw[] = [
70
- {
71
- path: '/dashboard',
72
- name: 'Dashboard',
73
- component: () => import('@/views/dashboard/index.vue'),
74
- meta: {
75
- title: '仪表盘',
76
- icon: 'dashboard',
77
- keepAlive: true,
78
- affix: true
79
- }
80
- },
81
- {
82
- path: '/system',
83
- name: 'System',
84
- redirect: '/system/user',
85
- meta: {
86
- title: '系统管理',
87
- icon: 'setting'
88
- },
89
- children: [
90
- {
91
- path: 'user',
92
- name: 'SystemUser',
93
- component: () => import('@/views/system/user/index.vue'),
94
- meta: {
95
- title: '用户管理',
96
- icon: 'user',
97
- keepAlive: true
98
- }
99
- },
100
- {
101
- path: 'role',
102
- name: 'SystemRole',
103
- component: () => import('@/views/system/role/index.vue'),
104
- meta: {
105
- title: '角色管理',
106
- icon: 'role',
107
- keepAlive: true
108
- }
109
- },
110
- {
111
- path: 'menu',
112
- name: 'SystemMenu',
113
- component: () => import('@/views/system/menu/index.vue'),
114
- meta: {
115
- title: '菜单管理',
116
- icon: 'menu',
117
- keepAlive: true
118
- }
119
- }
120
- ]
121
- }
122
- ]
123
-
124
- // Mock 菜单数据(参考 tineco-ui 格式)
125
- export const mockMenuData = [
126
- {
127
- menuCode: 'dashboard',
128
- menuName: '仪表盘',
129
- menuUrl: '/dashboard',
130
- icon: 'dashboard',
131
- closable: true,
132
- isDefault: true,
133
- isOut: false
134
- },
135
- {
136
- menuCode: 'system',
137
- menuName: '系统管理',
138
- menuUrl: '/system',
139
- icon: 'setting',
140
- closable: false,
141
- isDefault: false,
142
- isOut: false,
143
- children: [
144
- {
145
- menuCode: 'system_user',
146
- menuName: '用户管理',
147
- menuUrl: '/system/user',
148
- icon: 'user',
149
- closable: true,
150
- isDefault: false,
151
- isOut: false
152
- },
153
- {
154
- menuCode: 'system_role',
155
- menuName: '角色管理',
156
- menuUrl: '/system/role',
157
- icon: 'role',
158
- closable: true,
159
- isDefault: false,
160
- isOut: false
161
- },
162
- {
163
- menuCode: 'system_menu',
164
- menuName: '菜单管理',
165
- menuUrl: '/system/menu',
166
- icon: 'menu',
167
- closable: true,
168
- isDefault: false,
169
- isOut: false
170
- }
171
- ]
172
- }
1
+ /**
2
+ * 动态路由模板
3
+ */
4
+
5
+ import type { RouteRecordRaw } from 'vue-router'
6
+
7
+ // 布局路由(包含默认子路由和 catch-all 404)
8
+ export const layoutRoute: RouteRecordRaw = {
9
+ path: '/',
10
+ name: 'Layout',
11
+ component: () => import('@/components/Layout/index.vue'),
12
+ redirect: '/dashboard',
13
+ children: [
14
+ {
15
+ path: '/dashboard',
16
+ name: 'Dashboard',
17
+ component: () => import('@/views/dashboard/index.vue'),
18
+ meta: {
19
+ title: '仪表盘',
20
+ icon: 'dashboard',
21
+ keepAlive: true,
22
+ affix: true
23
+ }
24
+ },
25
+ {
26
+ path: '/system/user',
27
+ name: 'SystemUser',
28
+ component: () => import('@/views/system/user/index.vue'),
29
+ meta: {
30
+ title: '用户管理',
31
+ icon: 'user',
32
+ keepAlive: true
33
+ }
34
+ },
35
+ {
36
+ path: '/system/role',
37
+ name: 'SystemRole',
38
+ component: () => import('@/views/system/role/index.vue'),
39
+ meta: {
40
+ title: '角色管理',
41
+ icon: 'role',
42
+ keepAlive: true
43
+ }
44
+ },
45
+ {
46
+ path: '/system/menu',
47
+ name: 'SystemMenu',
48
+ component: () => import('@/views/system/menu/index.vue'),
49
+ meta: {
50
+ title: '菜单管理',
51
+ icon: 'menu',
52
+ keepAlive: true
53
+ }
54
+ },
55
+ // catch-all 路由:让 404 在 Layout 内部渲染,保持左侧菜单显示
56
+ {
57
+ path: '/:pathMatch(.*)*',
58
+ name: 'CatchAll',
59
+ component: () => import('@/views/error/404.vue'),
60
+ meta: {
61
+ title: '404',
62
+ hidden: true
63
+ }
64
+ }
65
+ ]
66
+ }
67
+
68
+ // 默认路由(用于开发,后续由后端返回)
69
+ export const defaultDynamicRoutes: RouteRecordRaw[] = [
70
+ {
71
+ path: '/dashboard',
72
+ name: 'Dashboard',
73
+ component: () => import('@/views/dashboard/index.vue'),
74
+ meta: {
75
+ title: '仪表盘',
76
+ icon: 'dashboard',
77
+ keepAlive: true,
78
+ affix: true
79
+ }
80
+ },
81
+ {
82
+ path: '/system',
83
+ name: 'System',
84
+ redirect: '/system/user',
85
+ meta: {
86
+ title: '系统管理',
87
+ icon: 'setting'
88
+ },
89
+ children: [
90
+ {
91
+ path: 'user',
92
+ name: 'SystemUser',
93
+ component: () => import('@/views/system/user/index.vue'),
94
+ meta: {
95
+ title: '用户管理',
96
+ icon: 'user',
97
+ keepAlive: true
98
+ }
99
+ },
100
+ {
101
+ path: 'role',
102
+ name: 'SystemRole',
103
+ component: () => import('@/views/system/role/index.vue'),
104
+ meta: {
105
+ title: '角色管理',
106
+ icon: 'role',
107
+ keepAlive: true
108
+ }
109
+ },
110
+ {
111
+ path: 'menu',
112
+ name: 'SystemMenu',
113
+ component: () => import('@/views/system/menu/index.vue'),
114
+ meta: {
115
+ title: '菜单管理',
116
+ icon: 'menu',
117
+ keepAlive: true
118
+ }
119
+ }
120
+ ]
121
+ }
122
+ ]
123
+
124
+ // Mock 菜单数据(参考 tineco-ui 格式)
125
+ export const mockMenuData = [
126
+ {
127
+ menuCode: 'dashboard',
128
+ menuName: '仪表盘',
129
+ menuUrl: '/dashboard',
130
+ icon: 'dashboard',
131
+ closable: true,
132
+ isDefault: true,
133
+ isOut: false
134
+ },
135
+ {
136
+ menuCode: 'system',
137
+ menuName: '系统管理',
138
+ menuUrl: '/system',
139
+ icon: 'setting',
140
+ closable: false,
141
+ isDefault: false,
142
+ isOut: false,
143
+ children: [
144
+ {
145
+ menuCode: 'system_user',
146
+ menuName: '用户管理',
147
+ menuUrl: '/system/user',
148
+ icon: 'user',
149
+ closable: true,
150
+ isDefault: false,
151
+ isOut: false
152
+ },
153
+ {
154
+ menuCode: 'system_role',
155
+ menuName: '角色管理',
156
+ menuUrl: '/system/role',
157
+ icon: 'role',
158
+ closable: true,
159
+ isDefault: false,
160
+ isOut: false
161
+ },
162
+ {
163
+ menuCode: 'system_menu',
164
+ menuName: '菜单管理',
165
+ menuUrl: '/system/menu',
166
+ icon: 'menu',
167
+ closable: true,
168
+ isDefault: false,
169
+ isOut: false
170
+ }
171
+ ]
172
+ }
173
173
  ]
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import type { Router } from 'vue-router'
6
- import { getToken } from '@/utils/auth'
6
+ import { getToken, clearToken } from '@/utils/auth'
7
7
  import { useUserStore } from '@/stores/user'
8
8
  import { useMenuStore } from '@/stores/menu'
9
9
  import { useAppStore } from '@/stores/app'
@@ -99,14 +99,12 @@ export function setupRouterGuards(router: Router, options: RouterGuardOptions =
99
99
  // 重新导航到目标路由,确保动态路由已添加
100
100
  next({ ...to, replace: true })
101
101
  } catch (error) {
102
- // 获取用户信息失败,清除 token 并跳转到登录页
102
+ // 获取用户信息失败,清除所有 token 相关数据并跳转到登录页
103
103
  console.error('获取用户信息失败:', error)
104
104
  userStore.clearUserInfo()
105
105
  menuStore.clearMenu()
106
- // 清除 token
107
- localStorage.removeItem('token')
108
- localStorage.removeItem('token_type')
109
- localStorage.removeItem('refresh_token')
106
+ // 使用 clearToken 清除所有 token 相关数据(包括 expires_time、refresh_time 等)
107
+ clearToken()
110
108
  next({ path: loginPath, query: { redirect: to.fullPath } })
111
109
  }
112
110
  }