xto-fronted 0.4.6 → 0.4.8

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.
Files changed (160) hide show
  1. package/.env.development +7 -7
  2. package/.env.production +7 -7
  3. package/dist/assets/403-AFBQifUI.js +1 -0
  4. package/dist/assets/403-BHEXXbt2.css +1 -0
  5. package/dist/assets/404-Ct_A1n7S.css +1 -0
  6. package/dist/assets/404-WFvpcD2_.js +1 -0
  7. package/dist/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
  8. package/dist/assets/index-1juADvYN.js +2 -0
  9. package/dist/assets/index-B-sX4Ru0.js +1 -0
  10. package/dist/assets/index-BMcziU5a.css +1 -0
  11. package/dist/assets/index-BRR97dc6.js +1 -0
  12. package/dist/assets/index-BZA0ksjx.css +1 -0
  13. package/dist/assets/index-BpV_8nl0.js +1 -0
  14. package/dist/assets/index-BvzhR4zp.js +1 -0
  15. package/dist/assets/index-CUh_s55Z.css +1 -0
  16. package/dist/assets/index-CVjdnIgR.css +1 -0
  17. package/dist/assets/index-CYq57-zj.js +1 -0
  18. package/dist/assets/index-CkL3sVAQ.js +2 -0
  19. package/dist/assets/index-CtrKVYJb.css +1 -0
  20. package/dist/assets/index-Cz2P_bsS.js +1 -0
  21. package/dist/assets/index-D9wlAuR_.js +1 -0
  22. package/dist/assets/index-DawJb02s.css +1 -0
  23. package/dist/assets/index-DfFR6NLf.js +1 -0
  24. package/dist/assets/index-DwVgMO8e.js +1 -0
  25. package/dist/assets/index-GDP-IkXE.css +1 -0
  26. package/dist/assets/index-Iaz1ZzPC.js +2 -0
  27. package/dist/assets/index-PfV8pzQz.css +1 -0
  28. package/dist/assets/index-Swfu6yvD.css +1 -0
  29. package/dist/assets/index-Te8_PRgJ.js +1 -0
  30. package/dist/assets/index-WyZ91RLx.css +1 -0
  31. package/dist/assets/index-tFYRoFdE.js +1 -0
  32. package/dist/assets/vendor-42ANG6Sg.js +6 -0
  33. package/dist/assets/vite-Dw-pgLOX.js +1 -0
  34. package/dist/assets/vue-vendor-Br-l7wbK.js +29 -0
  35. package/dist/assets/xto-base-C-IBqjVs.js +1 -0
  36. package/dist/assets/xto-base-C6eqMPdO.css +1 -0
  37. package/dist/assets/xto-business--V1F5Gwb.css +1 -0
  38. package/dist/assets/xto-core-DZK7Cyg0.js +1 -0
  39. package/dist/assets/xto-data-BFpiDgJi.js +1 -0
  40. package/dist/assets/xto-data-CnAQAQH2.css +1 -0
  41. package/dist/assets/xto-feedback-B7ipsTfz.js +1 -0
  42. package/dist/assets/xto-feedback-DBwJzoTj.css +1 -0
  43. package/dist/assets/xto-form-CrsyAjyr.css +1 -0
  44. package/dist/assets/xto-form-NRjKKNcY.js +1 -0
  45. package/dist/assets/xto-layout-BqU8RuWL.css +1 -0
  46. package/dist/assets/xto-navigation-BiSaXPfr.js +1 -0
  47. package/dist/assets/xto-navigation-C1cnSL2E.css +1 -0
  48. package/dist/assets/xto-navigation-CBPg4dCc.css +1 -0
  49. package/dist/assets/xto-navigation-CKabFu9d.js +1 -0
  50. package/dist/index-54irhCHL.js +1830 -0
  51. package/dist/{index-15Bu0M8D.js → index-BzRf1eoJ.js} +1 -1
  52. package/dist/{index-BO2Zf9u6.js → index-DH4aoCZb.js} +1 -1
  53. package/dist/{index-BBqvHkzE.js → index-Kqa7iZ9E.js} +1 -1
  54. package/dist/{index-BQqo0ZIb.js → index-pxkZlvBw.js} +1 -1
  55. package/dist/index.es.js +1 -1
  56. package/dist/index.html +28 -0
  57. package/dist/index.umd.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/package.json +85 -86
  60. package/src/api/auth.ts +25 -25
  61. package/src/api/system.ts +66 -66
  62. package/src/assets/styles/_dark.scss +406 -406
  63. package/src/components/Layout/Header.vue +973 -973
  64. package/src/components/Layout/Sidebar.vue +273 -212
  65. package/src/components/Layout/index.vue +443 -63
  66. package/src/composables/useApp.ts +61 -61
  67. package/src/composables/useAuth.ts +16 -16
  68. package/src/directives/permission.ts +27 -27
  69. package/src/env.d.ts +18 -18
  70. package/src/index.ts +47 -47
  71. package/src/router/dynamicRoutes.ts +162 -162
  72. package/src/router/guards.ts +128 -128
  73. package/src/router/index.ts +79 -79
  74. package/src/stores/auth.ts +65 -65
  75. package/src/stores/menu.ts +48 -48
  76. package/src/stores/user.ts +50 -50
  77. package/src/types/api.d.ts +80 -80
  78. package/src/utils/auth.ts +99 -99
  79. package/src/utils/config.ts +80 -80
  80. package/src/utils/permission.ts +32 -32
  81. package/src/utils/request.ts +124 -124
  82. package/src/views/login/index.vue +194 -188
  83. package/vite.config.ts +135 -135
  84. package/dist/index-B3PLzNB0.js +0 -345
  85. package/dist/index-B6DTsC6l.js +0 -1715
  86. package/dist/index-B7etKk33.js +0 -372
  87. package/dist/index-B7mpL6Zf.js +0 -475
  88. package/dist/index-BC2PGkkJ.js +0 -1644
  89. package/dist/index-BGgbfcmf.js +0 -475
  90. package/dist/index-BGmUwemj.js +0 -372
  91. package/dist/index-BQFfQj5Q.js +0 -142
  92. package/dist/index-BkRneTya.js +0 -142
  93. package/dist/index-BlRrngsc.js +0 -475
  94. package/dist/index-BmVvM7sm.js +0 -345
  95. package/dist/index-Bn4ThpX9.js +0 -142
  96. package/dist/index-BwfjwDKr.js +0 -1477
  97. package/dist/index-BxIL2hrt.js +0 -475
  98. package/dist/index-C-3fhbN2.js +0 -1644
  99. package/dist/index-C0VN9nFF.js +0 -142
  100. package/dist/index-C0xyGOsz.js +0 -475
  101. package/dist/index-C3c8NAZq.js +0 -1477
  102. package/dist/index-C42VtP71.js +0 -142
  103. package/dist/index-C6Nm0r9k.js +0 -475
  104. package/dist/index-C6w0-8xN.js +0 -1648
  105. package/dist/index-CD364XjV.js +0 -142
  106. package/dist/index-CHww99-i.js +0 -345
  107. package/dist/index-CIgWYERJ.js +0 -1644
  108. package/dist/index-CTs6DTuQ.js +0 -345
  109. package/dist/index-CWRs4WMN.js +0 -372
  110. package/dist/index-Cb-SxHJp.js +0 -345
  111. package/dist/index-CeCysOnl.js +0 -345
  112. package/dist/index-Cg1UpC8D.js +0 -1644
  113. package/dist/index-Cgkqpyx2.js +0 -345
  114. package/dist/index-CiuDEfo-.js +0 -142
  115. package/dist/index-CmQfZC8r.js +0 -372
  116. package/dist/index-CmkjhpX_.js +0 -475
  117. package/dist/index-CpxpXTQX.js +0 -1462
  118. package/dist/index-CqXFk_ET.js +0 -345
  119. package/dist/index-Cqix1YLE.js +0 -1697
  120. package/dist/index-CtvB5J9E.js +0 -372
  121. package/dist/index-Cu3Z2-PY.js +0 -345
  122. package/dist/index-CvDxK7Ab.js +0 -372
  123. package/dist/index-D-FER0vJ.js +0 -372
  124. package/dist/index-D2fQ8TK8.js +0 -475
  125. package/dist/index-D3xVcFvg.js +0 -372
  126. package/dist/index-D4crnrO6.js +0 -142
  127. package/dist/index-D7EzwTM5.js +0 -372
  128. package/dist/index-D7TZamyY.js +0 -1664
  129. package/dist/index-D88fiqXR.js +0 -475
  130. package/dist/index-DEbpF-M4.js +0 -1457
  131. package/dist/index-DFXuyPge.js +0 -1627
  132. package/dist/index-DLgimJYb.js +0 -1667
  133. package/dist/index-DPEVEyik.js +0 -475
  134. package/dist/index-DWy_UGhI.js +0 -345
  135. package/dist/index-DYVtddfw.js +0 -142
  136. package/dist/index-DYnXaqYf.js +0 -142
  137. package/dist/index-DcvRPHuy.js +0 -372
  138. package/dist/index-DdC1uV2v.js +0 -1700
  139. package/dist/index-Dga14ZN7.js +0 -1774
  140. package/dist/index-Dk2V44uP.js +0 -372
  141. package/dist/index-DnJ481u1.js +0 -475
  142. package/dist/index-Do1CBqg8.js +0 -345
  143. package/dist/index-DqQRSPeF.js +0 -345
  144. package/dist/index-Jb4VMHIS.js +0 -142
  145. package/dist/index-MC3wWjNt.js +0 -475
  146. package/dist/index-MG0JePmx.js +0 -142
  147. package/dist/index-PRFGBLWt.js +0 -475
  148. package/dist/index-QgkT42dc.js +0 -372
  149. package/dist/index-TrLCW5xL.js +0 -372
  150. package/dist/index-YDlNLFVk.js +0 -142
  151. package/dist/index-ZAJgA3XD.js +0 -475
  152. package/dist/index-a_ilWAvi.js +0 -345
  153. package/dist/index-bi1TMGid.js +0 -372
  154. package/dist/index-fyarVCog.js +0 -475
  155. package/dist/index-mnTZtPFa.js +0 -345
  156. package/dist/index-orZCyV6I.js +0 -345
  157. package/dist/index-p3TbK44c.js +0 -142
  158. package/dist/index-sRwZYbZ4.js +0 -372
  159. package/dist/index-wATqKEcF.js +0 -142
  160. package/dist/setup.d.ts +0 -17
@@ -1,1644 +0,0 @@
1
- import { ref as f, computed as b, watch as Ye, defineComponent as K, openBlock as g, createElementBlock as k, normalizeClass as z, createElementVNode as o, withDirectives as Re, toDisplayString as A, unref as p, vShow as Xe, createVNode as y, withCtx as T, Fragment as B, renderList as j, createBlock as Z, createTextVNode as W, createCommentVNode as O, onMounted as Je, onUnmounted as Qe, withModifiers as $e, Transition as Te, withKeys as Me, vModelText as Ze, normalizeStyle as Pe, resolveComponent as Ge, reactive as fe } from "vue";
2
- import { defineStore as ne } from "pinia";
3
- import { createRouter as _e, createWebHistory as ge, useRoute as ae, useRouter as H } from "vue-router";
4
- import { Menu as et, SubMenu as tt, MenuItem as Ee, Tabs as st, TabPane as ot } from "@xto/navigation";
5
- import { Icon as M, Button as re } from "@xto/base";
6
- import { Drawer as nt, Message as V } from "@xto/feedback";
7
- import { Form as at, FormItem as te, Input as Ae, Checkbox as rt } from "@xto/form";
8
- import lt from "axios";
9
- const J = "xto_", Ue = (e) => ({
10
- get(t) {
11
- const s = e.getItem(J + t);
12
- if (!s) return null;
13
- try {
14
- return JSON.parse(s);
15
- } catch {
16
- return s;
17
- }
18
- },
19
- set(t, s) {
20
- if (s == null) {
21
- e.removeItem(J + t);
22
- return;
23
- }
24
- const n = typeof s == "string" ? s : JSON.stringify(s);
25
- e.setItem(J + t, n);
26
- },
27
- remove(t) {
28
- e.removeItem(J + t);
29
- },
30
- clear() {
31
- Object.keys(e).forEach((s) => {
32
- s.startsWith(J) && e.removeItem(s);
33
- });
34
- }
35
- }), se = Ue(window.localStorage), oe = Ue(window.sessionStorage), h = {
36
- get: se.get,
37
- set: se.set,
38
- remove: se.remove,
39
- clear: se.clear
40
- }, so = {
41
- get: oe.get,
42
- set: oe.set,
43
- remove: oe.remove,
44
- clear: oe.clear
45
- }, Y = ne("app", () => {
46
- const e = f(h.get("appName") || "XTO App"), t = f(h.get("indexPath") || "/dashboard"), s = f(h.get("isDark") || !1), n = f(h.get("theme") || "light"), r = f(h.get("layout") || "sidebar"), i = f(h.get("isCollapsed") || !1), u = f(h.get("showTabs") ?? !0), a = f(h.get("showFooter") ?? !0), m = f(h.get("showBreadcrumb") ?? !0), d = f(h.get("primaryColor") || "#409eff"), v = f([]), w = b(() => s.value ? "dark" : "light"), l = (C) => {
47
- e.value = C, h.set("appName", C);
48
- }, $ = (C) => {
49
- t.value = C, h.set("indexPath", C);
50
- }, I = () => {
51
- s.value = !s.value, n.value = s.value ? "dark" : "light", x();
52
- }, E = (C) => {
53
- n.value = C, s.value = C === "dark", x();
54
- }, x = () => {
55
- const C = document.documentElement;
56
- s.value ? C.classList.add("dark") : C.classList.remove("dark"), h.set("isDark", s.value), h.set("theme", n.value);
57
- }, U = () => {
58
- i.value = !i.value, h.set("isCollapsed", i.value);
59
- }, R = (C) => {
60
- r.value = C, h.set("layout", C);
61
- }, P = () => {
62
- u.value = !u.value, h.set("showTabs", u.value);
63
- }, ce = () => {
64
- a.value = !a.value, h.set("showFooter", a.value);
65
- }, ue = () => {
66
- m.value = !m.value, h.set("showBreadcrumb", m.value);
67
- }, G = (C) => {
68
- d.value = C, document.documentElement.style.setProperty("--color-primary", C), h.set("primaryColor", C);
69
- }, de = (C) => {
70
- v.value.includes(C) || v.value.push(C);
71
- }, me = (C) => {
72
- const ee = v.value.indexOf(C);
73
- ee > -1 && v.value.splice(ee, 1);
74
- }, pe = () => {
75
- v.value = [];
76
- }, ve = () => {
77
- x(), d.value !== "#409eff" && document.documentElement.style.setProperty("--color-primary", d.value);
78
- };
79
- return Ye(s, x), {
80
- appName: e,
81
- indexPath: t,
82
- isDark: s,
83
- theme: n,
84
- layout: r,
85
- isCollapsed: i,
86
- showTabs: u,
87
- showFooter: a,
88
- showBreadcrumb: m,
89
- primaryColor: d,
90
- cachedViews: v,
91
- themeClass: w,
92
- setAppName: l,
93
- setIndexPath: $,
94
- toggleTheme: I,
95
- toggleCollapse: U,
96
- setTheme: E,
97
- setLayout: R,
98
- toggleTabs: P,
99
- toggleFooter: ce,
100
- toggleBreadcrumb: ue,
101
- setPrimaryColor: G,
102
- addCachedView: de,
103
- removeCachedView: me,
104
- clearCachedViews: pe,
105
- initTheme: ve
106
- };
107
- }), De = "/vite.svg", it = (e, t, s) => {
108
- const n = e[t];
109
- return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, i) => {
110
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
111
- i.bind(
112
- null,
113
- new Error(
114
- "Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : "")
115
- )
116
- )
117
- );
118
- });
119
- }, Oe = [
120
- {
121
- path: "/login",
122
- name: "Login",
123
- component: () => Promise.resolve().then(() => As),
124
- meta: {
125
- title: "登录",
126
- hidden: !0
127
- }
128
- },
129
- {
130
- path: "/404",
131
- name: "NotFound",
132
- component: () => Promise.resolve().then(() => Us),
133
- meta: {
134
- title: "404",
135
- hidden: !0
136
- }
137
- },
138
- {
139
- path: "/403",
140
- name: "Forbidden",
141
- component: () => Promise.resolve().then(() => Vs),
142
- meta: {
143
- title: "403",
144
- hidden: !0
145
- }
146
- }
147
- ], Ne = {
148
- path: "/:pathMatch(.*)*",
149
- redirect: "/404",
150
- meta: {
151
- hidden: !0
152
- }
153
- }, ze = {
154
- path: "/",
155
- name: "Layout",
156
- component: () => Promise.resolve().then(() => hs),
157
- redirect: "/dashboard",
158
- children: [
159
- {
160
- path: "/dashboard",
161
- name: "Dashboard",
162
- component: () => import("./index-MG0JePmx.js"),
163
- meta: {
164
- title: "仪表盘",
165
- icon: "dashboard",
166
- keepAlive: !0,
167
- affix: !0
168
- }
169
- },
170
- {
171
- path: "/system/user",
172
- name: "SystemUser",
173
- component: () => import("./index-D-FER0vJ.js"),
174
- meta: {
175
- title: "用户管理",
176
- icon: "user",
177
- keepAlive: !0
178
- }
179
- },
180
- {
181
- path: "/system/role",
182
- name: "SystemRole",
183
- component: () => import("./index-CqXFk_ET.js"),
184
- meta: {
185
- title: "角色管理",
186
- icon: "role",
187
- keepAlive: !0
188
- }
189
- },
190
- {
191
- path: "/system/menu",
192
- name: "SystemMenu",
193
- component: () => import("./index-C0xyGOsz.js"),
194
- meta: {
195
- title: "菜单管理",
196
- icon: "menu",
197
- keepAlive: !0
198
- }
199
- }
200
- ]
201
- }, oo = [
202
- {
203
- path: "/dashboard",
204
- name: "Dashboard",
205
- component: () => import("./index-MG0JePmx.js"),
206
- meta: {
207
- title: "仪表盘",
208
- icon: "dashboard",
209
- keepAlive: !0,
210
- affix: !0
211
- }
212
- },
213
- {
214
- path: "/system",
215
- name: "System",
216
- redirect: "/system/user",
217
- meta: {
218
- title: "系统管理",
219
- icon: "setting"
220
- },
221
- children: [
222
- {
223
- path: "user",
224
- name: "SystemUser",
225
- component: () => import("./index-D-FER0vJ.js"),
226
- meta: {
227
- title: "用户管理",
228
- icon: "user",
229
- keepAlive: !0
230
- }
231
- },
232
- {
233
- path: "role",
234
- name: "SystemRole",
235
- component: () => import("./index-CqXFk_ET.js"),
236
- meta: {
237
- title: "角色管理",
238
- icon: "role",
239
- keepAlive: !0
240
- }
241
- },
242
- {
243
- path: "menu",
244
- name: "SystemMenu",
245
- component: () => import("./index-C0xyGOsz.js"),
246
- meta: {
247
- title: "菜单管理",
248
- icon: "menu",
249
- keepAlive: !0
250
- }
251
- }
252
- ]
253
- }
254
- ], ct = [
255
- {
256
- id: 1,
257
- name: "Dashboard",
258
- path: "/dashboard",
259
- component: "dashboard/index",
260
- icon: "dashboard",
261
- title: "仪表盘",
262
- keepAlive: !0,
263
- affix: !0
264
- },
265
- {
266
- id: 2,
267
- name: "System",
268
- path: "/system",
269
- redirect: "/system/user",
270
- icon: "setting",
271
- title: "系统管理",
272
- children: [
273
- {
274
- id: 21,
275
- name: "SystemUser",
276
- path: "/system/user",
277
- component: "system/user/index",
278
- icon: "user",
279
- title: "用户管理",
280
- keepAlive: !0
281
- },
282
- {
283
- id: 22,
284
- name: "SystemRole",
285
- path: "/system/role",
286
- component: "system/role/index",
287
- icon: "role",
288
- title: "角色管理",
289
- keepAlive: !0
290
- },
291
- {
292
- id: 23,
293
- name: "SystemMenu",
294
- path: "/system/menu",
295
- component: "system/menu/index",
296
- icon: "menu",
297
- title: "菜单管理",
298
- keepAlive: !0
299
- }
300
- ]
301
- }
302
- ], ye = "token", ke = "refresh_token", be = "token_expire", le = () => h.get(ye), ut = (e) => {
303
- h.set(ye, e);
304
- }, no = () => h.get(ke), dt = (e) => {
305
- h.set(ke, e);
306
- }, mt = () => h.get(be), pt = (e) => {
307
- h.set(be, e);
308
- }, Ve = (e) => {
309
- ut(e.token), dt(e.refreshToken), pt(e.expireTime);
310
- }, Be = () => {
311
- h.remove(ye), h.remove(ke), h.remove(be);
312
- }, vt = () => {
313
- const e = mt();
314
- return e ? Date.now() > e : !0;
315
- }, Fe = () => !!le() && !vt(), N = ne("user", () => {
316
- const e = f(h.get("userInfo")), t = f(h.get("roles") || []), s = f(h.get("permissions") || []), n = b(() => !!e.value), r = b(() => {
317
- var l;
318
- return ((l = e.value) == null ? void 0 : l.username) || "";
319
- }), i = b(() => {
320
- var l;
321
- return ((l = e.value) == null ? void 0 : l.nickname) || "";
322
- }), u = b(() => {
323
- var l;
324
- return ((l = e.value) == null ? void 0 : l.avatar) || "";
325
- }), a = b(() => {
326
- var l;
327
- return (l = e.value) == null ? void 0 : l.id;
328
- });
329
- return {
330
- userInfo: e,
331
- roles: t,
332
- permissions: s,
333
- isLoggedIn: n,
334
- username: r,
335
- nickname: i,
336
- avatar: u,
337
- userId: a,
338
- setUserInfo: (l) => {
339
- e.value = l, t.value = l.roles || [], s.value = l.permissions || [], h.set("userInfo", l), h.set("roles", l.roles || []), h.set("permissions", l.permissions || []);
340
- },
341
- clearUserInfo: () => {
342
- e.value = null, t.value = [], s.value = [], h.remove("userInfo"), h.remove("roles"), h.remove("permissions");
343
- },
344
- hasPermission: (l) => Array.isArray(l) ? l.some(($) => s.value.includes($)) : s.value.includes(l),
345
- hasRole: (l) => Array.isArray(l) ? l.some(($) => t.value.includes($)) : t.value.includes(l)
346
- };
347
- }), we = _e({
348
- history: ge(),
349
- routes: [...Oe, ze, Ne],
350
- scrollBehavior: () => ({ left: 0, top: 0 })
351
- }), ht = ["/login", "/404", "/403"];
352
- we.beforeEach(async (e, t, s) => {
353
- const n = Y();
354
- if (n.initTheme(), Fe())
355
- if (e.path === "/login")
356
- s({ path: "/" });
357
- else {
358
- const r = N();
359
- r.isLoggedIn || (r.setUserInfo({
360
- id: 1,
361
- username: "admin",
362
- nickname: "管理员",
363
- avatar: "",
364
- email: "admin@example.com",
365
- phone: "13800138000",
366
- status: 1,
367
- roles: ["admin"],
368
- permissions: ["*"],
369
- createTime: (/* @__PURE__ */ new Date()).toISOString()
370
- }), ie().setMenuList(ct)), e.name && e.meta.keepAlive && n.addCachedView(e.name), s();
371
- }
372
- else
373
- ht.includes(e.path) ? s() : s("/login");
374
- });
375
- function ao() {
376
- const e = _e({
377
- history: ge(),
378
- routes: [...Oe, ze, Ne]
379
- });
380
- we.matcher = e.matcher;
381
- }
382
- const ie = ne("menu", () => {
383
- const e = f(h.get("menuList") || []), t = b(() => e.value.length > 0), s = (u) => {
384
- e.value = u, h.set("menuList", u);
385
- }, n = () => {
386
- e.value = [], h.remove("menuList");
387
- }, r = (u) => u.filter((a) => !a.hidden).map((a) => {
388
- const m = {
389
- path: a.path,
390
- name: a.name,
391
- meta: {
392
- title: a.title,
393
- icon: a.icon,
394
- keepAlive: a.keepAlive,
395
- hidden: a.hidden
396
- }
397
- };
398
- return a.redirect && (m.redirect = a.redirect), a.component && (m.component = () => it(/* @__PURE__ */ Object.assign({}), `../views/${a.component}.vue`, 3)), a.children && a.children.length > 0 && (m.children = r(a.children)), m;
399
- });
400
- return {
401
- menuList: e,
402
- hasMenu: t,
403
- setMenuList: s,
404
- clearMenu: n,
405
- generateRoutes: r,
406
- addRoutes: (u) => {
407
- r(u).forEach((m) => {
408
- we.addRoute("Layout", m);
409
- });
410
- }
411
- };
412
- }), Ce = ne("auth", () => {
413
- const e = f(le()), t = b(() => Fe()), s = f(""), n = f(""), r = f(""), i = f("/login");
414
- return {
415
- token: e,
416
- isLoggedIn: t,
417
- baseUrl: s,
418
- appId: n,
419
- clientId: r,
420
- loginPath: i,
421
- login: (l) => {
422
- e.value = l.token, Ve(l);
423
- },
424
- logout: () => {
425
- e.value = null, Be();
426
- },
427
- setBaseUrl: (l) => {
428
- s.value = l;
429
- },
430
- setAppId: (l) => {
431
- n.value = l;
432
- },
433
- setClientId: (l) => {
434
- r.value = l;
435
- },
436
- setLoginPath: (l) => {
437
- i.value = l;
438
- }
439
- };
440
- }), ft = { class: "sidebar__logo" }, _t = {
441
- key: 0,
442
- class: "sidebar__user"
443
- }, gt = { class: "sidebar__user-info" }, yt = { class: "sidebar__user-name" }, kt = { class: "sidebar__user-role" }, bt = /* @__PURE__ */ K({
444
- __name: "Sidebar",
445
- setup(e) {
446
- const t = ae(), s = H(), n = ie(), r = N(), i = Ce(), u = Y(), a = b(() => u.isCollapsed), m = b(() => t.path), d = b(() => u.isDark ? "#1d1e1f" : "#fff"), v = b(() => u.isDark ? "#cfd3dc" : "#303133"), w = b(() => "#409eff"), l = (E) => {
447
- E && E !== t.path && s.push(E);
448
- }, $ = () => {
449
- i.logout(), r.clearUserInfo(), n.clearMenu(), s.push("/login");
450
- }, I = (E) => ({
451
- dashboard: "dashboard",
452
- system: "system",
453
- user: "user",
454
- role: "role",
455
- menu: "list",
456
- setting: "setting"
457
- })[E || ""] || "file";
458
- return (E, x) => {
459
- var U;
460
- return g(), k("div", {
461
- class: z(["sidebar", { "sidebar--collapsed": a.value }])
462
- }, [
463
- o("div", ft, [
464
- x[0] || (x[0] = o("img", {
465
- src: De,
466
- alt: "Logo",
467
- class: "sidebar__logo-img"
468
- }, null, -1)),
469
- Re(o("span", { class: "sidebar__logo-text" }, A(p(u).appName), 513), [
470
- [Xe, !a.value]
471
- ])
472
- ]),
473
- y(p(et), {
474
- "default-active": m.value,
475
- mode: "vertical",
476
- collapse: a.value,
477
- "collapse-transition": !1,
478
- "background-color": d.value,
479
- "text-color": v.value,
480
- "active-text-color": w.value,
481
- class: "sidebar__menu",
482
- onSelect: l
483
- }, {
484
- default: T(() => [
485
- (g(!0), k(B, null, j(p(n).menuList, (R) => (g(), k(B, {
486
- key: R.path
487
- }, [
488
- R.children && R.children.length > 0 ? (g(), Z(p(tt), {
489
- key: 0,
490
- index: R.path
491
- }, {
492
- title: T(() => [
493
- y(p(M), {
494
- name: I(R.icon),
495
- size: 16
496
- }, null, 8, ["name"]),
497
- o("span", null, A(R.title), 1)
498
- ]),
499
- default: T(() => [
500
- (g(!0), k(B, null, j(R.children, (P) => (g(), Z(p(Ee), {
501
- key: P.path,
502
- index: P.path
503
- }, {
504
- default: T(() => [
505
- y(p(M), {
506
- name: I(P.icon),
507
- size: 16
508
- }, null, 8, ["name"]),
509
- o("span", null, A(P.title), 1)
510
- ]),
511
- _: 2
512
- }, 1032, ["index"]))), 128))
513
- ]),
514
- _: 2
515
- }, 1032, ["index"])) : (g(), Z(p(Ee), {
516
- key: 1,
517
- index: R.path
518
- }, {
519
- default: T(() => [
520
- y(p(M), {
521
- name: I(R.icon),
522
- size: 16
523
- }, null, 8, ["name"]),
524
- o("span", null, A(R.title), 1)
525
- ]),
526
- _: 2
527
- }, 1032, ["index"]))
528
- ], 64))), 128))
529
- ]),
530
- _: 1
531
- }, 8, ["default-active", "collapse", "background-color", "text-color", "active-text-color"]),
532
- a.value ? O("", !0) : (g(), k("div", _t, [
533
- o("div", gt, [
534
- o("span", yt, A(p(r).nickname), 1),
535
- o("span", kt, A((U = p(r).roles) == null ? void 0 : U.join(", ")), 1)
536
- ]),
537
- y(p(re), {
538
- type: "text",
539
- size: "small",
540
- onClick: $
541
- }, {
542
- default: T(() => [...x[1] || (x[1] = [
543
- W("退出", -1)
544
- ])]),
545
- _: 1
546
- })
547
- ]))
548
- ], 2);
549
- };
550
- }
551
- }), F = (e, t) => {
552
- const s = e.__vccOpts || e;
553
- for (const [n, r] of t)
554
- s[n] = r;
555
- return s;
556
- }, wt = /* @__PURE__ */ F(bt, [["__scopeId", "data-v-a7668285"]]), Ct = { class: "header" }, St = { class: "header__left" }, xt = {
557
- key: 0,
558
- class: "header__breadcrumb"
559
- }, Lt = {
560
- key: 0,
561
- class: "breadcrumb-separator"
562
- }, It = { class: "header__right" }, Tt = ["title"], Et = { class: "header__avatar" }, At = { class: "header__user-name" }, Rt = {
563
- key: 0,
564
- class: "header__dropdown"
565
- }, $t = { class: "header__dropdown-header" }, Mt = { class: "header__dropdown-avatar" }, Pt = { class: "header__dropdown-info" }, Ut = { class: "header__dropdown-name" }, Dt = { class: "header__dropdown-role" }, Ot = { class: "header__dropdown-menu" }, Nt = { class: "search-container" }, zt = { class: "search-input-wrapper" }, Vt = {
566
- key: 0,
567
- class: "search-results"
568
- }, Bt = ["onClick"], Ft = { class: "search-result-info" }, jt = { class: "search-result-title" }, Kt = {
569
- key: 0,
570
- class: "search-result-parent"
571
- }, qt = {
572
- key: 1,
573
- class: "search-empty"
574
- }, Wt = { class: "settings-drawer" }, Ht = { class: "settings-section" }, Yt = { class: "settings-layout-options" }, Xt = ["onClick"], Jt = { class: "layout-option__preview" }, Qt = {
575
- key: 0,
576
- class: "layout-preview-sidebar"
577
- }, Zt = {
578
- key: 1,
579
- class: "layout-preview-top"
580
- }, Gt = {
581
- key: 2,
582
- class: "layout-preview-mix"
583
- }, es = { class: "layout-option__label" }, ts = { class: "settings-section" }, ss = { class: "settings-color-options" }, os = ["title", "onClick"], ns = { class: "settings-section" }, as = { class: "settings-switch-list" }, rs = { class: "settings-switch-item" }, ls = { class: "settings-switch-item" }, is = /* @__PURE__ */ K({
584
- __name: "Header",
585
- setup(e) {
586
- const t = ae(), s = H(), n = Y(), r = N(), i = Ce(), u = ie(), a = f(!1), m = f(!1), d = f(null), v = f(!1), w = f(!1), l = f(""), $ = f(null), I = f(!1), E = [
587
- { value: "sidebar", label: "左侧菜单", icon: "sidebar-left" },
588
- { value: "top", label: "顶部菜单", icon: "menu" },
589
- { value: "mix", label: "混合菜单", icon: "grid" }
590
- ], x = [
591
- { value: "#409eff", label: "默认蓝" },
592
- { value: "#1890ff", label: "科技蓝" },
593
- { value: "#52c41a", label: "极光绿" },
594
- { value: "#faad14", label: "日落橙" },
595
- { value: "#f5222d", label: "薄暮红" },
596
- { value: "#722ed1", label: "酱紫" }
597
- ], U = b(() => t.matched.filter((c) => c.meta && c.meta.title).map((c) => ({
598
- title: c.meta.title,
599
- path: c.path
600
- }))), R = (L, c = "") => {
601
- const q = [];
602
- return L.forEach((_) => {
603
- _.children && _.children.length > 0 ? q.push(...R(_.children, _.title)) : q.push({ ..._, parentTitle: c });
604
- }), q;
605
- }, P = b(() => l.value.trim() ? R(u.menuList).filter(
606
- (c) => c.title.toLowerCase().includes(l.value.toLowerCase())
607
- ) : []), ce = b(() => n.layout), ue = () => {
608
- n.toggleCollapse();
609
- }, G = () => {
610
- n.toggleTheme();
611
- }, de = () => {
612
- m.value = !0;
613
- }, me = (L) => {
614
- n.setLayout(L);
615
- }, pe = (L) => {
616
- I.value = L;
617
- const c = document.documentElement;
618
- L ? c.classList.add("grey-mode") : c.classList.remove("grey-mode");
619
- }, ve = () => {
620
- document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen();
621
- }, C = () => {
622
- v.value = !!document.fullscreenElement;
623
- }, ee = () => {
624
- a.value = !a.value;
625
- }, X = () => {
626
- a.value = !1;
627
- }, Se = () => {
628
- w.value = !0;
629
- }, he = () => {
630
- w.value = !1, l.value = "";
631
- }, xe = (L) => {
632
- s.push(L), he();
633
- }, Ke = (L) => {
634
- n.setPrimaryColor(L);
635
- }, qe = () => {
636
- X(), s.push("/profile");
637
- }, We = () => {
638
- X(), s.push("/change-password");
639
- }, He = () => {
640
- X(), i.logout(), r.clearUserInfo(), u.clearMenu(), s.push("/login");
641
- }, Le = (L) => {
642
- d.value && !d.value.contains(L.target) && X(), $.value && !$.value.contains(L.target) && he();
643
- }, Ie = (L) => {
644
- L.key === "Escape" && (he(), X()), (L.ctrlKey || L.metaKey) && L.key === "k" && (L.preventDefault(), Se());
645
- };
646
- return Je(() => {
647
- document.addEventListener("click", Le), document.addEventListener("fullscreenchange", C), document.addEventListener("keydown", Ie), n.initTheme(), I.value = document.documentElement.classList.contains("grey-mode");
648
- }), Qe(() => {
649
- document.removeEventListener("click", Le), document.removeEventListener("fullscreenchange", C), document.removeEventListener("keydown", Ie);
650
- }), (L, c) => {
651
- var q;
652
- return g(), k("div", Ct, [
653
- o("div", St, [
654
- o("div", {
655
- class: "header__collapse",
656
- onClick: ue
657
- }, [
658
- y(p(M), {
659
- name: p(n).isCollapsed ? "menu-unfold" : "menu-fold",
660
- size: 18
661
- }, null, 8, ["name"])
662
- ]),
663
- p(n).showBreadcrumb ? (g(), k("div", xt, [
664
- (g(!0), k(B, null, j(U.value, (_, D) => (g(), k("span", {
665
- key: _.path
666
- }, [
667
- D > 0 ? (g(), k("span", Lt, "/")) : O("", !0),
668
- o("span", {
669
- class: z({ "is-current": D === U.value.length - 1 })
670
- }, A(_.title), 3)
671
- ]))), 128))
672
- ])) : O("", !0)
673
- ]),
674
- o("div", It, [
675
- o("div", {
676
- class: "header__action",
677
- onClick: Se,
678
- title: "搜索 (Ctrl+K)"
679
- }, [
680
- y(p(M), {
681
- name: "search",
682
- size: 16
683
- })
684
- ]),
685
- o("div", {
686
- class: "header__action",
687
- onClick: ve,
688
- title: v.value ? "退出全屏" : "全屏"
689
- }, [
690
- y(p(M), {
691
- name: v.value ? "fullscreen-exit" : "fullscreen",
692
- size: 16
693
- }, null, 8, ["name"])
694
- ], 8, Tt),
695
- o("div", {
696
- class: "header__action",
697
- onClick: de,
698
- title: "换肤设置"
699
- }, [
700
- y(p(M), {
701
- name: "setting",
702
- size: 16
703
- })
704
- ]),
705
- o("div", {
706
- class: "header__action",
707
- onClick: G,
708
- title: "切换主题"
709
- }, [
710
- y(p(M), {
711
- name: p(n).isDark ? "sun" : "moon",
712
- size: 16
713
- }, null, 8, ["name"])
714
- ]),
715
- o("div", {
716
- class: "header__user",
717
- ref_key: "dropdownRef",
718
- ref: d
719
- }, [
720
- o("div", {
721
- class: "header__user-trigger",
722
- onClick: $e(ee, ["stop"])
723
- }, [
724
- o("div", Et, [
725
- o("span", null, A(((q = p(r).nickname) == null ? void 0 : q.charAt(0)) || "U"), 1)
726
- ]),
727
- o("span", At, A(p(r).nickname), 1),
728
- o("span", {
729
- class: z(["header__user-arrow", { "is-active": a.value }])
730
- }, "▼", 2)
731
- ]),
732
- y(Te, { name: "dropdown" }, {
733
- default: T(() => {
734
- var _, D;
735
- return [
736
- a.value ? (g(), k("div", Rt, [
737
- o("div", $t, [
738
- o("div", Mt, [
739
- o("span", null, A(((_ = p(r).nickname) == null ? void 0 : _.charAt(0)) || "U"), 1)
740
- ]),
741
- o("div", Pt, [
742
- o("div", Ut, A(p(r).nickname), 1),
743
- o("div", Dt, A((D = p(r).roles) == null ? void 0 : D.join(", ")), 1)
744
- ])
745
- ]),
746
- c[8] || (c[8] = o("div", { class: "header__dropdown-divider" }, null, -1)),
747
- o("div", Ot, [
748
- o("div", {
749
- class: "header__dropdown-item",
750
- onClick: qe
751
- }, [
752
- y(p(M), {
753
- name: "user",
754
- size: 16
755
- }),
756
- c[4] || (c[4] = o("span", null, "个人信息", -1))
757
- ]),
758
- o("div", {
759
- class: "header__dropdown-item",
760
- onClick: We
761
- }, [
762
- y(p(M), {
763
- name: "lock",
764
- size: 16
765
- }),
766
- c[5] || (c[5] = o("span", null, "修改密码", -1))
767
- ]),
768
- c[7] || (c[7] = o("div", { class: "header__dropdown-divider" }, null, -1)),
769
- o("div", {
770
- class: "header__dropdown-item header__dropdown-item--danger",
771
- onClick: He
772
- }, [
773
- y(p(M), {
774
- name: "logout",
775
- size: 16
776
- }),
777
- c[6] || (c[6] = o("span", null, "退出登录", -1))
778
- ])
779
- ])
780
- ])) : O("", !0)
781
- ];
782
- }),
783
- _: 1
784
- })
785
- ], 512)
786
- ]),
787
- y(Te, { name: "search" }, {
788
- default: T(() => [
789
- w.value ? (g(), k("div", {
790
- key: 0,
791
- class: "header__search-modal",
792
- ref_key: "searchRef",
793
- ref: $
794
- }, [
795
- o("div", Nt, [
796
- o("div", zt, [
797
- y(p(M), {
798
- class: "search-icon",
799
- name: "search",
800
- size: 20
801
- }),
802
- Re(o("input", {
803
- "onUpdate:modelValue": c[0] || (c[0] = (_) => l.value = _),
804
- type: "text",
805
- class: "search-input",
806
- placeholder: "搜索菜单...",
807
- autofocus: "",
808
- onKeyup: c[1] || (c[1] = Me((_) => P.value[0] && xe(P.value[0].path), ["enter"]))
809
- }, null, 544), [
810
- [Ze, l.value]
811
- ]),
812
- c[9] || (c[9] = o("span", { class: "search-shortcut" }, "ESC 关闭", -1))
813
- ]),
814
- P.value.length > 0 ? (g(), k("div", Vt, [
815
- (g(!0), k(B, null, j(P.value, (_, D) => (g(), k("div", {
816
- key: _.path,
817
- class: z(["search-result-item", { "is-first": D === 0 }]),
818
- onClick: (Hs) => xe(_.path)
819
- }, [
820
- y(p(M), {
821
- class: "search-result-icon",
822
- name: _.icon || "file",
823
- size: 20
824
- }, null, 8, ["name"]),
825
- o("div", Ft, [
826
- o("span", jt, A(_.title), 1),
827
- _.parentTitle ? (g(), k("span", Kt, A(_.parentTitle), 1)) : O("", !0)
828
- ])
829
- ], 10, Bt))), 128))
830
- ])) : l.value ? (g(), k("div", qt, " 未找到匹配的菜单 ")) : O("", !0)
831
- ])
832
- ], 512)) : O("", !0)
833
- ]),
834
- _: 1
835
- }),
836
- y(p(nt), {
837
- modelValue: m.value,
838
- "onUpdate:modelValue": c[3] || (c[3] = (_) => m.value = _),
839
- title: "换肤设置",
840
- direction: "rtl",
841
- size: "320px"
842
- }, {
843
- default: T(() => [
844
- o("div", Wt, [
845
- o("div", Ht, [
846
- c[13] || (c[13] = o("div", { class: "settings-title" }, "布局模式", -1)),
847
- o("div", Yt, [
848
- (g(), k(B, null, j(E, (_) => o("div", {
849
- key: _.value,
850
- class: z(["layout-option", { "is-active": ce.value === _.value }]),
851
- onClick: (D) => me(_.value)
852
- }, [
853
- o("div", Jt, [
854
- _.value === "sidebar" ? (g(), k("div", Qt, [...c[10] || (c[10] = [
855
- o("div", { class: "preview-aside" }, null, -1),
856
- o("div", { class: "preview-main" }, [
857
- o("div", { class: "preview-header" }),
858
- o("div", { class: "preview-content" })
859
- ], -1)
860
- ])])) : _.value === "top" ? (g(), k("div", Zt, [...c[11] || (c[11] = [
861
- o("div", { class: "preview-header-full" }, null, -1),
862
- o("div", { class: "preview-content-full" }, null, -1)
863
- ])])) : (g(), k("div", Gt, [...c[12] || (c[12] = [
864
- o("div", { class: "preview-header-mix" }, [
865
- o("div", { class: "preview-mix-left" })
866
- ], -1),
867
- o("div", { class: "preview-mix-body" }, [
868
- o("div", { class: "preview-mix-aside" }),
869
- o("div", { class: "preview-mix-content" })
870
- ], -1)
871
- ])]))
872
- ]),
873
- o("span", es, A(_.label), 1)
874
- ], 10, Xt)), 64))
875
- ])
876
- ]),
877
- o("div", ts, [
878
- c[14] || (c[14] = o("div", { class: "settings-title" }, "主题色", -1)),
879
- o("div", ss, [
880
- (g(), k(B, null, j(x, (_) => o("div", {
881
- key: _.value,
882
- class: z(["color-option", { "is-active": p(n).primaryColor === _.value }]),
883
- style: Pe({ backgroundColor: _.value }),
884
- title: _.label,
885
- onClick: (D) => Ke(_.value)
886
- }, [
887
- p(n).primaryColor === _.value ? (g(), Z(p(M), {
888
- key: 0,
889
- name: "check",
890
- size: 12,
891
- color: "#fff"
892
- })) : O("", !0)
893
- ], 14, os)), 64))
894
- ])
895
- ]),
896
- o("div", ns, [
897
- c[19] || (c[19] = o("div", { class: "settings-title" }, "功能设置", -1)),
898
- o("div", as, [
899
- o("div", rs, [
900
- c[16] || (c[16] = o("span", null, "灰色模式", -1)),
901
- o("div", {
902
- class: z(["switch-wrapper", { "is-checked": I.value }]),
903
- onClick: c[2] || (c[2] = (_) => pe(!I.value))
904
- }, [...c[15] || (c[15] = [
905
- o("span", { class: "switch-core" }, null, -1)
906
- ])], 2)
907
- ]),
908
- o("div", ls, [
909
- c[18] || (c[18] = o("span", null, "暗黑模式", -1)),
910
- o("div", {
911
- class: z(["switch-wrapper", { "is-checked": p(n).isDark }]),
912
- onClick: G
913
- }, [...c[17] || (c[17] = [
914
- o("span", { class: "switch-core" }, null, -1)
915
- ])], 2)
916
- ])
917
- ])
918
- ])
919
- ])
920
- ]),
921
- _: 1
922
- }, 8, ["modelValue"])
923
- ]);
924
- };
925
- }
926
- }), cs = /* @__PURE__ */ F(is, [["__scopeId", "data-v-015c45c9"]]), us = { class: "layout" }, ds = { class: "layout__main" }, ms = { class: "layout__header" }, ps = { class: "layout__content" }, vs = /* @__PURE__ */ K({
927
- __name: "index",
928
- setup(e) {
929
- const t = Y(), s = b(
930
- () => t.isCollapsed ? "64px" : "210px"
931
- );
932
- return (n, r) => {
933
- const i = Ge("router-view");
934
- return g(), k("div", us, [
935
- o("aside", {
936
- class: "layout__aside",
937
- style: Pe({ width: s.value })
938
- }, [
939
- y(wt)
940
- ], 4),
941
- o("div", ds, [
942
- o("header", ms, [
943
- y(cs)
944
- ]),
945
- o("main", ps, [
946
- y(i)
947
- ])
948
- ])
949
- ]);
950
- };
951
- }
952
- }), je = /* @__PURE__ */ F(vs, [["__scopeId", "data-v-a3110011"]]), hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
953
- __proto__: null,
954
- default: je
955
- }, Symbol.toStringTag, { value: "Module" })), fs = { class: "tabs-wrapper" }, _s = { class: "tab-label" }, gs = ["onClick"], ys = /* @__PURE__ */ K({
956
- __name: "Tabs",
957
- setup(e) {
958
- const t = ae(), s = H(), n = b(() => {
959
- const a = [];
960
- return t.matched.forEach((m) => {
961
- var d;
962
- (d = m.meta) != null && d.affix && a.push({
963
- name: m.name,
964
- title: m.meta.title,
965
- path: m.path,
966
- affix: !0
967
- });
968
- }), a;
969
- }), r = b(() => t.path), i = (a) => {
970
- s.push(a);
971
- }, u = (a) => {
972
- const m = n.value.find((d) => d.path === a);
973
- if (!(m != null && m.affix) && a === r.value) {
974
- const d = n.value.findIndex((w) => w.path === a), v = n.value[d - 1] || n.value[d + 1];
975
- v && s.push(v.path);
976
- }
977
- };
978
- return (a, m) => (g(), k("div", fs, [
979
- y(p(st), {
980
- modelValue: r.value,
981
- "onUpdate:modelValue": m[0] || (m[0] = (d) => r.value = d),
982
- type: "card",
983
- onTabClick: i
984
- }, {
985
- default: T(() => [
986
- (g(!0), k(B, null, j(n.value, (d) => (g(), Z(p(ot), {
987
- key: d.path,
988
- name: d.path,
989
- label: d.title,
990
- closable: !d.affix
991
- }, {
992
- label: T(() => [
993
- o("span", _s, [
994
- W(A(d.title) + " ", 1),
995
- d.affix ? O("", !0) : (g(), k("span", {
996
- key: 0,
997
- class: "tab-close",
998
- onClick: $e((v) => u(d.path), ["stop"])
999
- }, " ✕ ", 8, gs))
1000
- ])
1001
- ]),
1002
- _: 2
1003
- }, 1032, ["name", "label", "closable"]))), 128))
1004
- ]),
1005
- _: 1
1006
- }, 8, ["modelValue"])
1007
- ]));
1008
- }
1009
- }), ro = /* @__PURE__ */ F(ys, [["__scopeId", "data-v-9156d8cd"]]), ks = {}, bs = { class: "footer" };
1010
- function ws(e, t) {
1011
- return g(), k("div", bs, [...t[0] || (t[0] = [
1012
- o("span", null, "Copyright © 2024 Xto Demo. All Rights Reserved.", -1)
1013
- ])]);
1014
- }
1015
- const lo = /* @__PURE__ */ F(ks, [["render", ws], ["__scopeId", "data-v-4852826a"]]), Cs = () => {
1016
- const e = lt.create({
1017
- baseURL: void 0,
1018
- timeout: 3e4,
1019
- headers: {
1020
- "Content-Type": "application/json"
1021
- }
1022
- });
1023
- return e.interceptors.request.use(
1024
- (t) => {
1025
- const s = le();
1026
- return s && (t.headers.Authorization = `Bearer ${s}`), t;
1027
- },
1028
- (t) => Promise.reject(t)
1029
- ), e.interceptors.response.use(
1030
- (t) => {
1031
- const { data: s } = t;
1032
- return s.code === 200 || s.code === 0 ? s.data : (V.error(s.message || "请求失败"), Promise.reject(new Error(s.message || "请求失败")));
1033
- },
1034
- (t) => {
1035
- var n;
1036
- const { response: s } = t;
1037
- if (s)
1038
- switch (s.status) {
1039
- case 401:
1040
- V.error("登录已过期,请重新登录"), Be(), window.location.href = "/login";
1041
- break;
1042
- case 403:
1043
- V.error("没有权限访问");
1044
- break;
1045
- case 404:
1046
- V.error("请求资源不存在");
1047
- break;
1048
- case 500:
1049
- V.error("服务器错误");
1050
- break;
1051
- default:
1052
- V.error(((n = s.data) == null ? void 0 : n.message) || "请求失败");
1053
- }
1054
- else
1055
- V.error("网络连接失败");
1056
- return Promise.reject(t);
1057
- }
1058
- ), e;
1059
- }, Q = Cs(), S = {
1060
- get(e, t) {
1061
- return Q.get(e, t);
1062
- },
1063
- post(e, t, s) {
1064
- return Q.post(e, t, s);
1065
- },
1066
- put(e, t, s) {
1067
- return Q.put(e, t, s);
1068
- },
1069
- patch(e, t, s) {
1070
- return Q.patch(e, t, s);
1071
- },
1072
- delete(e, t) {
1073
- return Q.delete(e, t);
1074
- }
1075
- };
1076
- function Ss(e) {
1077
- return S.post("/user-service/login", e);
1078
- }
1079
- function io() {
1080
- return S.post("/user-service/logout");
1081
- }
1082
- function xs() {
1083
- return S.get("/user-service/info");
1084
- }
1085
- function co(e) {
1086
- return S.post("/user-service/refresh", { refreshToken: e });
1087
- }
1088
- const Ls = { class: "login" }, Is = { class: "login__container" }, Ts = /* @__PURE__ */ K({
1089
- __name: "index",
1090
- setup(e) {
1091
- const t = H(), s = ae(), n = f(!1), r = f(!1), i = fe({
1092
- username: "admin",
1093
- password: "123456"
1094
- }), u = {
1095
- username: [
1096
- { required: !0, message: "请输入用户名", trigger: "blur" }
1097
- ],
1098
- password: [
1099
- { required: !0, message: "请输入密码", trigger: "blur" },
1100
- { min: 6, message: "密码长度至少6位", trigger: "blur" }
1101
- ]
1102
- }, a = f(), m = async () => {
1103
- var d;
1104
- try {
1105
- await ((d = a.value) == null ? void 0 : d.validate()), n.value = !0;
1106
- const v = await Ss({
1107
- username: i.username,
1108
- password: i.password
1109
- });
1110
- Ve(v), V.success("登录成功");
1111
- const w = s.query.redirect || "/";
1112
- t.push(w);
1113
- } catch (v) {
1114
- console.error("登录失败:", v);
1115
- } finally {
1116
- n.value = !1;
1117
- }
1118
- };
1119
- return (d, v) => (g(), k("div", Ls, [
1120
- o("div", Is, [
1121
- v[5] || (v[5] = o("div", { class: "login__header" }, [
1122
- o("img", {
1123
- src: De,
1124
- alt: "Logo",
1125
- class: "login__logo"
1126
- }),
1127
- o("h1", { class: "login__title" }, "Xto Demo"),
1128
- o("p", { class: "login__subtitle" }, "后台管理系统")
1129
- ], -1)),
1130
- y(p(at), {
1131
- ref_key: "formRef",
1132
- ref: a,
1133
- model: i,
1134
- rules: u,
1135
- class: "login__form",
1136
- "label-width": "0"
1137
- }, {
1138
- default: T(() => [
1139
- y(p(te), { prop: "username" }, {
1140
- default: T(() => [
1141
- y(p(Ae), {
1142
- modelValue: i.username,
1143
- "onUpdate:modelValue": v[0] || (v[0] = (w) => i.username = w),
1144
- placeholder: "用户名",
1145
- "prefix-icon": "👤",
1146
- size: "large"
1147
- }, null, 8, ["modelValue"])
1148
- ]),
1149
- _: 1
1150
- }),
1151
- y(p(te), { prop: "password" }, {
1152
- default: T(() => [
1153
- y(p(Ae), {
1154
- modelValue: i.password,
1155
- "onUpdate:modelValue": v[1] || (v[1] = (w) => i.password = w),
1156
- type: "password",
1157
- placeholder: "密码",
1158
- "prefix-icon": "🔒",
1159
- size: "large",
1160
- "show-password": "",
1161
- onKeyup: Me(m, ["enter"])
1162
- }, null, 8, ["modelValue"])
1163
- ]),
1164
- _: 1
1165
- }),
1166
- y(p(te), null, {
1167
- default: T(() => [
1168
- y(p(rt), {
1169
- modelValue: r.value,
1170
- "onUpdate:modelValue": v[2] || (v[2] = (w) => r.value = w)
1171
- }, {
1172
- default: T(() => [...v[3] || (v[3] = [
1173
- W("记住我", -1)
1174
- ])]),
1175
- _: 1
1176
- }, 8, ["modelValue"])
1177
- ]),
1178
- _: 1
1179
- }),
1180
- y(p(te), null, {
1181
- default: T(() => [
1182
- y(p(re), {
1183
- type: "primary",
1184
- size: "large",
1185
- loading: n.value,
1186
- class: "login__submit",
1187
- onClick: m
1188
- }, {
1189
- default: T(() => [...v[4] || (v[4] = [
1190
- W(" 登录 ", -1)
1191
- ])]),
1192
- _: 1
1193
- }, 8, ["loading"])
1194
- ]),
1195
- _: 1
1196
- })
1197
- ]),
1198
- _: 1
1199
- }, 8, ["model"]),
1200
- v[6] || (v[6] = o("div", { class: "login__footer" }, [
1201
- o("p", null, "默认账号: admin / 123456")
1202
- ], -1))
1203
- ])
1204
- ]));
1205
- }
1206
- }), Es = /* @__PURE__ */ F(Ts, [["__scopeId", "data-v-c2cc908e"]]), As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1207
- __proto__: null,
1208
- default: Es
1209
- }, Symbol.toStringTag, { value: "Module" })), Rs = { class: "error-page" }, $s = { class: "error-page__content" }, Ms = /* @__PURE__ */ K({
1210
- __name: "404",
1211
- setup(e) {
1212
- const t = H(), s = () => {
1213
- t.push("/");
1214
- };
1215
- return (n, r) => (g(), k("div", Rs, [
1216
- o("div", $s, [
1217
- r[1] || (r[1] = o("div", { class: "error-page__code" }, "404", -1)),
1218
- r[2] || (r[2] = o("div", { class: "error-page__title" }, "页面不存在", -1)),
1219
- r[3] || (r[3] = o("div", { class: "error-page__desc" }, "抱歉,您访问的页面不存在或已被删除", -1)),
1220
- y(p(re), {
1221
- type: "primary",
1222
- onClick: s
1223
- }, {
1224
- default: T(() => [...r[0] || (r[0] = [
1225
- W("返回首页", -1)
1226
- ])]),
1227
- _: 1
1228
- })
1229
- ])
1230
- ]));
1231
- }
1232
- }), Ps = /* @__PURE__ */ F(Ms, [["__scopeId", "data-v-c3c12c24"]]), Us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1233
- __proto__: null,
1234
- default: Ps
1235
- }, Symbol.toStringTag, { value: "Module" })), Ds = { class: "error-page" }, Os = { class: "error-page__content" }, Ns = /* @__PURE__ */ K({
1236
- __name: "403",
1237
- setup(e) {
1238
- const t = H(), s = () => {
1239
- t.push("/");
1240
- };
1241
- return (n, r) => (g(), k("div", Ds, [
1242
- o("div", Os, [
1243
- r[1] || (r[1] = o("div", { class: "error-page__code" }, "403", -1)),
1244
- r[2] || (r[2] = o("div", { class: "error-page__title" }, "无访问权限", -1)),
1245
- r[3] || (r[3] = o("div", { class: "error-page__desc" }, "抱歉,您没有权限访问此页面", -1)),
1246
- y(p(re), {
1247
- type: "primary",
1248
- onClick: s
1249
- }, {
1250
- default: T(() => [...r[0] || (r[0] = [
1251
- W("返回首页", -1)
1252
- ])]),
1253
- _: 1
1254
- })
1255
- ])
1256
- ]));
1257
- }
1258
- }), zs = /* @__PURE__ */ F(Ns, [["__scopeId", "data-v-dd5f2795"]]), Vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1259
- __proto__: null,
1260
- default: zs
1261
- }, Symbol.toStringTag, { value: "Module" }));
1262
- function uo() {
1263
- const e = Y(), t = N(), s = Ce(), n = b(() => t.nickname || t.username || ""), r = b(() => t.userInfo), i = b(() => e.appName), u = b(() => s.isLoggedIn), a = b(() => e.isDark), m = b(() => e.theme), d = b(() => e.isCollapsed), v = b(() => e.layout);
1264
- return {
1265
- userName: n,
1266
- userInfo: r,
1267
- appName: i,
1268
- isLoggedIn: u,
1269
- isDark: a,
1270
- theme: m,
1271
- isCollapsed: d,
1272
- layout: v,
1273
- toggleTheme: () => {
1274
- e.toggleTheme();
1275
- },
1276
- toggleCollapse: () => {
1277
- e.toggleCollapse();
1278
- }
1279
- };
1280
- }
1281
- function mo() {
1282
- const e = N(), t = (i) => {
1283
- const u = e.permissions;
1284
- return u.includes("*") ? !0 : Array.isArray(i) ? i.some((a) => u.includes(a)) : u.includes(i);
1285
- }, s = (i) => {
1286
- const u = e.roles;
1287
- return u.includes("admin") ? !0 : Array.isArray(i) ? i.some((a) => u.includes(a)) : u.includes(i);
1288
- }, n = b(() => e.roles.includes("admin")), r = b(() => e.isLoggedIn);
1289
- return {
1290
- hasPermission: t,
1291
- hasRole: s,
1292
- isAdmin: n,
1293
- isLoggedIn: r
1294
- };
1295
- }
1296
- function po(e, t = {}) {
1297
- const { rules: s, onSubmit: n } = t, r = f(), i = fe({ ...e }), u = f(!1), a = f(!1), m = f(!1), d = () => {
1298
- l(), m.value = !1, a.value = !0;
1299
- }, v = (I) => {
1300
- Object.assign(i, I), m.value = !0, a.value = !0;
1301
- }, w = () => {
1302
- a.value = !1, l();
1303
- }, l = () => {
1304
- var I;
1305
- Object.keys(e).forEach((E) => {
1306
- i[E] = e[E];
1307
- }), (I = r.value) == null || I.resetFields();
1308
- };
1309
- return {
1310
- formRef: r,
1311
- formData: i,
1312
- rules: s,
1313
- loading: u,
1314
- visible: a,
1315
- isEdit: m,
1316
- openAdd: d,
1317
- openEdit: v,
1318
- close: w,
1319
- resetForm: l,
1320
- handleSubmit: async () => {
1321
- var I;
1322
- try {
1323
- await ((I = r.value) == null ? void 0 : I.validate()), u.value = !0, await (n == null ? void 0 : n(i)), w();
1324
- } catch (E) {
1325
- console.error(E);
1326
- } finally {
1327
- u.value = !1;
1328
- }
1329
- }
1330
- };
1331
- }
1332
- function vo(e) {
1333
- const { fetchData: t, defaultPageSize: s = 10 } = e, n = f(!1), r = f([]), i = f(0), u = f(1), a = f(s), m = fe({}), d = async () => {
1334
- n.value = !0;
1335
- try {
1336
- const x = {
1337
- ...m,
1338
- page: u.value,
1339
- pageSize: a.value
1340
- }, U = await t(x);
1341
- r.value = U.list, i.value = U.total;
1342
- } catch (x) {
1343
- console.error(x);
1344
- } finally {
1345
- n.value = !1;
1346
- }
1347
- }, v = () => {
1348
- u.value = 1, d();
1349
- }, w = () => {
1350
- Object.keys(m).forEach((x) => {
1351
- m[x] = void 0;
1352
- }), u.value = 1, d();
1353
- }, l = (x) => {
1354
- u.value = x, d();
1355
- }, $ = (x) => {
1356
- a.value = x, u.value = 1, d();
1357
- }, I = () => {
1358
- d();
1359
- }, E = b(() => ({
1360
- current: u.value,
1361
- pageSize: a.value,
1362
- total: i.value
1363
- }));
1364
- return {
1365
- loading: n,
1366
- data: r,
1367
- total: i,
1368
- currentPage: u,
1369
- pageSize: a,
1370
- searchParams: m,
1371
- pagination: E,
1372
- getData: d,
1373
- handleSearch: v,
1374
- handleReset: w,
1375
- handlePageChange: l,
1376
- handleSizeChange: $,
1377
- refresh: I
1378
- };
1379
- }
1380
- function ho(e) {
1381
- const s = N().permissions;
1382
- return Array.isArray(e) ? e.some((n) => s.includes(n)) : s.includes(e);
1383
- }
1384
- function Bs(e) {
1385
- const s = N().roles;
1386
- return Array.isArray(e) ? e.some((n) => s.includes(n)) : s.includes(e);
1387
- }
1388
- function fo() {
1389
- return Bs("admin");
1390
- }
1391
- function _o(e, t = {}) {
1392
- const s = t.indexPath || "/dashboard";
1393
- return {
1394
- path: "/",
1395
- name: "Layout",
1396
- component: je,
1397
- redirect: s,
1398
- children: e
1399
- };
1400
- }
1401
- function go(e) {
1402
- return _e({
1403
- history: ge(),
1404
- routes: e,
1405
- scrollBehavior: () => ({ left: 0, top: 0 })
1406
- });
1407
- }
1408
- function yo(e) {
1409
- return S.get("/role/list", { params: e });
1410
- }
1411
- function ko(e) {
1412
- return S.get(`/role/${e}`);
1413
- }
1414
- function bo(e) {
1415
- return S.post("/role", e);
1416
- }
1417
- function wo(e, t) {
1418
- return S.put(`/role/${e}`, t);
1419
- }
1420
- function Co(e) {
1421
- return S.delete(`/role/${e}`);
1422
- }
1423
- function So(e, t) {
1424
- return S.patch(`/role/${e}/status`, { status: t });
1425
- }
1426
- function xo() {
1427
- return S.get("/user-service/menu/list");
1428
- }
1429
- function Fs() {
1430
- return S.get("/user-service/menu/tree");
1431
- }
1432
- function Lo(e) {
1433
- return S.post("/menu", e);
1434
- }
1435
- function Io(e, t) {
1436
- return S.put(`/menu/${e}`, t);
1437
- }
1438
- function To(e) {
1439
- return S.delete(`/menu/${e}`);
1440
- }
1441
- const js = ["/login", "/404", "/403"];
1442
- function Eo(e, t = {}) {
1443
- const s = t.whiteList || js, n = t.loginPath || "/login", r = t.homePath || "/";
1444
- e.beforeEach(async (i, u, a) => {
1445
- const m = Y(), d = N(), v = ie();
1446
- if (m.initTheme(), le())
1447
- if (i.path === n)
1448
- a({ path: r });
1449
- else if (d.isLoggedIn)
1450
- i.name && i.meta.keepAlive && m.addCachedView(i.name), a();
1451
- else
1452
- try {
1453
- if (t.fetchUserInfo) {
1454
- const l = await t.fetchUserInfo();
1455
- d.setUserInfo(l);
1456
- } else {
1457
- const l = await xs();
1458
- d.setUserInfo(l);
1459
- }
1460
- if (t.fetchMenu) {
1461
- const l = await t.fetchMenu();
1462
- v.setMenuList(l);
1463
- } else {
1464
- const l = await Fs();
1465
- v.setMenuList(l);
1466
- }
1467
- t.onLoginSuccess && t.onLoginSuccess(), i.name && i.meta.keepAlive && m.addCachedView(i.name), a({ ...i, replace: !0 });
1468
- } catch (l) {
1469
- console.error("获取用户信息失败:", l), d.clearUserInfo(), v.clearMenu(), localStorage.removeItem("token"), localStorage.removeItem("refreshToken"), a({ path: n, query: { redirect: i.fullPath } });
1470
- }
1471
- else
1472
- s.includes(i.path) ? a() : a({ path: n, query: { redirect: i.fullPath } });
1473
- }), e.afterEach(() => {
1474
- });
1475
- }
1476
- function Ao(e) {
1477
- return S.get("/user/list", { params: e });
1478
- }
1479
- function Ro(e) {
1480
- return S.get(`/user/${e}`);
1481
- }
1482
- function $o(e) {
1483
- return S.post("/user", e);
1484
- }
1485
- function Mo(e, t) {
1486
- return S.put(`/user/${e}`, t);
1487
- }
1488
- function Po(e) {
1489
- return S.delete(`/user/${e}`);
1490
- }
1491
- function Uo(e) {
1492
- return S.post("/user/batch-delete", { ids: e });
1493
- }
1494
- function Do(e, t) {
1495
- return S.patch(`/user/${e}/status`, { status: t });
1496
- }
1497
- function Oo(e) {
1498
- return S.post(`/user/${e}/reset-password`);
1499
- }
1500
- var Ks = /* @__PURE__ */ ((e) => (e[e.ENABLED = 1] = "ENABLED", e[e.DISABLED = 0] = "DISABLED", e))(Ks || {}), qs = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.MALE = 1] = "MALE", e[e.FEMALE = 2] = "FEMALE", e))(qs || {}), Ws = /* @__PURE__ */ ((e) => (e[e.DIRECTORY = 0] = "DIRECTORY", e[e.MENU = 1] = "MENU", e[e.BUTTON = 2] = "BUTTON", e))(Ws || {});
1501
- const No = {
1502
- 1: "启用",
1503
- 0: "禁用"
1504
- }, zo = {
1505
- 0: "未知",
1506
- 1: "男",
1507
- 2: "女"
1508
- }, Vo = {
1509
- 0: "目录",
1510
- 1: "菜单",
1511
- 2: "按钮"
1512
- }, Bo = [
1513
- {
1514
- label: "启用",
1515
- value: 1
1516
- /* ENABLED */
1517
- },
1518
- {
1519
- label: "禁用",
1520
- value: 0
1521
- /* DISABLED */
1522
- }
1523
- ], Fo = [
1524
- {
1525
- label: "未知",
1526
- value: 0
1527
- /* UNKNOWN */
1528
- },
1529
- {
1530
- label: "男",
1531
- value: 1
1532
- /* MALE */
1533
- },
1534
- {
1535
- label: "女",
1536
- value: 2
1537
- /* FEMALE */
1538
- }
1539
- ], jo = [
1540
- {
1541
- label: "目录",
1542
- value: 0
1543
- /* DIRECTORY */
1544
- },
1545
- {
1546
- label: "菜单",
1547
- value: 1
1548
- /* MENU */
1549
- },
1550
- {
1551
- label: "按钮",
1552
- value: 2
1553
- /* BUTTON */
1554
- }
1555
- ], Ko = {
1556
- mounted(e, t) {
1557
- var u;
1558
- const s = N(), { value: n } = t;
1559
- if (!n) return;
1560
- const r = s.permissions;
1561
- let i = !1;
1562
- Array.isArray(n) ? i = n.some((a) => r.includes(a) || r.includes("*")) : i = r.includes(n) || r.includes("*"), i || (u = e.parentNode) == null || u.removeChild(e);
1563
- }
1564
- };
1565
- export {
1566
- co as $,
1567
- yo as A,
1568
- le as B,
1569
- mt as C,
1570
- Ro as D,
1571
- xs as E,
1572
- lo as F,
1573
- qs as G,
1574
- cs as H,
1575
- Ao as I,
1576
- ho as J,
1577
- Bs as K,
1578
- je as L,
1579
- Ws as M,
1580
- Fe as N,
1581
- S as O,
1582
- fo as P,
1583
- vt as Q,
1584
- ze as R,
1585
- Ks as S,
1586
- ro as T,
1587
- h as U,
1588
- se as V,
1589
- Ss as W,
1590
- io as X,
1591
- ct as Y,
1592
- Ko as Z,
1593
- F as _,
1594
- Bo as a,
1595
- Oo as a0,
1596
- ao as a1,
1597
- we as a2,
1598
- so as a3,
1599
- oe as a4,
1600
- dt as a5,
1601
- ut as a6,
1602
- pt as a7,
1603
- Ve as a8,
1604
- Eo as a9,
1605
- Oe as aa,
1606
- Io as ab,
1607
- wo as ac,
1608
- So as ad,
1609
- Mo as ae,
1610
- Do as af,
1611
- uo as ag,
1612
- Y as ah,
1613
- mo as ai,
1614
- Ce as aj,
1615
- po as ak,
1616
- ie as al,
1617
- vo as am,
1618
- N as an,
1619
- jo as b,
1620
- zs as c,
1621
- Fo as d,
1622
- zo as e,
1623
- Vo as f,
1624
- Ps as g,
1625
- wt as h,
1626
- Es as i,
1627
- No as j,
1628
- Uo as k,
1629
- Be as l,
1630
- _o as m,
1631
- Lo as n,
1632
- bo as o,
1633
- go as p,
1634
- $o as q,
1635
- oo as r,
1636
- To as s,
1637
- Co as t,
1638
- Po as u,
1639
- Ne as v,
1640
- xo as w,
1641
- Fs as x,
1642
- no as y,
1643
- ko as z
1644
- };