xto-fronted 0.4.6 → 0.4.7

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