xto-fronted 0.1.0

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 (49) hide show
  1. package/README.md +95 -0
  2. package/dist/403-MQkNUulz.js +31 -0
  3. package/dist/404-BOFYLq4X.js +31 -0
  4. package/dist/App.vue.d.ts +2 -0
  5. package/dist/api/auth.d.ts +8 -0
  6. package/dist/api/system.d.ts +16 -0
  7. package/dist/api/user.d.ts +13 -0
  8. package/dist/components/Layout/Footer.vue.d.ts +2 -0
  9. package/dist/components/Layout/Header.vue.d.ts +4 -0
  10. package/dist/components/Layout/Sidebar.vue.d.ts +2 -0
  11. package/dist/components/Layout/Tabs.vue.d.ts +2 -0
  12. package/dist/components/Layout/index.vue.d.ts +2 -0
  13. package/dist/composables/useAuth.d.ts +9 -0
  14. package/dist/composables/useForm.d.ts +20 -0
  15. package/dist/composables/useTable.d.ts +29 -0
  16. package/dist/directives/permission.d.ts +4 -0
  17. package/dist/enums/index.d.ts +32 -0
  18. package/dist/index-BJxYdNPy.js +475 -0
  19. package/dist/index-BvnIIBR1.js +142 -0
  20. package/dist/index-CEvAq6KE.js +372 -0
  21. package/dist/index-DPkqej__.js +345 -0
  22. package/dist/index-pq9Z5K62.js +184 -0
  23. package/dist/index-vVfjShJR.js +1183 -0
  24. package/dist/index.d.ts +24 -0
  25. package/dist/index.es.js +73 -0
  26. package/dist/index.umd.js +1 -0
  27. package/dist/main.d.ts +0 -0
  28. package/dist/router/dynamicRoutes.d.ts +34 -0
  29. package/dist/router/index.d.ts +6 -0
  30. package/dist/router/staticRoutes.d.ts +3 -0
  31. package/dist/stores/app.d.ts +75 -0
  32. package/dist/stores/auth.d.ts +31 -0
  33. package/dist/stores/index.d.ts +9 -0
  34. package/dist/stores/menu.d.ts +108 -0
  35. package/dist/stores/user.d.ts +113 -0
  36. package/dist/style.css +1 -0
  37. package/dist/utils/auth.d.ts +18 -0
  38. package/dist/utils/permission.d.ts +17 -0
  39. package/dist/utils/request.d.ts +25 -0
  40. package/dist/utils/storage.d.ts +24 -0
  41. package/dist/views/dashboard/index.vue.d.ts +2 -0
  42. package/dist/views/error/403.vue.d.ts +2 -0
  43. package/dist/views/error/404.vue.d.ts +2 -0
  44. package/dist/views/login/index.vue.d.ts +4 -0
  45. package/dist/views/system/menu/index.vue.d.ts +4 -0
  46. package/dist/views/system/role/index.vue.d.ts +4 -0
  47. package/dist/views/system/user/index.vue.d.ts +4 -0
  48. package/dist/vite.svg +10 -0
  49. package/package.json +71 -0
@@ -0,0 +1,1183 @@
1
+ import { ref as _, computed as g, watch as ke, defineComponent as Y, openBlock as v, createElementBlock as f, createElementVNode as a, withDirectives as be, vShow as we, createVNode as I, unref as x, Fragment as N, renderList as j, toDisplayString as w, createCommentVNode as U, withCtx as $, createBlock as W, createTextVNode as ie, onMounted as Se, onUnmounted as Ce, normalizeClass as re, withModifiers as ce, Transition as xe, resolveComponent as Te, normalizeStyle as Ee, reactive as ue } from "vue";
2
+ import { defineStore as X } from "pinia";
3
+ import { createRouter as de, createWebHistory as he, useRoute as Q, useRouter as Z } from "vue-router";
4
+ import { Menu as Le, SubMenu as Ae, MenuItem as le, Tabs as Re, TabPane as $e } from "@xto/navigation";
5
+ import { Button as Me } from "@xto/base";
6
+ import { Input as Ie } from "@xto/form";
7
+ import De from "axios";
8
+ import { Message as D } from "@xto/feedback";
9
+ const B = "xto_", me = (e) => ({
10
+ get(t) {
11
+ const s = e.getItem(B + t);
12
+ if (!s) return null;
13
+ try {
14
+ return JSON.parse(s);
15
+ } catch {
16
+ return s;
17
+ }
18
+ },
19
+ set(t, s) {
20
+ if (s == null) {
21
+ e.removeItem(B + t);
22
+ return;
23
+ }
24
+ const o = typeof s == "string" ? s : JSON.stringify(s);
25
+ e.setItem(B + t, o);
26
+ },
27
+ remove(t) {
28
+ e.removeItem(B + t);
29
+ },
30
+ clear() {
31
+ Object.keys(e).forEach((s) => {
32
+ s.startsWith(B) && e.removeItem(s);
33
+ });
34
+ }
35
+ }), K = me(window.localStorage), q = me(window.sessionStorage), h = {
36
+ get: K.get,
37
+ set: K.set,
38
+ remove: K.remove,
39
+ clear: K.clear
40
+ }, ns = {
41
+ get: q.get,
42
+ set: q.set,
43
+ remove: q.remove,
44
+ clear: q.clear
45
+ }, J = X("app", () => {
46
+ const e = _(h.get("isDark") || !1), t = _(h.get("theme") || "light"), s = _(h.get("layout") || "sidebar"), o = _(h.get("isCollapsed") || !1), l = _(h.get("showTabs") ?? !0), d = _(h.get("showFooter") ?? !0), c = _(h.get("showBreadcrumb") ?? !0), n = _(h.get("primaryColor") || "#409eff"), i = _([]), m = g(() => e.value ? "dark" : "light"), S = () => {
47
+ e.value = !e.value, t.value = e.value ? "dark" : "light", u();
48
+ }, E = (r) => {
49
+ t.value = r, e.value = r === "dark", u();
50
+ }, u = () => {
51
+ const r = document.documentElement;
52
+ e.value ? r.classList.add("dark") : r.classList.remove("dark"), h.set("isDark", e.value), h.set("theme", t.value);
53
+ }, L = () => {
54
+ o.value = !o.value, h.set("isCollapsed", o.value);
55
+ }, C = (r) => {
56
+ s.value = r, h.set("layout", r);
57
+ }, A = () => {
58
+ l.value = !l.value, h.set("showTabs", l.value);
59
+ }, T = () => {
60
+ d.value = !d.value, h.set("showFooter", d.value);
61
+ }, R = () => {
62
+ c.value = !c.value, h.set("showBreadcrumb", c.value);
63
+ }, P = (r) => {
64
+ n.value = r, document.documentElement.style.setProperty("--color-primary", r), h.set("primaryColor", r);
65
+ }, M = (r) => {
66
+ i.value.includes(r) || i.value.push(r);
67
+ }, k = (r) => {
68
+ const F = i.value.indexOf(r);
69
+ F > -1 && i.value.splice(F, 1);
70
+ }, b = () => {
71
+ i.value = [];
72
+ }, p = () => {
73
+ u(), n.value !== "#409eff" && document.documentElement.style.setProperty("--color-primary", n.value);
74
+ };
75
+ return ke(e, u), {
76
+ isDark: e,
77
+ theme: t,
78
+ layout: s,
79
+ isCollapsed: o,
80
+ showTabs: l,
81
+ showFooter: d,
82
+ showBreadcrumb: c,
83
+ primaryColor: n,
84
+ cachedViews: i,
85
+ themeClass: m,
86
+ toggleTheme: S,
87
+ toggleCollapse: L,
88
+ setTheme: E,
89
+ setLayout: C,
90
+ toggleTabs: A,
91
+ toggleFooter: T,
92
+ toggleBreadcrumb: R,
93
+ setPrimaryColor: P,
94
+ addCachedView: M,
95
+ removeCachedView: k,
96
+ clearCachedViews: b,
97
+ initTheme: p
98
+ };
99
+ }), Ue = "/vite.svg", Oe = (e, t, s) => {
100
+ const o = e[t];
101
+ return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((l, d) => {
102
+ (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
103
+ d.bind(
104
+ null,
105
+ new Error(
106
+ "Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : "")
107
+ )
108
+ )
109
+ );
110
+ });
111
+ }, pe = [
112
+ {
113
+ path: "/login",
114
+ name: "Login",
115
+ component: () => import("./index-pq9Z5K62.js"),
116
+ meta: {
117
+ title: "登录",
118
+ hidden: !0
119
+ }
120
+ },
121
+ {
122
+ path: "/404",
123
+ name: "NotFound",
124
+ component: () => import("./404-BOFYLq4X.js"),
125
+ meta: {
126
+ title: "404",
127
+ hidden: !0
128
+ }
129
+ },
130
+ {
131
+ path: "/403",
132
+ name: "Forbidden",
133
+ component: () => import("./403-MQkNUulz.js"),
134
+ meta: {
135
+ title: "403",
136
+ hidden: !0
137
+ }
138
+ }
139
+ ], ve = {
140
+ path: "/:pathMatch(.*)*",
141
+ redirect: "/404",
142
+ meta: {
143
+ hidden: !0
144
+ }
145
+ }, _e = {
146
+ path: "/",
147
+ name: "Layout",
148
+ component: () => Promise.resolve().then(() => Nt),
149
+ redirect: "/dashboard",
150
+ children: [
151
+ {
152
+ path: "/dashboard",
153
+ name: "Dashboard",
154
+ component: () => import("./index-BvnIIBR1.js"),
155
+ meta: {
156
+ title: "仪表盘",
157
+ icon: "dashboard",
158
+ keepAlive: !0,
159
+ affix: !0
160
+ }
161
+ },
162
+ {
163
+ path: "/system/user",
164
+ name: "SystemUser",
165
+ component: () => import("./index-CEvAq6KE.js"),
166
+ meta: {
167
+ title: "用户管理",
168
+ icon: "user",
169
+ keepAlive: !0
170
+ }
171
+ },
172
+ {
173
+ path: "/system/role",
174
+ name: "SystemRole",
175
+ component: () => import("./index-DPkqej__.js"),
176
+ meta: {
177
+ title: "角色管理",
178
+ icon: "role",
179
+ keepAlive: !0
180
+ }
181
+ },
182
+ {
183
+ path: "/system/menu",
184
+ name: "SystemMenu",
185
+ component: () => import("./index-BJxYdNPy.js"),
186
+ meta: {
187
+ title: "菜单管理",
188
+ icon: "menu",
189
+ keepAlive: !0
190
+ }
191
+ }
192
+ ]
193
+ }, as = [
194
+ {
195
+ path: "/dashboard",
196
+ name: "Dashboard",
197
+ component: () => import("./index-BvnIIBR1.js"),
198
+ meta: {
199
+ title: "仪表盘",
200
+ icon: "dashboard",
201
+ keepAlive: !0,
202
+ affix: !0
203
+ }
204
+ },
205
+ {
206
+ path: "/system",
207
+ name: "System",
208
+ redirect: "/system/user",
209
+ meta: {
210
+ title: "系统管理",
211
+ icon: "setting"
212
+ },
213
+ children: [
214
+ {
215
+ path: "user",
216
+ name: "SystemUser",
217
+ component: () => import("./index-CEvAq6KE.js"),
218
+ meta: {
219
+ title: "用户管理",
220
+ icon: "user",
221
+ keepAlive: !0
222
+ }
223
+ },
224
+ {
225
+ path: "role",
226
+ name: "SystemRole",
227
+ component: () => import("./index-DPkqej__.js"),
228
+ meta: {
229
+ title: "角色管理",
230
+ icon: "role",
231
+ keepAlive: !0
232
+ }
233
+ },
234
+ {
235
+ path: "menu",
236
+ name: "SystemMenu",
237
+ component: () => import("./index-BJxYdNPy.js"),
238
+ meta: {
239
+ title: "菜单管理",
240
+ icon: "menu",
241
+ keepAlive: !0
242
+ }
243
+ }
244
+ ]
245
+ }
246
+ ], Ne = [
247
+ {
248
+ id: 1,
249
+ name: "Dashboard",
250
+ path: "/dashboard",
251
+ component: "dashboard/index",
252
+ icon: "dashboard",
253
+ title: "仪表盘",
254
+ keepAlive: !0,
255
+ affix: !0
256
+ },
257
+ {
258
+ id: 2,
259
+ name: "System",
260
+ path: "/system",
261
+ redirect: "/system/user",
262
+ icon: "setting",
263
+ title: "系统管理",
264
+ children: [
265
+ {
266
+ id: 21,
267
+ name: "SystemUser",
268
+ path: "/system/user",
269
+ component: "system/user/index",
270
+ icon: "user",
271
+ title: "用户管理",
272
+ keepAlive: !0
273
+ },
274
+ {
275
+ id: 22,
276
+ name: "SystemRole",
277
+ path: "/system/role",
278
+ component: "system/role/index",
279
+ icon: "role",
280
+ title: "角色管理",
281
+ keepAlive: !0
282
+ },
283
+ {
284
+ id: 23,
285
+ name: "SystemMenu",
286
+ path: "/system/menu",
287
+ component: "system/menu/index",
288
+ icon: "menu",
289
+ title: "菜单管理",
290
+ keepAlive: !0
291
+ }
292
+ ]
293
+ }
294
+ ], G = "token", ee = "refresh_token", te = "token_expire", se = () => h.get(G), Pe = (e) => {
295
+ h.set(G, e);
296
+ }, rs = () => h.get(ee), Fe = (e) => {
297
+ h.set(ee, e);
298
+ }, Ve = () => h.get(te), Be = (e) => {
299
+ h.set(te, e);
300
+ }, ze = (e) => {
301
+ Pe(e.token), Fe(e.refreshToken), Be(e.expireTime);
302
+ }, fe = () => {
303
+ h.remove(G), h.remove(ee), h.remove(te);
304
+ }, je = () => {
305
+ const e = Ve();
306
+ return e ? Date.now() > e : !0;
307
+ }, ge = () => !!se() && !je(), O = X("user", () => {
308
+ const e = _(h.get("userInfo")), t = _(h.get("roles") || []), s = _(h.get("permissions") || []), o = g(() => !!e.value), l = g(() => {
309
+ var u;
310
+ return ((u = e.value) == null ? void 0 : u.username) || "";
311
+ }), d = g(() => {
312
+ var u;
313
+ return ((u = e.value) == null ? void 0 : u.nickname) || "";
314
+ }), c = g(() => {
315
+ var u;
316
+ return ((u = e.value) == null ? void 0 : u.avatar) || "";
317
+ }), n = g(() => {
318
+ var u;
319
+ return (u = e.value) == null ? void 0 : u.id;
320
+ });
321
+ return {
322
+ userInfo: e,
323
+ roles: t,
324
+ permissions: s,
325
+ isLoggedIn: o,
326
+ username: l,
327
+ nickname: d,
328
+ avatar: c,
329
+ userId: n,
330
+ setUserInfo: (u) => {
331
+ e.value = u, t.value = u.roles || [], s.value = u.permissions || [], h.set("userInfo", u), h.set("roles", u.roles || []), h.set("permissions", u.permissions || []);
332
+ },
333
+ clearUserInfo: () => {
334
+ e.value = null, t.value = [], s.value = [], h.remove("userInfo"), h.remove("roles"), h.remove("permissions");
335
+ },
336
+ hasPermission: (u) => Array.isArray(u) ? u.some((L) => s.value.includes(L)) : s.value.includes(u),
337
+ hasRole: (u) => Array.isArray(u) ? u.some((L) => t.value.includes(L)) : t.value.includes(u)
338
+ };
339
+ }), oe = de({
340
+ history: he(),
341
+ routes: [...pe, _e, ve],
342
+ scrollBehavior: () => ({ left: 0, top: 0 })
343
+ }), He = ["/login", "/404", "/403"];
344
+ oe.beforeEach(async (e, t, s) => {
345
+ const o = J();
346
+ if (o.initTheme(), ge())
347
+ if (e.path === "/login")
348
+ s({ path: "/" });
349
+ else {
350
+ const l = O();
351
+ l.isLoggedIn || (l.setUserInfo({
352
+ id: 1,
353
+ username: "admin",
354
+ nickname: "管理员",
355
+ avatar: "",
356
+ email: "admin@example.com",
357
+ phone: "13800138000",
358
+ status: 1,
359
+ roles: ["admin"],
360
+ permissions: ["*"],
361
+ createTime: (/* @__PURE__ */ new Date()).toISOString()
362
+ }), ne().setMenuList(Ne)), e.name && e.meta.keepAlive && o.addCachedView(e.name), s();
363
+ }
364
+ else
365
+ He.includes(e.path) ? s() : s("/login");
366
+ });
367
+ function ls() {
368
+ const e = de({
369
+ history: he(),
370
+ routes: [...pe, _e, ve]
371
+ });
372
+ oe.matcher = e.matcher;
373
+ }
374
+ const ne = X("menu", () => {
375
+ const e = _(h.get("menuList") || []), t = g(() => e.value.length > 0), s = (c) => {
376
+ e.value = c, h.set("menuList", c);
377
+ }, o = () => {
378
+ e.value = [], h.remove("menuList");
379
+ }, l = (c) => c.filter((n) => !n.hidden).map((n) => {
380
+ const i = {
381
+ path: n.path,
382
+ name: n.name,
383
+ meta: {
384
+ title: n.title,
385
+ icon: n.icon,
386
+ keepAlive: n.keepAlive,
387
+ hidden: n.hidden
388
+ }
389
+ };
390
+ return n.redirect && (i.redirect = n.redirect), n.component && (i.component = () => Oe(/* @__PURE__ */ Object.assign({}), `../views/${n.component}.vue`, 3)), n.children && n.children.length > 0 && (i.children = l(n.children)), i;
391
+ });
392
+ return {
393
+ menuList: e,
394
+ hasMenu: t,
395
+ setMenuList: s,
396
+ clearMenu: o,
397
+ generateRoutes: l,
398
+ addRoutes: (c) => {
399
+ l(c).forEach((i) => {
400
+ oe.addRoute("Layout", i);
401
+ });
402
+ }
403
+ };
404
+ }), ye = X("auth", () => {
405
+ const e = _(se()), t = g(() => ge());
406
+ return {
407
+ token: e,
408
+ isLoggedIn: t,
409
+ login: (l) => {
410
+ e.value = l.token, ze(l);
411
+ },
412
+ logout: () => {
413
+ e.value = null, fe();
414
+ }
415
+ };
416
+ }), Ke = { class: "sidebar" }, qe = { class: "sidebar__logo" }, We = { class: "sidebar__logo-text" }, Ye = {
417
+ key: 0,
418
+ class: "sidebar__search"
419
+ }, Xe = {
420
+ key: 0,
421
+ class: "sidebar__search-results"
422
+ }, Je = ["onClick"], Qe = { class: "menu-icon" }, Ze = { class: "sidebar__search-item-info" }, Ge = { class: "sidebar__search-item-title" }, et = {
423
+ key: 0,
424
+ class: "sidebar__search-item-parent"
425
+ }, tt = { class: "menu-icon" }, st = { class: "menu-icon" }, ot = { class: "menu-icon" }, nt = {
426
+ key: 1,
427
+ class: "sidebar__user"
428
+ }, at = { class: "sidebar__user-info" }, rt = { class: "sidebar__user-name" }, lt = { class: "sidebar__user-role" }, it = /* @__PURE__ */ Y({
429
+ __name: "Sidebar",
430
+ setup(e) {
431
+ const t = Q(), s = Z(), o = ne(), l = O(), d = ye(), c = J(), n = _(""), i = g(() => c.isCollapsed), m = g(() => t.path), S = g(() => c.isDark ? "#1d1e1f" : "#fff"), E = g(() => c.isDark ? "#cfd3dc" : "#303133"), u = g(() => "#409eff"), L = (k, b = "") => {
432
+ const p = [];
433
+ return k.forEach((r) => {
434
+ r.children && r.children.length > 0 ? p.push(...L(r.children, r.title)) : p.push({ ...r, parentTitle: b });
435
+ }), p;
436
+ }, C = g(() => n.value.trim() ? L(o.menuList).filter(
437
+ (b) => b.title.toLowerCase().includes(n.value.toLowerCase())
438
+ ) : []), A = g(() => n.value.trim() ? o.menuList.map((k) => {
439
+ if (k.children && k.children.length > 0) {
440
+ const b = k.children.filter(
441
+ (p) => p.title.toLowerCase().includes(n.value.toLowerCase())
442
+ );
443
+ return b.length > 0 ? { ...k, children: b } : null;
444
+ }
445
+ return k.title.toLowerCase().includes(n.value.toLowerCase()) ? k : null;
446
+ }).filter(Boolean) : o.menuList), T = (k) => {
447
+ k && k !== t.path && (s.push(k), n.value = "");
448
+ }, R = (k) => {
449
+ s.push(k), n.value = "";
450
+ }, P = () => {
451
+ d.logout(), l.clearUserInfo(), o.clearMenu(), s.push("/login");
452
+ }, M = (k) => ({
453
+ dashboard: "📊",
454
+ system: "⚙️",
455
+ user: "👤",
456
+ role: "👥",
457
+ menu: "📋",
458
+ setting: "🔧"
459
+ })[k || ""] || "📄";
460
+ return (k, b) => (v(), f("div", Ke, [
461
+ a("div", qe, [
462
+ b[1] || (b[1] = a("img", {
463
+ src: Ue,
464
+ alt: "Logo",
465
+ class: "sidebar__logo-img"
466
+ }, null, -1)),
467
+ be(a("span", We, "Xto Demo", 512), [
468
+ [we, !i.value]
469
+ ])
470
+ ]),
471
+ i.value ? U("", !0) : (v(), f("div", Ye, [
472
+ I(x(Ie), {
473
+ modelValue: n.value,
474
+ "onUpdate:modelValue": b[0] || (b[0] = (p) => n.value = p),
475
+ placeholder: "搜索菜单...",
476
+ size: "small",
477
+ clearable: ""
478
+ }, null, 8, ["modelValue"]),
479
+ C.value.length > 0 ? (v(), f("div", Xe, [
480
+ (v(!0), f(N, null, j(C.value, (p) => (v(), f("div", {
481
+ key: p.path,
482
+ class: "sidebar__search-item",
483
+ onClick: (r) => R(p.path)
484
+ }, [
485
+ a("span", Qe, w(M(p.icon)), 1),
486
+ a("div", Ze, [
487
+ a("span", Ge, w(p.title), 1),
488
+ p.parentTitle ? (v(), f("span", et, w(p.parentTitle), 1)) : U("", !0)
489
+ ])
490
+ ], 8, Je))), 128))
491
+ ])) : U("", !0)
492
+ ])),
493
+ I(x(Le), {
494
+ "default-active": m.value,
495
+ collapse: i.value,
496
+ "collapse-transition": !1,
497
+ "background-color": S.value,
498
+ "text-color": E.value,
499
+ "active-text-color": u.value,
500
+ class: "sidebar__menu",
501
+ onSelect: T
502
+ }, {
503
+ default: $(() => [
504
+ (v(!0), f(N, null, j(A.value, (p) => (v(), f(N, {
505
+ key: p.path
506
+ }, [
507
+ p.children && p.children.length > 0 ? (v(), W(x(Ae), {
508
+ key: 0,
509
+ index: p.path
510
+ }, {
511
+ title: $(() => [
512
+ a("span", tt, w(M(p.icon)), 1),
513
+ a("span", null, w(p.title), 1)
514
+ ]),
515
+ default: $(() => [
516
+ (v(!0), f(N, null, j(p.children, (r) => (v(), W(x(le), {
517
+ key: r.path,
518
+ index: r.path
519
+ }, {
520
+ default: $(() => [
521
+ a("span", st, w(M(r.icon)), 1),
522
+ a("span", null, w(r.title), 1)
523
+ ]),
524
+ _: 2
525
+ }, 1032, ["index"]))), 128))
526
+ ]),
527
+ _: 2
528
+ }, 1032, ["index"])) : (v(), W(x(le), {
529
+ key: 1,
530
+ index: p.path
531
+ }, {
532
+ default: $(() => [
533
+ a("span", ot, w(M(p.icon)), 1),
534
+ a("span", null, w(p.title), 1)
535
+ ]),
536
+ _: 2
537
+ }, 1032, ["index"]))
538
+ ], 64))), 128))
539
+ ]),
540
+ _: 1
541
+ }, 8, ["default-active", "collapse", "background-color", "text-color", "active-text-color"]),
542
+ i.value ? U("", !0) : (v(), f("div", nt, [
543
+ a("div", at, [
544
+ a("span", rt, w(x(l).nickname), 1),
545
+ a("span", lt, w(x(l).roles.join(", ")), 1)
546
+ ]),
547
+ I(x(Me), {
548
+ type: "text",
549
+ size: "small",
550
+ onClick: P
551
+ }, {
552
+ default: $(() => [...b[2] || (b[2] = [
553
+ ie("退出", -1)
554
+ ])]),
555
+ _: 1
556
+ })
557
+ ]))
558
+ ]));
559
+ }
560
+ }), H = (e, t) => {
561
+ const s = e.__vccOpts || e;
562
+ for (const [o, l] of t)
563
+ s[o] = l;
564
+ return s;
565
+ }, ct = /* @__PURE__ */ H(it, [["__scopeId", "data-v-69e6558d"]]), ut = { class: "header" }, dt = { class: "header__left" }, ht = { key: 0 }, mt = { key: 1 }, pt = { class: "header__breadcrumb" }, vt = { key: 0 }, _t = { class: "header__right" }, ft = ["title"], gt = {
566
+ key: 0,
567
+ viewBox: "0 0 24 24",
568
+ width: "16",
569
+ height: "16",
570
+ fill: "currentColor"
571
+ }, yt = {
572
+ key: 1,
573
+ viewBox: "0 0 24 24",
574
+ width: "16",
575
+ height: "16",
576
+ fill: "currentColor"
577
+ }, kt = { key: 0 }, bt = { key: 1 }, wt = { class: "header__avatar" }, St = { class: "header__user-name" }, Ct = {
578
+ key: 0,
579
+ class: "header__dropdown"
580
+ }, xt = { class: "header__dropdown-header" }, Tt = { class: "header__dropdown-avatar" }, Et = { class: "header__dropdown-info" }, Lt = { class: "header__dropdown-name" }, At = { class: "header__dropdown-role" }, Rt = /* @__PURE__ */ Y({
581
+ __name: "Header",
582
+ setup(e) {
583
+ const t = Q(), s = Z(), o = J(), l = O(), d = ye(), c = ne(), n = g(() => o.isCollapsed), i = _(!1), m = _(null), S = _(!1), E = g(() => t.matched.filter((r) => r.meta && r.meta.title).map((r) => ({
584
+ title: r.meta.title,
585
+ path: r.path
586
+ }))), u = () => {
587
+ o.toggleCollapse();
588
+ }, L = () => {
589
+ o.toggleTheme();
590
+ }, C = () => {
591
+ document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen();
592
+ }, A = () => {
593
+ S.value = !!document.fullscreenElement;
594
+ }, T = () => {
595
+ i.value = !i.value;
596
+ }, R = () => {
597
+ i.value = !1;
598
+ }, P = () => {
599
+ R(), alert("个人信息功能开发中...");
600
+ }, M = () => {
601
+ R(), alert("修改密码功能开发中...");
602
+ }, k = () => {
603
+ R(), d.logout(), l.clearUserInfo(), c.clearMenu(), s.push("/login");
604
+ }, b = (p) => {
605
+ m.value && !m.value.contains(p.target) && R();
606
+ };
607
+ return Se(() => {
608
+ document.addEventListener("click", b), document.addEventListener("fullscreenchange", A);
609
+ }), Ce(() => {
610
+ document.removeEventListener("click", b), document.removeEventListener("fullscreenchange", A);
611
+ }), (p, r) => {
612
+ var F;
613
+ return v(), f("div", ut, [
614
+ a("div", dt, [
615
+ a("div", {
616
+ class: "header__collapse",
617
+ onClick: u
618
+ }, [
619
+ n.value ? (v(), f("span", ht, "☰")) : (v(), f("span", mt, "☰"))
620
+ ]),
621
+ a("div", pt, [
622
+ (v(!0), f(N, null, j(E.value, (V, ae) => (v(), f("span", {
623
+ key: V.path
624
+ }, [
625
+ ae > 0 ? (v(), f("span", vt, " / ")) : U("", !0),
626
+ a("span", {
627
+ class: re({ "is-current": ae === E.value.length - 1 })
628
+ }, w(V.title), 3)
629
+ ]))), 128))
630
+ ])
631
+ ]),
632
+ a("div", _t, [
633
+ a("div", {
634
+ class: "header__action",
635
+ onClick: C,
636
+ title: S.value ? "Exit Fullscreen" : "Fullscreen"
637
+ }, [
638
+ S.value ? (v(), f("svg", gt, [...r[0] || (r[0] = [
639
+ a("path", { d: "M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" }, null, -1)
640
+ ])])) : (v(), f("svg", yt, [...r[1] || (r[1] = [
641
+ a("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }, null, -1)
642
+ ])]))
643
+ ], 8, ft),
644
+ a("div", {
645
+ class: "header__action",
646
+ onClick: L,
647
+ title: "切换主题"
648
+ }, [
649
+ x(o).isDark ? (v(), f("span", kt, "🌙")) : (v(), f("span", bt, "☀️"))
650
+ ]),
651
+ a("div", {
652
+ class: "header__user",
653
+ ref_key: "dropdownRef",
654
+ ref: m
655
+ }, [
656
+ a("div", {
657
+ class: "header__user-trigger",
658
+ onClick: ce(T, ["stop"])
659
+ }, [
660
+ a("div", wt, [
661
+ a("span", null, w(((F = x(l).nickname) == null ? void 0 : F.charAt(0)) || "U"), 1)
662
+ ]),
663
+ a("span", St, w(x(l).nickname), 1),
664
+ a("span", {
665
+ class: re(["header__user-arrow", { "is-active": i.value }])
666
+ }, "▼", 2)
667
+ ]),
668
+ I(xe, { name: "dropdown" }, {
669
+ default: $(() => {
670
+ var V;
671
+ return [
672
+ i.value ? (v(), f("div", Ct, [
673
+ a("div", xt, [
674
+ a("div", Tt, [
675
+ a("span", null, w(((V = x(l).nickname) == null ? void 0 : V.charAt(0)) || "U"), 1)
676
+ ]),
677
+ a("div", Et, [
678
+ a("div", Lt, w(x(l).nickname), 1),
679
+ a("div", At, w(x(l).roles.join(", ")), 1)
680
+ ])
681
+ ]),
682
+ r[6] || (r[6] = a("div", { class: "header__dropdown-divider" }, null, -1)),
683
+ a("div", { class: "header__dropdown-menu" }, [
684
+ a("div", {
685
+ class: "header__dropdown-item",
686
+ onClick: P
687
+ }, [...r[2] || (r[2] = [
688
+ a("span", { class: "header__dropdown-icon" }, "👤", -1),
689
+ a("span", null, "个人信息", -1)
690
+ ])]),
691
+ a("div", {
692
+ class: "header__dropdown-item",
693
+ onClick: M
694
+ }, [...r[3] || (r[3] = [
695
+ a("span", { class: "header__dropdown-icon" }, "🔐", -1),
696
+ a("span", null, "修改密码", -1)
697
+ ])]),
698
+ r[5] || (r[5] = a("div", { class: "header__dropdown-divider" }, null, -1)),
699
+ a("div", {
700
+ class: "header__dropdown-item header__dropdown-item--danger",
701
+ onClick: k
702
+ }, [...r[4] || (r[4] = [
703
+ a("span", { class: "header__dropdown-icon" }, "🚪", -1),
704
+ a("span", null, "退出登录", -1)
705
+ ])])
706
+ ])
707
+ ])) : U("", !0)
708
+ ];
709
+ }),
710
+ _: 1
711
+ })
712
+ ], 512)
713
+ ])
714
+ ]);
715
+ };
716
+ }
717
+ }), $t = /* @__PURE__ */ H(Rt, [["__scopeId", "data-v-a8667482"]]), Mt = { class: "layout" }, It = { class: "layout__main" }, Dt = { class: "layout__content" }, Ut = /* @__PURE__ */ Y({
718
+ __name: "index",
719
+ setup(e) {
720
+ const t = J(), s = g(
721
+ () => t.isCollapsed ? "64px" : "210px"
722
+ );
723
+ return (o, l) => {
724
+ const d = Te("router-view");
725
+ return v(), f("div", Mt, [
726
+ a("aside", {
727
+ class: "layout__aside",
728
+ style: Ee({ width: s.value })
729
+ }, [
730
+ I(ct)
731
+ ], 4),
732
+ a("div", It, [
733
+ I($t, { class: "layout__header" }),
734
+ a("main", Dt, [
735
+ I(d)
736
+ ])
737
+ ])
738
+ ]);
739
+ };
740
+ }
741
+ }), Ot = /* @__PURE__ */ H(Ut, [["__scopeId", "data-v-1a24e6d0"]]), Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
742
+ __proto__: null,
743
+ default: Ot
744
+ }, Symbol.toStringTag, { value: "Module" })), Pt = { class: "tabs-wrapper" }, Ft = { class: "tab-label" }, Vt = ["onClick"], Bt = /* @__PURE__ */ Y({
745
+ __name: "Tabs",
746
+ setup(e) {
747
+ const t = Q(), s = Z(), o = g(() => {
748
+ const n = [];
749
+ return t.matched.forEach((i) => {
750
+ var m;
751
+ (m = i.meta) != null && m.affix && n.push({
752
+ name: i.name,
753
+ title: i.meta.title,
754
+ path: i.path,
755
+ affix: !0
756
+ });
757
+ }), n;
758
+ }), l = g(() => t.path), d = (n) => {
759
+ s.push(n);
760
+ }, c = (n) => {
761
+ const i = o.value.find((m) => m.path === n);
762
+ if (!(i != null && i.affix) && n === l.value) {
763
+ const m = o.value.findIndex((E) => E.path === n), S = o.value[m - 1] || o.value[m + 1];
764
+ S && s.push(S.path);
765
+ }
766
+ };
767
+ return (n, i) => (v(), f("div", Pt, [
768
+ I(x(Re), {
769
+ modelValue: l.value,
770
+ "onUpdate:modelValue": i[0] || (i[0] = (m) => l.value = m),
771
+ type: "card",
772
+ onTabClick: d
773
+ }, {
774
+ default: $(() => [
775
+ (v(!0), f(N, null, j(o.value, (m) => (v(), W(x($e), {
776
+ key: m.path,
777
+ name: m.path,
778
+ label: m.title,
779
+ closable: !m.affix
780
+ }, {
781
+ label: $(() => [
782
+ a("span", Ft, [
783
+ ie(w(m.title) + " ", 1),
784
+ m.affix ? U("", !0) : (v(), f("span", {
785
+ key: 0,
786
+ class: "tab-close",
787
+ onClick: ce((S) => c(m.path), ["stop"])
788
+ }, " ✕ ", 8, Vt))
789
+ ])
790
+ ]),
791
+ _: 2
792
+ }, 1032, ["name", "label", "closable"]))), 128))
793
+ ]),
794
+ _: 1
795
+ }, 8, ["modelValue"])
796
+ ]));
797
+ }
798
+ }), is = /* @__PURE__ */ H(Bt, [["__scopeId", "data-v-bd3be691"]]), zt = {}, jt = { class: "footer" };
799
+ function Ht(e, t) {
800
+ return v(), f("div", jt, [...t[0] || (t[0] = [
801
+ a("span", null, "Copyright © 2024 Xto Demo. All Rights Reserved.", -1)
802
+ ])]);
803
+ }
804
+ const cs = /* @__PURE__ */ H(zt, [["render", Ht], ["__scopeId", "data-v-317ae311"]]);
805
+ function us() {
806
+ const e = O(), t = (d) => {
807
+ const c = e.permissions;
808
+ return c.includes("*") ? !0 : Array.isArray(d) ? d.some((n) => c.includes(n)) : c.includes(d);
809
+ }, s = (d) => {
810
+ const c = e.roles;
811
+ return c.includes("admin") ? !0 : Array.isArray(d) ? d.some((n) => c.includes(n)) : c.includes(d);
812
+ }, o = g(() => e.roles.includes("admin")), l = g(() => e.isLoggedIn);
813
+ return {
814
+ hasPermission: t,
815
+ hasRole: s,
816
+ isAdmin: o,
817
+ isLoggedIn: l
818
+ };
819
+ }
820
+ function ds(e, t = {}) {
821
+ const { rules: s, onSubmit: o } = t, l = _(), d = ue({ ...e }), c = _(!1), n = _(!1), i = _(!1), m = () => {
822
+ u(), i.value = !1, n.value = !0;
823
+ }, S = (C) => {
824
+ Object.assign(d, C), i.value = !0, n.value = !0;
825
+ }, E = () => {
826
+ n.value = !1, u();
827
+ }, u = () => {
828
+ var C;
829
+ Object.keys(e).forEach((A) => {
830
+ d[A] = e[A];
831
+ }), (C = l.value) == null || C.resetFields();
832
+ };
833
+ return {
834
+ formRef: l,
835
+ formData: d,
836
+ rules: s,
837
+ loading: c,
838
+ visible: n,
839
+ isEdit: i,
840
+ openAdd: m,
841
+ openEdit: S,
842
+ close: E,
843
+ resetForm: u,
844
+ handleSubmit: async () => {
845
+ var C;
846
+ try {
847
+ await ((C = l.value) == null ? void 0 : C.validate()), c.value = !0, await (o == null ? void 0 : o(d)), E();
848
+ } catch (A) {
849
+ console.error(A);
850
+ } finally {
851
+ c.value = !1;
852
+ }
853
+ }
854
+ };
855
+ }
856
+ function hs(e) {
857
+ const { fetchData: t, defaultPageSize: s = 10 } = e, o = _(!1), l = _([]), d = _(0), c = _(1), n = _(s), i = ue({}), m = async () => {
858
+ o.value = !0;
859
+ try {
860
+ const T = {
861
+ ...i,
862
+ page: c.value,
863
+ pageSize: n.value
864
+ }, R = await t(T);
865
+ l.value = R.list, d.value = R.total;
866
+ } catch (T) {
867
+ console.error(T);
868
+ } finally {
869
+ o.value = !1;
870
+ }
871
+ }, S = () => {
872
+ c.value = 1, m();
873
+ }, E = () => {
874
+ Object.keys(i).forEach((T) => {
875
+ i[T] = void 0;
876
+ }), c.value = 1, m();
877
+ }, u = (T) => {
878
+ c.value = T, m();
879
+ }, L = (T) => {
880
+ n.value = T, c.value = 1, m();
881
+ }, C = () => {
882
+ m();
883
+ }, A = g(() => ({
884
+ current: c.value,
885
+ pageSize: n.value,
886
+ total: d.value
887
+ }));
888
+ return {
889
+ loading: o,
890
+ data: l,
891
+ total: d,
892
+ currentPage: c,
893
+ pageSize: n,
894
+ searchParams: i,
895
+ pagination: A,
896
+ getData: m,
897
+ handleSearch: S,
898
+ handleReset: E,
899
+ handlePageChange: u,
900
+ handleSizeChange: L,
901
+ refresh: C
902
+ };
903
+ }
904
+ function ms(e) {
905
+ const s = O().permissions;
906
+ return Array.isArray(e) ? e.some((o) => s.includes(o)) : s.includes(e);
907
+ }
908
+ function Kt(e) {
909
+ const s = O().roles;
910
+ return Array.isArray(e) ? e.some((o) => s.includes(o)) : s.includes(e);
911
+ }
912
+ function ps() {
913
+ return Kt("admin");
914
+ }
915
+ const qt = () => {
916
+ const e = De.create({
917
+ baseURL: void 0,
918
+ timeout: 15e3,
919
+ headers: {
920
+ "Content-Type": "application/json"
921
+ }
922
+ });
923
+ return e.interceptors.request.use(
924
+ (t) => {
925
+ const s = se();
926
+ return s && (t.headers.Authorization = `Bearer ${s}`), t;
927
+ },
928
+ (t) => Promise.reject(t)
929
+ ), e.interceptors.response.use(
930
+ (t) => {
931
+ const { data: s } = t;
932
+ return s.code === 200 || s.code === 0 ? t : (D.error(s.message || "请求失败"), Promise.reject(new Error(s.message || "请求失败")));
933
+ },
934
+ (t) => {
935
+ var o;
936
+ const { response: s } = t;
937
+ if (s)
938
+ switch (s.status) {
939
+ case 401:
940
+ D.error("登录已过期,请重新登录"), fe(), window.location.href = "/login";
941
+ break;
942
+ case 403:
943
+ D.error("没有权限访问");
944
+ break;
945
+ case 404:
946
+ D.error("请求资源不存在");
947
+ break;
948
+ case 500:
949
+ D.error("服务器错误");
950
+ break;
951
+ default:
952
+ D.error(((o = s.data) == null ? void 0 : o.message) || "请求失败");
953
+ }
954
+ else
955
+ D.error("网络连接失败");
956
+ return Promise.reject(t);
957
+ }
958
+ ), e;
959
+ }, z = qt(), y = {
960
+ get(e, t) {
961
+ return z.get(e, t).then((s) => s.data);
962
+ },
963
+ post(e, t, s) {
964
+ return z.post(e, t, s).then((o) => o.data);
965
+ },
966
+ put(e, t, s) {
967
+ return z.put(e, t, s).then((o) => o.data);
968
+ },
969
+ patch(e, t, s) {
970
+ return z.patch(e, t, s).then((o) => o.data);
971
+ },
972
+ delete(e, t) {
973
+ return z.delete(e, t).then((s) => s.data);
974
+ }
975
+ };
976
+ function vs(e) {
977
+ return y.post("/auth/login", e);
978
+ }
979
+ function _s() {
980
+ return y.post("/auth/logout");
981
+ }
982
+ function fs() {
983
+ return y.get("/user/info");
984
+ }
985
+ function gs(e) {
986
+ return y.post("/auth/refresh", { refreshToken: e });
987
+ }
988
+ function ys(e) {
989
+ return y.get("/role/list", { params: e });
990
+ }
991
+ function ks(e) {
992
+ return y.get(`/role/${e}`);
993
+ }
994
+ function bs(e) {
995
+ return y.post("/role", e);
996
+ }
997
+ function ws(e, t) {
998
+ return y.put(`/role/${e}`, t);
999
+ }
1000
+ function Ss(e) {
1001
+ return y.delete(`/role/${e}`);
1002
+ }
1003
+ function Cs(e, t) {
1004
+ return y.patch(`/role/${e}/status`, { status: t });
1005
+ }
1006
+ function xs() {
1007
+ return y.get("/menu/list");
1008
+ }
1009
+ function Ts() {
1010
+ return y.get("/menu/tree");
1011
+ }
1012
+ function Es(e) {
1013
+ return y.post("/menu", e);
1014
+ }
1015
+ function Ls(e, t) {
1016
+ return y.put(`/menu/${e}`, t);
1017
+ }
1018
+ function As(e) {
1019
+ return y.delete(`/menu/${e}`);
1020
+ }
1021
+ function Rs(e) {
1022
+ return y.get("/user/list", { params: e });
1023
+ }
1024
+ function $s(e) {
1025
+ return y.get(`/user/${e}`);
1026
+ }
1027
+ function Ms(e) {
1028
+ return y.post("/user", e);
1029
+ }
1030
+ function Is(e, t) {
1031
+ return y.put(`/user/${e}`, t);
1032
+ }
1033
+ function Ds(e) {
1034
+ return y.delete(`/user/${e}`);
1035
+ }
1036
+ function Us(e) {
1037
+ return y.post("/user/batch-delete", { ids: e });
1038
+ }
1039
+ function Os(e, t) {
1040
+ return y.patch(`/user/${e}/status`, { status: t });
1041
+ }
1042
+ function Ns(e) {
1043
+ return y.post(`/user/${e}/reset-password`);
1044
+ }
1045
+ var Wt = /* @__PURE__ */ ((e) => (e[e.ENABLED = 1] = "ENABLED", e[e.DISABLED = 0] = "DISABLED", e))(Wt || {}), Yt = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.MALE = 1] = "MALE", e[e.FEMALE = 2] = "FEMALE", e))(Yt || {}), Xt = /* @__PURE__ */ ((e) => (e[e.DIRECTORY = 0] = "DIRECTORY", e[e.MENU = 1] = "MENU", e[e.BUTTON = 2] = "BUTTON", e))(Xt || {});
1046
+ const Ps = {
1047
+ 1: "启用",
1048
+ 0: "禁用"
1049
+ }, Fs = {
1050
+ 0: "未知",
1051
+ 1: "男",
1052
+ 2: "女"
1053
+ }, Vs = {
1054
+ 0: "目录",
1055
+ 1: "菜单",
1056
+ 2: "按钮"
1057
+ }, Bs = [
1058
+ {
1059
+ label: "启用",
1060
+ value: 1
1061
+ /* ENABLED */
1062
+ },
1063
+ {
1064
+ label: "禁用",
1065
+ value: 0
1066
+ /* DISABLED */
1067
+ }
1068
+ ], zs = [
1069
+ {
1070
+ label: "未知",
1071
+ value: 0
1072
+ /* UNKNOWN */
1073
+ },
1074
+ {
1075
+ label: "男",
1076
+ value: 1
1077
+ /* MALE */
1078
+ },
1079
+ {
1080
+ label: "女",
1081
+ value: 2
1082
+ /* FEMALE */
1083
+ }
1084
+ ], js = [
1085
+ {
1086
+ label: "目录",
1087
+ value: 0
1088
+ /* DIRECTORY */
1089
+ },
1090
+ {
1091
+ label: "菜单",
1092
+ value: 1
1093
+ /* MENU */
1094
+ },
1095
+ {
1096
+ label: "按钮",
1097
+ value: 2
1098
+ /* BUTTON */
1099
+ }
1100
+ ], Hs = {
1101
+ mounted(e, t) {
1102
+ var c;
1103
+ const s = O(), { value: o } = t;
1104
+ if (!o) return;
1105
+ const l = s.permissions;
1106
+ let d = !1;
1107
+ Array.isArray(o) ? d = o.some((n) => l.includes(n) || l.includes("*")) : d = l.includes(o) || l.includes("*"), d || (c = e.parentNode) == null || c.removeChild(e);
1108
+ }
1109
+ };
1110
+ export {
1111
+ Ns as $,
1112
+ ys as A,
1113
+ se as B,
1114
+ Ve as C,
1115
+ $s as D,
1116
+ fs as E,
1117
+ cs as F,
1118
+ Yt as G,
1119
+ $t as H,
1120
+ Rs as I,
1121
+ ms as J,
1122
+ Kt as K,
1123
+ ge as L,
1124
+ Xt as M,
1125
+ y as N,
1126
+ ps as O,
1127
+ je as P,
1128
+ _e as Q,
1129
+ h as R,
1130
+ Wt as S,
1131
+ is as T,
1132
+ K as U,
1133
+ vs as V,
1134
+ _s as W,
1135
+ Ne as X,
1136
+ Hs as Y,
1137
+ gs as Z,
1138
+ Ue as _,
1139
+ O as a,
1140
+ ls as a0,
1141
+ oe as a1,
1142
+ ns as a2,
1143
+ q as a3,
1144
+ Fe as a4,
1145
+ Pe as a5,
1146
+ Be as a6,
1147
+ ze as a7,
1148
+ pe as a8,
1149
+ Ls as a9,
1150
+ ws as aa,
1151
+ Cs as ab,
1152
+ Is as ac,
1153
+ Os as ad,
1154
+ J as ae,
1155
+ us as af,
1156
+ ds as ag,
1157
+ hs as ah,
1158
+ ne as b,
1159
+ H as c,
1160
+ Bs as d,
1161
+ js as e,
1162
+ zs as f,
1163
+ Fs as g,
1164
+ Vs as h,
1165
+ Ot as i,
1166
+ ct as j,
1167
+ Ps as k,
1168
+ Us as l,
1169
+ fe as m,
1170
+ Es as n,
1171
+ bs as o,
1172
+ Ms as p,
1173
+ as as q,
1174
+ As as r,
1175
+ Ss as s,
1176
+ Ds as t,
1177
+ ye as u,
1178
+ ve as v,
1179
+ xs as w,
1180
+ Ts as x,
1181
+ rs as y,
1182
+ ks as z
1183
+ };