xto-fronted 0.2.6 → 0.2.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 (107) hide show
  1. package/.env.development +4 -0
  2. package/.env.production +4 -0
  3. package/README.md +94 -196
  4. package/dist/{components/Layout/TopMenu.vue.d.ts → App.vue.d.ts} +1 -1
  5. package/dist/api/auth.d.ts +8 -10
  6. package/dist/api/system.d.ts +11 -12
  7. package/dist/api/user.d.ts +12 -3
  8. package/dist/components/Layout/Footer.vue.d.ts +1 -1
  9. package/dist/components/Layout/Header.vue.d.ts +3 -14
  10. package/dist/components/Layout/Sidebar.vue.d.ts +1 -1
  11. package/dist/components/Layout/Tabs.vue.d.ts +1 -1
  12. package/dist/components/Layout/index.vue.d.ts +1 -1
  13. package/dist/composables/useAuth.d.ts +4 -19
  14. package/dist/directives/permission.d.ts +0 -1
  15. package/dist/index-CWRs4WMN.js +372 -0
  16. package/dist/index-CpxpXTQX.js +1462 -0
  17. package/dist/index-Cu3Z2-PY.js +345 -0
  18. package/dist/index-DPEVEyik.js +475 -0
  19. package/dist/index-DYnXaqYf.js +142 -0
  20. package/dist/index.d.ts +12 -25
  21. package/dist/index.es.js +76 -1521
  22. package/dist/index.umd.js +1 -20
  23. package/dist/main.d.ts +0 -1
  24. package/dist/router/dynamicRoutes.d.ts +33 -17
  25. package/dist/router/index.d.ts +4 -26
  26. package/dist/router/layoutRoute.d.ts +18 -0
  27. package/dist/router/staticRoutes.d.ts +2 -18
  28. package/dist/setup.d.ts +17 -0
  29. package/dist/stores/app.d.ts +15 -9
  30. package/dist/stores/auth.d.ts +48 -62
  31. package/dist/stores/index.d.ts +3 -1
  32. package/dist/stores/menu.d.ts +29 -47
  33. package/dist/stores/user.d.ts +84 -64
  34. package/dist/style.css +1 -1
  35. package/dist/utils/auth.d.ts +10 -10
  36. package/dist/utils/permission.d.ts +10 -1
  37. package/dist/utils/request.d.ts +7 -23
  38. package/dist/{components/Layout/Breadcrumb.vue.d.ts → views/dashboard/index.vue.d.ts} +1 -1
  39. package/dist/{components/Error → views/error}/403.vue.d.ts +1 -1
  40. package/dist/{components/Error → views/error}/404.vue.d.ts +1 -1
  41. package/dist/views/login/index.vue.d.ts +4 -0
  42. package/dist/views/system/menu/index.vue.d.ts +4 -0
  43. package/dist/views/system/role/index.vue.d.ts +4 -0
  44. package/dist/views/system/user/index.vue.d.ts +4 -0
  45. package/dist/vite.svg +9 -9
  46. package/index.html +13 -0
  47. package/package.json +27 -31
  48. package/public/vite.svg +10 -0
  49. package/src/App.vue +20 -0
  50. package/src/api/auth.ts +26 -0
  51. package/src/api/system.ts +65 -0
  52. package/src/api/user.ts +46 -0
  53. package/src/assets/styles/_dark.scss +407 -0
  54. package/src/assets/styles/_reset.scss +126 -0
  55. package/src/assets/styles/_root.scss +140 -0
  56. package/src/assets/styles/_transition.scss +119 -0
  57. package/src/assets/styles/_variables.scss +45 -0
  58. package/src/assets/styles/index.scss +187 -0
  59. package/src/components/Layout/Footer.vue +17 -0
  60. package/src/components/Layout/Header.vue +390 -0
  61. package/src/components/Layout/Sidebar.vue +297 -0
  62. package/src/components/Layout/Tabs.vue +134 -0
  63. package/src/components/Layout/index.vue +62 -0
  64. package/src/composables/useAuth.ts +45 -0
  65. package/src/composables/useForm.ts +79 -0
  66. package/src/composables/useTable.ts +97 -0
  67. package/src/directives/permission.ts +38 -0
  68. package/src/enums/index.ts +63 -0
  69. package/src/env.d.ts +17 -0
  70. package/src/index.ts +48 -0
  71. package/src/main.ts +34 -0
  72. package/src/router/dynamicRoutes.ts +163 -0
  73. package/src/router/index.ts +81 -0
  74. package/src/router/layoutRoute.ts +45 -0
  75. package/src/router/staticRoutes.ts +43 -0
  76. package/src/setup.ts +54 -0
  77. package/src/stores/app.ts +163 -0
  78. package/src/stores/auth.ts +66 -0
  79. package/src/stores/index.ts +15 -0
  80. package/src/stores/menu.ts +80 -0
  81. package/src/stores/user.ts +73 -0
  82. package/src/style.css +11 -0
  83. package/src/types/api.d.ts +84 -0
  84. package/src/types/global.d.ts +45 -0
  85. package/src/types/router.d.ts +48 -0
  86. package/src/types/xto.d.ts +149 -0
  87. package/src/utils/auth.ts +62 -0
  88. package/src/utils/permission.ts +42 -0
  89. package/src/utils/request.ts +124 -0
  90. package/src/utils/storage.ts +63 -0
  91. package/src/views/dashboard/index.vue +284 -0
  92. package/src/views/error/403.vue +57 -0
  93. package/src/views/error/404.vue +57 -0
  94. package/src/views/login/index.vue +248 -0
  95. package/src/views/system/menu/index.vue +381 -0
  96. package/src/views/system/role/index.vue +304 -0
  97. package/src/views/system/user/index.vue +327 -0
  98. package/tsconfig.json +26 -0
  99. package/tsconfig.node.json +11 -0
  100. package/vite.config.ts +140 -0
  101. package/dist/api/menu.d.ts +0 -4
  102. package/dist/components/Login/index.vue.d.ts +0 -25
  103. package/dist/components/SettingDrawer/index.vue.d.ts +0 -19
  104. package/dist/composables/index.d.ts +0 -8
  105. package/dist/composables/useApp.d.ts +0 -65
  106. package/dist/composables/useMenu.d.ts +0 -34
  107. package/dist/config/index.d.ts +0 -31
@@ -0,0 +1,1462 @@
1
+ import { ref as m, computed as b, watch as Ie, defineComponent as B, openBlock as v, createElementBlock as f, createElementVNode as n, withDirectives as Ae, vShow as Le, createVNode as I, unref as g, Fragment as z, renderList as X, toDisplayString as L, createCommentVNode as V, withCtx as $, createBlock as ee, createTextVNode as F, onMounted as $e, onUnmounted as Ee, normalizeClass as _e, withModifiers as ge, Transition as Re, resolveComponent as Me, normalizeStyle as Pe, reactive as re, 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 De, 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 ae, Form as Be, FormItem as Q, Checkbox as ze } from "@xto/form";
7
+ import { Message as U } 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
+ }, W = 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"), a = 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 = b(() => t.value ? "dark" : "light"), l = (k) => {
47
+ e.value = k, p.set("appName", k);
48
+ }, C = (k) => {
49
+ s.value = k, p.set("indexPath", k);
50
+ }, E = () => {
51
+ t.value = !t.value, r.value = t.value ? "dark" : "light", A();
52
+ }, R = (k) => {
53
+ r.value = k, t.value = k === "dark", A();
54
+ }, A = () => {
55
+ const k = document.documentElement;
56
+ t.value ? k.classList.add("dark") : k.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 = (k) => {
60
+ a.value = k, p.set("layout", k);
61
+ }, P = () => {
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
+ }, _ = (k) => {
68
+ d.value = k, document.documentElement.style.setProperty("--color-primary", k), p.set("primaryColor", k);
69
+ }, h = (k) => {
70
+ y.value.includes(k) || y.value.push(k);
71
+ }, Y = (k) => {
72
+ const ve = y.value.indexOf(k);
73
+ ve > -1 && y.value.splice(ve, 1);
74
+ }, N = () => {
75
+ y.value = [];
76
+ }, J = () => {
77
+ A(), d.value !== "#409eff" && document.documentElement.style.setProperty("--color-primary", d.value);
78
+ };
79
+ return Ie(t, A), {
80
+ appName: e,
81
+ indexPath: s,
82
+ isDark: t,
83
+ theme: r,
84
+ layout: a,
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: P,
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((a, 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(() => rs),
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-DYnXaqYf.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-CWRs4WMN.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-Cu3Z2-PY.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-DPEVEyik.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-DYnXaqYf.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-CWRs4WMN.js"),
226
+ meta: {
227
+ title: "用户管理",
228
+ icon: "user",
229
+ keepAlive: !0
230
+ }
231
+ },
232
+ {
233
+ path: "role",
234
+ name: "SystemRole",
235
+ component: () => import("./index-Cu3Z2-PY.js"),
236
+ meta: {
237
+ title: "角色管理",
238
+ icon: "role",
239
+ keepAlive: !0
240
+ }
241
+ },
242
+ {
243
+ path: "menu",
244
+ name: "SystemMenu",
245
+ component: () => import("./index-DPEVEyik.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
+ }, Is = () => p.get(de), qe = (e) => {
305
+ p.set(de, e);
306
+ }, Xe = () => p.get(pe), We = (e) => {
307
+ p.set(pe, e);
308
+ }, Ye = (e) => {
309
+ Ke(e.token), qe(e.refreshToken), We(e.expireTime);
310
+ }, xe = () => {
311
+ p.remove(ue), p.remove(de), p.remove(pe);
312
+ }, Je = () => {
313
+ const e = Xe();
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 = b(() => !!e.value), a = b(() => {
317
+ var l;
318
+ return ((l = e.value) == null ? void 0 : l.username) || "";
319
+ }), c = b(() => {
320
+ var l;
321
+ return ((l = e.value) == null ? void 0 : l.nickname) || "";
322
+ }), i = b(() => {
323
+ var l;
324
+ return ((l = e.value) == null ? void 0 : l.avatar) || "";
325
+ }), o = b(() => {
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: a,
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 = W();
354
+ if (r.initTheme(), Ce())
355
+ if (e.path === "/login")
356
+ t({ path: "/" });
357
+ else {
358
+ const a = D();
359
+ a.isLoggedIn || (a.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 As() {
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 = b(() => e.value.length > 0), t = (i) => {
384
+ e.value = i, p.set("menuList", i);
385
+ }, r = () => {
386
+ e.value = [], p.remove("menuList");
387
+ }, a = (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 = a(o.children)), u;
399
+ });
400
+ return {
401
+ menuList: e,
402
+ hasMenu: s,
403
+ setMenuList: t,
404
+ clearMenu: r,
405
+ generateRoutes: a,
406
+ addRoutes: (i) => {
407
+ a(i).forEach((u) => {
408
+ he.addRoute("Layout", u);
409
+ });
410
+ }
411
+ };
412
+ }), ne = te("auth", () => {
413
+ const e = m(me()), s = b(() => Ce()), t = m(""), r = m(""), a = m(""), c = m("/login");
414
+ return {
415
+ token: e,
416
+ isLoggedIn: s,
417
+ baseUrl: t,
418
+ appId: r,
419
+ clientId: a,
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
+ a.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" }, at = { class: "sidebar__search-item-info" }, rt = { 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__ */ B({
453
+ __name: "Sidebar",
454
+ setup(e) {
455
+ const s = ce(), t = j(), r = oe(), a = D(), c = ne(), i = W(), o = m(""), u = b(() => i.isCollapsed), d = b(() => s.path), y = b(() => i.isDark ? "#1d1e1f" : "#fff"), x = b(() => i.isDark ? "#cfd3dc" : "#303133"), l = b(() => "#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 = b(() => o.value.trim() ? C(r.menuList).filter(
461
+ (T) => T.title.toLowerCase().includes(o.value.toLowerCase())
462
+ ) : []), R = b(() => 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), A = (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(), a.clearUserInfo(), r.clearMenu(), t.push("/login");
476
+ }, P = (S) => ({
477
+ dashboard: "📊",
478
+ system: "⚙️",
479
+ user: "👤",
480
+ role: "👥",
481
+ menu: "📋",
482
+ setting: "🔧"
483
+ })[S || ""] || "📄";
484
+ return (S, T) => (v(), f("div", Ze, [
485
+ n("div", Ge, [
486
+ T[1] || (T[1] = n("img", {
487
+ src: ke,
488
+ alt: "Logo",
489
+ class: "sidebar__logo-img"
490
+ }, null, -1)),
491
+ Ae(n("span", et, "Xto Demo", 512), [
492
+ [Le, !u.value]
493
+ ])
494
+ ]),
495
+ u.value ? V("", !0) : (v(), f("div", tt, [
496
+ I(g(ae), {
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(), f("div", st, [
504
+ (v(!0), f(z, null, X(E.value, (_) => (v(), f("div", {
505
+ key: _.path,
506
+ class: "sidebar__search-item",
507
+ onClick: (h) => M(_.path)
508
+ }, [
509
+ n("span", nt, L(P(_.icon)), 1),
510
+ n("div", at, [
511
+ n("span", rt, L(_.title), 1),
512
+ _.parentTitle ? (v(), f("span", lt, L(_.parentTitle), 1)) : V("", !0)
513
+ ])
514
+ ], 8, ot))), 128))
515
+ ])) : V("", !0)
516
+ ])),
517
+ I(g(De), {
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: A
526
+ }, {
527
+ default: $(() => [
528
+ (v(!0), f(z, null, X(R.value, (_) => (v(), f(z, {
529
+ key: _.path
530
+ }, [
531
+ _.children && _.children.length > 0 ? (v(), ee(g(Oe), {
532
+ key: 0,
533
+ index: _.path
534
+ }, {
535
+ title: $(() => [
536
+ n("span", it, L(P(_.icon)), 1),
537
+ n("span", null, L(_.title), 1)
538
+ ]),
539
+ default: $(() => [
540
+ (v(!0), f(z, null, X(_.children, (h) => (v(), ee(g(fe), {
541
+ key: h.path,
542
+ index: h.path
543
+ }, {
544
+ default: $(() => [
545
+ n("span", ct, L(P(h.icon)), 1),
546
+ n("span", null, L(h.title), 1)
547
+ ]),
548
+ _: 2
549
+ }, 1032, ["index"]))), 128))
550
+ ]),
551
+ _: 2
552
+ }, 1032, ["index"])) : (v(), ee(g(fe), {
553
+ key: 1,
554
+ index: _.path
555
+ }, {
556
+ default: $(() => [
557
+ n("span", ut, L(P(_.icon)), 1),
558
+ n("span", null, L(_.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(), f("div", dt, [
567
+ n("div", pt, [
568
+ n("span", mt, L(g(a).nickname), 1),
569
+ n("span", ht, L(g(a).roles.join(", ")), 1)
570
+ ]),
571
+ I(g(se), {
572
+ type: "text",
573
+ size: "small",
574
+ onClick: H
575
+ }, {
576
+ default: $(() => [...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, a] of s)
587
+ t[r] = a;
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
+ }, It = { key: 0 }, At = { key: 1 }, Lt = { class: "header__avatar" }, $t = { class: "header__user-name" }, Et = {
602
+ key: 0,
603
+ class: "header__dropdown"
604
+ }, Rt = { 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 = /* @__PURE__ */ B({
605
+ __name: "Header",
606
+ setup(e) {
607
+ const s = ce(), t = j(), r = W(), a = D(), c = ne(), i = oe(), o = b(() => r.isCollapsed), u = m(!1), d = m(null), y = m(!1), x = b(() => 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
+ }, A = () => {
619
+ u.value = !u.value;
620
+ }, M = () => {
621
+ u.value = !1;
622
+ }, H = () => {
623
+ M(), alert("个人信息功能开发中...");
624
+ }, P = () => {
625
+ M(), alert("修改密码功能开发中...");
626
+ }, S = () => {
627
+ M(), c.logout(), a.clearUserInfo(), i.clearMenu(), t.push("/login");
628
+ }, T = (_) => {
629
+ d.value && !d.value.contains(_.target) && M();
630
+ };
631
+ return $e(() => {
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(), f("div", ft, [
638
+ n("div", gt, [
639
+ n("div", {
640
+ class: "header__collapse",
641
+ onClick: l
642
+ }, [
643
+ o.value ? (v(), f("span", yt, "☰")) : (v(), f("span", kt, "☰"))
644
+ ]),
645
+ n("div", bt, [
646
+ (v(!0), f(z, null, X(x.value, (N, J) => (v(), f("span", {
647
+ key: N.path
648
+ }, [
649
+ J > 0 ? (v(), f("span", wt, " / ")) : V("", !0),
650
+ n("span", {
651
+ class: _e({ "is-current": J === x.value.length - 1 })
652
+ }, L(N.title), 3)
653
+ ]))), 128))
654
+ ])
655
+ ]),
656
+ n("div", St, [
657
+ n("div", {
658
+ class: "header__action",
659
+ onClick: E,
660
+ title: y.value ? "Exit Fullscreen" : "Fullscreen"
661
+ }, [
662
+ y.value ? (v(), f("svg", Ct, [...h[0] || (h[0] = [
663
+ n("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }, null, -1)
664
+ ])])) : (v(), f("svg", Tt, [...h[1] || (h[1] = [
665
+ n("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }, null, -1)
666
+ ])]))
667
+ ], 8, xt),
668
+ n("div", {
669
+ class: "header__action",
670
+ onClick: C,
671
+ title: "切换主题"
672
+ }, [
673
+ g(r).isDark ? (v(), f("span", It, "🌙")) : (v(), f("span", At, "☀️"))
674
+ ]),
675
+ n("div", {
676
+ class: "header__user",
677
+ ref_key: "dropdownRef",
678
+ ref: d
679
+ }, [
680
+ n("div", {
681
+ class: "header__user-trigger",
682
+ onClick: ge(A, ["stop"])
683
+ }, [
684
+ n("div", Lt, [
685
+ n("span", null, L(((Y = g(a).nickname) == null ? void 0 : Y.charAt(0)) || "U"), 1)
686
+ ]),
687
+ n("span", $t, L(g(a).nickname), 1),
688
+ n("span", {
689
+ class: _e(["header__user-arrow", { "is-active": u.value }])
690
+ }, "▼", 2)
691
+ ]),
692
+ I(Re, { name: "dropdown" }, {
693
+ default: $(() => {
694
+ var N;
695
+ return [
696
+ u.value ? (v(), f("div", Et, [
697
+ n("div", Rt, [
698
+ n("div", Mt, [
699
+ n("span", null, L(((N = g(a).nickname) == null ? void 0 : N.charAt(0)) || "U"), 1)
700
+ ]),
701
+ n("div", Pt, [
702
+ n("div", Ut, L(g(a).nickname), 1),
703
+ n("div", Dt, L(g(a).roles.join(", ")), 1)
704
+ ])
705
+ ]),
706
+ h[6] || (h[6] = n("div", { class: "header__dropdown-divider" }, null, -1)),
707
+ n("div", { class: "header__dropdown-menu" }, [
708
+ n("div", {
709
+ class: "header__dropdown-item",
710
+ onClick: H
711
+ }, [...h[2] || (h[2] = [
712
+ n("span", { class: "header__dropdown-icon" }, "👤", -1),
713
+ n("span", null, "个人信息", -1)
714
+ ])]),
715
+ n("div", {
716
+ class: "header__dropdown-item",
717
+ onClick: P
718
+ }, [...h[3] || (h[3] = [
719
+ n("span", { class: "header__dropdown-icon" }, "🔐", -1),
720
+ n("span", null, "修改密码", -1)
721
+ ])]),
722
+ h[5] || (h[5] = n("div", { class: "header__dropdown-divider" }, null, -1)),
723
+ n("div", {
724
+ class: "header__dropdown-item header__dropdown-item--danger",
725
+ onClick: S
726
+ }, [...h[4] || (h[4] = [
727
+ n("span", { class: "header__dropdown-icon" }, "🚪", -1),
728
+ n("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" }, Bt = { class: "layout__main" }, zt = { class: "layout__content" }, Ft = /* @__PURE__ */ B({
742
+ __name: "index",
743
+ setup(e) {
744
+ const s = W(), t = b(
745
+ () => s.isCollapsed ? "64px" : "210px"
746
+ );
747
+ return (r, a) => {
748
+ const c = Me("router-view");
749
+ return v(), f("div", Vt, [
750
+ n("aside", {
751
+ class: "layout__aside",
752
+ style: Pe({ width: t.value })
753
+ }, [
754
+ I(_t)
755
+ ], 4),
756
+ n("div", Bt, [
757
+ I(Nt, { class: "layout__header" }),
758
+ n("main", zt, [
759
+ I(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"], Xt = /* @__PURE__ */ B({
769
+ __name: "Tabs",
770
+ setup(e) {
771
+ const s = ce(), t = j(), r = b(() => {
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
+ }), a = b(() => 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 === a.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(), f("div", Ht, [
792
+ I(g(Ne), {
793
+ modelValue: a.value,
794
+ "onUpdate:modelValue": u[0] || (u[0] = (d) => a.value = d),
795
+ type: "card",
796
+ onTabClick: c
797
+ }, {
798
+ default: $(() => [
799
+ (v(!0), f(z, null, X(r.value, (d) => (v(), ee(g(Ve), {
800
+ key: d.path,
801
+ name: d.path,
802
+ label: d.title,
803
+ closable: !d.affix
804
+ }, {
805
+ label: $(() => [
806
+ n("span", Kt, [
807
+ F(L(d.title) + " ", 1),
808
+ d.affix ? V("", !0) : (v(), f("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
+ }), Ls = /* @__PURE__ */ O(Xt, [["__scopeId", "data-v-9156d8cd"]]), Wt = {}, Yt = { class: "footer" };
823
+ function Jt(e, s) {
824
+ return v(), f("div", Yt, [...s[0] || (s[0] = [
825
+ n("span", null, "Copyright © 2024 Xto Demo. All Rights Reserved.", -1)
826
+ ])]);
827
+ }
828
+ const $s = /* @__PURE__ */ O(Wt, [["render", Jt], ["__scopeId", "data-v-4852826a"]]), Qt = { class: "login" }, Zt = { class: "login__container" }, Gt = /* @__PURE__ */ B({
829
+ __name: "index",
830
+ setup(e) {
831
+ const s = j(), t = ne(), r = D(), a = oe(), c = m(!1), i = m(!1), o = re({
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
+ }), a.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
+ ]), U.success("登录成功"), s.push("/"), c.value = !1;
910
+ }, 1e3);
911
+ } catch {
912
+ c.value = !1;
913
+ }
914
+ };
915
+ return (x, l) => (v(), f("div", Qt, [
916
+ n("div", Zt, [
917
+ l[5] || (l[5] = n("div", { class: "login__header" }, [
918
+ n("img", {
919
+ src: ke,
920
+ alt: "Logo",
921
+ class: "login__logo"
922
+ }),
923
+ n("h1", { class: "login__title" }, "Xto Demo"),
924
+ n("p", { class: "login__subtitle" }, "后台管理系统")
925
+ ], -1)),
926
+ I(g(Be), {
927
+ ref_key: "formRef",
928
+ ref: d,
929
+ model: o,
930
+ rules: u,
931
+ class: "login__form",
932
+ "label-width": "0"
933
+ }, {
934
+ default: $(() => [
935
+ I(g(Q), { prop: "username" }, {
936
+ default: $(() => [
937
+ I(g(ae), {
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
+ I(g(Q), { prop: "password" }, {
948
+ default: $(() => [
949
+ I(g(ae), {
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
+ I(g(Q), null, {
963
+ default: $(() => [
964
+ I(g(ze), {
965
+ modelValue: i.value,
966
+ "onUpdate:modelValue": l[2] || (l[2] = (C) => i.value = C)
967
+ }, {
968
+ default: $(() => [...l[3] || (l[3] = [
969
+ F("记住我", -1)
970
+ ])]),
971
+ _: 1
972
+ }, 8, ["modelValue"])
973
+ ]),
974
+ _: 1
975
+ }),
976
+ I(g(Q), null, {
977
+ default: $(() => [
978
+ I(g(se), {
979
+ type: "primary",
980
+ size: "large",
981
+ loading: c.value,
982
+ class: "login__submit",
983
+ onClick: y
984
+ }, {
985
+ default: $(() => [...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] = n("div", { class: "login__footer" }, [
997
+ n("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__ */ B({
1006
+ __name: "404",
1007
+ setup(e) {
1008
+ const s = j(), t = () => {
1009
+ s.push("/");
1010
+ };
1011
+ return (r, a) => (v(), f("div", ss, [
1012
+ n("div", os, [
1013
+ a[1] || (a[1] = n("div", { class: "error-page__code" }, "404", -1)),
1014
+ a[2] || (a[2] = n("div", { class: "error-page__title" }, "页面不存在", -1)),
1015
+ a[3] || (a[3] = n("div", { class: "error-page__desc" }, "抱歉,您访问的页面不存在或已被删除", -1)),
1016
+ I(g(se), {
1017
+ type: "primary",
1018
+ onClick: t
1019
+ }, {
1020
+ default: $(() => [...a[0] || (a[0] = [
1021
+ F("返回首页", -1)
1022
+ ])]),
1023
+ _: 1
1024
+ })
1025
+ ])
1026
+ ]));
1027
+ }
1028
+ }), as = /* @__PURE__ */ O(ns, [["__scopeId", "data-v-c3c12c24"]]), rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1029
+ __proto__: null,
1030
+ default: as
1031
+ }, Symbol.toStringTag, { value: "Module" })), ls = { class: "error-page" }, is = { class: "error-page__content" }, cs = /* @__PURE__ */ B({
1032
+ __name: "403",
1033
+ setup(e) {
1034
+ const s = j(), t = () => {
1035
+ s.push("/");
1036
+ };
1037
+ return (r, a) => (v(), f("div", ls, [
1038
+ n("div", is, [
1039
+ a[1] || (a[1] = n("div", { class: "error-page__code" }, "403", -1)),
1040
+ a[2] || (a[2] = n("div", { class: "error-page__title" }, "无访问权限", -1)),
1041
+ a[3] || (a[3] = n("div", { class: "error-page__desc" }, "抱歉,您没有权限访问此页面", -1)),
1042
+ I(g(se), {
1043
+ type: "primary",
1044
+ onClick: t
1045
+ }, {
1046
+ default: $(() => [...a[0] || (a[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 = D(), s = (c) => {
1060
+ const i = e.permissions;
1061
+ return i.includes("*") ? !0 : Array.isArray(c) ? c.some((o) => i.includes(o)) : i.includes(c);
1062
+ }, t = (c) => {
1063
+ const i = e.roles;
1064
+ return i.includes("admin") ? !0 : Array.isArray(c) ? c.some((o) => i.includes(o)) : i.includes(c);
1065
+ }, r = b(() => e.roles.includes("admin")), a = b(() => e.isLoggedIn);
1066
+ return {
1067
+ hasPermission: s,
1068
+ hasRole: t,
1069
+ isAdmin: r,
1070
+ isLoggedIn: a
1071
+ };
1072
+ }
1073
+ function Rs(e, s = {}) {
1074
+ const { rules: t, onSubmit: r } = s, a = m(), c = re({ ...e }), i = m(!1), o = m(!1), u = m(!1), d = () => {
1075
+ l(), u.value = !1, o.value = !0;
1076
+ }, y = (E) => {
1077
+ Object.assign(c, E), u.value = !0, o.value = !0;
1078
+ }, x = () => {
1079
+ o.value = !1, l();
1080
+ }, l = () => {
1081
+ var E;
1082
+ Object.keys(e).forEach((R) => {
1083
+ c[R] = e[R];
1084
+ }), (E = a.value) == null || E.resetFields();
1085
+ };
1086
+ return {
1087
+ formRef: a,
1088
+ formData: c,
1089
+ rules: t,
1090
+ loading: i,
1091
+ visible: o,
1092
+ isEdit: u,
1093
+ openAdd: d,
1094
+ openEdit: y,
1095
+ close: x,
1096
+ resetForm: l,
1097
+ handleSubmit: async () => {
1098
+ var E;
1099
+ try {
1100
+ await ((E = a.value) == null ? void 0 : E.validate()), i.value = !0, await (r == null ? void 0 : r(c)), x();
1101
+ } catch (R) {
1102
+ console.error(R);
1103
+ } finally {
1104
+ i.value = !1;
1105
+ }
1106
+ }
1107
+ };
1108
+ }
1109
+ function Ms(e) {
1110
+ const { fetchData: s, defaultPageSize: t = 10 } = e, r = m(!1), a = m([]), c = m(0), i = m(1), o = m(t), u = re({}), d = async () => {
1111
+ r.value = !0;
1112
+ try {
1113
+ const A = {
1114
+ ...u,
1115
+ page: i.value,
1116
+ pageSize: o.value
1117
+ }, M = await s(A);
1118
+ a.value = M.list, c.value = M.total;
1119
+ } catch (A) {
1120
+ console.error(A);
1121
+ } finally {
1122
+ r.value = !1;
1123
+ }
1124
+ }, y = () => {
1125
+ i.value = 1, d();
1126
+ }, x = () => {
1127
+ Object.keys(u).forEach((A) => {
1128
+ u[A] = void 0;
1129
+ }), i.value = 1, d();
1130
+ }, l = (A) => {
1131
+ i.value = A, d();
1132
+ }, C = (A) => {
1133
+ o.value = A, i.value = 1, d();
1134
+ }, E = () => {
1135
+ d();
1136
+ }, R = b(() => ({
1137
+ current: i.value,
1138
+ pageSize: o.value,
1139
+ total: c.value
1140
+ }));
1141
+ return {
1142
+ loading: r,
1143
+ data: a,
1144
+ total: c,
1145
+ currentPage: i,
1146
+ pageSize: o,
1147
+ searchParams: u,
1148
+ pagination: R,
1149
+ getData: d,
1150
+ handleSearch: y,
1151
+ handleReset: x,
1152
+ handlePageChange: l,
1153
+ handleSizeChange: C,
1154
+ refresh: E
1155
+ };
1156
+ }
1157
+ function Ps(e) {
1158
+ const t = D().permissions;
1159
+ return Array.isArray(e) ? e.some((r) => t.includes(r)) : t.includes(e);
1160
+ }
1161
+ function ps(e) {
1162
+ const t = D().roles;
1163
+ return Array.isArray(e) ? e.some((r) => t.includes(r)) : t.includes(e);
1164
+ }
1165
+ function Us() {
1166
+ return ps("admin");
1167
+ }
1168
+ const ms = () => {
1169
+ const e = Fe.create({
1170
+ baseURL: void 0,
1171
+ timeout: 3e4,
1172
+ headers: {
1173
+ "Content-Type": "application/json"
1174
+ }
1175
+ });
1176
+ return e.interceptors.request.use(
1177
+ (s) => {
1178
+ const t = me();
1179
+ return t && (s.headers.Authorization = `Bearer ${t}`), s;
1180
+ },
1181
+ (s) => Promise.reject(s)
1182
+ ), e.interceptors.response.use(
1183
+ (s) => {
1184
+ const { data: t } = s;
1185
+ return t.code === 200 || t.code === 0 ? t.data : (U.error(t.message || "请求失败"), Promise.reject(new Error(t.message || "请求失败")));
1186
+ },
1187
+ (s) => {
1188
+ var r;
1189
+ const { response: t } = s;
1190
+ if (t)
1191
+ switch (t.status) {
1192
+ case 401:
1193
+ U.error("登录已过期,请重新登录"), xe(), window.location.href = "/login";
1194
+ break;
1195
+ case 403:
1196
+ U.error("没有权限访问");
1197
+ break;
1198
+ case 404:
1199
+ U.error("请求资源不存在");
1200
+ break;
1201
+ case 500:
1202
+ U.error("服务器错误");
1203
+ break;
1204
+ default:
1205
+ U.error(((r = t.data) == null ? void 0 : r.message) || "请求失败");
1206
+ }
1207
+ else
1208
+ U.error("网络连接失败");
1209
+ return Promise.reject(s);
1210
+ }
1211
+ ), e;
1212
+ }, q = ms(), w = {
1213
+ get(e, s) {
1214
+ return q.get(e, s);
1215
+ },
1216
+ post(e, s, t) {
1217
+ return q.post(e, s, t);
1218
+ },
1219
+ put(e, s, t) {
1220
+ return q.put(e, s, t);
1221
+ },
1222
+ patch(e, s, t) {
1223
+ return q.patch(e, s, t);
1224
+ },
1225
+ delete(e, s) {
1226
+ return q.delete(e, s);
1227
+ }
1228
+ };
1229
+ function Ds(e, s = {}) {
1230
+ const t = s.indexPath || "/dashboard";
1231
+ return {
1232
+ path: "/",
1233
+ name: "Layout",
1234
+ component: Te,
1235
+ redirect: t,
1236
+ children: e
1237
+ };
1238
+ }
1239
+ function Os(e) {
1240
+ return le({
1241
+ history: ie(),
1242
+ routes: e,
1243
+ scrollBehavior: () => ({ left: 0, top: 0 })
1244
+ });
1245
+ }
1246
+ function Ns(e) {
1247
+ return w.post("/auth/login", e);
1248
+ }
1249
+ function Vs() {
1250
+ return w.post("/auth/logout");
1251
+ }
1252
+ function Bs() {
1253
+ return w.get("/user/info");
1254
+ }
1255
+ function zs(e) {
1256
+ return w.post("/auth/refresh", { refreshToken: e });
1257
+ }
1258
+ function Fs(e) {
1259
+ return w.get("/role/list", { params: e });
1260
+ }
1261
+ function js(e) {
1262
+ return w.get(`/role/${e}`);
1263
+ }
1264
+ function Hs(e) {
1265
+ return w.post("/role", e);
1266
+ }
1267
+ function Ks(e, s) {
1268
+ return w.put(`/role/${e}`, s);
1269
+ }
1270
+ function qs(e) {
1271
+ return w.delete(`/role/${e}`);
1272
+ }
1273
+ function Xs(e, s) {
1274
+ return w.patch(`/role/${e}/status`, { status: s });
1275
+ }
1276
+ function Ws() {
1277
+ return w.get("/menu/list");
1278
+ }
1279
+ function Ys() {
1280
+ return w.get("/menu/tree");
1281
+ }
1282
+ function Js(e) {
1283
+ return w.post("/menu", e);
1284
+ }
1285
+ function Qs(e, s) {
1286
+ return w.put(`/menu/${e}`, s);
1287
+ }
1288
+ function Zs(e) {
1289
+ return w.delete(`/menu/${e}`);
1290
+ }
1291
+ function Gs(e) {
1292
+ return w.get("/user/list", { params: e });
1293
+ }
1294
+ function eo(e) {
1295
+ return w.get(`/user/${e}`);
1296
+ }
1297
+ function to(e) {
1298
+ return w.post("/user", e);
1299
+ }
1300
+ function so(e, s) {
1301
+ return w.put(`/user/${e}`, s);
1302
+ }
1303
+ function oo(e) {
1304
+ return w.delete(`/user/${e}`);
1305
+ }
1306
+ function no(e) {
1307
+ return w.post("/user/batch-delete", { ids: e });
1308
+ }
1309
+ function ao(e, s) {
1310
+ return w.patch(`/user/${e}/status`, { status: s });
1311
+ }
1312
+ function ro(e) {
1313
+ return w.post(`/user/${e}/reset-password`);
1314
+ }
1315
+ 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 || {});
1316
+ const lo = {
1317
+ 1: "启用",
1318
+ 0: "禁用"
1319
+ }, io = {
1320
+ 0: "未知",
1321
+ 1: "男",
1322
+ 2: "女"
1323
+ }, co = {
1324
+ 0: "目录",
1325
+ 1: "菜单",
1326
+ 2: "按钮"
1327
+ }, uo = [
1328
+ {
1329
+ label: "启用",
1330
+ value: 1
1331
+ /* ENABLED */
1332
+ },
1333
+ {
1334
+ label: "禁用",
1335
+ value: 0
1336
+ /* DISABLED */
1337
+ }
1338
+ ], po = [
1339
+ {
1340
+ label: "未知",
1341
+ value: 0
1342
+ /* UNKNOWN */
1343
+ },
1344
+ {
1345
+ label: "男",
1346
+ value: 1
1347
+ /* MALE */
1348
+ },
1349
+ {
1350
+ label: "女",
1351
+ value: 2
1352
+ /* FEMALE */
1353
+ }
1354
+ ], mo = [
1355
+ {
1356
+ label: "目录",
1357
+ value: 0
1358
+ /* DIRECTORY */
1359
+ },
1360
+ {
1361
+ label: "菜单",
1362
+ value: 1
1363
+ /* MENU */
1364
+ },
1365
+ {
1366
+ label: "按钮",
1367
+ value: 2
1368
+ /* BUTTON */
1369
+ }
1370
+ ], ho = {
1371
+ mounted(e, s) {
1372
+ var i;
1373
+ const t = D(), { value: r } = s;
1374
+ if (!r) return;
1375
+ const a = t.permissions;
1376
+ let c = !1;
1377
+ Array.isArray(r) ? c = r.some((o) => a.includes(o) || a.includes("*")) : c = a.includes(r) || a.includes("*"), c || (i = e.parentNode) == null || i.removeChild(e);
1378
+ }
1379
+ };
1380
+ function vo(e = {}) {
1381
+ const s = W(), t = ne();
1382
+ e.appName && s.setAppName(e.appName), e.baseUrl && t.setBaseUrl(e.baseUrl), e.appId && t.setAppId(e.appId), e.clientId && t.setClientId(e.clientId), e.indexPath && s.setIndexPath(e.indexPath), e.loginPath && t.setLoginPath(e.loginPath);
1383
+ }
1384
+ export {
1385
+ ho as $,
1386
+ js as A,
1387
+ Fs as B,
1388
+ me as C,
1389
+ Xe as D,
1390
+ eo as E,
1391
+ $s as F,
1392
+ vs as G,
1393
+ Nt as H,
1394
+ Bs as I,
1395
+ Gs as J,
1396
+ Ps as K,
1397
+ Te as L,
1398
+ _s as M,
1399
+ ps as N,
1400
+ Ce as O,
1401
+ w as P,
1402
+ Us as Q,
1403
+ Je as R,
1404
+ hs as S,
1405
+ Ls as T,
1406
+ Se as U,
1407
+ p as V,
1408
+ Z as W,
1409
+ Ns as X,
1410
+ Vs as Y,
1411
+ He as Z,
1412
+ O as _,
1413
+ uo as a,
1414
+ zs as a0,
1415
+ ro as a1,
1416
+ As as a2,
1417
+ he as a3,
1418
+ Cs as a4,
1419
+ G as a5,
1420
+ qe as a6,
1421
+ Ke as a7,
1422
+ We as a8,
1423
+ Ye as a9,
1424
+ be as aa,
1425
+ Qs as ab,
1426
+ Ks as ac,
1427
+ Xs as ad,
1428
+ so as ae,
1429
+ ao as af,
1430
+ W as ag,
1431
+ Es as ah,
1432
+ ne as ai,
1433
+ Rs as aj,
1434
+ oe as ak,
1435
+ Ms as al,
1436
+ D as am,
1437
+ mo as b,
1438
+ us as c,
1439
+ po as d,
1440
+ io as e,
1441
+ co as f,
1442
+ as as g,
1443
+ _t as h,
1444
+ es as i,
1445
+ lo as j,
1446
+ no as k,
1447
+ xe as l,
1448
+ Ds as m,
1449
+ Js as n,
1450
+ Hs as o,
1451
+ Os as p,
1452
+ to as q,
1453
+ vo as r,
1454
+ Ts as s,
1455
+ Zs as t,
1456
+ qs as u,
1457
+ oo as v,
1458
+ we as w,
1459
+ Ws as x,
1460
+ Ys as y,
1461
+ Is as z
1462
+ };