@npm.365xs.cn/vue-admin-framework 0.1.0 → 0.2.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.
package/dist/index.js CHANGED
@@ -1,37 +1,85 @@
1
- import { defineComponent as oe, computed as B, resolveComponent as C, openBlock as i, createBlock as T, withCtx as m, createElementBlock as p, Fragment as j, renderList as W, createVNode as v, resolveDynamicComponent as G, createElementVNode as d, toDisplayString as E, createTextVNode as z, ref as q, onMounted as de, watch as re, normalizeClass as X, unref as M, createCommentVNode as L, withModifiers as ke, KeepAlive as xe, nextTick as Te } from "vue";
2
- import { useRoute as fe, useRouter as me } from "vue-router";
3
- import { UserFilled as Se, User as Ce, Tickets as Ae, Key as ae, DataAnalysis as Ee, OfficeBuilding as Me, Menu as Y, Lock as he, List as Ie, Grid as $e, Document as Ue, Connection as se, Avatar as Le, Aim as ie, Setting as Ne, ArrowRight as Ve, ArrowLeft as Oe, Bell as Re, SwitchButton as Fe, Close as Be, MoreFilled as ze, Refresh as He, Loading as Ke } from "@element-plus/icons-vue";
4
- function Z(e) {
5
- return e.flatMap((o) => [
6
- ...o.route ? [o] : [],
7
- ...Z(o.children)
1
+ import { defineComponent as se, computed as z, resolveComponent as x, openBlock as d, createBlock as T, withCtx as v, createElementBlock as A, Fragment as G, renderList as Q, createVNode as w, resolveDynamicComponent as X, createElementVNode as g, toDisplayString as I, createTextVNode as H, ref as R, onMounted as ge, watch as ie, normalizeClass as ee, unref as N, createCommentVNode as B, withModifiers as Ee, KeepAlive as Te, nextTick as xe } from "vue";
2
+ import { useRoute as ve, useRouter as ye } from "vue-router";
3
+ import { UserFilled as Me, User as Ie, Tickets as Ue, Key as le, DataAnalysis as Le, OfficeBuilding as Ne, Menu as te, Lock as pe, List as Re, Grid as $e, Document as Ve, Connection as ce, Avatar as Oe, Aim as ue, Setting as Fe, ArrowRight as De, ArrowLeft as Be, Bell as ze, SwitchButton as qe, Close as Pe, MoreFilled as He, Refresh as je, Loading as Ke } from "@element-plus/icons-vue";
4
+ function ne(e) {
5
+ return e.flatMap((t) => [
6
+ ...t.route ? [t] : [],
7
+ ...ne(t.children)
8
8
  ]);
9
9
  }
10
- function qe(e, o, r = []) {
11
- for (const s of e) {
12
- const t = [...r, s];
13
- if (s.route === o) return t;
14
- const l = qe(s.children, o, t);
15
- if (l.length) return l;
10
+ function Je(e, t, r = []) {
11
+ for (const a of e) {
12
+ const n = [...r, a];
13
+ if (a.route === t) return n;
14
+ const i = Je(a.children, t, n);
15
+ if (i.length) return i;
16
16
  }
17
17
  return [];
18
18
  }
19
- function Rt(e, o) {
20
- return Z(e).find((r) => r.route === o);
19
+ function Wt(e, t) {
20
+ return ne(e).find((r) => r.route === t);
21
21
  }
22
- function ne(e) {
22
+ function ae(e) {
23
23
  return `menu:${e.applicationCode}:${e.menuCode}`;
24
24
  }
25
- function ve(e, o, r = []) {
26
- for (const s of e) {
27
- const t = [...r, s];
28
- if (s === o) return t;
29
- const l = ve(s.children, o, t);
30
- if (l.length) return l;
25
+ function we(e, t, r = []) {
26
+ for (const a of e) {
27
+ const n = [...r, a];
28
+ if (a === t) return n;
29
+ const i = we(a.children, t, n);
30
+ if (i.length) return i;
31
31
  }
32
32
  return [];
33
33
  }
34
- const le = /* @__PURE__ */ oe({
34
+ function be(e) {
35
+ if (!Array.isArray(e)) throw new Error("当前账号菜单响应格式无效。");
36
+ return e.map(We).sort(Ge);
37
+ }
38
+ function Gt(e, t, r, a) {
39
+ if (a.length === 0) return !1;
40
+ const n = new Set(a);
41
+ return _e(e).some((i) => i.applicationCode === t && (r === null || i.menuCode === r) && i.apiCodes.some((l) => n.has(l)));
42
+ }
43
+ function Qt(e) {
44
+ return (t) => {
45
+ if (t.applicationCode === e) return null;
46
+ if (!t.menuDomain || !t.route) return "";
47
+ try {
48
+ const r = new URL(t.menuDomain);
49
+ if (!["http:", "https:"].includes(r.protocol) || !r.hostname || r.username || r.password || r.pathname !== "/" || r.search || r.hash || r.origin !== t.menuDomain.replace(/\/$/, "") || !t.route.startsWith("/") || t.route.startsWith("//") || /[\\?#]/.test(t.route) || Array.from(t.route).some((n) => {
50
+ const i = n.charCodeAt(0);
51
+ return i < 32 || i === 127;
52
+ })) return "";
53
+ const a = new URL(t.route, r.origin);
54
+ return a.origin === r.origin ? a.href : "";
55
+ } catch {
56
+ return "";
57
+ }
58
+ };
59
+ }
60
+ function We(e) {
61
+ if (!e || typeof e != "object") throw new Error("当前账号菜单节点格式无效。");
62
+ const t = e;
63
+ if (typeof t.applicationCode != "string" || typeof t.menuCode != "string" || typeof t.name != "string") throw new Error("当前账号菜单节点缺少应用编码、菜单编码或名称。");
64
+ return {
65
+ applicationCode: t.applicationCode,
66
+ menuDomain: typeof t.menuDomain == "string" && t.menuDomain ? t.menuDomain : null,
67
+ menuCode: t.menuCode,
68
+ name: t.name,
69
+ route: typeof t.route == "string" && t.route ? t.route : null,
70
+ icon: typeof t.icon == "string" && t.icon ? t.icon : null,
71
+ sortOrder: typeof t.sortOrder == "number" && Number.isFinite(t.sortOrder) ? t.sortOrder : 0,
72
+ apiCodes: Array.isArray(t.apiCodes) ? t.apiCodes.filter((r) => typeof r == "string") : [],
73
+ children: be(t.children || [])
74
+ };
75
+ }
76
+ function _e(e) {
77
+ return e.flatMap((t) => [t, ..._e(t.children)]);
78
+ }
79
+ function Ge(e, t) {
80
+ return e.applicationCode.localeCompare(t.applicationCode) || e.sortOrder - t.sortOrder || e.menuCode.localeCompare(t.menuCode);
81
+ }
82
+ const de = /* @__PURE__ */ se({
35
83
  name: "FrameworkMenuItem",
36
84
  __name: "FrameworkMenuItem",
37
85
  props: {
@@ -39,79 +87,79 @@ const le = /* @__PURE__ */ oe({
39
87
  resolveExternalMenuHref: { type: Function }
40
88
  },
41
89
  setup(e) {
42
- const o = e, r = {
43
- api: se,
44
- avatar: Le,
45
- connection: se,
46
- document: Ue,
90
+ const t = e, r = {
91
+ api: ce,
92
+ avatar: Oe,
93
+ connection: ce,
94
+ document: Ve,
47
95
  grid: $e,
48
- key: ae,
49
- list: Ie,
50
- lock: he,
51
- menu: Y,
52
- "office-building": Me,
53
- overview: Ee,
54
- shield: ae,
55
- tickets: Ae,
56
- user: Ce,
57
- users: Se
58
- }, s = B(() => {
59
- const u = o.item.icon?.toLowerCase();
60
- return u ? r[u] || Y : Y;
61
- }), t = B(() => ne(o.item)), l = B(() => o.resolveExternalMenuHref?.(o.item) ?? null);
62
- return (u, f) => {
63
- const c = C("el-icon"), b = C("FrameworkMenuItem", !0), h = C("el-sub-menu"), k = C("el-menu-item");
64
- return e.item.children.length ? (i(), T(h, {
96
+ key: le,
97
+ list: Re,
98
+ lock: pe,
99
+ menu: te,
100
+ "office-building": Ne,
101
+ overview: Le,
102
+ shield: le,
103
+ tickets: Ue,
104
+ user: Ie,
105
+ users: Me
106
+ }, a = z(() => {
107
+ const l = t.item.icon?.toLowerCase();
108
+ return l ? r[l] || te : te;
109
+ }), n = z(() => ae(t.item)), i = z(() => t.resolveExternalMenuHref?.(t.item) ?? null);
110
+ return (l, c) => {
111
+ const u = x("el-icon"), m = x("FrameworkMenuItem", !0), f = x("el-sub-menu"), k = x("el-menu-item");
112
+ return e.item.children.length ? (d(), T(f, {
65
113
  key: 0,
66
- index: t.value
114
+ index: n.value
67
115
  }, {
68
- title: m(() => [
69
- v(c, null, {
70
- default: m(() => [
71
- (i(), T(G(s.value)))
116
+ title: v(() => [
117
+ w(u, null, {
118
+ default: v(() => [
119
+ (d(), T(X(a.value)))
72
120
  ]),
73
121
  _: 1
74
122
  }),
75
- d("span", null, E(e.item.name), 1)
123
+ g("span", null, I(e.item.name), 1)
76
124
  ]),
77
- default: m(() => [
78
- (i(!0), p(j, null, W(e.item.children, (_) => (i(), T(b, {
125
+ default: v(() => [
126
+ (d(!0), A(G, null, Q(e.item.children, (_) => (d(), T(m, {
79
127
  key: `${_.applicationCode}:${_.menuCode}`,
80
128
  item: _,
81
129
  "resolve-external-menu-href": e.resolveExternalMenuHref
82
130
  }, null, 8, ["item", "resolve-external-menu-href"]))), 128))
83
131
  ]),
84
132
  _: 1
85
- }, 8, ["index"])) : e.item.route ? (i(), T(k, {
133
+ }, 8, ["index"])) : e.item.route ? (d(), T(k, {
86
134
  key: 1,
87
- index: t.value,
88
- disabled: l.value === "",
89
- title: l.value === "" ? "跨应用菜单缺少有效域名或路径" : l.value || void 0
135
+ index: n.value,
136
+ disabled: i.value === "",
137
+ title: i.value === "" ? "跨应用菜单缺少有效域名或路径" : i.value || void 0
90
138
  }, {
91
- title: m(() => [
92
- z(E(e.item.name), 1)
139
+ title: v(() => [
140
+ H(I(e.item.name), 1)
93
141
  ]),
94
- default: m(() => [
95
- v(c, null, {
96
- default: m(() => [
97
- (i(), T(G(s.value)))
142
+ default: v(() => [
143
+ w(u, null, {
144
+ default: v(() => [
145
+ (d(), T(X(a.value)))
98
146
  ]),
99
147
  _: 1
100
148
  })
101
149
  ]),
102
150
  _: 1
103
- }, 8, ["index", "disabled", "title"])) : (i(), T(k, {
151
+ }, 8, ["index", "disabled", "title"])) : (d(), T(k, {
104
152
  key: 2,
105
- index: t.value,
153
+ index: n.value,
106
154
  disabled: ""
107
155
  }, {
108
- title: m(() => [
109
- z(E(e.item.name), 1)
156
+ title: v(() => [
157
+ H(I(e.item.name), 1)
110
158
  ]),
111
- default: m(() => [
112
- v(c, null, {
113
- default: m(() => [
114
- (i(), T(G(s.value)))
159
+ default: v(() => [
160
+ w(u, null, {
161
+ default: v(() => [
162
+ (d(), T(X(a.value)))
115
163
  ]),
116
164
  _: 1
117
165
  })
@@ -121,50 +169,50 @@ const le = /* @__PURE__ */ oe({
121
169
  };
122
170
  }
123
171
  });
124
- function ee(e) {
172
+ function re(e) {
125
173
  if (!Array.isArray(e)) return [];
126
- const o = /* @__PURE__ */ new Set();
174
+ const t = /* @__PURE__ */ new Set();
127
175
  return e.flatMap((r) => {
128
176
  if (!r || typeof r != "object") return [];
129
- const s = "path" in r && typeof r.path == "string" ? r.path : "", t = "title" in r && typeof r.title == "string" ? r.title : "";
130
- return !je(s) || !t.trim() || o.has(s) ? [] : (o.add(s), [{ path: s, title: t.trim() }]);
177
+ const a = "path" in r && typeof r.path == "string" ? r.path : "", n = "title" in r && typeof r.title == "string" ? r.title : "";
178
+ return !Ze(a) || !n.trim() || t.has(a) ? [] : (t.add(a), [{ path: a, title: n.trim() }]);
131
179
  });
132
180
  }
133
- function Pe(e, o, r) {
134
- const s = ee(e), t = s.findIndex((f) => f.path === o.path), l = t >= 0 ? s.map((f, c) => c === t ? o : f) : [...s, o], u = Math.max(1, r);
135
- for (; l.length > u; ) {
136
- const f = l.findIndex((c) => c.path !== o.path);
137
- if (f < 0) break;
138
- l.splice(f, 1);
139
- }
140
- return l;
141
- }
142
- function De(e, o, r) {
143
- const s = ee(e), t = s.findIndex((f) => f.path === o);
144
- if (t < 0 || s.length <= 1)
145
- return { tabs: s, navigateTo: null };
146
- const l = s.filter((f) => f.path !== o);
147
- if (o !== r) return { tabs: l, navigateTo: null };
148
- const u = l[Math.min(t, l.length - 1)];
149
- return { tabs: l, navigateTo: u?.path || null };
150
- }
151
- function Je(e, o) {
152
- const r = ee(e).find((s) => s.path === o);
181
+ function Qe(e, t, r) {
182
+ const a = re(e), n = a.findIndex((c) => c.path === t.path), i = n >= 0 ? a.map((c, u) => u === n ? t : c) : [...a, t], l = Math.max(1, r);
183
+ for (; i.length > l; ) {
184
+ const c = i.findIndex((u) => u.path !== t.path);
185
+ if (c < 0) break;
186
+ i.splice(c, 1);
187
+ }
188
+ return i;
189
+ }
190
+ function Xe(e, t, r) {
191
+ const a = re(e), n = a.findIndex((c) => c.path === t);
192
+ if (n < 0 || a.length <= 1)
193
+ return { tabs: a, navigateTo: null };
194
+ const i = a.filter((c) => c.path !== t);
195
+ if (t !== r) return { tabs: i, navigateTo: null };
196
+ const l = i[Math.min(n, i.length - 1)];
197
+ return { tabs: i, navigateTo: l?.path || null };
198
+ }
199
+ function Ye(e, t) {
200
+ const r = re(e).find((a) => a.path === t);
153
201
  return r ? [r] : [];
154
202
  }
155
- function je(e) {
203
+ function Ze(e) {
156
204
  return e.startsWith("/") && !e.startsWith("//");
157
205
  }
158
- const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-brand-mark" }, Qe = { key: 0 }, Xe = { key: 0 }, Ye = { class: "saf-sidebar-nav" }, Ze = { key: 0 }, et = ["title"], tt = { key: 2 }, nt = { class: "saf-sidebar-footer" }, ot = { key: 0 }, rt = ["title"], at = { key: 0 }, st = { class: "saf-main-shell" }, it = { class: "saf-topbar" }, lt = { class: "saf-topbar-context" }, ct = { class: "saf-topbar-actions" }, ut = {
206
+ const et = { class: "saf-sidebar saf-desktop-sidebar" }, tt = { class: "saf-brand-mark" }, nt = { key: 0 }, rt = { key: 0 }, ot = { class: "saf-sidebar-nav" }, at = { key: 0 }, st = ["title"], it = { key: 2 }, lt = { class: "saf-sidebar-footer" }, ct = { key: 0 }, ut = ["title"], dt = { key: 0 }, ft = { class: "saf-main-shell" }, mt = { class: "saf-topbar" }, ht = { class: "saf-topbar-context" }, gt = { class: "saf-topbar-actions" }, vt = {
159
207
  key: 1,
160
208
  class: "saf-topbar-divider"
161
- }, dt = { class: "saf-operator" }, ft = { class: "saf-page-tabs" }, mt = { class: "saf-page-tabs__scroller" }, ht = ["onClick"], vt = { class: "saf-content-frame" }, gt = { class: "saf-workspace" }, wt = {
209
+ }, yt = { class: "saf-operator" }, pt = { class: "saf-page-tabs" }, wt = { class: "saf-page-tabs__scroller" }, bt = ["onClick"], _t = { class: "saf-content-frame" }, kt = { class: "saf-workspace" }, Ct = {
162
210
  key: 0,
163
211
  class: "saf-route-breadcrumbs"
164
- }, yt = { class: "saf-sidebar saf-mobile-sidebar" }, pt = { class: "saf-brand" }, bt = { class: "saf-brand-mark" }, _t = { key: 0 }, kt = { class: "saf-sidebar-nav" }, xt = {
212
+ }, At = { class: "saf-sidebar saf-mobile-sidebar" }, St = { class: "saf-brand" }, Et = { class: "saf-brand-mark" }, Tt = { key: 0 }, xt = { class: "saf-sidebar-nav" }, Mt = {
165
213
  key: 1,
166
214
  class: "saf-nav-feedback"
167
- }, Tt = /* @__PURE__ */ oe({
215
+ }, It = /* @__PURE__ */ se({
168
216
  __name: "AdminFrameworkLayout",
169
217
  props: {
170
218
  brandName: {},
@@ -183,35 +231,35 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
183
231
  showNotifications: { type: Boolean, default: !0 }
184
232
  },
185
233
  emits: ["logout", "settings", "notifications"],
186
- setup(e, { emit: o }) {
187
- const r = e, s = o, t = fe(), l = me(), u = q(!1), f = q(!1), c = q([]), b = q({}), h = q(!0), k = B(() => new Map(
188
- Z(r.menus).map((n) => [ne(n), n])
189
- )), _ = B(() => Z(r.menus).find(
190
- (n) => n.route === t.path && (r.resolveExternalMenuHref?.(n) ?? null) === null
191
- )), S = B(() => _.value ? ne(_.value) : ""), A = B(
192
- () => _.value ? ve(r.menus, _.value) : []
193
- ), R = B(
194
- () => _.value?.name || String(t.meta.title || r.consoleName)
195
- ), F = B(
196
- () => `${t.path}:${b.value[t.path] || 0}`
234
+ setup(e, { emit: t }) {
235
+ const r = e, a = t, n = ve(), i = ye(), l = R(!1), c = R(!1), u = R([]), m = R({}), f = R(!0), k = z(() => new Map(
236
+ ne(r.menus).map((o) => [ae(o), o])
237
+ )), _ = z(() => ne(r.menus).find(
238
+ (o) => o.route === n.path && (r.resolveExternalMenuHref?.(o) ?? null) === null
239
+ )), C = z(() => _.value ? ae(_.value) : ""), S = z(
240
+ () => _.value ? we(r.menus, _.value) : []
241
+ ), $ = z(
242
+ () => _.value?.name || String(n.meta.title || r.consoleName)
243
+ ), F = z(
244
+ () => `${n.path}:${m.value[n.path] || 0}`
197
245
  );
198
- de(() => {
199
- c.value = H(), y();
200
- }), re(
201
- () => [t.path, t.meta.title, r.menus],
246
+ ge(() => {
247
+ u.value = D(), y();
248
+ }), ie(
249
+ () => [n.path, n.meta.title, r.menus],
202
250
  y,
203
251
  { deep: !0 }
204
- ), re(
205
- c,
206
- (n) => {
207
- typeof window < "u" && window.sessionStorage.setItem(r.tabStorageKey, JSON.stringify(n));
252
+ ), ie(
253
+ u,
254
+ (o) => {
255
+ typeof window < "u" && window.sessionStorage.setItem(r.tabStorageKey, JSON.stringify(o));
208
256
  },
209
257
  { deep: !0 }
210
258
  );
211
- function H() {
259
+ function D() {
212
260
  if (typeof window > "u") return [];
213
261
  try {
214
- return ee(
262
+ return re(
215
263
  JSON.parse(window.sessionStorage.getItem(r.tabStorageKey) || "[]")
216
264
  );
217
265
  } catch {
@@ -219,226 +267,226 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
219
267
  }
220
268
  }
221
269
  function y() {
222
- t.name !== "oauth-callback" && (c.value = Pe(
223
- c.value,
224
- { path: t.path, title: R.value },
270
+ n.name !== "oauth-callback" && (u.value = Qe(
271
+ u.value,
272
+ { path: n.path, title: $.value },
225
273
  r.maxTabs
226
274
  ));
227
275
  }
228
- async function U(n) {
229
- const a = k.value.get(n);
230
- if (!a?.route) return;
231
- const g = r.resolveExternalMenuHref?.(a) ?? null;
232
- if (g !== null) {
233
- g && window.location.assign(g), f.value = !1;
276
+ async function U(o) {
277
+ const s = k.value.get(o);
278
+ if (!s?.route) return;
279
+ const h = r.resolveExternalMenuHref?.(s) ?? null;
280
+ if (h !== null) {
281
+ h && window.location.assign(h), c.value = !1;
234
282
  return;
235
283
  }
236
- await N(a.route);
284
+ await V(s.route);
237
285
  }
238
- async function N(n) {
239
- n !== t.path && await l.push(n), f.value = !1;
286
+ async function V(o) {
287
+ o !== n.path && await i.push(o), c.value = !1;
240
288
  }
241
- async function I(n) {
242
- const a = De(c.value, n, t.path);
243
- c.value = a.tabs, a.navigateTo && await l.push(a.navigateTo);
289
+ async function M(o) {
290
+ const s = Xe(u.value, o, n.path);
291
+ u.value = s.tabs, s.navigateTo && await i.push(s.navigateTo);
244
292
  }
245
- function V() {
246
- c.value = Je(c.value, t.path);
293
+ function O() {
294
+ u.value = Ye(u.value, n.path);
247
295
  }
248
- function K() {
249
- V();
296
+ function p() {
297
+ O();
250
298
  }
251
- async function D() {
252
- h.value = !1, b.value = {
253
- ...b.value,
254
- [t.path]: (b.value[t.path] || 0) + 1
255
- }, await Te(), h.value = !0;
299
+ async function q() {
300
+ f.value = !1, m.value = {
301
+ ...m.value,
302
+ [n.path]: (m.value[n.path] || 0) + 1
303
+ }, await xe(), f.value = !0;
256
304
  }
257
- function te() {
258
- c.value = [], typeof window < "u" && window.sessionStorage.removeItem(r.tabStorageKey), s("logout");
305
+ function W() {
306
+ u.value = [], typeof window < "u" && window.sessionStorage.removeItem(r.tabStorageKey), a("logout");
259
307
  }
260
- return (n, a) => {
261
- const g = C("el-icon"), x = C("el-menu"), $ = C("el-button"), P = C("el-avatar"), J = C("el-dropdown-item"), Q = C("el-dropdown-menu"), ye = C("el-dropdown"), pe = C("RouterView"), be = C("el-drawer");
262
- return i(), p("div", {
263
- class: X(["saf-shell", { "saf-shell--collapsed": u.value }])
308
+ return (o, s) => {
309
+ const h = x("el-icon"), E = x("el-menu"), L = x("el-button"), K = x("el-avatar"), J = x("el-dropdown-item"), oe = x("el-dropdown-menu"), Y = x("el-dropdown"), Z = x("RouterView"), Ae = x("el-drawer");
310
+ return d(), A("div", {
311
+ class: ee(["saf-shell", { "saf-shell--collapsed": l.value }])
264
312
  }, [
265
- d("aside", We, [
266
- d("div", {
267
- class: X(["saf-brand", { "saf-brand--compact": u.value }])
313
+ g("aside", et, [
314
+ g("div", {
315
+ class: ee(["saf-brand", { "saf-brand--compact": l.value }])
268
316
  }, [
269
- d("span", Ge, [
270
- v(g, null, {
271
- default: m(() => [
272
- v(M(ie))
317
+ g("span", tt, [
318
+ w(h, null, {
319
+ default: v(() => [
320
+ w(N(ue))
273
321
  ]),
274
322
  _: 1
275
323
  })
276
324
  ]),
277
- u.value ? L("", !0) : (i(), p("div", Qe, [
278
- d("strong", null, E(e.brandName), 1),
279
- e.brandSubtitle ? (i(), p("small", Xe, E(e.brandSubtitle), 1)) : L("", !0)
325
+ l.value ? B("", !0) : (d(), A("div", nt, [
326
+ g("strong", null, I(e.brandName), 1),
327
+ e.brandSubtitle ? (d(), A("small", rt, I(e.brandSubtitle), 1)) : B("", !0)
280
328
  ]))
281
329
  ], 2),
282
- d("nav", Ye, [
283
- e.menus.length ? (i(), T(x, {
330
+ g("nav", ot, [
331
+ e.menus.length ? (d(), T(E, {
284
332
  key: 0,
285
- "default-active": S.value,
286
- collapse: u.value,
333
+ "default-active": C.value,
334
+ collapse: l.value,
287
335
  "collapse-transition": !1,
288
336
  onSelect: U
289
337
  }, {
290
- default: m(() => [
291
- (i(!0), p(j, null, W(e.menus, (w) => (i(), T(le, {
292
- key: `${w.applicationCode}:${w.menuCode}`,
293
- item: w,
338
+ default: v(() => [
339
+ (d(!0), A(G, null, Q(e.menus, (b) => (d(), T(de, {
340
+ key: `${b.applicationCode}:${b.menuCode}`,
341
+ item: b,
294
342
  "resolve-external-menu-href": e.resolveExternalMenuHref
295
343
  }, null, 8, ["item", "resolve-external-menu-href"]))), 128))
296
344
  ]),
297
345
  _: 1
298
- }, 8, ["default-active", "collapse"])) : (i(), p("div", {
346
+ }, 8, ["default-active", "collapse"])) : (d(), A("div", {
299
347
  key: 1,
300
- class: X(["saf-nav-feedback", { "saf-nav-feedback--compact": u.value }])
348
+ class: ee(["saf-nav-feedback", { "saf-nav-feedback--compact": l.value }])
301
349
  }, [
302
- e.navigationLoaded ? e.navigationError ? (i(), p("span", {
350
+ e.navigationLoaded ? e.navigationError ? (d(), A("span", {
303
351
  key: 1,
304
352
  title: e.navigationError
305
- }, "菜单加载失败", 8, et)) : (i(), p("span", tt, "当前账号暂无菜单")) : (i(), p("span", Ze, "正在加载菜单..."))
353
+ }, "菜单加载失败", 8, st)) : (d(), A("span", it, "当前账号暂无菜单")) : (d(), A("span", at, "正在加载菜单..."))
306
354
  ], 2))
307
355
  ]),
308
- d("div", nt, [
309
- e.showSettings ? (i(), p("button", {
356
+ g("div", lt, [
357
+ e.showSettings ? (d(), A("button", {
310
358
  key: 0,
311
359
  type: "button",
312
360
  title: "系统设置",
313
- onClick: a[0] || (a[0] = (w) => s("settings"))
361
+ onClick: s[0] || (s[0] = (b) => a("settings"))
314
362
  }, [
315
- v(g, null, {
316
- default: m(() => [
317
- v(M(Ne))
363
+ w(h, null, {
364
+ default: v(() => [
365
+ w(N(Fe))
318
366
  ]),
319
367
  _: 1
320
368
  }),
321
- u.value ? L("", !0) : (i(), p("span", ot, "系统设置"))
322
- ])) : L("", !0),
323
- d("button", {
369
+ l.value ? B("", !0) : (d(), A("span", ct, "系统设置"))
370
+ ])) : B("", !0),
371
+ g("button", {
324
372
  type: "button",
325
- title: u.value ? "展开侧栏" : "收起侧栏",
326
- onClick: a[1] || (a[1] = (w) => u.value = !u.value)
373
+ title: l.value ? "展开侧栏" : "收起侧栏",
374
+ onClick: s[1] || (s[1] = (b) => l.value = !l.value)
327
375
  }, [
328
- v(g, null, {
329
- default: m(() => [
330
- (i(), T(G(u.value ? M(Ve) : M(Oe))))
376
+ w(h, null, {
377
+ default: v(() => [
378
+ (d(), T(X(l.value ? N(De) : N(Be))))
331
379
  ]),
332
380
  _: 1
333
381
  }),
334
- u.value ? L("", !0) : (i(), p("span", at, "收起侧栏"))
335
- ], 8, rt)
382
+ l.value ? B("", !0) : (d(), A("span", dt, "收起侧栏"))
383
+ ], 8, ut)
336
384
  ])
337
385
  ]),
338
- d("div", st, [
339
- d("header", it, [
340
- v($, {
386
+ g("div", ft, [
387
+ g("header", mt, [
388
+ w(L, {
341
389
  class: "saf-mobile-menu-button",
342
390
  text: "",
343
391
  circle: "",
344
- icon: M(Y),
392
+ icon: N(te),
345
393
  "aria-label": "打开导航",
346
- onClick: a[2] || (a[2] = (w) => f.value = !0)
394
+ onClick: s[2] || (s[2] = (b) => c.value = !0)
347
395
  }, null, 8, ["icon"]),
348
- d("div", lt, [
349
- d("span", null, [
350
- v(g, null, {
351
- default: m(() => [
352
- v(M(he))
396
+ g("div", ht, [
397
+ g("span", null, [
398
+ w(h, null, {
399
+ default: v(() => [
400
+ w(N(pe))
353
401
  ]),
354
402
  _: 1
355
403
  }),
356
- z(E(e.consoleName), 1)
404
+ H(I(e.consoleName), 1)
357
405
  ]),
358
- a[5] || (a[5] = d("i", null, null, -1)),
359
- d("strong", null, E(R.value), 1)
406
+ s[5] || (s[5] = g("i", null, null, -1)),
407
+ g("strong", null, I($.value), 1)
360
408
  ]),
361
- d("div", ct, [
362
- e.showNotifications ? (i(), T($, {
409
+ g("div", gt, [
410
+ e.showNotifications ? (d(), T(L, {
363
411
  key: 0,
364
412
  text: "",
365
413
  circle: "",
366
- icon: M(Re),
414
+ icon: N(ze),
367
415
  "aria-label": "通知",
368
- onClick: a[3] || (a[3] = (w) => s("notifications"))
369
- }, null, 8, ["icon"])) : L("", !0),
370
- e.showNotifications ? (i(), p("i", ut)) : L("", !0),
371
- v(P, { size: 30 }, {
372
- default: m(() => [
373
- z(E(e.initials), 1)
416
+ onClick: s[3] || (s[3] = (b) => a("notifications"))
417
+ }, null, 8, ["icon"])) : B("", !0),
418
+ e.showNotifications ? (d(), A("i", vt)) : B("", !0),
419
+ w(K, { size: 30 }, {
420
+ default: v(() => [
421
+ H(I(e.initials), 1)
374
422
  ]),
375
423
  _: 1
376
424
  }),
377
- d("div", dt, [
378
- d("strong", null, E(e.username), 1),
379
- d("span", null, E(e.loginAccount), 1)
425
+ g("div", yt, [
426
+ g("strong", null, I(e.username), 1),
427
+ g("span", null, I(e.loginAccount), 1)
380
428
  ]),
381
- v($, {
429
+ w(L, {
382
430
  text: "",
383
431
  circle: "",
384
- icon: M(Fe),
432
+ icon: N(qe),
385
433
  "aria-label": "退出登录",
386
434
  title: "退出登录",
387
- onClick: te
435
+ onClick: W
388
436
  }, null, 8, ["icon"])
389
437
  ])
390
438
  ]),
391
- d("div", ft, [
392
- d("div", mt, [
393
- (i(!0), p(j, null, W(c.value, (w) => (i(), p("button", {
394
- key: w.path,
439
+ g("div", pt, [
440
+ g("div", wt, [
441
+ (d(!0), A(G, null, Q(u.value, (b) => (d(), A("button", {
442
+ key: b.path,
395
443
  type: "button",
396
- class: X(["saf-page-tab", { "saf-page-tab--active": M(t).path === w.path }]),
397
- onClick: (_e) => N(w.path)
444
+ class: ee(["saf-page-tab", { "saf-page-tab--active": N(n).path === b.path }]),
445
+ onClick: (Se) => V(b.path)
398
446
  }, [
399
- d("span", null, E(w.title), 1),
400
- c.value.length > 1 ? (i(), T(g, {
447
+ g("span", null, I(b.title), 1),
448
+ u.value.length > 1 ? (d(), T(h, {
401
449
  key: 0,
402
450
  class: "saf-page-tab__close",
403
451
  title: "关闭",
404
- onClick: ke((_e) => I(w.path), ["stop"])
452
+ onClick: Ee((Se) => M(b.path), ["stop"])
405
453
  }, {
406
- default: m(() => [
407
- v(M(Be))
454
+ default: v(() => [
455
+ w(N(Pe))
408
456
  ]),
409
457
  _: 1
410
- }, 8, ["onClick"])) : L("", !0)
411
- ], 10, ht))), 128))
458
+ }, 8, ["onClick"])) : B("", !0)
459
+ ], 10, bt))), 128))
412
460
  ]),
413
- v(ye, { trigger: "click" }, {
414
- dropdown: m(() => [
415
- v(Q, null, {
416
- default: m(() => [
417
- v(J, {
418
- icon: M(He),
419
- onClick: D
461
+ w(Y, { trigger: "click" }, {
462
+ dropdown: v(() => [
463
+ w(oe, null, {
464
+ default: v(() => [
465
+ w(J, {
466
+ icon: N(je),
467
+ onClick: q
420
468
  }, {
421
- default: m(() => [...a[6] || (a[6] = [
422
- z(" 刷新当前 ", -1)
469
+ default: v(() => [...s[6] || (s[6] = [
470
+ H(" 刷新当前 ", -1)
423
471
  ])]),
424
472
  _: 1
425
473
  }, 8, ["icon"]),
426
- v(J, {
427
- disabled: c.value.length <= 1,
428
- onClick: V
474
+ w(J, {
475
+ disabled: u.value.length <= 1,
476
+ onClick: O
429
477
  }, {
430
- default: m(() => [...a[7] || (a[7] = [
431
- z(" 关闭其他 ", -1)
478
+ default: v(() => [...s[7] || (s[7] = [
479
+ H(" 关闭其他 ", -1)
432
480
  ])]),
433
481
  _: 1
434
482
  }, 8, ["disabled"]),
435
- v(J, {
436
- disabled: c.value.length <= 1,
483
+ w(J, {
484
+ disabled: u.value.length <= 1,
437
485
  divided: "",
438
- onClick: K
486
+ onClick: p
439
487
  }, {
440
- default: m(() => [...a[8] || (a[8] = [
441
- z(" 关闭全部 ", -1)
488
+ default: v(() => [...s[8] || (s[8] = [
489
+ H(" 关闭全部 ", -1)
442
490
  ])]),
443
491
  _: 1
444
492
  }, 8, ["disabled"])
@@ -446,28 +494,28 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
446
494
  _: 1
447
495
  })
448
496
  ]),
449
- default: m(() => [
450
- v($, {
497
+ default: v(() => [
498
+ w(L, {
451
499
  class: "saf-tab-menu-button",
452
500
  text: "",
453
- icon: M(ze),
501
+ icon: N(He),
454
502
  "aria-label": "页签操作"
455
503
  }, null, 8, ["icon"])
456
504
  ]),
457
505
  _: 1
458
506
  })
459
507
  ]),
460
- d("div", vt, [
461
- d("main", gt, [
462
- A.value.length > 1 ? (i(), p("div", wt, [
463
- (i(!0), p(j, null, W(A.value, (w) => (i(), p("span", {
464
- key: `${w.applicationCode}:${w.menuCode}`
465
- }, E(w.name), 1))), 128))
466
- ])) : L("", !0),
467
- v(pe, null, {
468
- default: m(({ Component: w }) => [
469
- (i(), T(xe, { max: e.maxTabs }, [
470
- h.value ? (i(), T(G(w), { key: F.value })) : L("", !0)
508
+ g("div", _t, [
509
+ g("main", kt, [
510
+ S.value.length > 1 ? (d(), A("div", Ct, [
511
+ (d(!0), A(G, null, Q(S.value, (b) => (d(), A("span", {
512
+ key: `${b.applicationCode}:${b.menuCode}`
513
+ }, I(b.name), 1))), 128))
514
+ ])) : B("", !0),
515
+ w(Z, null, {
516
+ default: v(({ Component: b }) => [
517
+ (d(), T(Te, { max: e.maxTabs }, [
518
+ f.value ? (d(), T(X(b), { key: F.value })) : B("", !0)
471
519
  ], 1032, ["max"]))
472
520
  ]),
473
521
  _: 1
@@ -475,45 +523,45 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
475
523
  ])
476
524
  ])
477
525
  ]),
478
- v(be, {
479
- modelValue: f.value,
480
- "onUpdate:modelValue": a[4] || (a[4] = (w) => f.value = w),
526
+ w(Ae, {
527
+ modelValue: c.value,
528
+ "onUpdate:modelValue": s[4] || (s[4] = (b) => c.value = b),
481
529
  direction: "ltr",
482
530
  size: "248px",
483
531
  "with-header": !1,
484
532
  class: "saf-mobile-nav-drawer"
485
533
  }, {
486
- default: m(() => [
487
- d("aside", yt, [
488
- d("div", pt, [
489
- d("span", bt, [
490
- v(g, null, {
491
- default: m(() => [
492
- v(M(ie))
534
+ default: v(() => [
535
+ g("aside", At, [
536
+ g("div", St, [
537
+ g("span", Et, [
538
+ w(h, null, {
539
+ default: v(() => [
540
+ w(N(ue))
493
541
  ]),
494
542
  _: 1
495
543
  })
496
544
  ]),
497
- d("div", null, [
498
- d("strong", null, E(e.brandName), 1),
499
- e.brandSubtitle ? (i(), p("small", _t, E(e.brandSubtitle), 1)) : L("", !0)
545
+ g("div", null, [
546
+ g("strong", null, I(e.brandName), 1),
547
+ e.brandSubtitle ? (d(), A("small", Tt, I(e.brandSubtitle), 1)) : B("", !0)
500
548
  ])
501
549
  ]),
502
- d("nav", kt, [
503
- e.menus.length ? (i(), T(x, {
550
+ g("nav", xt, [
551
+ e.menus.length ? (d(), T(E, {
504
552
  key: 0,
505
- "default-active": S.value,
553
+ "default-active": C.value,
506
554
  onSelect: U
507
555
  }, {
508
- default: m(() => [
509
- (i(!0), p(j, null, W(e.menus, (w) => (i(), T(le, {
510
- key: `${w.applicationCode}:${w.menuCode}`,
511
- item: w,
556
+ default: v(() => [
557
+ (d(!0), A(G, null, Q(e.menus, (b) => (d(), T(de, {
558
+ key: `${b.applicationCode}:${b.menuCode}`,
559
+ item: b,
512
560
  "resolve-external-menu-href": e.resolveExternalMenuHref
513
561
  }, null, 8, ["item", "resolve-external-menu-href"]))), 128))
514
562
  ]),
515
563
  _: 1
516
- }, 8, ["default-active"])) : (i(), p("div", xt, E(e.navigationError || "当前账号暂无菜单"), 1))
564
+ }, 8, ["default-active"])) : (d(), A("div", Mt, I(e.navigationError || "当前账号暂无菜单"), 1))
517
565
  ])
518
566
  ])
519
567
  ]),
@@ -522,81 +570,176 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
522
570
  ], 2);
523
571
  };
524
572
  }
525
- }), ge = (e, o) => {
573
+ }), ke = (e, t) => {
526
574
  const r = e.__vccOpts || e;
527
- for (const [s, t] of o)
528
- r[s] = t;
575
+ for (const [a, n] of t)
576
+ r[a] = n;
529
577
  return r;
530
- }, Ft = /* @__PURE__ */ ge(Tt, [["__scopeId", "data-v-6ef4786f"]]), St = { class: "saf-oauth-callback" }, Ct = {
578
+ }, Xt = /* @__PURE__ */ ke(It, [["__scopeId", "data-v-6ef4786f"]]), Ut = { class: "saf-oauth-callback" }, Lt = {
531
579
  key: 1,
532
580
  class: "saf-oauth-loading"
533
- }, At = /* @__PURE__ */ oe({
581
+ }, Nt = /* @__PURE__ */ se({
534
582
  __name: "OAuthCallbackView",
535
583
  props: {
536
584
  client: {},
537
585
  retryPath: { default: "/" }
538
586
  },
539
587
  emits: ["completed"],
540
- setup(e, { emit: o }) {
541
- const r = e, s = o, t = fe(), l = me(), u = q(""), f = q(!1);
542
- de(c);
543
- async function c() {
544
- const h = typeof t.query.code == "string" ? t.query.code : "", k = typeof t.query.state == "string" ? t.query.state : "", _ = typeof t.query.error_description == "string" ? t.query.error_description : typeof t.query.error == "string" ? t.query.error : "";
588
+ setup(e, { emit: t }) {
589
+ const r = e, a = t, n = ve(), i = ye(), l = R(""), c = R(!1);
590
+ ge(u);
591
+ async function u() {
592
+ const f = typeof n.query.code == "string" ? n.query.code : "", k = typeof n.query.state == "string" ? n.query.state : "", _ = typeof n.query.error_description == "string" ? n.query.error_description : typeof n.query.error == "string" ? n.query.error : "";
545
593
  try {
546
594
  if (_) throw new Error(_);
547
- if (!h || !k) throw new Error("登录回调缺少 code 或 state。");
548
- const S = await r.client.completeLogin(h, k);
549
- s("completed", S), await l.replace(S);
550
- } catch (S) {
551
- u.value = S instanceof Error ? S.message : "登录失败。";
595
+ if (!f || !k) throw new Error("登录回调缺少 code 或 state。");
596
+ const C = await r.client.completeLogin(f, k);
597
+ a("completed", C), await i.replace(C);
598
+ } catch (C) {
599
+ l.value = C instanceof Error ? C.message : "登录失败。";
552
600
  }
553
601
  }
554
- async function b() {
555
- f.value = !0;
602
+ async function m() {
603
+ c.value = !0;
556
604
  try {
557
605
  await r.client.beginLogin(r.retryPath);
558
- } catch (h) {
559
- u.value = h instanceof Error ? h.message : "重新登录失败。", f.value = !1;
606
+ } catch (f) {
607
+ l.value = f instanceof Error ? f.message : "重新登录失败。", c.value = !1;
560
608
  }
561
609
  }
562
- return (h, k) => {
563
- const _ = C("el-button"), S = C("el-result"), A = C("el-icon");
564
- return i(), p("main", St, [
565
- u.value ? (i(), T(S, {
610
+ return (f, k) => {
611
+ const _ = x("el-button"), C = x("el-result"), S = x("el-icon");
612
+ return d(), A("main", Ut, [
613
+ l.value ? (d(), T(C, {
566
614
  key: 0,
567
615
  icon: "error",
568
616
  title: "登录失败",
569
- "sub-title": u.value
617
+ "sub-title": l.value
570
618
  }, {
571
- extra: m(() => [
572
- v(_, {
619
+ extra: v(() => [
620
+ w(_, {
573
621
  type: "primary",
574
- loading: f.value,
575
- onClick: b
622
+ loading: c.value,
623
+ onClick: m
576
624
  }, {
577
- default: m(() => [...k[0] || (k[0] = [
578
- z(" 重新登录 ", -1)
625
+ default: v(() => [...k[0] || (k[0] = [
626
+ H(" 重新登录 ", -1)
579
627
  ])]),
580
628
  _: 1
581
629
  }, 8, ["loading"])
582
630
  ]),
583
631
  _: 1
584
- }, 8, ["sub-title"])) : (i(), p("div", Ct, [
585
- v(A, {
632
+ }, 8, ["sub-title"])) : (d(), A("div", Lt, [
633
+ w(S, {
586
634
  class: "is-loading",
587
635
  size: 28
588
636
  }, {
589
- default: m(() => [
590
- v(M(Ke))
637
+ default: v(() => [
638
+ w(N(Ke))
591
639
  ]),
592
640
  _: 1
593
641
  }),
594
- k[1] || (k[1] = d("span", null, "正在完成登录...", -1))
642
+ k[1] || (k[1] = g("span", null, "正在完成登录...", -1))
595
643
  ]))
596
644
  ]);
597
645
  };
598
646
  }
599
- }), Bt = /* @__PURE__ */ ge(At, [["__scopeId", "data-v-ef3407f8"]]), Et = new Uint32Array([
647
+ }), Yt = /* @__PURE__ */ ke(Nt, [["__scopeId", "data-v-ef3407f8"]]);
648
+ class j extends Error {
649
+ status;
650
+ code;
651
+ requestId;
652
+ constructor(t, r, a = "ACCESS_REQUEST_FAILED", n = "") {
653
+ super(t), this.name = "AdminAccessError", this.status = r, this.code = a, this.requestId = n;
654
+ }
655
+ }
656
+ function Rt(e) {
657
+ const t = e.baseUrl.trim().replace(/\/$/, "");
658
+ async function r() {
659
+ return $t(await n("/api/current/me"));
660
+ }
661
+ async function a() {
662
+ const l = await n("/api/me/menus");
663
+ if (!l || typeof l != "object")
664
+ throw new j("当前账号菜单响应格式无效。", 502, "INVALID_MENU_RESPONSE");
665
+ const c = l;
666
+ if (c.applicationCode !== null)
667
+ throw new j("当前账号菜单响应不是全应用菜单。", 502, "INVALID_MENU_SCOPE");
668
+ return be(c.menus);
669
+ }
670
+ async function n(l, c = !0) {
671
+ if (!t)
672
+ throw new j(
673
+ "缺少 VITE_ACCESS_API_BASE_URL,无法读取当前用户和菜单。",
674
+ 0,
675
+ "ACCESS_API_NOT_CONFIGURED"
676
+ );
677
+ const u = await e.oauthClient.getValidAccessToken();
678
+ if (!u)
679
+ throw new j("登录状态已失效,请重新登录。", 401, "UNAUTHENTICATED");
680
+ const m = await i()(new URL(`${t}${Vt(l)}`), {
681
+ method: "GET",
682
+ headers: {
683
+ Accept: "application/json",
684
+ Authorization: `Bearer ${u}`
685
+ }
686
+ });
687
+ if (m.status === 401 && c) {
688
+ if (await e.oauthClient.refreshAccessToken()) return n(l, !1);
689
+ e.oauthClient.clearSession();
690
+ }
691
+ if (!m.ok) {
692
+ const f = await Ot(m);
693
+ throw new j(
694
+ f.message || f.detail || f.title || Ft(m.status),
695
+ m.status,
696
+ f.code,
697
+ f.requestId || f.traceId || m.headers.get("X-Request-Id") || ""
698
+ );
699
+ }
700
+ return m.json();
701
+ }
702
+ function i() {
703
+ const l = e.fetcher || globalThis.fetch;
704
+ if (!l) throw new Error("管理后台 Access 客户端缺少 Fetch 运行环境。");
705
+ return l;
706
+ }
707
+ return { getCurrentUser: r, getCurrentMenus: a };
708
+ }
709
+ function $t(e) {
710
+ if (!e || typeof e != "object")
711
+ throw new j("当前用户响应格式无效。", 502, "INVALID_CURRENT_USER");
712
+ const t = e;
713
+ if ([
714
+ "userId",
715
+ "displayName",
716
+ "username",
717
+ "loginAccount",
718
+ "employeeNo",
719
+ "mobile",
720
+ "email",
721
+ "status",
722
+ "lastLoginAt",
723
+ "createdAt"
724
+ ].some((a) => typeof t[a] != "string"))
725
+ throw new j("当前用户响应缺少标准字段。", 502, "INVALID_CURRENT_USER");
726
+ if (!fe(t.organizations) || !fe(t.roles))
727
+ throw new j("当前用户关系数据格式无效。", 502, "INVALID_CURRENT_USER");
728
+ return t;
729
+ }
730
+ function fe(e) {
731
+ return Array.isArray(e) && e.every((t) => t !== null && typeof t == "object" && typeof t.id == "string" && typeof t.name == "string" && (t.code === void 0 || typeof t.code == "string"));
732
+ }
733
+ function Vt(e) {
734
+ return e.startsWith("/") ? e : `/${e}`;
735
+ }
736
+ async function Ot(e) {
737
+ return e.json().catch(() => ({}));
738
+ }
739
+ function Ft(e) {
740
+ return e === 401 ? "登录状态已失效,请重新登录。" : e === 403 ? "当前用户无权从该页面调用此 API。" : e === 404 ? "请求的数据不存在或已被移除。" : e === 429 ? "请求过于频繁,请稍后再试。" : e >= 500 ? "用户中心暂时不可用,请稍后再试。" : "用户中心请求失败。";
741
+ }
742
+ const Dt = new Uint32Array([
600
743
  1116352408,
601
744
  1899447441,
602
745
  3049323471,
@@ -661,7 +804,7 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
661
804
  2756734187,
662
805
  3204031479,
663
806
  3329325298
664
- ]), Mt = new Uint32Array([
807
+ ]), Bt = new Uint32Array([
665
808
  1779033703,
666
809
  3144134277,
667
810
  1013904242,
@@ -671,233 +814,326 @@ const We = { class: "saf-sidebar saf-desktop-sidebar" }, Ge = { class: "saf-bran
671
814
  528734635,
672
815
  1541459225
673
816
  ]);
674
- function It(e) {
675
- const o = Math.ceil((e.length + 9) / 64) * 64, r = new Uint8Array(o);
817
+ function zt(e) {
818
+ const t = Math.ceil((e.length + 9) / 64) * 64, r = new Uint8Array(t);
676
819
  r.set(e), r[e.length] = 128;
677
- const s = BigInt(e.length) * 8n;
678
- for (let b = 0; b < 8; b += 1)
679
- r[o - 1 - b] = Number(s >> BigInt(b * 8) & 0xffn);
680
- const t = new Uint32Array(Mt), l = new Uint32Array(64), u = new DataView(r.buffer);
681
- for (let b = 0; b < o; b += 64) {
820
+ const a = BigInt(e.length) * 8n;
821
+ for (let m = 0; m < 8; m += 1)
822
+ r[t - 1 - m] = Number(a >> BigInt(m * 8) & 0xffn);
823
+ const n = new Uint32Array(Bt), i = new Uint32Array(64), l = new DataView(r.buffer);
824
+ for (let m = 0; m < t; m += 64) {
682
825
  for (let y = 0; y < 16; y += 1)
683
- l[y] = u.getUint32(b + y * 4);
826
+ i[y] = l.getUint32(m + y * 4);
684
827
  for (let y = 16; y < 64; y += 1) {
685
- const U = l[y - 15], N = l[y - 2], I = O(U, 7) ^ O(U, 18) ^ U >>> 3, V = O(N, 17) ^ O(N, 19) ^ N >>> 10;
686
- l[y] = l[y - 16] + I + l[y - 7] + V >>> 0;
828
+ const U = i[y - 15], V = i[y - 2], M = P(U, 7) ^ P(U, 18) ^ U >>> 3, O = P(V, 17) ^ P(V, 19) ^ V >>> 10;
829
+ i[y] = i[y - 16] + M + i[y - 7] + O >>> 0;
687
830
  }
688
- let h = t[0], k = t[1], _ = t[2], S = t[3], A = t[4], R = t[5], F = t[6], H = t[7];
831
+ let f = n[0], k = n[1], _ = n[2], C = n[3], S = n[4], $ = n[5], F = n[6], D = n[7];
689
832
  for (let y = 0; y < 64; y += 1) {
690
- const U = O(A, 6) ^ O(A, 11) ^ O(A, 25), N = A & R ^ ~A & F, I = H + U + N + Et[y] + l[y] >>> 0, V = O(h, 2) ^ O(h, 13) ^ O(h, 22), K = h & k ^ h & _ ^ k & _, D = V + K >>> 0;
691
- H = F, F = R, R = A, A = S + I >>> 0, S = _, _ = k, k = h, h = I + D >>> 0;
833
+ const U = P(S, 6) ^ P(S, 11) ^ P(S, 25), V = S & $ ^ ~S & F, M = D + U + V + Dt[y] + i[y] >>> 0, O = P(f, 2) ^ P(f, 13) ^ P(f, 22), p = f & k ^ f & _ ^ k & _, q = O + p >>> 0;
834
+ D = F, F = $, $ = S, S = C + M >>> 0, C = _, _ = k, k = f, f = M + q >>> 0;
692
835
  }
693
- t[0] = t[0] + h >>> 0, t[1] = t[1] + k >>> 0, t[2] = t[2] + _ >>> 0, t[3] = t[3] + S >>> 0, t[4] = t[4] + A >>> 0, t[5] = t[5] + R >>> 0, t[6] = t[6] + F >>> 0, t[7] = t[7] + H >>> 0;
836
+ n[0] = n[0] + f >>> 0, n[1] = n[1] + k >>> 0, n[2] = n[2] + _ >>> 0, n[3] = n[3] + C >>> 0, n[4] = n[4] + S >>> 0, n[5] = n[5] + $ >>> 0, n[6] = n[6] + F >>> 0, n[7] = n[7] + D >>> 0;
694
837
  }
695
- const f = new Uint8Array(32), c = new DataView(f.buffer);
696
- return t.forEach((b, h) => c.setUint32(h * 4, b)), f;
838
+ const c = new Uint8Array(32), u = new DataView(c.buffer);
839
+ return n.forEach((m, f) => u.setUint32(f * 4, m)), c;
697
840
  }
698
- function O(e, o) {
699
- return e >>> o | e << 32 - o;
841
+ function P(e, t) {
842
+ return e >>> t | e << 32 - t;
700
843
  }
701
- function zt(e) {
702
- const o = e.now || Date.now, r = e.refreshSkewMs ?? 3e4, s = e.transactionLifetimeMs ?? 10 * 6e4, t = e.storageNamespace.trim();
703
- if (!t) throw new Error("OAuth storageNamespace 不能为空。");
704
- const l = `${t}_oauth_session`, u = `${t}_oauth_transaction`, f = `${t}-oauth-session-changed`;
705
- let c = null;
706
- function b() {
844
+ function Zt(e) {
845
+ const t = e.now || Date.now, r = e.refreshSkewMs ?? 3e4, a = e.transactionLifetimeMs ?? 10 * 6e4, n = e.storageNamespace.trim();
846
+ if (!n) throw new Error("OAuth storageNamespace 不能为空。");
847
+ const i = `${n}_oauth_session`, l = `${n}_oauth_transaction`, c = `${n}-oauth-session-changed`;
848
+ let u = null;
849
+ function m() {
707
850
  return e.mockMode === !0;
708
851
  }
709
- function h() {
710
- const n = I(), a = n.getItem(l);
711
- if (!a) return null;
852
+ function f() {
853
+ const o = M(), s = o.getItem(i);
854
+ if (!s) return null;
712
855
  try {
713
- const g = JSON.parse(a);
714
- return g.accessToken && g.refreshToken && Number.isFinite(g.expiresAt) ? g : null;
856
+ const h = JSON.parse(s);
857
+ return h.accessToken && h.refreshToken && Number.isFinite(h.expiresAt) ? h : null;
715
858
  } catch {
716
- return n.removeItem(l), null;
859
+ return o.removeItem(i), null;
717
860
  }
718
861
  }
719
862
  function k() {
720
- I().removeItem(l), K().dispatchEvent(new Event(f));
863
+ M().removeItem(i), p().dispatchEvent(new Event(c));
721
864
  }
722
- function _(n) {
723
- const a = K();
724
- return a.addEventListener(f, n), () => a.removeEventListener(f, n);
865
+ function _(o) {
866
+ const s = p();
867
+ return s.addEventListener(c, o), () => s.removeEventListener(c, o);
725
868
  }
726
- async function S(n = Ut(V())) {
727
- if (b()) return;
728
- const a = I(), g = V(), x = D(), $ = ue(x, 64), P = ue(x, 32), J = {
729
- state: P,
730
- verifier: $,
869
+ async function C(o = Pt(O()), s = {}) {
870
+ if (m()) return;
871
+ const h = M(), E = O(), L = q(), K = he(L, 64), J = he(L, 32), oe = {
872
+ state: J,
873
+ verifier: K,
731
874
  redirectUri: e.redirectUri,
732
- returnUrl: $t(n, e.defaultReturnUrl),
733
- createdAt: o()
875
+ returnUrl: qt(o, e.defaultReturnUrl),
876
+ createdAt: t()
734
877
  };
735
- a.setItem(u, JSON.stringify(J));
736
- const Q = ce(e.authority, "/oauth2/authorize", g.origin);
737
- Q.search = new URLSearchParams({
878
+ h.setItem(l, JSON.stringify(oe));
879
+ const Y = me(e.authority, "/oauth2/authorize", E.origin), Z = new URLSearchParams({
738
880
  response_type: "code",
739
881
  client_id: e.clientId,
740
882
  redirect_uri: e.redirectUri,
741
- state: P,
742
- code_challenge: await Lt(x, $),
883
+ state: J,
884
+ code_challenge: await Ht(L, K),
743
885
  code_challenge_method: "S256"
744
- }).toString(), g.assign(Q.toString());
886
+ });
887
+ s.prompt && Z.set("prompt", s.prompt), Y.search = Z.toString(), E.assign(Y.toString());
745
888
  }
746
- async function A(n, a) {
747
- const g = I(), x = N();
748
- if (g.removeItem(u), !x || x.state !== a || o() - x.createdAt > s)
889
+ async function S(o, s) {
890
+ const h = M(), E = V();
891
+ if (h.removeItem(l), !E || E.state !== s || t() - E.createdAt > a)
749
892
  throw new Error("登录状态校验失败,请重新登录。");
750
- const $ = await U({
893
+ const L = await U({
751
894
  grant_type: "authorization_code",
752
895
  client_id: e.clientId,
753
- code: n,
754
- redirect_uri: x.redirectUri,
755
- code_verifier: x.verifier
896
+ code: o,
897
+ redirect_uri: E.redirectUri,
898
+ code_verifier: E.verifier
756
899
  });
757
- return y($), x.returnUrl;
900
+ return y(L), E.returnUrl;
758
901
  }
759
- async function R() {
760
- const n = h();
761
- return n ? n.expiresAt > o() + r ? n.accessToken : F() : null;
902
+ async function $() {
903
+ const o = f();
904
+ return o ? o.expiresAt > t() + r ? o.accessToken : F() : null;
762
905
  }
763
906
  async function F() {
764
- return c || (c = (async () => {
765
- const n = h();
766
- if (!n) return null;
907
+ return u || (u = (async () => {
908
+ const o = f();
909
+ if (!o) return null;
767
910
  try {
768
- const a = await U({
911
+ const s = await U({
769
912
  grant_type: "refresh_token",
770
913
  client_id: e.clientId,
771
- refresh_token: n.refreshToken
914
+ refresh_token: o.refreshToken
772
915
  });
773
- return y(a), a.access_token;
916
+ return y(s), s.access_token;
774
917
  } catch {
775
918
  return k(), null;
776
919
  }
777
920
  })().finally(() => {
778
- c = null;
779
- }), c);
921
+ u = null;
922
+ }), u);
780
923
  }
781
- function H(n) {
924
+ function D(o) {
782
925
  try {
783
- const a = n.split(".")[1];
784
- if (!a) return "";
785
- const g = a.replace(/-/g, "+").replace(/_/g, "/"), x = g.padEnd(Math.ceil(g.length / 4) * 4, "=");
926
+ const s = o.split(".")[1];
927
+ if (!s) return "";
928
+ const h = s.replace(/-/g, "+").replace(/_/g, "/"), E = h.padEnd(Math.ceil(h.length / 4) * 4, "=");
786
929
  return JSON.parse(decodeURIComponent(
787
- Array.from(atob(x)).map((P) => `%${P.charCodeAt(0).toString(16).padStart(2, "0")}`).join("")
930
+ Array.from(atob(E)).map((K) => `%${K.charCodeAt(0).toString(16).padStart(2, "0")}`).join("")
788
931
  )).sub || "";
789
932
  } catch {
790
933
  return "";
791
934
  }
792
935
  }
793
- function y(n) {
794
- if (n.token_type.toLowerCase() !== "bearer" || !n.access_token || !n.refresh_token || n.expires_in <= 0)
936
+ function y(o) {
937
+ if (o.token_type.toLowerCase() !== "bearer" || !o.access_token || !o.refresh_token || o.expires_in <= 0)
795
938
  throw new Error("用户中心返回的 Token 响应无效。");
796
- const a = {
797
- accessToken: n.access_token,
798
- refreshToken: n.refresh_token,
799
- expiresAt: o() + n.expires_in * 1e3
939
+ const s = {
940
+ accessToken: o.access_token,
941
+ refreshToken: o.refresh_token,
942
+ expiresAt: t() + o.expires_in * 1e3
800
943
  };
801
- I().setItem(l, JSON.stringify(a)), K().dispatchEvent(new Event(f));
944
+ M().setItem(i, JSON.stringify(s)), p().dispatchEvent(new Event(c));
802
945
  }
803
- async function U(n) {
804
- const a = V(), g = await te()(
805
- ce(e.authority, "/oauth2/token", a.origin),
946
+ async function U(o) {
947
+ const s = O(), h = await W()(
948
+ me(e.authority, "/oauth2/token", s.origin),
806
949
  {
807
950
  method: "POST",
808
951
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
809
- body: new URLSearchParams(n)
952
+ body: new URLSearchParams(o)
810
953
  }
811
- ), x = await g.json().catch(() => null);
812
- if (!g.ok) {
813
- const $ = x;
954
+ ), E = await h.json().catch(() => null);
955
+ if (!h.ok) {
956
+ const L = E;
814
957
  throw new Error(
815
- $?.error_description || $?.error || "Token 请求失败。"
958
+ L?.error_description || L?.error || "Token 请求失败。"
816
959
  );
817
960
  }
818
- return x;
961
+ return E;
819
962
  }
820
- function N() {
821
- const a = I().getItem(u);
822
- if (!a) return null;
963
+ function V() {
964
+ const s = M().getItem(l);
965
+ if (!s) return null;
823
966
  try {
824
- return JSON.parse(a);
967
+ return JSON.parse(s);
825
968
  } catch {
826
969
  return null;
827
970
  }
828
971
  }
829
- function I() {
830
- const n = e.storage || (typeof window > "u" ? void 0 : window.sessionStorage);
831
- if (!n) throw new Error("OAuth 客户端缺少 Storage 运行环境。");
832
- return n;
972
+ function M() {
973
+ const o = e.storage || (typeof window > "u" ? void 0 : window.sessionStorage);
974
+ if (!o) throw new Error("OAuth 客户端缺少 Storage 运行环境。");
975
+ return o;
833
976
  }
834
- function V() {
835
- const n = e.location || (typeof window > "u" ? void 0 : window.location);
836
- if (!n) throw new Error("OAuth 客户端缺少 Location 运行环境。");
837
- return n;
977
+ function O() {
978
+ const o = e.location || (typeof window > "u" ? void 0 : window.location);
979
+ if (!o) throw new Error("OAuth 客户端缺少 Location 运行环境。");
980
+ return o;
838
981
  }
839
- function K() {
840
- const n = e.eventTarget || (typeof window > "u" ? void 0 : window);
841
- if (!n) throw new Error("OAuth 客户端缺少 EventTarget 运行环境。");
842
- return n;
982
+ function p() {
983
+ const o = e.eventTarget || (typeof window > "u" ? void 0 : window);
984
+ if (!o) throw new Error("OAuth 客户端缺少 EventTarget 运行环境。");
985
+ return o;
843
986
  }
844
- function D() {
845
- const n = e.crypto || globalThis.crypto;
846
- if (!n) throw new Error("OAuth 客户端缺少 Crypto 运行环境。");
847
- return n;
987
+ function q() {
988
+ const o = e.crypto || globalThis.crypto;
989
+ if (!o) throw new Error("OAuth 客户端缺少 Crypto 运行环境。");
990
+ return o;
848
991
  }
849
- function te() {
850
- const n = e.fetcher || globalThis.fetch;
851
- if (!n) throw new Error("OAuth 客户端缺少 Fetch 运行环境。");
852
- return n;
992
+ function W() {
993
+ const o = e.fetcher || globalThis.fetch;
994
+ if (!o) throw new Error("OAuth 客户端缺少 Fetch 运行环境。");
995
+ return o;
853
996
  }
854
997
  return {
855
- isMockMode: b,
856
- getSession: h,
998
+ isMockMode: m,
999
+ getSession: f,
857
1000
  clearSession: k,
858
1001
  onSessionChanged: _,
859
- beginLogin: S,
860
- completeLogin: A,
861
- getValidAccessToken: R,
1002
+ beginLogin: C,
1003
+ completeLogin: S,
1004
+ getValidAccessToken: $,
862
1005
  refreshAccessToken: F,
863
- readAccessTokenSubject: H
1006
+ readAccessTokenSubject: D
864
1007
  };
865
1008
  }
866
- function $t(e, o) {
867
- return e.startsWith("/") && !e.startsWith("//") ? e : o;
1009
+ function qt(e, t) {
1010
+ return e.startsWith("/") && !e.startsWith("//") ? e : t;
868
1011
  }
869
- function ce(e, o, r) {
870
- return new URL(`${e.replace(/\/$/, "")}${o}`, r);
1012
+ function me(e, t, r) {
1013
+ return new URL(`${e.replace(/\/$/, "")}${t}`, r);
871
1014
  }
872
- function Ut(e) {
1015
+ function Pt(e) {
873
1016
  return `${e.pathname}${e.search}${e.hash}`;
874
1017
  }
875
- function ue(e, o) {
876
- const r = e.getRandomValues(new Uint8Array(o));
877
- return we(r);
1018
+ function he(e, t) {
1019
+ const r = e.getRandomValues(new Uint8Array(t));
1020
+ return Ce(r);
878
1021
  }
879
- async function Lt(e, o) {
880
- const r = new TextEncoder().encode(o), s = e.subtle ? new Uint8Array(await e.subtle.digest("SHA-256", r)) : It(r);
881
- return we(s);
1022
+ async function Ht(e, t) {
1023
+ const r = new TextEncoder().encode(t), a = e.subtle ? new Uint8Array(await e.subtle.digest("SHA-256", r)) : zt(r);
1024
+ return Ce(a);
882
1025
  }
883
- function we(e) {
884
- let o = "";
1026
+ function Ce(e) {
1027
+ let t = "";
885
1028
  return e.forEach((r) => {
886
- o += String.fromCharCode(r);
887
- }), btoa(o).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1029
+ t += String.fromCharCode(r);
1030
+ }), btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1031
+ }
1032
+ function en(e) {
1033
+ const t = e.accessClient || Rt({
1034
+ oauthClient: e.oauthClient,
1035
+ baseUrl: e.accessApiBaseUrl
1036
+ }), r = R(""), a = R(null), n = R(""), i = R(""), l = R([]), c = R(!1), u = R("");
1037
+ let m = null, f = 0;
1038
+ const k = z(() => (n.value.trim() || "?").slice(0, 1).toUpperCase()), _ = z(() => e.oauthClient.isMockMode() || !!r.value);
1039
+ function C() {
1040
+ const p = r.value;
1041
+ r.value = e.oauthClient.isMockMode() ? "" : e.oauthClient.getSession()?.accessToken || "", p !== r.value && U(), !r.value && !e.oauthClient.isMockMode() && y();
1042
+ }
1043
+ async function S() {
1044
+ if (e.oauthClient.isMockMode()) return !0;
1045
+ const p = await e.oauthClient.getValidAccessToken();
1046
+ return C(), !!p;
1047
+ }
1048
+ async function $() {
1049
+ if (!c.value)
1050
+ return m || (m = F().finally(() => {
1051
+ m = null;
1052
+ }), m);
1053
+ }
1054
+ async function F() {
1055
+ if (u.value = "", e.oauthClient.isMockMode()) {
1056
+ a.value = e.mockUser ? structuredClone(e.mockUser) : null, D(a.value, ""), l.value = structuredClone(e.mockMenus || []), c.value = !0;
1057
+ return;
1058
+ }
1059
+ const p = await e.oauthClient.getValidAccessToken();
1060
+ if (C(), !p) {
1061
+ y(), l.value = [], u.value = "登录状态已失效。", c.value = !0;
1062
+ return;
1063
+ }
1064
+ const q = f, W = r.value || p, o = e.oauthClient.readAccessTokenSubject(p);
1065
+ D(null, o);
1066
+ const [s, h] = await Promise.allSettled([
1067
+ t.getCurrentUser(),
1068
+ t.getCurrentMenus()
1069
+ ]);
1070
+ q !== f || W !== r.value || (s.status === "fulfilled" ? (a.value = s.value, D(s.value, o)) : a.value = null, h.status === "fulfilled" ? l.value = h.value : (l.value = [], u.value = h.reason instanceof Error ? h.reason.message : "当前账号菜单加载失败。"), c.value = !0);
1071
+ }
1072
+ function D(p, q) {
1073
+ n.value = p?.displayName || p?.username || p?.loginAccount || p?.userId || q || (e.oauthClient.isMockMode() ? "演示用户" : "当前用户"), i.value = p?.loginAccount || q;
1074
+ }
1075
+ function y() {
1076
+ a.value = null, n.value = "", i.value = "";
1077
+ }
1078
+ function U() {
1079
+ f += 1, l.value = [], c.value = !1, u.value = "", y();
1080
+ }
1081
+ function V() {
1082
+ U();
1083
+ for (const p of e.storageKeysToClear || [])
1084
+ typeof sessionStorage < "u" && sessionStorage.removeItem(p);
1085
+ C();
1086
+ }
1087
+ async function M(p) {
1088
+ await e.oauthClient.beginLogin(p);
1089
+ }
1090
+ async function O(p = e.defaultReturnUrl) {
1091
+ if (e.oauthClient.clearSession(), V(), e.oauthClient.isMockMode()) {
1092
+ await $();
1093
+ return;
1094
+ }
1095
+ await e.oauthClient.beginLogin(p, { prompt: "login" });
1096
+ }
1097
+ return C(), e.oauthClient.onSessionChanged(() => {
1098
+ C();
1099
+ }), {
1100
+ accessToken: r,
1101
+ currentUser: a,
1102
+ username: n,
1103
+ loginAccount: i,
1104
+ menus: l,
1105
+ navigationLoaded: c,
1106
+ navigationError: u,
1107
+ initials: k,
1108
+ authenticated: _,
1109
+ sync: C,
1110
+ ensureAuthenticated: S,
1111
+ ensureLoaded: $,
1112
+ ensureNavigation: $,
1113
+ clear: V,
1114
+ login: M,
1115
+ logout: O
1116
+ };
888
1117
  }
889
1118
  export {
890
- Ft as AdminFrameworkLayout,
891
- le as FrameworkMenuItem,
892
- Bt as OAuthCallbackView,
893
- De as closeVisitedTab,
894
- zt as createOAuthPkceClient,
895
- Rt as findMenuByRoute,
896
- qe as findMenuTrail,
897
- Z as flattenRoutableMenus,
898
- ee as normalizeVisitedTabs,
899
- Je as retainActiveTab,
900
- $t as sanitizeReturnUrl,
901
- It as sha256,
902
- Pe as upsertVisitedTab
1119
+ j as AdminAccessError,
1120
+ Xt as AdminFrameworkLayout,
1121
+ de as FrameworkMenuItem,
1122
+ Yt as OAuthCallbackView,
1123
+ Xe as closeVisitedTab,
1124
+ Rt as createAdminAccessClient,
1125
+ en as createAdminFrameworkSession,
1126
+ Qt as createExternalMenuHrefResolver,
1127
+ Zt as createOAuthPkceClient,
1128
+ Wt as findMenuByRoute,
1129
+ Je as findMenuTrail,
1130
+ ne as flattenRoutableMenus,
1131
+ Gt as hasPageAccess,
1132
+ $t as normalizeCurrentUser,
1133
+ be as normalizeFrameworkMenus,
1134
+ re as normalizeVisitedTabs,
1135
+ Ye as retainActiveTab,
1136
+ qt as sanitizeReturnUrl,
1137
+ zt as sha256,
1138
+ Qe as upsertVisitedTab
903
1139
  };