xto-fronted 0.2.5 → 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
package/dist/index.es.js CHANGED
@@ -1,1524 +1,79 @@
1
- import Ue from "axios";
2
- import { Message as R, Tooltip as Pe, Drawer as Me } from "@xto/feedback";
3
- import { ref as C, computed as w, watch as Ne, reactive as he, defineComponent as F, openBlock as y, createElementBlock as L, createElementVNode as a, withDirectives as _e, toDisplayString as T, unref as h, vShow as ve, createVNode as x, isRef as ge, withCtx as I, Fragment as M, renderList as j, createBlock as V, createTextVNode as oe, createCommentVNode as D, normalizeClass as ae, onMounted as Be, onUnmounted as Re, withModifiers as Ae, Transition as Ve, resolveComponent as De, normalizeStyle as Fe, withKeys as Oe } from "vue";
4
- import { defineStore as re } from "pinia";
5
- import { useRouter as W, useRoute as le, createRouter as ye, createWebHistory as we } from "vue-router";
6
- import { Menu as be, SubMenu as ke, MenuItem as se } from "@xto/navigation";
7
- import { Button as ce, Icon as q } from "@xto/base";
8
- import { Switch as fe, Input as de, Form as ze, FormItem as ue } from "@xto/form";
9
- const He = {
10
- appName: "XTO App",
11
- baseUrl: "",
12
- appId: "",
13
- clientId: "",
14
- indexPath: "/dashboard",
15
- loginPath: "/login"
16
- };
17
- let ne = { ...He };
18
- function je(e) {
19
- ne = { ...ne, ...e };
20
- }
21
- function N() {
22
- return ne;
23
- }
24
- function Fs(e) {
25
- return ne[e];
26
- }
27
- const Q = () => `tooyu-cloud:${N().appId}:`, Ce = (e) => ({
28
- get(s) {
29
- const t = Q(), n = e.getItem(t + s);
30
- if (!n) return null;
31
- try {
32
- return JSON.parse(n);
33
- } catch {
34
- return n;
35
- }
36
- },
37
- set(s, t) {
38
- const n = Q();
39
- if (t == null) {
40
- e.removeItem(n + s);
41
- return;
42
- }
43
- const o = typeof t == "string" ? t : JSON.stringify(t);
44
- e.setItem(n + s, o);
45
- },
46
- remove(s) {
47
- const t = Q();
48
- e.removeItem(t + s);
49
- },
50
- clear() {
51
- const s = Q();
52
- Object.keys(e).forEach((n) => {
53
- n.startsWith(s) && e.removeItem(n);
54
- });
55
- }
56
- }), Z = Ce(window.localStorage), ee = Ce(window.sessionStorage), k = {
57
- get: Z.get,
58
- set: Z.set,
59
- remove: Z.remove,
60
- clear: Z.clear
61
- }, Os = {
62
- get: ee.get,
63
- set: ee.set,
64
- remove: ee.remove,
65
- clear: ee.clear
66
- }, pe = "login_info", Ke = "user_info", G = () => k.get(pe), qe = (e) => {
67
- const s = {
68
- accessToken: e.access_token,
69
- refreshToken: e.refresh_token,
70
- expiresTime: e.expires_time,
71
- refreshTime: e.refresh_time,
72
- tokenType: e.token_type,
73
- code: e.code
74
- };
75
- k.set(pe, s);
76
- }, Le = () => {
77
- const e = G();
78
- return (e == null ? void 0 : e.accessToken) || null;
79
- }, We = () => {
80
- const e = G();
81
- return (e == null ? void 0 : e.tokenType) || "Bearer";
82
- }, zs = () => {
83
- const e = G();
84
- return (e == null ? void 0 : e.code) || null;
85
- }, xe = () => {
86
- k.remove(pe), k.remove(Ke);
87
- }, Ie = () => !!Le(), Ye = () => {
88
- const e = N(), s = Ue.create({
89
- baseURL: e.baseUrl,
90
- timeout: 15e3,
91
- headers: {
92
- "Content-Type": "application/json"
93
- }
94
- });
95
- return s.interceptors.request.use(
96
- (t) => {
97
- const n = Le();
98
- if (n) {
99
- const o = We();
100
- t.headers.Authorization = `${o} ${n}`;
101
- }
102
- return t;
103
- },
104
- (t) => Promise.reject(t)
105
- ), s.interceptors.response.use(
106
- (t) => {
107
- if (t.config.responseType === "blob")
108
- return t;
109
- const { data: n } = t;
110
- return n.code === 200 || n.code === 0 ? t : (R.error(n.message || "请求失败"), Promise.reject(new Error(n.message || "请求失败")));
111
- },
112
- (t) => {
113
- var o;
114
- const { response: n } = t;
115
- if (n)
116
- switch (n.status) {
117
- case 401:
118
- case 403:
119
- R.error("登录已过期,请重新登录"), xe(), window.location.href = "/login";
120
- break;
121
- case 404:
122
- R.error("请求资源不存在");
123
- break;
124
- case 500:
125
- R.error("服务器错误");
126
- break;
127
- default:
128
- R.error(((o = n.data) == null ? void 0 : o.message) || "请求失败");
129
- }
130
- else
131
- R.error("网络连接失败");
132
- return Promise.reject(t);
133
- }
134
- ), s;
135
- };
136
- let te = null;
137
- function H() {
138
- return te || (te = Ye()), te;
139
- }
140
- function Ge() {
141
- te = null;
142
- }
143
- new Proxy({}, {
144
- get(e, s) {
145
- return H()[s];
146
- }
147
- });
148
- const J = {
149
- get(e, s) {
150
- return H().get(e, s).then((t) => t.data);
151
- },
152
- post(e, s, t) {
153
- return H().post(e, s, t).then((n) => n.data);
154
- },
155
- put(e, s, t) {
156
- return H().put(e, s, t).then((n) => n.data);
157
- },
158
- patch(e, s, t) {
159
- return H().patch(e, s, t).then((n) => n.data);
160
- },
161
- delete(e, s) {
162
- return H().delete(e, s).then((t) => t.data);
163
- },
164
- /**
165
- * 下载文件(blob 响应)
166
- * 直接返回 Blob 对象,绕过响应拦截器的业务错误处理
167
- */
168
- download(e, s) {
169
- return H().get(e, { ...s, responseType: "blob" }).then((t) => (t.headers["content-type"] || "").includes("application/json") ? t.data.text().then((o) => {
170
- try {
171
- const d = JSON.parse(o);
172
- return R.error(d.message || "请求失败"), Promise.reject(new Error(d.message || "请求失败"));
173
- } catch {
174
- return R.error("请求失败"), Promise.reject(new Error("请求失败"));
175
- }
176
- }) : t.data);
177
- }
178
- }, $e = "/vite.svg", X = re("app", () => {
179
- const e = C(k.get("isDark") || !1), s = C(k.get("theme") || "light"), t = C(k.get("layout") || "sidebar"), n = C(k.get("isCollapsed") || !1), o = C(k.get("showTabs") ?? !0), d = C(k.get("showFooter") ?? !0), l = C(k.get("showBreadcrumb") ?? !0), r = C(k.get("primaryColor") || "#409eff"), i = C(k.get("isGrayscale") || !1), u = C([]), p = w(() => e.value ? "dark" : "light"), f = () => {
180
- e.value = !e.value, s.value = e.value ? "dark" : "light", _();
181
- }, v = ($) => {
182
- s.value = $, e.value = $ === "dark", _();
183
- }, _ = () => {
184
- const $ = document.documentElement;
185
- e.value ? $.classList.add("dark") : $.classList.remove("dark"), k.set("isDark", e.value), k.set("theme", s.value);
186
- }, c = () => {
187
- n.value = !n.value, k.set("isCollapsed", n.value);
188
- }, g = ($) => {
189
- t.value = $, k.set("layout", $);
190
- }, m = () => {
191
- o.value = !o.value, k.set("showTabs", o.value);
192
- }, b = () => {
193
- d.value = !d.value, k.set("showFooter", d.value);
194
- }, E = () => {
195
- l.value = !l.value, k.set("showBreadcrumb", l.value);
196
- }, P = ($) => {
197
- r.value = $, document.documentElement.style.setProperty("--color-primary", $), k.set("primaryColor", $);
198
- }, O = ($) => {
199
- i.value = $;
200
- const Y = document.documentElement;
201
- $ ? Y.classList.add("grayscale") : Y.classList.remove("grayscale"), k.set("isGrayscale", $);
202
- }, z = ($) => {
203
- u.value.includes($) || u.value.push($);
204
- }, B = ($) => {
205
- const Y = u.value.indexOf($);
206
- Y > -1 && u.value.splice(Y, 1);
207
- }, S = () => {
208
- u.value = [];
209
- }, U = () => {
210
- _(), r.value !== "#409eff" && document.documentElement.style.setProperty("--color-primary", r.value), i.value && document.documentElement.classList.add("grayscale");
211
- };
212
- return Ne(e, _), {
213
- isDark: e,
214
- theme: s,
215
- layout: t,
216
- isCollapsed: n,
217
- showTabs: o,
218
- showFooter: d,
219
- showBreadcrumb: l,
220
- primaryColor: r,
221
- isGrayscale: i,
222
- cachedViews: u,
223
- themeClass: p,
224
- toggleTheme: f,
225
- toggleCollapse: c,
226
- setTheme: v,
227
- setLayout: g,
228
- toggleTabs: m,
229
- toggleFooter: b,
230
- toggleBreadcrumb: E,
231
- setPrimaryColor: P,
232
- setGrayscale: O,
233
- addCachedView: z,
234
- removeCachedView: B,
235
- clearCachedViews: S,
236
- initTheme: U
237
- };
238
- }), Te = re("auth", () => {
239
- const e = C(G()), s = w(() => Ie()), t = (r) => {
240
- qe(r), e.value = G();
241
- }, n = () => {
242
- e.value = null, xe();
243
- }, o = w(() => {
244
- var r;
245
- return ((r = e.value) == null ? void 0 : r.accessToken) || null;
246
- }), d = w(() => {
247
- var r;
248
- return ((r = e.value) == null ? void 0 : r.tokenType) || "Bearer";
249
- }), l = w(() => {
250
- var r;
251
- return ((r = e.value) == null ? void 0 : r.code) || null;
252
- });
253
- return {
254
- loginInfo: e,
255
- isLoggedIn: s,
256
- accessToken: o,
257
- tokenType: d,
258
- code: l,
259
- login: t,
260
- logout: n
261
- };
262
- }), Se = re("user", () => {
263
- const e = C(k.get("user_info")), s = w(() => !!e.value), t = w(() => {
264
- var r;
265
- return ((r = e.value) == null ? void 0 : r.userName) || "";
266
- }), n = w(() => {
267
- var r;
268
- return ((r = e.value) == null ? void 0 : r.avatar) || "";
269
- }), o = w(() => {
270
- var r;
271
- return (r = e.value) == null ? void 0 : r.userId;
272
- });
273
- return {
274
- userInfo: e,
275
- isLoggedIn: s,
276
- userName: t,
277
- avatar: n,
278
- userId: o,
279
- setUserInfo: (r) => {
280
- e.value = r, k.set("user_info", r);
281
- },
282
- clearUserInfo: () => {
283
- e.value = null, k.remove("user_info");
284
- }
285
- };
286
- }), K = re("menu", () => {
287
- const e = "menu_list", s = "menu_btn_list", t = C(k.get(e) || []), n = C(k.get(s) || {}), o = w(() => t.value.length > 0), d = w(() => {
288
- const f = N();
289
- function v(c) {
290
- if (c && c.length > 0)
291
- for (let g = 0; g < c.length; g++) {
292
- const m = c[g];
293
- if (m.default)
294
- return m.path;
295
- {
296
- const b = v(m.children || []);
297
- if (b)
298
- return b;
299
- }
300
- }
301
- return null;
302
- }
303
- return v(t.value) || f.indexPath || "/dashboard";
304
- }), l = (f, v) => {
305
- const _ = [];
306
- return !f || f.length <= 0 || f.forEach((c) => {
307
- if (c.type === 1) {
308
- const g = {
309
- code: c.menuCode,
310
- name: c.menuName,
311
- path: "",
312
- title: c.menuName
313
- }, m = v || "";
314
- let b = n.value[m] || [];
315
- b.push(g), n.value[m] = b;
316
- } else {
317
- const g = [];
318
- let m = c.menuUrl, b = c.isOut || !1;
319
- !b && c.menuUrl && (c.menuUrl.startsWith("http") ? m = "/iframe/" + encodeURIComponent(m) : c.menuUrl.startsWith("keep-alive:") && (m = "/iframe/keep-alive/" + encodeURIComponent(m.split("keep-alive:")[1])));
320
- const E = {
321
- code: c.menuCode,
322
- name: c.menuName,
323
- path: m,
324
- icon: "grid",
325
- closable: c.closable,
326
- default: c.isDefault,
327
- out: b,
328
- children: g,
329
- title: c.menuName
330
- };
331
- if (_.push(E), c.children && c.children.length > 0) {
332
- const P = l(c.children, c.menuUrl);
333
- E.children = P;
334
- }
335
- }
336
- }), _;
337
- }, r = (f) => {
338
- t.value = f, k.set(e, f);
339
- }, i = (f) => {
340
- const v = t.value.findIndex((_) => _.code === "home");
341
- v > -1 && t.value.splice(v, 1), t.value.unshift({
342
- ...f,
343
- code: "home",
344
- name: "首页"
345
- }), k.set(e, t.value);
346
- }, u = (f, v) => {
347
- if (p(), !(v != null && v.skipIndexMenu)) {
348
- const c = N();
349
- t.value.push({
350
- code: "home",
351
- name: "首页",
352
- icon: "grid",
353
- closable: !1,
354
- default: !1,
355
- out: !1,
356
- path: c.indexPath || "/dashboard",
357
- title: "首页"
358
- });
359
- }
360
- const _ = l(f);
361
- t.value.push(..._), k.set(e, t.value), k.set(s, n.value);
362
- }, p = () => {
363
- t.value = [], n.value = {}, k.remove(e), k.remove(s);
364
- };
365
- return {
366
- menuList: t,
367
- menuBtnListMap: n,
368
- hasMenu: o,
369
- index: d,
370
- setMenuList: r,
371
- setIndexMenu: i,
372
- setMenuFromRemote: u,
373
- clearMenu: p
374
- };
375
- });
376
- function Je(e) {
377
- const s = N();
378
- return J.post("/user/v1.0/login/by-domain", {
379
- appId: s.appId,
380
- clientId: s.clientId,
381
- uid: e.uid,
382
- password: e.password,
383
- code: !0
384
- });
385
- }
386
- function Xe() {
387
- return J.put("/user/v1.0/user/logout");
388
- }
389
- function Hs(e, s) {
390
- return J.get(`/user/v1.0/login/by-code?appId=${e}&code=${s}`);
391
- }
392
- function Qe() {
393
- return J.get("/user/v1.0/user/get-me");
394
- }
395
- function Ze() {
396
- const e = N();
397
- return J.get(`/user/v1.0/menu/get-menu?appId=${e.appId}`);
398
- }
399
- function ie() {
400
- const e = W(), s = le(), t = Te(), n = Se(), o = K(), d = C(!1), l = w(() => t.isLoggedIn), r = w(() => n.userInfo), i = w(() => n.userName || ""), u = w(() => o.menuList), p = w(() => o.index), f = async (b, E) => {
401
- d.value = !0;
402
- try {
403
- m();
404
- const O = (await Je({ uid: b, password: E })).data;
405
- t.login(O), await _(), await c();
406
- const z = s.query.redirectUrl;
407
- if (z) {
408
- const B = decodeURIComponent(z);
409
- if (B.startsWith("http")) {
410
- const S = O.code;
411
- location.href = B.includes("?") ? `${B}&code=${S}` : `${B}?code=${S}`;
412
- } else
413
- await e.replace(B);
414
- } else
415
- await e.replace(p.value || "/");
416
- return R.success("登录成功"), { success: !0, data: O };
417
- } catch (P) {
418
- return R.error((P == null ? void 0 : P.message) || "登录失败"), { success: !1, error: P };
419
- } finally {
420
- d.value = !1;
421
- }
422
- }, v = async (b = !0) => {
423
- const E = N();
424
- try {
425
- await Xe();
426
- } catch (P) {
427
- console.error("退出登录接口失败", P);
428
- } finally {
429
- m(), e.push(E.loginPath || "/login"), b && R.success("退出登录成功");
430
- }
431
- }, _ = async () => {
432
- const b = await Qe();
433
- return n.setUserInfo(b.data), b.data;
434
- }, c = async () => {
435
- const b = await Ze();
436
- return o.setMenuFromRemote(b.data), o.menuList;
437
- }, g = async () => {
438
- if (!t.isLoggedIn)
439
- return !1;
440
- try {
441
- return n.userInfo || await _(), o.hasMenu || await c(), !0;
442
- } catch (b) {
443
- return console.error("初始化应用失败", b), m(), !1;
444
- }
445
- }, m = () => {
446
- t.logout(), n.clearUserInfo(), o.clearMenu();
447
- };
448
- return {
449
- // 状态
450
- loading: d,
451
- isLoggedIn: l,
452
- userInfo: r,
453
- userName: i,
454
- menuList: u,
455
- indexPath: p,
456
- // 方法
457
- login: f,
458
- logout: v,
459
- loadUserInfo: _,
460
- loadMenu: c,
461
- initApp: g,
462
- clearAllState: m
463
- };
464
- }
465
- function js() {
466
- const e = K(), s = Te(), t = Se(), n = w(() => s.isLoggedIn), o = w(() => t.userName), d = w(() => t.userInfo), l = (p) => {
467
- const f = window.location.pathname, _ = (e.menuBtnListMap[f] || []).map((c) => c.code);
468
- return Array.isArray(p) ? p.some((c) => _.includes(c)) : _.includes(p);
469
- };
470
- return {
471
- // 状态
472
- isLoggedIn: n,
473
- userName: o,
474
- userInfo: d,
475
- // 方法
476
- hasPermission: l,
477
- hasAnyPermission: (p) => p.some((f) => l(f)),
478
- hasAllPermissions: (p) => p.every((f) => l(f)),
479
- getCurrentPagePermissions: () => {
480
- const p = window.location.pathname;
481
- return (e.menuBtnListMap[p] || []).map((v) => v.code);
482
- }
483
- };
484
- }
485
- function Ee() {
486
- const e = le(), s = W(), t = K(), n = X(), o = C(""), d = w(() => e.path), l = w(() => n.isCollapsed), r = w(() => t.menuList), i = w(() => t.hasMenu), u = (g, m = "") => {
487
- const b = [];
488
- return g.forEach((E) => {
489
- E.children && E.children.length > 0 ? b.push(...u(E.children, E.title)) : b.push({ ...E, parentTitle: m });
490
- }), b;
491
- }, p = w(() => o.value.trim() ? u(r.value).filter(
492
- (m) => m.title.toLowerCase().includes(o.value.toLowerCase())
493
- ) : []), f = w(() => o.value.trim() ? r.value.map((g) => {
494
- if (g.children && g.children.length > 0) {
495
- const m = g.children.filter(
496
- (b) => b.title.toLowerCase().includes(o.value.toLowerCase())
497
- );
498
- return m.length > 0 ? { ...g, children: m } : null;
499
- }
500
- return g.title.toLowerCase().includes(o.value.toLowerCase()) ? g : null;
501
- }).filter(Boolean) : r.value);
502
- return {
503
- // 状态
504
- searchKeyword: o,
505
- activeMenu: d,
506
- isCollapsed: l,
507
- menuList: r,
508
- hasMenu: i,
509
- searchResults: p,
510
- filteredMenuList: f,
511
- // 方法
512
- flattenMenus: u,
513
- handleMenuSelect: (g) => {
514
- g && g !== e.path && (s.push(g), o.value = "");
515
- },
516
- handleSearchItemClick: (g) => {
517
- s.push(g), o.value = "";
518
- },
519
- clearSearch: () => {
520
- o.value = "";
521
- }
522
- };
523
- }
524
- function Ks(e, s = {}) {
525
- const { rules: t, onSubmit: n } = s, o = C(), d = he({ ...e }), l = C(!1), r = C(!1), i = C(!1), u = () => {
526
- v(), i.value = !1, r.value = !0;
527
- }, p = (c) => {
528
- Object.assign(d, c), i.value = !0, r.value = !0;
529
- }, f = () => {
530
- r.value = !1, v();
531
- }, v = () => {
532
- var c;
533
- Object.keys(e).forEach((g) => {
534
- d[g] = e[g];
535
- }), (c = o.value) == null || c.resetFields();
536
- };
537
- return {
538
- formRef: o,
539
- formData: d,
540
- rules: t,
541
- loading: l,
542
- visible: r,
543
- isEdit: i,
544
- openAdd: u,
545
- openEdit: p,
546
- close: f,
547
- resetForm: v,
548
- handleSubmit: async () => {
549
- var c;
550
- try {
551
- await ((c = o.value) == null ? void 0 : c.validate()), l.value = !0, await (n == null ? void 0 : n(d)), f();
552
- } catch (g) {
553
- console.error(g);
554
- } finally {
555
- l.value = !1;
556
- }
557
- }
558
- };
559
- }
560
- function qs(e) {
561
- const { fetchData: s, defaultPageSize: t = 10 } = e, n = C(!1), o = C([]), d = C(0), l = C(1), r = C(t), i = he({}), u = async () => {
562
- n.value = !0;
563
- try {
564
- const m = {
565
- ...i,
566
- page: l.value,
567
- pageSize: r.value
568
- }, b = await s(m);
569
- o.value = b.list, d.value = b.total;
570
- } catch (m) {
571
- console.error(m);
572
- } finally {
573
- n.value = !1;
574
- }
575
- }, p = () => {
576
- l.value = 1, u();
577
- }, f = () => {
578
- Object.keys(i).forEach((m) => {
579
- i[m] = void 0;
580
- }), l.value = 1, u();
581
- }, v = (m) => {
582
- l.value = m, u();
583
- }, _ = (m) => {
584
- r.value = m, l.value = 1, u();
585
- }, c = () => {
586
- u();
587
- }, g = w(() => ({
588
- current: l.value,
589
- pageSize: r.value,
590
- total: d.value
591
- }));
592
- return {
593
- loading: n,
594
- data: o,
595
- total: d,
596
- currentPage: l,
597
- pageSize: r,
598
- searchParams: i,
599
- pagination: g,
600
- getData: u,
601
- handleSearch: p,
602
- handleReset: f,
603
- handlePageChange: v,
604
- handleSizeChange: _,
605
- refresh: c
606
- };
607
- }
608
- const et = { class: "sidebar" }, tt = { class: "sidebar__logo" }, st = { key: 1 }, nt = {
609
- key: 0,
610
- class: "sidebar__user"
611
- }, ot = { class: "sidebar__user-info" }, at = { class: "sidebar__user-name" }, rt = { class: "sidebar__user-role" }, lt = /* @__PURE__ */ F({
612
- __name: "Sidebar",
613
- setup(e) {
614
- const { logout: s, userName: t, userInfo: n } = ie(), o = N(), {
615
- activeMenu: d,
616
- isCollapsed: l,
617
- filteredMenuList: r,
618
- handleMenuSelect: i
619
- } = Ee();
620
- return (u, p) => {
621
- var f;
622
- return y(), L("div", et, [
623
- a("div", tt, [
624
- p[1] || (p[1] = a("img", {
625
- src: $e,
626
- alt: "Logo",
627
- class: "sidebar__logo-img"
628
- }, null, -1)),
629
- _e(a("span", { class: "sidebar__logo-text" }, T(h(o).appName), 513), [
630
- [ve, !h(l)]
631
- ])
632
- ]),
633
- x(h(be), {
634
- modelValue: h(d),
635
- "onUpdate:modelValue": p[0] || (p[0] = (v) => ge(d) ? d.value = v : null),
636
- collapse: h(l),
637
- "collapse-transition": !1,
638
- class: "sidebar__menu",
639
- onSelect: h(i)
640
- }, {
641
- default: I(() => [
642
- (y(!0), L(M, null, j(h(r), (v) => (y(), L(M, {
643
- key: v.path
644
- }, [
645
- v.children && v.children.length > 0 ? (y(), V(h(ke), {
646
- key: 0,
647
- index: v.path,
648
- icon: "grid"
649
- }, {
650
- title: I(() => [
651
- _e(a("span", null, T(v.title), 513), [
652
- [ve, !h(l)]
653
- ])
654
- ]),
655
- default: I(() => [
656
- (y(!0), L(M, null, j(v.children, (_) => (y(), V(h(se), {
657
- key: _.path,
658
- index: _.path,
659
- icon: "grid"
660
- }, {
661
- default: I(() => [
662
- a("span", null, T(_.title), 1)
663
- ]),
664
- _: 2
665
- }, 1032, ["index"]))), 128))
666
- ]),
667
- _: 2
668
- }, 1032, ["index"])) : (y(), V(h(se), {
669
- key: 1,
670
- index: v.path,
671
- icon: "grid"
672
- }, {
673
- default: I(() => [
674
- h(l) ? (y(), V(h(Pe), {
675
- key: 0,
676
- content: v.title,
677
- placement: "right"
678
- }, {
679
- default: I(() => [...p[2] || (p[2] = [
680
- a("span", null, null, -1)
681
- ])]),
682
- _: 1
683
- }, 8, ["content"])) : (y(), L("span", st, T(v.title), 1))
684
- ]),
685
- _: 2
686
- }, 1032, ["index"]))
687
- ], 64))), 128))
688
- ]),
689
- _: 1
690
- }, 8, ["modelValue", "collapse", "onSelect"]),
691
- h(l) ? D("", !0) : (y(), L("div", nt, [
692
- a("div", ot, [
693
- a("span", at, T(h(t) || "用户"), 1),
694
- a("span", rt, T(((f = h(n)) == null ? void 0 : f.departmentName) || ""), 1)
695
- ]),
696
- x(h(ce), {
697
- type: "text",
698
- size: "small",
699
- onClick: h(s)
700
- }, {
701
- default: I(() => [...p[3] || (p[3] = [
702
- oe("退出", -1)
703
- ])]),
704
- _: 1
705
- }, 8, ["onClick"])
706
- ]))
707
- ]);
708
- };
709
- }
710
- }), A = (e, s) => {
711
- const t = e.__vccOpts || e;
712
- for (const [n, o] of s)
713
- t[n] = o;
714
- return t;
715
- }, ct = /* @__PURE__ */ A(lt, [["__scopeId", "data-v-d6c5528d"]]), it = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
716
- <rect x="3" y="3" width="18" height="4" rx="1"/>
717
- <rect x="3" y="9" width="6" height="12" rx="1"/>
718
- <rect x="11" y="9" width="10" height="12" rx="1"/>
719
- </svg>`, ut = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
720
- <rect x="3" y="3" width="18" height="4" rx="1"/>
721
- <rect x="3" y="9" width="18" height="12" rx="1"/>
722
- </svg>`, dt = { class: "setting-drawer" }, ht = { class: "setting-section" }, pt = { class: "setting-section__content" }, _t = { class: "layout-options" }, vt = ["onClick"], ft = ["innerHTML"], mt = { class: "layout-option__label" }, gt = { class: "setting-section" }, yt = { class: "setting-section__content" }, wt = { class: "setting-item" }, bt = { class: "setting-item" }, kt = /* @__PURE__ */ F({
723
- inheritAttrs: !1,
724
- __name: "index",
725
- props: {
726
- visible: { type: Boolean }
727
- },
728
- emits: ["update:visible"],
729
- setup(e, { emit: s }) {
730
- const t = X(), n = {
731
- navLeft: it,
732
- navTop: ut
733
- }, o = [
734
- { value: "sidebar", label: "左侧导航", icon: "navLeft" },
735
- { value: "top", label: "顶部导航", icon: "navTop" }
736
- ], d = w({
737
- get: () => t.layout,
738
- set: (i) => t.setLayout(i)
739
- }), l = s, r = () => {
740
- l("update:visible", !1);
741
- };
742
- return (i, u) => (y(), V(h(Me), {
743
- "model-value": e.visible,
744
- title: "皮肤设置",
745
- direction: "rtl",
746
- size: 280,
747
- "onUpdate:modelValue": r
748
- }, {
749
- default: I(() => [
750
- a("div", dt, [
751
- a("div", ht, [
752
- u[0] || (u[0] = a("h4", { class: "setting-section__title" }, "导航模式", -1)),
753
- a("div", pt, [
754
- a("div", _t, [
755
- (y(), L(M, null, j(o, (p) => a("div", {
756
- key: p.value,
757
- class: ae(["layout-option", { "is-active": d.value === p.value }]),
758
- onClick: (f) => d.value = p.value
759
- }, [
760
- a("div", {
761
- class: "layout-option__preview",
762
- innerHTML: n[p.icon]
763
- }, null, 8, ft),
764
- a("span", mt, T(p.label), 1)
765
- ], 10, vt)), 64))
766
- ])
767
- ])
768
- ]),
769
- a("div", gt, [
770
- u[3] || (u[3] = a("h4", { class: "setting-section__title" }, "界面设置", -1)),
771
- a("div", yt, [
772
- a("div", wt, [
773
- u[1] || (u[1] = a("span", { class: "setting-item__label" }, "显示面包屑", -1)),
774
- x(h(fe), {
775
- "model-value": h(t).showBreadcrumb,
776
- "onUpdate:modelValue": h(t).toggleBreadcrumb
777
- }, null, 8, ["model-value", "onUpdate:modelValue"])
778
- ]),
779
- a("div", bt, [
780
- u[2] || (u[2] = a("span", { class: "setting-item__label" }, "灰度模式", -1)),
781
- x(h(fe), {
782
- "model-value": h(t).isGrayscale,
783
- "onUpdate:modelValue": h(t).setGrayscale
784
- }, null, 8, ["model-value", "onUpdate:modelValue"])
785
- ])
786
- ])
787
- ])
788
- ])
789
- ]),
790
- _: 1
791
- }, 8, ["model-value"]));
792
- }
793
- }), Ct = /* @__PURE__ */ A(kt, [["__scopeId", "data-v-3a74bfd0"]]), Lt = {
794
- key: 0,
795
- class: "breadcrumb"
796
- }, xt = ["onClick"], It = /* @__PURE__ */ F({
797
- __name: "Breadcrumb",
798
- setup(e) {
799
- const s = le(), t = W(), n = K(), o = w(() => {
800
- var p;
801
- const l = s.path, r = n.menuList, i = (f, v, _ = []) => {
802
- for (const c of f) {
803
- const g = {
804
- title: c.title,
805
- path: c.path,
806
- isLast: !1
807
- };
808
- if (c.path === v)
809
- return g.isLast = !0, [..._, g];
810
- if (c.children && c.children.length > 0) {
811
- const m = i(c.children, v, [..._, g]);
812
- if (m)
813
- return m;
814
- }
815
- }
816
- return null;
817
- }, u = i(r, l);
818
- return u && u.length > 0 ? u : (p = s.meta) != null && p.title ? [{ title: s.meta.title, path: l, isLast: !0 }] : [];
819
- }), d = (l) => {
820
- !l.isLast && l.path && t.push(l.path);
821
- };
822
- return (l, r) => o.value.length > 0 ? (y(), L("div", Lt, [
823
- (y(!0), L(M, null, j(o.value, (i, u) => (y(), L(M, {
824
- key: i.path
825
- }, [
826
- a("span", {
827
- class: ae(["breadcrumb__item", { "breadcrumb__item--link": !i.isLast }]),
828
- onClick: (p) => d(i)
829
- }, T(i.title), 11, xt),
830
- u < o.value.length - 1 ? (y(), V(h(q), {
831
- key: 0,
832
- name: "arrow-right",
833
- size: 12,
834
- class: "breadcrumb__separator"
835
- })) : D("", !0)
836
- ], 64))), 128))
837
- ])) : D("", !0);
838
- }
839
- }), $t = /* @__PURE__ */ A(It, [["__scopeId", "data-v-31468670"]]), Tt = { class: "header" }, St = { class: "header__left" }, Et = { class: "header__right" }, Ut = {
840
- key: 0,
841
- class: "header__search-results"
842
- }, Pt = ["onClick"], Mt = { class: "header__search-info" }, Nt = { class: "header__search-title" }, Bt = {
843
- key: 0,
844
- class: "header__search-parent"
845
- }, Rt = ["title"], At = { class: "header__avatar" }, Vt = { class: "header__user-name" }, Dt = {
846
- key: 0,
847
- class: "header__dropdown"
848
- }, Ft = { class: "header__dropdown-header" }, Ot = { class: "header__dropdown-avatar" }, zt = { class: "header__dropdown-info" }, Ht = { class: "header__dropdown-name" }, jt = { class: "header__dropdown-role" }, Kt = { class: "header__dropdown-menu" }, qt = /* @__PURE__ */ F({
849
- __name: "Header",
850
- props: {
851
- showCollapse: { type: Boolean }
852
- },
853
- setup(e) {
854
- const s = X(), { logout: t, userName: n, userInfo: o } = ie(), {
855
- searchKeyword: d,
856
- searchResults: l,
857
- handleSearchItemClick: r
858
- } = Ee(), i = C(!1), u = C(null), p = C(null), f = C(!1), v = C(!1), _ = w(() => n.value || "用户"), c = () => {
859
- s.toggleCollapse();
860
- }, g = () => {
861
- s.toggleTheme();
862
- }, m = () => {
863
- document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen();
864
- }, b = () => {
865
- f.value = !!document.fullscreenElement;
866
- }, E = () => {
867
- i.value = !i.value;
868
- }, P = () => {
869
- i.value = !1;
870
- }, O = async () => {
871
- P(), await t();
872
- }, z = (B) => {
873
- u.value && !u.value.contains(B.target) && P(), p.value && !p.value.contains(B.target) && (d.value = "");
874
- };
875
- return Be(() => {
876
- document.addEventListener("click", z), document.addEventListener("fullscreenchange", b);
877
- }), Re(() => {
878
- document.removeEventListener("click", z), document.removeEventListener("fullscreenchange", b);
879
- }), (B, S) => (y(), L("div", Tt, [
880
- a("div", St, [
881
- e.showCollapse ? (y(), L("div", {
882
- key: 0,
883
- class: "header__collapse",
884
- onClick: c
885
- }, [...S[3] || (S[3] = [
886
- a("span", null, "☰", -1)
887
- ])])) : D("", !0),
888
- h(s).showBreadcrumb ? (y(), V($t, { key: 1 })) : D("", !0)
889
- ]),
890
- a("div", Et, [
891
- a("div", {
892
- class: "header__search",
893
- ref_key: "searchRef",
894
- ref: p
895
- }, [
896
- x(h(de), {
897
- modelValue: h(d),
898
- "onUpdate:modelValue": S[0] || (S[0] = (U) => ge(d) ? d.value = U : null),
899
- placeholder: "搜索菜单...",
900
- size: "small",
901
- clearable: ""
902
- }, null, 8, ["modelValue"]),
903
- h(l).length > 0 ? (y(), L("div", Ut, [
904
- (y(!0), L(M, null, j(h(l), (U) => (y(), L("div", {
905
- key: U.path,
906
- class: "header__search-item",
907
- onClick: ($) => h(r)(U.path)
908
- }, [
909
- x(h(q), {
910
- name: "grid",
911
- size: 16,
912
- class: "header__search-icon"
913
- }),
914
- a("div", Mt, [
915
- a("span", Nt, T(U.title), 1),
916
- U.parentTitle ? (y(), L("span", Bt, T(U.parentTitle), 1)) : D("", !0)
917
- ])
918
- ], 8, Pt))), 128))
919
- ])) : D("", !0)
920
- ], 512),
921
- a("div", {
922
- class: "header__action",
923
- onClick: m,
924
- title: f.value ? "退出全屏" : "全屏"
925
- }, [
926
- x(h(q), {
927
- name: f.value ? "fullscreen-exit" : "fullscreen",
928
- size: 16
929
- }, null, 8, ["name"])
930
- ], 8, Rt),
931
- a("div", {
932
- class: "header__action",
933
- onClick: g,
934
- title: "切换主题"
935
- }, [
936
- x(h(q), {
937
- name: h(s).isDark ? "sun" : "moon",
938
- size: 16
939
- }, null, 8, ["name"])
940
- ]),
941
- a("div", {
942
- class: "header__action",
943
- onClick: S[1] || (S[1] = (U) => v.value = !0),
944
- title: "皮肤设置"
945
- }, [
946
- x(h(q), {
947
- name: "skin",
948
- size: 16
949
- })
950
- ]),
951
- a("div", {
952
- class: "header__user",
953
- ref_key: "dropdownRef",
954
- ref: u
955
- }, [
956
- a("div", {
957
- class: "header__user-trigger",
958
- onClick: Ae(E, ["stop"])
959
- }, [
960
- a("div", At, [
961
- a("span", null, T(_.value.charAt(0)), 1)
962
- ]),
963
- a("span", Vt, T(_.value), 1),
964
- a("span", {
965
- class: ae(["header__user-arrow", { "is-active": i.value }])
966
- }, "▼", 2)
967
- ]),
968
- x(Ve, { name: "dropdown" }, {
969
- default: I(() => {
970
- var U;
971
- return [
972
- i.value ? (y(), L("div", Dt, [
973
- a("div", Ft, [
974
- a("div", Ot, [
975
- a("span", null, T(_.value.charAt(0)), 1)
976
- ]),
977
- a("div", zt, [
978
- a("div", Ht, T(_.value), 1),
979
- a("div", jt, T(((U = h(o)) == null ? void 0 : U.departmentName) || ""), 1)
980
- ])
981
- ]),
982
- S[5] || (S[5] = a("div", { class: "header__dropdown-divider" }, null, -1)),
983
- a("div", Kt, [
984
- a("div", {
985
- class: "header__dropdown-item header__dropdown-item--danger",
986
- onClick: O
987
- }, [
988
- x(h(q), {
989
- name: "logout",
990
- size: 16
991
- }),
992
- S[4] || (S[4] = a("span", null, "退出登录", -1))
993
- ])
994
- ])
995
- ])) : D("", !0)
996
- ];
997
- }),
998
- _: 1
999
- })
1000
- ], 512)
1001
- ]),
1002
- x(Ct, {
1003
- visible: v.value,
1004
- "onUpdate:visible": S[2] || (S[2] = (U) => v.value = U)
1005
- }, null, 8, ["visible"])
1006
- ]));
1007
- }
1008
- }), me = /* @__PURE__ */ A(qt, [["__scopeId", "data-v-b15434d8"]]), Wt = { class: "top-menu" }, Yt = /* @__PURE__ */ F({
1009
- __name: "TopMenu",
1010
- setup(e) {
1011
- const s = le(), t = W(), n = K(), o = w(() => s.path), d = (l) => {
1012
- t.push(l);
1013
- };
1014
- return (l, r) => (y(), L("div", Wt, [
1015
- x(h(be), {
1016
- "default-active": o.value,
1017
- mode: "horizontal",
1018
- class: "top-menu__inner",
1019
- onSelect: d
1020
- }, {
1021
- default: I(() => [
1022
- (y(!0), L(M, null, j(h(n).menuList, (i) => (y(), L(M, {
1023
- key: i.path
1024
- }, [
1025
- i.children && i.children.length > 0 ? (y(), V(h(ke), {
1026
- key: 0,
1027
- index: i.path,
1028
- icon: "grid"
1029
- }, {
1030
- title: I(() => [
1031
- a("span", null, T(i.title), 1)
1032
- ]),
1033
- default: I(() => [
1034
- (y(!0), L(M, null, j(i.children, (u) => (y(), V(h(se), {
1035
- key: u.path,
1036
- index: u.path,
1037
- icon: "grid"
1038
- }, {
1039
- default: I(() => [
1040
- a("span", null, T(u.title), 1)
1041
- ]),
1042
- _: 2
1043
- }, 1032, ["index"]))), 128))
1044
- ]),
1045
- _: 2
1046
- }, 1032, ["index"])) : (y(), V(h(se), {
1047
- key: 1,
1048
- index: i.path,
1049
- icon: "grid"
1050
- }, {
1051
- default: I(() => [
1052
- a("span", null, T(i.title), 1)
1053
- ]),
1054
- _: 2
1055
- }, 1032, ["index"]))
1056
- ], 64))), 128))
1057
- ]),
1058
- _: 1
1059
- }, 8, ["default-active"])
1060
- ]));
1061
- }
1062
- }), Gt = /* @__PURE__ */ A(Yt, [["__scopeId", "data-v-f9b502d8"]]), Jt = { class: "layout__main" }, Xt = { class: "layout__content" }, Qt = { class: "layout__top" }, Zt = { class: "layout__content" }, es = /* @__PURE__ */ F({
1063
- __name: "index",
1064
- setup(e) {
1065
- const s = X(), t = w(
1066
- () => s.isCollapsed ? "64px" : "210px"
1067
- ), n = w(() => s.layout), o = w(() => n.value === "sidebar"), d = w(() => n.value === "sidebar");
1068
- return (l, r) => {
1069
- const i = De("router-view");
1070
- return y(), L("div", {
1071
- class: ae(["layout", `layout--${n.value}`])
1072
- }, [
1073
- o.value ? (y(), L(M, { key: 0 }, [
1074
- a("aside", {
1075
- class: "layout__aside",
1076
- style: Fe({ width: t.value })
1077
- }, [
1078
- x(ct)
1079
- ], 4),
1080
- a("div", Jt, [
1081
- x(me, {
1082
- class: "layout__header",
1083
- "show-collapse": d.value
1084
- }, null, 8, ["show-collapse"]),
1085
- a("main", Xt, [
1086
- x(i)
1087
- ])
1088
- ])
1089
- ], 64)) : n.value === "top" ? (y(), L(M, { key: 1 }, [
1090
- a("div", Qt, [
1091
- r[0] || (r[0] = a("div", { class: "layout__logo" }, [
1092
- a("img", {
1093
- src: $e,
1094
- alt: "Logo",
1095
- class: "layout__logo-img"
1096
- })
1097
- ], -1)),
1098
- x(Gt),
1099
- x(me, {
1100
- class: "layout__header--top",
1101
- "show-collapse": !1
1102
- })
1103
- ]),
1104
- a("main", Zt, [
1105
- x(i)
1106
- ])
1107
- ], 64)) : D("", !0)
1108
- ], 2);
1109
- };
1110
- }
1111
- }), ts = /* @__PURE__ */ A(es, [["__scopeId", "data-v-a2789d75"]]), ss = {}, ns = { class: "tabs-wrapper" };
1112
- function os(e, s) {
1113
- return y(), L("div", ns);
1114
- }
1115
- const Ws = /* @__PURE__ */ A(ss, [["render", os], ["__scopeId", "data-v-3b1e382a"]]), as = {}, rs = { class: "footer" };
1116
- function ls(e, s) {
1117
- return y(), L("div", rs, [...s[0] || (s[0] = [
1118
- a("span", null, "Copyright © 2024 Xto Demo. All Rights Reserved.", -1)
1119
- ])]);
1120
- }
1121
- const Ys = /* @__PURE__ */ A(as, [["render", ls], ["__scopeId", "data-v-317ae311"]]), cs = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
1122
- <circle cx="12" cy="8" r="4"/>
1123
- <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
1124
- </svg>`, is = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
1125
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
1126
- <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
1127
- </svg>`, us = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
1128
- <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
1129
- <circle cx="12" cy="12" r="3"/>
1130
- </svg>`, ds = `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
1131
- <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/>
1132
- <line x1="1" y1="1" x2="23" y2="23"/>
1133
- </svg>`, hs = { class: "login" }, ps = { class: "login__container" }, _s = { class: "login__header" }, vs = ["src"], fs = { class: "login__title" }, ms = { class: "login__subtitle" }, gs = ["innerHTML"], ys = ["innerHTML"], ws = ["innerHTML"], bs = /* @__PURE__ */ F({
1134
- __name: "index",
1135
- props: {
1136
- logo: {},
1137
- title: {},
1138
- subtitle: {}
1139
- },
1140
- emits: ["success", "error"],
1141
- setup(e, { emit: s }) {
1142
- const t = s, { login: n, loading: o } = ie(), d = N(), l = he({
1143
- uid: "",
1144
- password: ""
1145
- }), r = C(!1), i = {
1146
- uid: [
1147
- { required: !0, message: "请输入账号", trigger: "blur" }
1148
- ],
1149
- password: [
1150
- { required: !0, message: "请输入密码", trigger: "blur" }
1151
- ]
1152
- }, u = C(), p = {
1153
- user: cs,
1154
- lock: is,
1155
- eye: us,
1156
- eyeOff: ds
1157
- }, f = async () => {
1158
- var v;
1159
- try {
1160
- await ((v = u.value) == null ? void 0 : v.validate());
1161
- const _ = await n(l.uid, l.password);
1162
- _.success ? t("success", _.data) : t("error", _.error);
1163
- } catch (_) {
1164
- console.error("登录失败", _), t("error", _);
1165
- }
1166
- };
1167
- return (v, _) => (y(), L("div", hs, [
1168
- a("div", ps, [
1169
- a("div", _s, [
1170
- a("img", {
1171
- src: e.logo || "/vite.svg",
1172
- alt: "Logo",
1173
- class: "login__logo"
1174
- }, null, 8, vs),
1175
- a("h1", fs, T(e.title || h(d).appName), 1),
1176
- a("p", ms, T(e.subtitle || "后台管理系统"), 1)
1177
- ]),
1178
- x(h(ze), {
1179
- ref_key: "formRef",
1180
- ref: u,
1181
- model: l,
1182
- rules: i,
1183
- class: "login__form",
1184
- "label-width": "0"
1185
- }, {
1186
- default: I(() => [
1187
- x(h(ue), { prop: "uid" }, {
1188
- default: I(() => [
1189
- x(h(de), {
1190
- modelValue: l.uid,
1191
- "onUpdate:modelValue": _[0] || (_[0] = (c) => l.uid = c),
1192
- placeholder: "请输入账号",
1193
- size: "large"
1194
- }, {
1195
- prefix: I(() => [
1196
- a("span", {
1197
- class: "login__input-icon",
1198
- innerHTML: p.user
1199
- }, null, 8, gs)
1200
- ]),
1201
- _: 1
1202
- }, 8, ["modelValue"])
1203
- ]),
1204
- _: 1
1205
- }),
1206
- x(h(ue), { prop: "password" }, {
1207
- default: I(() => [
1208
- x(h(de), {
1209
- modelValue: l.password,
1210
- "onUpdate:modelValue": _[2] || (_[2] = (c) => l.password = c),
1211
- type: r.value ? "text" : "password",
1212
- placeholder: "请输入密码",
1213
- size: "large",
1214
- onKeyup: Oe(f, ["enter"])
1215
- }, {
1216
- prefix: I(() => [
1217
- a("span", {
1218
- class: "login__input-icon",
1219
- innerHTML: p.lock
1220
- }, null, 8, ys)
1221
- ]),
1222
- suffix: I(() => [
1223
- a("span", {
1224
- class: "login__input-icon login__input-icon--clickable",
1225
- onClick: _[1] || (_[1] = (c) => r.value = !r.value),
1226
- innerHTML: r.value ? p.eyeOff : p.eye
1227
- }, null, 8, ws)
1228
- ]),
1229
- _: 1
1230
- }, 8, ["modelValue", "type"])
1231
- ]),
1232
- _: 1
1233
- }),
1234
- x(h(ue), null, {
1235
- default: I(() => [
1236
- x(h(ce), {
1237
- type: "primary",
1238
- size: "large",
1239
- loading: h(o),
1240
- class: "login__submit",
1241
- onClick: f
1242
- }, {
1243
- default: I(() => [..._[3] || (_[3] = [
1244
- oe(" 登录 ", -1)
1245
- ])]),
1246
- _: 1
1247
- }, 8, ["loading"])
1248
- ]),
1249
- _: 1
1250
- })
1251
- ]),
1252
- _: 1
1253
- }, 8, ["model"])
1254
- ])
1255
- ]));
1256
- }
1257
- }), Gs = /* @__PURE__ */ A(bs, [["__scopeId", "data-v-a48f4a52"]]), ks = { class: "error-page" }, Cs = { class: "error-page__content" }, Ls = /* @__PURE__ */ F({
1258
- __name: "404",
1259
- setup(e) {
1260
- const s = W(), t = () => {
1261
- s.push("/");
1262
- };
1263
- return (n, o) => (y(), L("div", ks, [
1264
- a("div", Cs, [
1265
- o[1] || (o[1] = a("div", { class: "error-page__code" }, "404", -1)),
1266
- o[2] || (o[2] = a("div", { class: "error-page__title" }, "页面不存在", -1)),
1267
- o[3] || (o[3] = a("div", { class: "error-page__desc" }, "抱歉,您访问的页面不存在或已被删除", -1)),
1268
- x(h(ce), {
1269
- type: "primary",
1270
- onClick: t
1271
- }, {
1272
- default: I(() => [...o[0] || (o[0] = [
1273
- oe("返回首页", -1)
1274
- ])]),
1275
- _: 1
1276
- })
1277
- ])
1278
- ]));
1279
- }
1280
- }), Js = /* @__PURE__ */ A(Ls, [["__scopeId", "data-v-25c06185"]]), xs = { class: "error-page" }, Is = { class: "error-page__content" }, $s = /* @__PURE__ */ F({
1281
- __name: "403",
1282
- setup(e) {
1283
- const s = W(), t = () => {
1284
- s.push("/");
1285
- };
1286
- return (n, o) => (y(), L("div", xs, [
1287
- a("div", Is, [
1288
- o[1] || (o[1] = a("div", { class: "error-page__code" }, "403", -1)),
1289
- o[2] || (o[2] = a("div", { class: "error-page__title" }, "无访问权限", -1)),
1290
- o[3] || (o[3] = a("div", { class: "error-page__desc" }, "抱歉,您没有权限访问此页面", -1)),
1291
- x(h(ce), {
1292
- type: "primary",
1293
- onClick: t
1294
- }, {
1295
- default: I(() => [...o[0] || (o[0] = [
1296
- oe("返回首页", -1)
1297
- ])]),
1298
- _: 1
1299
- })
1300
- ])
1301
- ]));
1302
- }
1303
- }), Xs = /* @__PURE__ */ A($s, [["__scopeId", "data-v-42d7e36e"]]);
1304
- function Qs(e) {
1305
- const s = K(), t = window.location.pathname, o = (s.menuBtnListMap[t] || []).map((d) => d.code);
1306
- return Array.isArray(e) ? e.some((d) => o.includes(d)) : o.includes(e);
1307
- }
1308
- const Ts = ["/login", "/404", "/403"];
1309
- function Zs(e, s) {
1310
- const t = N(), n = ye({
1311
- history: we((s == null ? void 0 : s.base) || ""),
1312
- routes: e,
1313
- scrollBehavior: (s == null ? void 0 : s.scrollBehavior) || (() => ({ left: 0, top: 0 }))
1314
- });
1315
- return n.beforeEach(async (o, d, l) => {
1316
- const r = X();
1317
- if (r.initTheme(), Ie())
1318
- if (o.path === t.loginPath)
1319
- l({ path: t.indexPath || "/" });
1320
- else {
1321
- const { initApp: i, isLoggedIn: u } = ie();
1322
- if (!u.value && !await i()) {
1323
- l(t.loginPath || "/login");
1324
- return;
1325
- }
1326
- o.name && o.meta.keepAlive && r.addCachedView(o.name), l();
1327
- }
1328
- else
1329
- Ts.includes(o.path) ? l() : l({
1330
- path: t.loginPath || "/login",
1331
- query: { redirectUrl: encodeURIComponent(o.fullPath) }
1332
- });
1333
- }), n;
1334
- }
1335
- function en(e, s) {
1336
- const t = ye({
1337
- history: we(),
1338
- routes: s
1339
- });
1340
- e.matcher = t.matcher;
1341
- }
1342
- function tn(e) {
1343
- const s = N();
1344
- return [
1345
- {
1346
- path: (e == null ? void 0 : e.loginPath) || s.loginPath || "/login",
1347
- name: "Login",
1348
- component: e == null ? void 0 : e.loginComponent,
1349
- meta: {
1350
- title: "登录",
1351
- hidden: !0
1352
- }
1353
- },
1354
- {
1355
- path: "/403",
1356
- name: "Forbidden",
1357
- component: e == null ? void 0 : e.forbiddenComponent,
1358
- meta: {
1359
- title: "403",
1360
- hidden: !0
1361
- }
1362
- }
1363
- ];
1364
- }
1365
- function sn(e, s = {}) {
1366
- const t = s.indexPath || "/dashboard", n = [...e];
1367
- return s.notFoundComponent && n.push({
1368
- path: "/:pathMatch(.*)*",
1369
- name: "LayoutNotFound",
1370
- component: s.notFoundComponent,
1371
- meta: {
1372
- title: "404",
1373
- hidden: !0
1374
- }
1375
- }), {
1376
- path: "/",
1377
- name: "Layout",
1378
- component: s.layoutComponent || ts,
1379
- redirect: t,
1380
- children: n
1381
- };
1382
- }
1383
- function nn(e = {}) {
1384
- return [
1385
- {
1386
- path: "/403",
1387
- name: "Forbidden",
1388
- component: e.forbiddenComponent,
1389
- meta: {
1390
- title: "403",
1391
- hidden: !0
1392
- }
1393
- }
1394
- ];
1395
- }
1396
- var Ss = /* @__PURE__ */ ((e) => (e[e.ENABLED = 1] = "ENABLED", e[e.DISABLED = 0] = "DISABLED", e))(Ss || {}), Es = /* @__PURE__ */ ((e) => (e[e.UNKNOWN = 0] = "UNKNOWN", e[e.MALE = 1] = "MALE", e[e.FEMALE = 2] = "FEMALE", e))(Es || {}), Us = /* @__PURE__ */ ((e) => (e[e.DIRECTORY = 0] = "DIRECTORY", e[e.MENU = 1] = "MENU", e[e.BUTTON = 2] = "BUTTON", e))(Us || {});
1397
- const on = {
1398
- 1: "启用",
1399
- 0: "禁用"
1400
- }, an = {
1401
- 0: "未知",
1402
- 1: "男",
1403
- 2: "女"
1404
- }, rn = {
1405
- 0: "目录",
1406
- 1: "菜单",
1407
- 2: "按钮"
1408
- }, ln = [
1409
- {
1410
- label: "启用",
1411
- value: 1
1412
- /* ENABLED */
1413
- },
1414
- {
1415
- label: "禁用",
1416
- value: 0
1417
- /* DISABLED */
1418
- }
1419
- ], cn = [
1420
- {
1421
- label: "未知",
1422
- value: 0
1423
- /* UNKNOWN */
1424
- },
1425
- {
1426
- label: "男",
1427
- value: 1
1428
- /* MALE */
1429
- },
1430
- {
1431
- label: "女",
1432
- value: 2
1433
- /* FEMALE */
1434
- }
1435
- ], un = [
1436
- {
1437
- label: "目录",
1438
- value: 0
1439
- /* DIRECTORY */
1440
- },
1441
- {
1442
- label: "菜单",
1443
- value: 1
1444
- /* MENU */
1445
- },
1446
- {
1447
- label: "按钮",
1448
- value: 2
1449
- /* BUTTON */
1450
- }
1451
- ], dn = {
1452
- mounted(e, s) {
1453
- var i;
1454
- const t = K(), { value: n } = s;
1455
- if (!n) return;
1456
- const o = window.location.pathname, l = (t.menuBtnListMap[o] || []).map((u) => u.code);
1457
- let r = !1;
1458
- Array.isArray(n) ? r = n.some((u) => l.includes(u)) : r = l.includes(n), r || (i = e.parentNode) == null || i.removeChild(e);
1459
- }
1460
- };
1461
- function hn(e) {
1462
- return je(e), Ge(), {
1463
- config: N()
1464
- };
1465
- }
1
+ import { F as s, c as t, G as o, d as r, e as u, H as n, L as i, i as l, M as d, b as p, f as T, g, h as R, S as c, a as k, j as S, T as h, k as U, l as M, m as f, n as m, o as x, p as y, q as b, r as D, s as L, t as A, u as F, v as E, w as G, x as O, y as I, z as P, A as j, B as v, C as w, D as H, E as N, I as X, J as q, K as z, N as B, O as C, P as J, Q as K, R as Q, U as V, V as W, W as Y, X as Z, Y as $, Z as _, $ as ee, a0 as ae, a1 as se, a2 as te, a3 as oe, a4 as re, a5 as ue, a6 as ne, a7 as ie, a8 as le, a9 as de, aa as pe, ab as Te, ac as ge, ad as Re, ae as ce, af as ke, ag as Se, ah as he, ai as Ue, aj as Me, ak as fe, al as me, am as xe } from "./index-CpxpXTQX.js";
1466
2
  export {
1467
- Ys as Footer,
1468
- Xs as Forbidden,
1469
- Es as Gender,
1470
- cn as GenderOptions,
1471
- an as GenderText,
1472
- me as Header,
1473
- ts as Layout,
1474
- Gs as Login,
1475
- Us as MenuType,
1476
- un as MenuTypeOptions,
1477
- rn as MenuTypeText,
1478
- Js as NotFound,
1479
- Ct as SettingDrawer,
1480
- ct as Sidebar,
1481
- Ss as Status,
1482
- ln as StatusOptions,
1483
- on as StatusText,
1484
- Ws as Tabs,
1485
- xe as clearToken,
1486
- nn as createErrorRoutes,
1487
- sn as createLayoutRoute,
1488
- Zs as createRouter,
1489
- tn as createStaticRoutes,
1490
- hn as createXtoApp,
1491
- zs as getCode,
1492
- N as getConfig,
1493
- Fs as getConfigValue,
1494
- Qe as getCurrentUser,
1495
- G as getLoginInfo,
1496
- H as getRequest,
1497
- Le as getToken,
1498
- We as getTokenType,
1499
- Ze as getUserMenu,
1500
- Qs as hasPermission,
1501
- Ie as hasToken,
3
+ s as Footer,
4
+ t as Forbidden,
5
+ o as Gender,
6
+ r as GenderOptions,
7
+ u as GenderText,
8
+ n as Header,
9
+ i as Layout,
10
+ l as Login,
11
+ d as MenuType,
12
+ p as MenuTypeOptions,
13
+ T as MenuTypeText,
14
+ g as NotFound,
15
+ R as Sidebar,
16
+ c as Status,
17
+ k as StatusOptions,
18
+ S as StatusText,
19
+ h as Tabs,
20
+ U as batchDeleteUsers,
21
+ M as clearToken,
22
+ f as createLayoutRoute,
23
+ m as createMenu,
24
+ x as createRole,
25
+ y as createRouter,
26
+ b as createUser,
27
+ D as createXtoApp,
28
+ L as defaultDynamicRoutes,
29
+ A as deleteMenu,
30
+ F as deleteRole,
31
+ E as deleteUser,
32
+ G as errorRoute,
33
+ O as getMenuList,
34
+ I as getMenuTree,
35
+ P as getRefreshToken,
36
+ j as getRoleDetail,
37
+ v as getRoleList,
38
+ w as getToken,
39
+ H as getTokenExpire,
40
+ N as getUserDetail,
41
+ X as getUserInfo,
42
+ q as getUserList,
43
+ z as hasPermission,
44
+ B as hasRole,
45
+ C as hasToken,
1502
46
  J as http,
1503
- k as local,
1504
- Z as localStorageUtil,
1505
- Je as login,
1506
- Hs as loginByCode,
1507
- Xe as logout,
1508
- dn as permissionDirective,
1509
- Ge as resetRequest,
1510
- en as resetRouter,
1511
- Os as session,
1512
- ee as sessionStorageUtil,
1513
- je as setConfig,
1514
- qe as setLoginInfo,
1515
- ie as useApp,
1516
- X as useAppStore,
1517
- js as useAuth,
1518
- Te as useAuthStore,
1519
- Ks as useForm,
1520
- Ee as useMenu,
1521
- K as useMenuStore,
1522
- qs as useTable,
1523
- Se as useUserStore
47
+ K as isAdmin,
48
+ Q as isTokenExpired,
49
+ V as layoutRoute,
50
+ W as local,
51
+ Y as localStorageUtil,
52
+ Z as login,
53
+ $ as logout,
54
+ _ as mockMenuData,
55
+ ee as permissionDirective,
56
+ ae as refreshToken,
57
+ se as resetPassword,
58
+ te as resetRouter,
59
+ oe as router,
60
+ re as session,
61
+ ue as sessionStorageUtil,
62
+ ne as setRefreshToken,
63
+ ie as setToken,
64
+ le as setTokenExpire,
65
+ de as setTokenInfo,
66
+ pe as staticRoutes,
67
+ Te as updateMenu,
68
+ ge as updateRole,
69
+ Re as updateRoleStatus,
70
+ ce as updateUser,
71
+ ke as updateUserStatus,
72
+ Se as useAppStore,
73
+ he as useAuth,
74
+ Ue as useAuthStore,
75
+ Me as useForm,
76
+ fe as useMenuStore,
77
+ me as useTable,
78
+ xe as useUserStore
1524
79
  };