xto-fronted 0.1.0 → 0.1.2

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