xto-fronted 0.4.103 → 0.4.104
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.
- package/dist/{index-CNx4xpUG.js → index-C2zTmROz.js} +439 -439
- package/dist/{index-BsPaXQak.js → index-Ci9SM-gg.js} +1 -1
- package/dist/{index-DEChud2_.js → index-HtulbTHk.js} +1 -1
- package/dist/{index-BlN5yXBT.js → index-j1GPEQjY.js} +1 -1
- package/dist/{index-DdACCkye.js → index-x7bKZmey.js} +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/router/guards.ts +129 -127
|
@@ -3,7 +3,7 @@ import { Form as S, FormItem as c, Input as x, Select as W, Switch as U } from "
|
|
|
3
3
|
import { Tag as X, Pagination as Y } from "@xto/data";
|
|
4
4
|
import { Popconfirm as Z, Modal as ee, Message as C } from "@xto/feedback";
|
|
5
5
|
import { Space as D, Button as g } from "@xto/base";
|
|
6
|
-
import { S as d, a as te, _ as le } from "./index-
|
|
6
|
+
import { S as d, a as te, _ as le } from "./index-C2zTmROz.js";
|
|
7
7
|
const se = { class: "user-page" }, ae = { class: "search-section" }, oe = { class: "table-section" }, ne = { class: "table-toolbar" }, ie = { class: "toolbar-left" }, de = { class: "toolbar-right" }, re = { class: "table-count" }, ue = { class: "table-wrapper" }, me = { class: "data-table" }, ce = { key: 0 }, pe = { key: 1 }, ve = { class: "col-id" }, fe = { class: "id-badge" }, he = { class: "col-user" }, ge = { class: "user-info" }, ke = { class: "user-avatar" }, _e = { class: "user-detail" }, ye = { class: "user-nickname" }, xe = { class: "user-username" }, Ve = { class: "col-contact" }, be = { class: "contact-info" }, Ee = { class: "contact-email" }, Be = { class: "contact-phone" }, Ce = { class: "col-roles" }, De = { class: "role-tags" }, Le = { class: "col-status" }, we = { class: "status-switch" }, ze = { class: "col-time" }, Ae = { class: "time-text" }, Ne = { class: "col-actions" }, Se = { class: "pagination-wrapper" }, Ue = { class: "status-field" }, Me = { class: "status-label" }, Te = /* @__PURE__ */ R({
|
|
8
8
|
__name: "index",
|
|
9
9
|
setup(Ie) {
|
|
@@ -3,7 +3,7 @@ import { Form as Y, FormItem as p, Input as _, Select as j, InputNumber as G, Sw
|
|
|
3
3
|
import { Tag as E } from "@xto/data";
|
|
4
4
|
import { Modal as J, Message as K } from "@xto/feedback";
|
|
5
5
|
import { Button as h, Space as N } from "@xto/base";
|
|
6
|
-
import { S as r, M as c, b as P, _ as Q } from "./index-
|
|
6
|
+
import { S as r, M as c, b as P, _ as Q } from "./index-C2zTmROz.js";
|
|
7
7
|
const W = { class: "menu-page" }, X = { class: "table-section" }, Z = { class: "table-toolbar" }, ee = { class: "toolbar-left" }, te = { class: "toolbar-right" }, se = { class: "table-count" }, le = { class: "table-wrapper" }, oe = { class: "data-table" }, ae = { key: 0 }, ne = { key: 1 }, de = { class: "data-row tree-row--level-0" }, ie = { class: "col-name" }, re = { class: "menu-info" }, ue = { class: "menu-icon-wrapper" }, pe = ["onClick"], ce = { class: "col-icon" }, me = { class: "icon-text" }, fe = { class: "col-path" }, ve = { class: "path-code" }, ye = { class: "col-type" }, _e = { class: "col-sort" }, he = { class: "sort-badge" }, ke = { class: "col-status" }, be = { class: "col-actions" }, ge = { class: "col-name" }, Ve = { class: "menu-info" }, Ee = { class: "menu-icon-wrapper" }, xe = ["onClick"], Ce = { class: "col-icon" }, Me = { class: "icon-text" }, Ne = { class: "col-path" }, we = { class: "path-code" }, Ae = { class: "col-type" }, Be = { class: "col-sort" }, De = { class: "sort-badge" }, Le = { class: "col-status" }, Ue = { class: "col-actions" }, Ie = { class: "form-grid" }, Te = { class: "status-field" }, Se = { class: "status-label" }, ze = { class: "status-field" }, Re = { class: "status-label" }, $e = { class: "status-field" }, Oe = { class: "status-label" }, He = /* @__PURE__ */ $({
|
|
8
8
|
__name: "index",
|
|
9
9
|
setup(qe) {
|
|
@@ -3,7 +3,7 @@ import { Form as N, FormItem as v, Input as x, Select as Q, Switch as S } from "
|
|
|
3
3
|
import { Tag as W, Pagination as X } from "@xto/data";
|
|
4
4
|
import { Popconfirm as Y, Modal as Z, Message as B } from "@xto/feedback";
|
|
5
5
|
import { Space as L, Button as f } from "@xto/base";
|
|
6
|
-
import { S as d, a as ee, _ as te } from "./index-
|
|
6
|
+
import { S as d, a as ee, _ as te } from "./index-C2zTmROz.js";
|
|
7
7
|
const le = { class: "role-page" }, se = { class: "search-section" }, oe = { class: "table-section" }, ae = { class: "table-toolbar" }, ne = { class: "toolbar-left" }, ie = { class: "toolbar-right" }, de = { class: "table-count" }, re = { class: "table-wrapper" }, ue = { class: "data-table" }, ce = { key: 0 }, pe = { key: 1 }, me = { class: "col-id" }, ve = { class: "id-badge" }, fe = { class: "col-name" }, ge = { class: "role-name" }, ye = { class: "col-code" }, _e = { class: "col-desc" }, ke = { class: "desc-text" }, he = { class: "col-status" }, xe = { class: "status-switch" }, Ve = { class: "col-time" }, be = { class: "time-text" }, Ee = { class: "col-actions" }, Ce = { class: "pagination-wrapper" }, Be = { class: "status-field" }, Le = { class: "status-label" }, De = /* @__PURE__ */ P({
|
|
8
8
|
__name: "index",
|
|
9
9
|
setup(we) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as g, ref as l, resolveComponent as b, openBlock as a, createElementBlock as o, createElementVNode as s, Fragment as n, renderList as c, normalizeStyle as r, toDisplayString as i, normalizeClass as d, createBlock as w, withCtx as U, createVNode as u, unref as v } from "vue";
|
|
2
2
|
import { Progress as _ } from "@xto/data";
|
|
3
|
-
import { _ as q } from "./index-
|
|
3
|
+
import { _ as q } from "./index-C2zTmROz.js";
|
|
4
4
|
const x = { class: "dashboard" }, C = { class: "stats-section" }, B = { class: "stat-content" }, M = { class: "stat-title" }, I = {
|
|
5
5
|
key: 0,
|
|
6
6
|
viewBox: "0 0 24 24",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as a, c as t, G as o, d as r, e as u, H as n, L as i, i as p, M as l, b as T, f as d, g, h as R, S as c, a as k, j as S, T as f, k as h, l as U, m, n as A, o as M, p as y, q as x, r as L, s as D, t as b, u as C, v as I, w as F, x as G, y as E, z as B, A as O, B as v, C as w, D as H, E as N, I as P, J as j, K as q, N as z } from "./index-
|
|
1
|
+
import { F as a, c as t, G as o, d as r, e as u, H as n, L as i, i as p, M as l, b as T, f as d, g, h as R, S as c, a as k, j as S, T as f, k as h, l as U, m, n as A, o as M, p as y, q as x, r as L, s as D, t as b, u as C, v as I, w as F, x as G, y as E, z as B, A as O, B as v, C as w, D as H, E as N, I as P, J as j, K as q, N as z } from "./index-C2zTmROz.js";
|
|
2
2
|
import { G as K, b as X, A as Q, c as V, a as W, d as Y, e as Z, f as _, g as $, F as ee, D as se, C as ae, H as te, h as oe, i as re, I as ue, J as ne, j as ie, k as pe, y as le, K as Te, L as de, l as ge, m as Re, n as ce, z as ke, M as Se, E as fe, N as he, x as Ue, O as me, o as Ae, p as Me, r as ye, q as xe, P as Le, Q as De, R as be, S as Ce, T as Ie, U as Fe, V as Ge, W as Ee, B as Be, X as Oe, u as ve, s as we, t as He, v as Ne, w as Pe } from "./user-Qd_jMBaH.js";
|
|
3
3
|
export {
|
|
4
4
|
a as Footer,
|
package/package.json
CHANGED
package/src/router/guards.ts
CHANGED
|
@@ -1,127 +1,129 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 路由守卫设置
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Router } from 'vue-router'
|
|
6
|
-
import { getToken, clearToken } from '@/utils/auth'
|
|
7
|
-
import { useUserStore } from '@/stores/user'
|
|
8
|
-
import { useMenuStore } from '@/stores/menu'
|
|
9
|
-
import { useAppStore } from '@/stores/app'
|
|
10
|
-
import { getUserInfo } from '@/api/auth'
|
|
11
|
-
import { getMenuTree } from '@/api/system'
|
|
12
|
-
|
|
13
|
-
// 白名单路由
|
|
14
|
-
const defaultWhiteList = ['/login', '/404', '/403']
|
|
15
|
-
|
|
16
|
-
interface RouterGuardOptions {
|
|
17
|
-
// 白名单路由
|
|
18
|
-
whiteList?: string[]
|
|
19
|
-
// 登录页路径
|
|
20
|
-
loginPath?: string
|
|
21
|
-
// 首页路径
|
|
22
|
-
homePath?: string
|
|
23
|
-
// 应用ID
|
|
24
|
-
appId?: string
|
|
25
|
-
// 获取用户信息的回调(可选,默认调用 API)
|
|
26
|
-
fetchUserInfo?: () => Promise<any>
|
|
27
|
-
// 获取菜单的回调(可选,默认调用 API)
|
|
28
|
-
fetchMenu?: () => Promise<any>
|
|
29
|
-
// 登录成功后的回调
|
|
30
|
-
onLoginSuccess?: () => void
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 设置路由守卫
|
|
35
|
-
* @param router 路由实例
|
|
36
|
-
* @param options 配置选项
|
|
37
|
-
*/
|
|
38
|
-
export function setupRouterGuards(router: Router, options: RouterGuardOptions = {}) {
|
|
39
|
-
const whiteList = options.whiteList || defaultWhiteList
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 路由守卫设置
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Router } from 'vue-router'
|
|
6
|
+
import { getToken, clearToken } from '@/utils/auth'
|
|
7
|
+
import { useUserStore } from '@/stores/user'
|
|
8
|
+
import { useMenuStore } from '@/stores/menu'
|
|
9
|
+
import { useAppStore } from '@/stores/app'
|
|
10
|
+
import { getUserInfo } from '@/api/auth'
|
|
11
|
+
import { getMenuTree } from '@/api/system'
|
|
12
|
+
|
|
13
|
+
// 白名单路由
|
|
14
|
+
const defaultWhiteList = ['/login', '/404', '/403']
|
|
15
|
+
|
|
16
|
+
interface RouterGuardOptions {
|
|
17
|
+
// 白名单路由
|
|
18
|
+
whiteList?: string[]
|
|
19
|
+
// 登录页路径
|
|
20
|
+
loginPath?: string
|
|
21
|
+
// 首页路径
|
|
22
|
+
homePath?: string
|
|
23
|
+
// 应用ID
|
|
24
|
+
appId?: string
|
|
25
|
+
// 获取用户信息的回调(可选,默认调用 API)
|
|
26
|
+
fetchUserInfo?: () => Promise<any>
|
|
27
|
+
// 获取菜单的回调(可选,默认调用 API)
|
|
28
|
+
fetchMenu?: () => Promise<any>
|
|
29
|
+
// 登录成功后的回调
|
|
30
|
+
onLoginSuccess?: () => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 设置路由守卫
|
|
35
|
+
* @param router 路由实例
|
|
36
|
+
* @param options 配置选项
|
|
37
|
+
*/
|
|
38
|
+
export function setupRouterGuards(router: Router, options: RouterGuardOptions = {}) {
|
|
39
|
+
const whiteList = options.whiteList || defaultWhiteList
|
|
40
|
+
|
|
41
|
+
router.beforeEach(async (to, _from, next) => {
|
|
42
|
+
const appStore = useAppStore()
|
|
43
|
+
const userStore = useUserStore()
|
|
44
|
+
const menuStore = useMenuStore()
|
|
45
|
+
|
|
46
|
+
// 从 store 获取路径配置(createXtoApp 已设置)
|
|
47
|
+
const loginPath = appStore.loginPath || options.loginPath || '/login'
|
|
48
|
+
const homePath = appStore.indexPath || options.homePath || '/dashboard'
|
|
49
|
+
|
|
50
|
+
// 初始化主题
|
|
51
|
+
appStore.initTheme()
|
|
52
|
+
|
|
53
|
+
// 检查是否有 token
|
|
54
|
+
const token = getToken()
|
|
55
|
+
|
|
56
|
+
if (token) {
|
|
57
|
+
// 已登录
|
|
58
|
+
if (to.path === loginPath) {
|
|
59
|
+
// 已登录访问登录页,跳转到首页
|
|
60
|
+
next({ path: homePath })
|
|
61
|
+
} else {
|
|
62
|
+
// 检查是否已获取用户信息
|
|
63
|
+
if (userStore.isLoggedIn) {
|
|
64
|
+
// 已有用户信息,直接放行
|
|
65
|
+
// 添加缓存页面
|
|
66
|
+
if (to.name && to.meta.keepAlive) {
|
|
67
|
+
appStore.addCachedView(to.name as string)
|
|
68
|
+
}
|
|
69
|
+
next()
|
|
70
|
+
} else {
|
|
71
|
+
// 尝试获取用户信息
|
|
72
|
+
try {
|
|
73
|
+
// 获取用户信息
|
|
74
|
+
if (options.fetchUserInfo) {
|
|
75
|
+
const userInfo = await options.fetchUserInfo()
|
|
76
|
+
userStore.setUserInfo(userInfo)
|
|
77
|
+
} else {
|
|
78
|
+
const userInfo = await getUserInfo()
|
|
79
|
+
userStore.setUserInfo(userInfo)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 获取菜单
|
|
83
|
+
if (options.fetchMenu) {
|
|
84
|
+
const menuList = await options.fetchMenu()
|
|
85
|
+
menuStore.setMenuList(menuList)
|
|
86
|
+
} else {
|
|
87
|
+
const menuList = await getMenuTree(options.appId)
|
|
88
|
+
menuStore.setMenuList(menuList)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 登录成功回调
|
|
92
|
+
if (options.onLoginSuccess) {
|
|
93
|
+
options.onLoginSuccess()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 添加缓存页面
|
|
97
|
+
if (to.name && to.meta.keepAlive) {
|
|
98
|
+
appStore.addCachedView(to.name as string)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 重新导航到目标路由,确保动态路由已添加
|
|
102
|
+
next({ ...to, replace: true })
|
|
103
|
+
} catch (error) {
|
|
104
|
+
// 获取用户信息失败,清除所有 token 相关数据并跳转到登录页
|
|
105
|
+
console.error('获取用户信息失败:', error)
|
|
106
|
+
userStore.clearUserInfo()
|
|
107
|
+
menuStore.clearMenu()
|
|
108
|
+
// 使用 clearToken 清除所有 token 相关数据(包括 expires_time、refresh_time 等)
|
|
109
|
+
clearToken()
|
|
110
|
+
next({ path: loginPath, query: { redirect: to.fullPath } })
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
// 未登录
|
|
116
|
+
if (whiteList.includes(to.path)) {
|
|
117
|
+
// 在白名单中,直接放行
|
|
118
|
+
next()
|
|
119
|
+
} else {
|
|
120
|
+
// 不在白名单中,跳转到登录页
|
|
121
|
+
next({ path: loginPath, query: { redirect: to.fullPath } })
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
router.afterEach(() => {
|
|
127
|
+
// 可以在这里添加进度条结束等
|
|
128
|
+
})
|
|
129
|
+
}
|