@campus-admin/core 1.0.0 → 2.0.1

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 (65) hide show
  1. package/README.md +24 -159
  2. package/dist/app.d.ts +2 -0
  3. package/dist/context.d.ts +29 -15
  4. package/dist/copyright.d.ts +2 -0
  5. package/dist/i18n.d.ts +352 -0
  6. package/dist/index.d.ts +23 -32
  7. package/dist/index.js +2475 -424
  8. package/dist/layout/CaCopyright.vue.d.ts +3 -0
  9. package/dist/layout/CaLayout.vue.d.ts +3 -0
  10. package/dist/layout/HeaderBar.vue.d.ts +3 -0
  11. package/dist/layout/PageHeader.vue.d.ts +3 -0
  12. package/dist/layout/PageTitle.vue.d.ts +3 -0
  13. package/dist/layout/SideMenu.vue.d.ts +3 -0
  14. package/dist/layout/TabsBar.vue.d.ts +3 -0
  15. package/dist/layout/breakpoints.d.ts +21 -0
  16. package/dist/{components/overlay/ca-loading-overlay.vue.d.ts → pages/AuthPreview.vue.d.ts} +2 -6
  17. package/dist/{components/overlay/ca-toast-list.vue.d.ts → pages/ExceptionPage.vue.d.ts} +2 -5
  18. package/dist/{components/overlay/ca-overlay-list.vue.d.ts → pages/ForgotPage.vue.d.ts} +2 -5
  19. package/dist/pages/LoginPage.vue.d.ts +3 -0
  20. package/dist/pages/LoginSplit.vue.d.ts +6 -0
  21. package/dist/pages/RegisterPage.vue.d.ts +6 -0
  22. package/dist/pages/auth/AuthIcon.vue.d.ts +10 -0
  23. package/dist/pages/auth/AuthShell.vue.d.ts +29 -0
  24. package/dist/pages/auth/CaptchaField.vue.d.ts +20 -0
  25. package/dist/pages/auth/ForgotForm.vue.d.ts +6 -0
  26. package/dist/pages/auth/LoginForm.vue.d.ts +6 -0
  27. package/dist/pages/auth/RegisterForm.vue.d.ts +6 -0
  28. package/dist/pages/auth/SmsField.vue.d.ts +14 -0
  29. package/dist/pages/auth/WechatPane.vue.d.ts +3 -0
  30. package/dist/pages/auth/options.d.ts +15 -0
  31. package/dist/router.d.ts +15 -0
  32. package/dist/security.d.ts +15 -0
  33. package/dist/services/auth.d.ts +11 -0
  34. package/dist/services/ca.d.ts +48 -0
  35. package/dist/services/feedback.d.ts +54 -0
  36. package/dist/storage.d.ts +12 -0
  37. package/dist/stores/layout.d.ts +41 -0
  38. package/dist/stores/session.d.ts +53 -0
  39. package/dist/stores/tabs.d.ts +49 -0
  40. package/dist/stores/theme.d.ts +280 -0
  41. package/dist/style.css +2 -0
  42. package/dist/tabs-policy.d.ts +4 -0
  43. package/dist/types.d.ts +224 -0
  44. package/package.json +23 -61
  45. package/dist/application.d.ts +0 -51
  46. package/dist/campus.d.ts +0 -9
  47. package/dist/components/overlay/index.d.ts +0 -6
  48. package/dist/components/overlay/style/index.d.ts +0 -10
  49. package/dist/container.d.ts +0 -21
  50. package/dist/contracts/config.d.ts +0 -13
  51. package/dist/contracts/provider.d.ts +0 -24
  52. package/dist/core.css +0 -2
  53. package/dist/facade.d.ts +0 -15
  54. package/dist/index.umd.cjs +0 -1
  55. package/dist/plugin.d.ts +0 -49
  56. package/dist/services/index.d.ts +0 -7
  57. package/dist/services/loading.d.ts +0 -21
  58. package/dist/services/modal.d.ts +0 -47
  59. package/dist/services/store.d.ts +0 -20
  60. package/dist/services/toast.d.ts +0 -19
  61. package/dist/services/use-store.d.ts +0 -9
  62. package/dist/vue-application.d.ts +0 -21
  63. package/dist/vue.d.ts +0 -8
  64. package/types/ca.d.ts +0 -22
  65. /package/dist/{components/overlay/ca-overlay-host.vue.d.ts → CampusRoot.vue.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,474 +1,2525 @@
1
- import { Fragment as e, Transition as t, TransitionGroup as n, computed as r, createApp as i, createApp as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineAsyncComponent as f, defineComponent as ee, defineComponent as p, inject as m, nextTick as te, normalizeClass as ne, onBeforeUnmount as re, onMounted as ie, onScopeDispose as h, onUnmounted as ae, openBlock as g, provide as oe, readonly as se, ref as _, renderList as v, shallowRef as y, toDisplayString as b, toRef as ce, toRefs as le, unref as x, watch as S, watch as ue, watchEffect as de, withCtx as C, withModifiers as fe } from "vue";
2
- import { AlertTriangle as pe, Check as me, Info as he, X as ge } from "@lucide/vue";
3
- import { builtInComponents as _e, clearToasts as ve, closeToast as ye, toast as be, toast as xe, toasts as Se } from "@campus-admin/ui";
4
- import { createLocale as Ce, installLocale as we } from "@campus-admin/locale";
1
+ import './style.css'
2
+ import "element-plus/es/components/base/style/css";
3
+ import "element-plus/theme-chalk/dark/css-vars.css";
4
+ import "@campus-admin/theme/nova.css";
5
+ import { Fragment as e, KeepAlive as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createStaticVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, h as f, mergeModels as p, nextTick as m, normalizeClass as h, normalizeStyle as g, onBeforeUnmount as _, onMounted as v, openBlock as y, reactive as b, ref as x, renderList as S, renderSlot as C, resolveComponent as w, resolveDynamicComponent as T, toDisplayString as E, unref as D, useModel as O, vShow as k, watch as A, watchEffect as j, withCtx as M, withDirectives as N, withModifiers as P } from "vue";
6
+ import { createPinia as F, defineStore as I } from "pinia";
7
+ import { installUi as L, translateKey as ee } from "@campus-admin/ui";
8
+ import { LOCALES as te, frameworkMessages as ne } from "@campus-admin/locale";
9
+ import { createI18n as re, useI18n as R } from "vue-i18n";
10
+ import { RouterLink as z, createRouter as ie, createWebHashHistory as ae, createWebHistory as oe, useRoute as B, useRouter as V } from "vue-router";
11
+ import { applyTheme as se, deriveCssVars as ce, isHexColor as le, resolveMode as ue, resolveTheme as de } from "@campus-admin/theme";
12
+ import { ElLoading as fe, ElMessage as pe, ElMessageBox as me, ElNotification as he } from "element-plus";
13
+ import "element-plus/es/components/loading/style/css";
14
+ import "element-plus/es/components/notification/style/css";
15
+ import "element-plus/es/components/message/style/css";
16
+ import "element-plus/es/components/message-box/style/css";
5
17
  export * from "@campus-admin/ui";
6
- export * from "@campus-admin/locale";
7
- //#region src/components/overlay/ca-loading-overlay.vue?vue&type=script&setup=true&lang.ts
8
- var Te = {
18
+ // packages/core/src/storage.ts
19
+ var ge = "ca:";
20
+ function H(e, t = "local") {
21
+ try {
22
+ return (t === "local" ? localStorage : sessionStorage).getItem(ge + e);
23
+ } catch {
24
+ return null;
25
+ }
26
+ }
27
+ function U(e, t, n = "local") {
28
+ try {
29
+ let r = n === "local" ? localStorage : sessionStorage;
30
+ t === null ? r.removeItem(ge + e) : r.setItem(ge + e, t);
31
+ } catch {}
32
+ }
33
+ function _e(e, t = "local") {
34
+ let n = H(e, t);
35
+ if (n) try {
36
+ return JSON.parse(n);
37
+ } catch {
38
+ return;
39
+ }
40
+ }
41
+ function ve(e, t, n = "local") {
42
+ U(e, JSON.stringify(t), n);
43
+ }
44
+ // packages/core/src/i18n.ts
45
+ var ye = (e) => typeof e == "object" && !!e && !Array.isArray(e);
46
+ function be(e, t) {
47
+ let n = { ...e };
48
+ for (let [e, r] of Object.entries(t)) {
49
+ let t = n[e];
50
+ n[e] = ye(t) && ye(r) ? be(t, r) : r;
51
+ }
52
+ return n;
53
+ }
54
+ var xe = "locale";
55
+ function Se(e) {
56
+ return e === "zh-CN" || e === "en-US";
57
+ }
58
+ function Ce(e) {
59
+ let t = H(xe), n = Se(t) ? t : e.defaultLocale ?? "zh-CN", r = Object.fromEntries(["zh-CN", "en-US"].map((t) => [t, be(ne[t], e.messages?.[t] ?? {})])), i = re({
60
+ legacy: !1,
61
+ locale: n,
62
+ fallbackLocale: "zh-CN",
63
+ messages: r
64
+ });
65
+ return typeof document < "u" && A(() => i.global.locale.value, (e) => {
66
+ document.documentElement.lang = e;
67
+ }, { immediate: !0 }), we = i, i;
68
+ }
69
+ var we;
70
+ function Te(e, t) {
71
+ return we ? we.global.t(e, t ?? {}) : e;
72
+ }
73
+ function Ee(e) {
74
+ U(xe, e);
75
+ }
76
+ function W() {
77
+ let { t: e, te: t, locale: n } = R();
78
+ return {
79
+ t: e,
80
+ te: t,
81
+ label: (n) => t(n) ? e(n) : n,
82
+ locale: n
83
+ };
84
+ }
85
+ // packages/core/src/CampusRoot.vue
86
+ var De = /* @__PURE__ */ d({
87
+ __name: "CampusRoot",
88
+ setup(e) {
89
+ let { locale: t } = W();
90
+ return (e, n) => {
91
+ let r = w("router-view"), a = w("ca-config-provider");
92
+ return y(), i(a, { locale: D(t) }, {
93
+ default: M(() => [u(r)]),
94
+ _: 1
95
+ }, 8, ["locale"]);
96
+ };
97
+ }
98
+ });
99
+ // packages/core/src/types.ts
100
+ function Oe(e) {
101
+ return "children" in e;
102
+ }
103
+ // packages/core/src/context.ts
104
+ var ke;
105
+ function Ae(e) {
106
+ ke = e;
107
+ }
108
+ function G() {
109
+ if (!ke) throw Error("[campus] 请先调用 createCampusApp()");
110
+ return ke;
111
+ }
112
+ function je(e) {
113
+ for (let t of G().menus) for (let n of t.children) if (Oe(n)) {
114
+ let r = n.children.find((t) => t.key === e);
115
+ if (r) return { titles: [
116
+ t.title,
117
+ n.title,
118
+ r.title
119
+ ] };
120
+ } else if (n.key === e) return { titles: [t.title, n.title] };
121
+ }
122
+ function Me(e) {
123
+ let t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
124
+ for (let o of e) {
125
+ if (i.has(o.key)) throw Error(`[campus] 菜单一级场景键重复:${o.key}`);
126
+ i.add(o.key);
127
+ for (let e of o.children) {
128
+ let i = Oe(e) ? e : void 0;
129
+ if (i) {
130
+ if (a.has(i.key)) throw Error(`[campus] 菜单组键重复:${i.key}`);
131
+ a.add(i.key);
132
+ }
133
+ for (let a of i ? i.children : [e]) {
134
+ if (n.has(a.key)) throw Error(`[campus] 菜单页面键重复:${a.key}`);
135
+ if (r.has(a.path)) throw Error(`[campus] 菜单路径重复:${a.path}`);
136
+ if (!a.path.startsWith("/")) throw Error(`[campus] 菜单路径必须以 / 开头:${a.path}`);
137
+ n.add(a.key), r.add(a.path), t.push({
138
+ ...a,
139
+ appKey: o.key,
140
+ groupKey: i?.key
141
+ });
142
+ }
143
+ }
144
+ }
145
+ return t;
146
+ }
147
+ function Ne(e, t) {
148
+ if (e !== void 0 && !t.some((t) => t.path === e)) throw Error(`[campus] 账户页路径不在菜单页面里:${e}`);
149
+ }
150
+ // packages/core/src/stores/theme.ts
151
+ var Pe = "theme-mode", Fe = "box-style", Ie = "user-primary";
152
+ function Le() {
153
+ return H(Fe) === "border" ? "border" : "shadow";
154
+ }
155
+ function Re() {
156
+ let e = H(Ie);
157
+ return le(e) ? e : void 0;
158
+ }
159
+ function ze() {
160
+ let e = H(Pe);
161
+ return e === "light" || e === "dark" || e === "auto" ? e : "auto";
162
+ }
163
+ var Be = I("campus-theme", () => {
164
+ let e = x({}), t = x(ze()), r = x(Le()), i = x(Re()), a = typeof matchMedia == "function" ? matchMedia("(prefers-color-scheme: dark)") : void 0, o = x(a?.matches ?? !1);
165
+ a?.addEventListener("change", (e) => o.value = e.matches);
166
+ let s = n(() => de(e.value)), c = n(() => e.value.tenantDefault?.locks?.includes("primary") ?? !1), l = n(() => {
167
+ let e = s.value.theme, t = i.value;
168
+ return !t || c.value ? e : {
169
+ ...e,
170
+ primary: t,
171
+ headerBg: e.headerBg === e.primary ? t : e.headerBg
172
+ };
173
+ }), u = n(() => s.value.issues), d = n(() => ue(t.value, o.value)), f = n(() => ce(l.value, d.value));
174
+ j(() => se(f.value, d.value, l.value.style)), j(() => {
175
+ document.documentElement.dataset.caBox = r.value;
176
+ });
177
+ function p(e) {
178
+ (e === void 0 || le(e)) && (i.value = e, U(Ie, e ?? null));
179
+ }
180
+ function h(e) {
181
+ r.value = e, U(Fe, e);
182
+ }
183
+ function g() {
184
+ return `theme-layers:${G().theme?.cacheKey ?? location.host}`;
185
+ }
186
+ function _(e) {
187
+ t.value = e, U(Pe, e);
188
+ }
189
+ function v(e, t) {
190
+ let n = document, r = ue(e, o.value) !== d.value, i = typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
191
+ if (!t || !r || i || !n.startViewTransition) {
192
+ _(e);
193
+ return;
194
+ }
195
+ let a = Math.hypot(Math.max(t.x, innerWidth - t.x), Math.max(t.y, innerHeight - t.y)), s = ue(e, o.value) === "dark", c = document.documentElement;
196
+ c.dataset.caThemeTransition = s ? "to-dark" : "to-light";
197
+ let l = !1, u = () => {
198
+ l || (l = !0, _(e));
199
+ }, f = n.startViewTransition(async () => {
200
+ u(), await m();
201
+ });
202
+ setTimeout(u, 300);
203
+ let p = () => delete c.dataset.caThemeTransition;
204
+ setTimeout(p, 2e3), f.finished?.then(p, p), f.ready.then(() => {
205
+ let e = `circle(${a}px at ${t.x}px ${t.y}px)`, n = `circle(0px at ${t.x}px ${t.y}px)`;
206
+ c.animate({ clipPath: s ? [e, n] : [n, e] }, {
207
+ duration: 450,
208
+ easing: "ease-in-out",
209
+ pseudoElement: s ? "::view-transition-old(root)" : "::view-transition-new(root)"
210
+ });
211
+ }).catch(() => {});
212
+ }
213
+ function y(t, n = !0) {
214
+ e.value = t, n && ve(g(), t);
215
+ }
216
+ async function b() {
217
+ let t = _e(g());
218
+ t && (e.value = t);
219
+ let n = G().theme?.load;
220
+ if (n) {
221
+ try {
222
+ y(await n());
223
+ } catch (e) {
224
+ console.warn("[campus] 加载站点主题失败,继续使用缓存或默认主题:", e);
225
+ }
226
+ u.value.length && console.warn("[campus] 主题配置有被忽略的字段:", u.value);
227
+ }
228
+ }
229
+ return {
230
+ layers: e,
231
+ mode: t,
232
+ boxStyle: r,
233
+ setBoxStyle: h,
234
+ userPrimary: i,
235
+ primaryLocked: c,
236
+ setPrimary: p,
237
+ theme: l,
238
+ issues: u,
239
+ effectiveMode: d,
240
+ cssVars: f,
241
+ setMode: v,
242
+ setLayers: y,
243
+ boot: b
244
+ };
245
+ });
246
+ // packages/core/src/copyright.ts
247
+ function Ve(e, t = (/* @__PURE__ */ new Date()).getFullYear()) {
248
+ return e.replaceAll("{year}", String(t));
249
+ }
250
+ // packages/core/src/pages/auth/options.ts
251
+ var He = /^1[3-9]\d{9}$/;
252
+ function K() {
253
+ return G().login ?? {};
254
+ }
255
+ function Ue() {
256
+ let e = G().auth;
257
+ return {
258
+ captcha: typeof e.captcha == "function",
259
+ register: typeof e.register == "function" && typeof e.sendSmsCode == "function",
260
+ forgot: typeof e.resetPassword == "function" && typeof e.sendSmsCode == "function"
261
+ };
262
+ }
263
+ function We(e) {
264
+ return typeof e == "string" && e.startsWith("/") && !e.startsWith("//") ? e : "/";
265
+ }
266
+ // packages/core/src/pages/auth/AuthShell.vue?vue&type=script&setup=true&lang.ts
267
+ var Ge = { class: "ca-auth__card" }, Ke = { class: "ca-auth__panel" }, qe = ["src"], Je = { class: "ca-auth__qrcode" }, Ye = ["src", "alt"], Xe = {
268
+ key: 0,
269
+ class: "ca-auth__caption"
270
+ }, Ze = { class: "ca-auth__site" }, Qe = {
271
+ key: 0,
272
+ class: "ca-auth__caption"
273
+ }, $e = { class: "ca-auth__main" }, et = { class: "ca-auth__brand" }, tt = ["src"], nt = {
274
+ class: "ca-auth__tabs",
275
+ role: "tablist"
276
+ }, rt = [
277
+ "aria-selected",
278
+ "tabindex",
279
+ "onClick",
280
+ "onKeydown"
281
+ ], it = {
282
+ class: "ca-auth__body",
283
+ role: "tabpanel"
284
+ }, at = {
9
285
  key: 0,
10
- class: "ca-loading",
11
- role: "status",
12
- "aria-live": "polite"
13
- }, Ee = { class: "ca-loading__box" }, De = {
286
+ class: "ca-auth__footer"
287
+ }, ot = {
14
288
  key: 0,
15
- class: "ca-loading__text"
16
- }, Oe = /*@__PURE__*/ p({
17
- name: "CaLoadingOverlay",
18
- __name: "ca-loading-overlay",
289
+ class: "ca-auth__version"
290
+ }, st = /*@__PURE__*/ d({
291
+ __name: "AuthShell",
19
292
  props: {
20
- visible: {
21
- type: Boolean,
22
- default: !1
23
- },
24
- text: { default: "" }
293
+ tabs: {},
294
+ active: {},
295
+ preview: { type: Boolean }
25
296
  },
26
- setup(e) {
27
- return (n, r) => (g(), o(t, { name: "ca-loading-fade" }, {
28
- default: C(() => [e.visible ? (g(), c("div", Te, [l("div", Ee, [r[0] ||= l("span", {
29
- class: "ca-loading__spinner",
30
- "aria-hidden": "true"
31
- }, null, -1), e.text ? (g(), c("p", De, b(e.text), 1)) : s("", !0)])])) : s("", !0)]),
32
- _: 1
33
- }));
297
+ emits: ["update:active"],
298
+ setup(t, { emit: r }) {
299
+ let c = t, u = r, { t: d, label: f } = W(), p = G().brand, m = K(), _ = Be(), v = n(() => f(_.theme.siteName ?? p.name)), b = n(() => _.theme.logo ?? p.logo), x = n(() => m.panel?.logo ?? b.value), w = n(() => m.panel?.qrcode), T = n(() => {
300
+ let e = m.panel?.caption ?? p.subtitle;
301
+ return e ? f(e) : "";
302
+ }), O = n(() => m.background ?? "var(--ca-login-bg)"), k = n(() => m.footer ? m.footer.map((e) => Ve(f(e))) : p.copyright ? Ve(f(p.copyright)).split("\n").filter(Boolean) : []);
303
+ function A(e, t) {
304
+ if (e.key !== "ArrowRight" && e.key !== "ArrowLeft") return;
305
+ let n = (t + (e.key === "ArrowRight" ? 1 : -1) + c.tabs.length) % c.tabs.length, r = c.tabs[n];
306
+ r.to || u("update:active", r.key), e.currentTarget.parentElement?.querySelectorAll("[role=tab]")[n]?.focus(), e.preventDefault();
307
+ }
308
+ return (n, r) => (y(), o("div", { class: h(["ca-auth", { "ca-auth--preview": t.preview }]) }, [s("div", {
309
+ class: "ca-auth__stage",
310
+ style: g({ background: O.value })
311
+ }, [s("div", Ge, [s("aside", Ke, [x.value ? (y(), o("img", {
312
+ key: 0,
313
+ src: x.value,
314
+ alt: "",
315
+ class: "ca-auth__logo"
316
+ }, null, 8, qe)) : a("v-if", !0), w.value ? (y(), o(e, { key: 1 }, [s("div", Je, [s("img", {
317
+ src: w.value,
318
+ alt: D(d)("campus.auth.qrcodeAlt")
319
+ }, null, 8, Ye)]), T.value ? (y(), o("p", Xe, E(T.value), 1)) : a("v-if", !0)], 64)) : (y(), o(e, { key: 2 }, [s("h2", Ze, E(v.value), 1), T.value ? (y(), o("p", Qe, E(T.value), 1)) : a("v-if", !0)], 64))]), s("section", $e, [
320
+ s("div", et, [b.value ? (y(), o("img", {
321
+ key: 0,
322
+ src: b.value,
323
+ alt: ""
324
+ }, null, 8, tt)) : a("v-if", !0), s("span", null, E(v.value), 1)]),
325
+ s("div", nt, [(y(!0), o(e, null, S(t.tabs, (n, r) => (y(), o(e, { key: n.key }, [n.to && !t.preview ? (y(), i(D(z), {
326
+ key: 0,
327
+ to: n.to,
328
+ role: "tab",
329
+ "aria-selected": "false",
330
+ class: "ca-auth__tab",
331
+ onKeydown: (e) => A(e, r)
332
+ }, {
333
+ default: M(() => [l(E(n.label), 1)]),
334
+ _: 2
335
+ }, 1032, ["to", "onKeydown"])) : (y(), o("button", {
336
+ key: 1,
337
+ type: "button",
338
+ role: "tab",
339
+ class: h(["ca-auth__tab", { "ca-auth__tab--active": n.key === t.active }]),
340
+ "aria-selected": n.key === t.active,
341
+ tabindex: n.key === t.active ? 0 : -1,
342
+ onClick: (e) => n.to ? void 0 : u("update:active", n.key),
343
+ onKeydown: (e) => A(e, r)
344
+ }, E(n.label), 43, rt))], 64))), 128))]),
345
+ s("div", it, [C(n.$slots, "default", {}, void 0, !0)]),
346
+ k.value.length ? (y(), o("div", at, [(y(!0), o(e, null, S(k.value, (e) => (y(), o("p", { key: e }, E(e), 1))), 128))])) : a("v-if", !0)
347
+ ])]), D(m).version ? (y(), o("span", ot, E(D(m).version), 1)) : a("v-if", !0)], 4)], 2));
34
348
  }
35
- }), w = (e, t) => {
349
+ }), q = (e, t) => {
36
350
  let n = e.__vccOpts || e;
37
351
  for (let [e, r] of t) n[e] = r;
38
352
  return n;
39
- }, T = /*#__PURE__*/ w(Oe, [["__scopeId", "data-v-ea638a9d"]]), ke = {
40
- class: "ca-toast-list",
41
- "aria-live": "polite",
42
- "aria-atomic": "false"
43
- }, Ae = {
44
- class: "ca-toast__icon",
353
+ }, ct = /*#__PURE__*/ q(st, [["__scopeId", "data-v-47cc63eb"]]), J = I("campus-layout", () => {
354
+ let e = x(!1), t = x("desktop"), n = x(!1), r = x(!1);
355
+ function i() {
356
+ e.value = !e.value;
357
+ }
358
+ function a(e) {
359
+ t.value = e, e !== "phone" && (n.value = !1), e !== "pad" && (r.value = !1);
360
+ }
361
+ function o() {
362
+ n.value = !1;
363
+ }
364
+ function s() {
365
+ n.value = !0;
366
+ }
367
+ function c() {
368
+ r.value = !1;
369
+ }
370
+ function l() {
371
+ r.value = !0;
372
+ }
373
+ function u() {
374
+ n.value = !1, r.value = !1;
375
+ }
376
+ function d() {
377
+ e.value = !1, u();
378
+ }
379
+ return {
380
+ reset: d,
381
+ contentFullscreen: e,
382
+ mode: t,
383
+ mobileMenuOpen: n,
384
+ padPanelOpen: r,
385
+ toggleContentFullscreen: i,
386
+ setMode: a,
387
+ closeMobileMenu: o,
388
+ openMobileMenu: s,
389
+ closePadPanel: c,
390
+ openPadPanel: l,
391
+ closeOverlays: u
392
+ };
393
+ });
394
+ // packages/core/src/tabs-policy.ts
395
+ function lt(e, t, n = Date.now()) {
396
+ return {
397
+ ...e,
398
+ [t]: Math.max(n, ...Object.values(e).map((e) => e + 1))
399
+ };
400
+ }
401
+ function ut(e, t, n, r, i) {
402
+ let a = e.filter((e) => !r.includes(e));
403
+ if (!(a.length <= i)) return a.filter((e) => e !== n).reduce((e, n) => e === void 0 || (t[n] ?? 0) < (t[e] ?? 0) ? n : e, void 0);
404
+ }
405
+ // packages/core/src/stores/tabs.ts
406
+ var dt = "tabs", Y = I("campus-tabs", () => {
407
+ let e = Me(G().menus), t = new Set(e.map((e) => e.key)), r = e.filter((e) => e.affix).map((e) => e.key), i = _e(dt, "session"), a = !Array.isArray(i) && Array.isArray(i?.affix) ? i.affix : [], o = x(a.filter((e) => t.has(e) && !r.includes(e))), s = n(() => [...r, ...o.value]), c = G().maxTabs, l = typeof c == "number" && Number.isFinite(c) ? Math.max(1, Math.floor(c)) : 20, u = (Array.isArray(i) ? i : Array.isArray(i?.visited) ? i.visited : []).filter((e) => typeof e == "string" && t.has(e)), d = x([.../* @__PURE__ */ new Set([...s.value, ...u])]), f = !Array.isArray(i) && i?.active && typeof i.active == "object" ? i.active : {}, p = x(Object.fromEntries(Object.entries(f).filter(([e, n]) => t.has(e) && typeof n == "number" && Number.isFinite(n))));
408
+ for (let [e, t] of d.value.entries()) Number.isFinite(p.value[t]) || (p.value[t] = e + 1);
409
+ for (;;) {
410
+ let e = ut(d.value, p.value, "", s.value, l);
411
+ if (!e) break;
412
+ d.value.splice(d.value.indexOf(e), 1), delete p.value[e];
413
+ }
414
+ let h = x({}), g = x(null), _ = n(() => d.value.filter((e) => e !== g.value));
415
+ function v() {
416
+ p.value = Object.fromEntries(d.value.map((e) => [e, p.value[e] ?? 0])), ve(dt, {
417
+ visited: d.value,
418
+ active: p.value,
419
+ affix: o.value
420
+ }, "session");
421
+ }
422
+ function y(e) {
423
+ if (!t.has(e)) return;
424
+ d.value.includes(e) || d.value.push(e), p.value = lt(p.value, e);
425
+ let n = ut(d.value, p.value, e, s.value, l);
426
+ n && d.value.splice(d.value.indexOf(n), 1), v();
427
+ }
428
+ function b(e) {
429
+ if (s.value.includes(e)) return;
430
+ let t = d.value.indexOf(e);
431
+ if (t !== -1) return d.value.splice(t, 1), v(), d.value[t] ?? d.value[t - 1];
432
+ }
433
+ function S(e) {
434
+ d.value = d.value.filter((t) => t === e || s.value.includes(t)), v();
435
+ }
436
+ function C(e) {
437
+ let t = d.value.indexOf(e);
438
+ t !== -1 && (d.value = d.value.filter((e, n) => n >= t || s.value.includes(e)), v());
439
+ }
440
+ function w(e) {
441
+ let t = d.value.indexOf(e);
442
+ t !== -1 && (d.value = d.value.filter((e, n) => n <= t || s.value.includes(e)), v());
443
+ }
444
+ function T() {
445
+ d.value = [...s.value], v();
446
+ }
447
+ async function E(e) {
448
+ g.value = e, await m(), h.value[e] = (h.value[e] ?? 0) + 1, g.value = null;
449
+ }
450
+ function D(e, n) {
451
+ return !t.has(e) || r.includes(e) || n && !d.value.includes(e) ? !1 : (n && !o.value.includes(e) && o.value.push(e), n || (o.value = o.value.filter((t) => t !== e)), v(), !0);
452
+ }
453
+ function O() {
454
+ o.value = [], d.value = [...r], p.value = {}, h.value = {}, g.value = null, v();
455
+ }
456
+ return {
457
+ reset: O,
458
+ visited: d,
459
+ versions: h,
460
+ cached: _,
461
+ affixKeys: s,
462
+ activeAt: p,
463
+ maxTabs: l,
464
+ open: y,
465
+ close: b,
466
+ closeLeft: C,
467
+ closeRight: w,
468
+ closeOthers: S,
469
+ closeAll: T,
470
+ refresh: E,
471
+ setAffix: D
472
+ };
473
+ }), ft = "session", X = I("campus-session", () => {
474
+ let e = _e(ft, "session"), t = x(e?.token ?? ""), r = x(e?.user), i = n(() => !!(t.value && r.value));
475
+ function a(e) {
476
+ if (!e) return !0;
477
+ let t = r.value?.permissions;
478
+ return t === "*" || !!t?.includes(e);
479
+ }
480
+ function o(e) {
481
+ r.value && (r.value = {
482
+ ...r.value,
483
+ permissions: e
484
+ }, ve(ft, {
485
+ token: t.value,
486
+ user: r.value
487
+ }, "session"));
488
+ }
489
+ async function s(e) {
490
+ let n = await G().auth.login(e);
491
+ t.value = n.token, r.value = n.user, ve(ft, n, "session");
492
+ }
493
+ async function c() {
494
+ try {
495
+ await G().auth.logout?.();
496
+ } catch (e) {
497
+ console.warn("[campus] 退出时通知服务端失败,已清除本地登录态:", e);
498
+ } finally {
499
+ t.value = "", r.value = void 0, U(ft, null, "session"), Y().reset(), J().reset();
500
+ }
501
+ }
502
+ function l() {
503
+ t.value = "", r.value = void 0, U(ft, null, "session"), Y().reset(), J().reset();
504
+ }
505
+ return {
506
+ token: t,
507
+ user: r,
508
+ isLoggedIn: i,
509
+ can: a,
510
+ setPermissions: o,
511
+ login: s,
512
+ logout: c,
513
+ expire: l
514
+ };
515
+ }), pt = {
516
+ class: "ca-auth-icon",
517
+ viewBox: "0 0 24 24",
518
+ width: "16",
519
+ height: "16",
520
+ fill: "none",
521
+ stroke: "currentColor",
522
+ "stroke-width": "1.8",
523
+ "stroke-linecap": "round",
524
+ "stroke-linejoin": "round",
45
525
  "aria-hidden": "true"
46
- }, je = { class: "ca-toast__text" }, Me = { key: 0 }, E = /*#__PURE__*/ w(/* @__PURE__ */ p({
47
- name: "CaToastList",
48
- __name: "ca-toast-list",
49
- props: { items: { default: () => [] } },
526
+ }, mt = ["d"], Z = /* @__PURE__ */ d({
527
+ __name: "AuthIcon",
528
+ props: { name: {} },
529
+ setup(e) {
530
+ let t = {
531
+ user: "M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm-7 8c0-3.3 3.1-6 7-6s7 2.7 7 6",
532
+ lock: "M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3",
533
+ phone: "M8 3h8a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm3 15h2",
534
+ shield: "M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.500-7-10V6l7-3Zm-3 9 2.500 2.500L15 10",
535
+ message: "M4 5h16v11H9l-4 3.500V16H4z"
536
+ };
537
+ return (n, r) => (y(), o("svg", pt, [s("path", { d: t[e.name] }, null, 8, mt)]));
538
+ }
539
+ }), ht = { class: "ca-auth-row" }, gt = [
540
+ "title",
541
+ "aria-label",
542
+ "disabled"
543
+ ], _t = ["src"], vt = { key: 1 }, yt = /* @__PURE__ */ d({
544
+ __name: "CaptchaField",
545
+ props: /*@__PURE__*/ p({ scene: {} }, {
546
+ code: { default: "" },
547
+ codeModifiers: {},
548
+ captchaKey: { default: "" },
549
+ captchaKeyModifiers: {}
550
+ }),
551
+ emits: ["update:code", "update:captchaKey"],
552
+ setup(e, { expose: t }) {
553
+ let n = e, r = O(e, "code"), i = O(e, "captchaKey"), { t: c } = W(), l = x(""), d = x(!1), f = x(!1);
554
+ async function p() {
555
+ f.value = !0;
556
+ try {
557
+ let e = await G().auth.captcha(n.scene);
558
+ i.value = e.key, l.value = e.image, d.value = !1;
559
+ } catch {
560
+ l.value = "", d.value = !0;
561
+ } finally {
562
+ r.value = "", f.value = !1;
563
+ }
564
+ }
565
+ return v(p), t({ refresh: p }), (e, t) => {
566
+ let n = w("ca-input");
567
+ return y(), o("div", ht, [u(n, {
568
+ modelValue: r.value,
569
+ "onUpdate:modelValue": t[0] ||= (e) => r.value = e,
570
+ placeholder: D(c)("campus.auth.captchaPlaceholder"),
571
+ "aria-label": D(c)("campus.auth.captcha"),
572
+ autocomplete: "off",
573
+ maxlength: "8"
574
+ }, {
575
+ prefix: M(() => [u(Z, { name: "shield" })]),
576
+ _: 1
577
+ }, 8, [
578
+ "modelValue",
579
+ "placeholder",
580
+ "aria-label"
581
+ ]), s("button", {
582
+ type: "button",
583
+ class: "ca-auth-captcha",
584
+ title: D(c)("campus.auth.captchaRefresh"),
585
+ "aria-label": D(c)("campus.auth.captchaRefresh"),
586
+ disabled: f.value,
587
+ onClick: p
588
+ }, [l.value ? (y(), o("img", {
589
+ key: 0,
590
+ src: l.value,
591
+ alt: ""
592
+ }, null, 8, _t)) : d.value ? (y(), o("span", vt, E(D(c)("campus.auth.captchaFailed")), 1)) : a("v-if", !0)], 8, gt)]);
593
+ };
594
+ }
595
+ }), bt = {
596
+ key: 1,
597
+ class: "ca-auth-links"
598
+ }, xt = { class: "ca-auth-help" }, St = /* @__PURE__ */ d({
599
+ __name: "LoginForm",
600
+ props: { preview: { type: Boolean } },
50
601
  setup(t) {
51
- return (r, i) => (g(), c("div", ke, [d(n, { name: "ca-toast" }, {
52
- default: C(() => [(g(!0), c(e, null, v(t.items, (e) => (g(), c("div", {
53
- key: e.id,
54
- class: ne(["ca-toast", e.tone]),
55
- role: "status"
56
- }, [l("span", Ae, [e.tone === "success" ? (g(), o(x(me), {
602
+ let r = t, c = B(), d = V(), f = X(), { t: p, label: m } = W(), h = Ue(), g = K(), _ = b({
603
+ username: "",
604
+ password: "",
605
+ captcha: ""
606
+ }), v = x(""), C = x(), T = x(), O = x(!1), k = x(""), A = x("error"), j = n(() => ({
607
+ username: [{
608
+ required: !0,
609
+ message: p("campus.login.required", { label: p("campus.login.username") }),
610
+ trigger: "blur"
611
+ }],
612
+ password: [{
613
+ required: !0,
614
+ message: p("campus.login.required", { label: p("campus.login.password") }),
615
+ trigger: "blur"
616
+ }],
617
+ captcha: h.captcha ? [{
618
+ required: !0,
619
+ message: p("campus.auth.captchaRequired"),
620
+ trigger: "blur"
621
+ }] : []
622
+ })), N = n(() => (g.helps ?? [
623
+ 1,
624
+ 2,
625
+ 3,
626
+ 4
627
+ ].map((e) => `campus.auth.help${e}`)).map((e) => m(e).split("{forgot}").flatMap((e, t, n) => t < n.length - 1 ? [e, null] : [e])));
628
+ async function F() {
629
+ try {
630
+ await T.value?.validate();
631
+ } catch {
632
+ return;
633
+ }
634
+ if (r.preview) A.value = "info", k.value = p("campus.auth.previewNote");
635
+ else {
636
+ O.value = !0, k.value = "", A.value = "error";
637
+ try {
638
+ await f.login({
639
+ username: _.username,
640
+ password: _.password,
641
+ captcha: h.captcha ? {
642
+ key: v.value,
643
+ code: _.captcha
644
+ } : void 0
645
+ }), await d.replace(We(c.query.redirect));
646
+ } catch (e) {
647
+ k.value = e instanceof Error && e.message ? e.message : p("campus.login.failed"), C.value?.refresh();
648
+ } finally {
649
+ O.value = !1;
650
+ }
651
+ }
652
+ }
653
+ function I(e) {
654
+ r.preview && e.preventDefault();
655
+ }
656
+ let L = n(() => h.forgot || h.register);
657
+ return (t, n) => {
658
+ let r = w("ca-alert"), c = w("ca-input"), d = w("ca-form-item"), f = w("ca-button"), m = w("ca-form");
659
+ return y(), o(e, null, [
660
+ k.value ? (y(), i(r, {
661
+ key: 0,
662
+ title: k.value,
663
+ type: A.value,
664
+ "show-icon": "",
665
+ closable: !1,
666
+ class: "ca-auth-alert"
667
+ }, null, 8, ["title", "type"])) : a("v-if", !0),
668
+ u(m, {
669
+ ref_key: "formRef",
670
+ ref: T,
671
+ model: _,
672
+ rules: j.value,
673
+ size: "large",
674
+ class: "ca-auth-form",
675
+ onSubmit: P(F, ["prevent"])
676
+ }, {
677
+ default: M(() => [
678
+ u(d, { prop: "username" }, {
679
+ default: M(() => [u(c, {
680
+ modelValue: _.username,
681
+ "onUpdate:modelValue": n[0] ||= (e) => _.username = e,
682
+ placeholder: D(p)("campus.auth.accountPlaceholder"),
683
+ "aria-label": D(p)("campus.login.username"),
684
+ autocomplete: "username"
685
+ }, {
686
+ prefix: M(() => [u(Z, { name: "user" })]),
687
+ _: 1
688
+ }, 8, [
689
+ "modelValue",
690
+ "placeholder",
691
+ "aria-label"
692
+ ])]),
693
+ _: 1
694
+ }),
695
+ u(d, { prop: "password" }, {
696
+ default: M(() => [u(c, {
697
+ modelValue: _.password,
698
+ "onUpdate:modelValue": n[1] ||= (e) => _.password = e,
699
+ type: "password",
700
+ "show-password": "",
701
+ placeholder: D(p)("campus.auth.passwordPlaceholder"),
702
+ "aria-label": D(p)("campus.login.password"),
703
+ autocomplete: "current-password"
704
+ }, {
705
+ prefix: M(() => [u(Z, { name: "lock" })]),
706
+ _: 1
707
+ }, 8, [
708
+ "modelValue",
709
+ "placeholder",
710
+ "aria-label"
711
+ ])]),
712
+ _: 1
713
+ }),
714
+ D(h).captcha ? (y(), i(d, {
715
+ key: 0,
716
+ prop: "captcha"
717
+ }, {
718
+ default: M(() => [u(yt, {
719
+ ref_key: "captchaRef",
720
+ ref: C,
721
+ code: _.captcha,
722
+ "onUpdate:code": n[2] ||= (e) => _.captcha = e,
723
+ "captcha-key": v.value,
724
+ "onUpdate:captchaKey": n[3] ||= (e) => v.value = e,
725
+ scene: "login"
726
+ }, null, 8, ["code", "captcha-key"])]),
727
+ _: 1
728
+ })) : a("v-if", !0),
729
+ u(f, {
730
+ type: "primary",
731
+ "native-type": "submit",
732
+ size: "large",
733
+ loading: O.value,
734
+ class: "ca-auth-submit"
735
+ }, {
736
+ default: M(() => [l(E(D(p)("campus.login.submit")), 1)]),
737
+ _: 1
738
+ }, 8, ["loading"])
739
+ ]),
740
+ _: 1
741
+ }, 8, ["model", "rules"]),
742
+ L.value ? (y(), o("div", bt, [D(h).forgot ? (y(), i(D(z), {
743
+ key: 0,
744
+ to: "/forgot",
745
+ onClick: I
746
+ }, {
747
+ default: M(() => [l(E(D(p)("campus.auth.forgotLink")), 1)]),
748
+ _: 1
749
+ })) : a("v-if", !0), D(h).register ? (y(), i(D(z), {
750
+ key: 1,
751
+ to: "/register",
752
+ onClick: I
753
+ }, {
754
+ default: M(() => [l(E(D(p)("campus.auth.registerLink")), 1)]),
755
+ _: 1
756
+ })) : a("v-if", !0)])) : a("v-if", !0),
757
+ s("div", xt, [s("h3", null, E(D(p)("campus.auth.helpTitle")), 1), s("ol", null, [(y(!0), o(e, null, S(N.value, (t, n) => (y(), o("li", { key: n }, [(y(!0), o(e, null, S(t, (t, n) => (y(), o(e, { key: n }, [t === null ? D(h).forgot ? (y(), i(D(z), {
758
+ key: 1,
759
+ to: "/forgot",
760
+ onClick: I
761
+ }, {
762
+ default: M(() => [l(E(D(p)("campus.auth.findPassword")), 1)]),
763
+ _: 1
764
+ })) : (y(), o(e, { key: 2 }, [l(E(D(p)("campus.auth.findPassword")), 1)], 64)) : (y(), o(e, { key: 0 }, [l(E(t), 1)], 64))], 64))), 128))]))), 128))])])
765
+ ], 64);
766
+ };
767
+ }
768
+ }), Ct = { class: "ca-auth-wechat" }, wt = { class: "ca-auth-wechat__code" }, Tt = ["src", "alt"], Et = ["aria-label"], Dt = { class: "ca-auth-wechat__hint" }, Ot = {
769
+ key: 0,
770
+ class: "ca-auth-wechat__note"
771
+ }, kt = /* @__PURE__ */ d({
772
+ __name: "WechatPane",
773
+ setup(e) {
774
+ let { t } = W(), r = n(() => K().panel?.qrcode);
775
+ return (e, n) => (y(), o("div", Ct, [
776
+ s("div", wt, [r.value ? (y(), o("img", {
57
777
  key: 0,
58
- size: 15,
59
- "stroke-width": 3
60
- })) : e.tone === "danger" ? (g(), o(x(ge), {
778
+ src: r.value,
779
+ alt: D(t)("campus.auth.qrcodeAlt")
780
+ }, null, 8, Tt)) : (y(), o("svg", {
61
781
  key: 1,
62
- size: 15,
63
- "stroke-width": 3
64
- })) : e.tone === "warning" ? (g(), o(x(pe), {
65
- key: 2,
66
- size: 15,
67
- "stroke-width": 3
68
- })) : (g(), o(x(he), {
69
- key: 3,
70
- size: 15,
71
- "stroke-width": 3
72
- }))]), l("span", je, [u(b(e.text) + " ", 1), e.description ? (g(), c("small", Me, b(e.description), 1)) : s("", !0)])], 2))), 128))]),
782
+ viewBox: "0 0 100 100",
783
+ role: "img",
784
+ "aria-label": D(t)("campus.auth.qrcodeAlt")
785
+ }, [...n[0] ||= [c("<rect x=\"8\" y=\"8\" width=\"26\" height=\"26\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"5\"></rect><rect x=\"66\" y=\"8\" width=\"26\" height=\"26\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"5\"></rect><rect x=\"8\" y=\"66\" width=\"26\" height=\"26\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"5\"></rect><rect x=\"16\" y=\"16\" width=\"10\" height=\"10\" fill=\"currentColor\"></rect><rect x=\"74\" y=\"16\" width=\"10\" height=\"10\" fill=\"currentColor\"></rect><rect x=\"16\" y=\"74\" width=\"10\" height=\"10\" fill=\"currentColor\"></rect><path d=\"M44 10h8v10h-8zM44 28h16v8H44zM10 44h10v8H10zM28 44h16v10H28zM52 46h10v10H52zM70 44h22v8H70zM44 62h8v14h-8zM58 66h14v8H58zM78 62h14v14H78zM56 82h14v10H56z\" fill=\"currentColor\"></path>", 7)]], 8, Et))]),
786
+ s("p", Dt, E(D(t)("campus.auth.wechatHint")), 1),
787
+ r.value ? a("v-if", !0) : (y(), o("p", Ot, E(D(t)("campus.auth.wechatNote")), 1))
788
+ ]));
789
+ }
790
+ }), At = /* @__PURE__ */ d({
791
+ __name: "LoginSplit",
792
+ props: { preview: { type: Boolean } },
793
+ setup(e) {
794
+ let { t } = W(), r = K().tabs?.length ? K().tabs : ["account", "wechat"], a = x(r[0]), o = n(() => r.map((e) => ({
795
+ key: e,
796
+ label: t(e === "account" ? "campus.auth.tabAccount" : "campus.auth.tabWechat")
797
+ })));
798
+ return (t, n) => (y(), i(ct, {
799
+ active: a.value,
800
+ "onUpdate:active": n[0] ||= (e) => a.value = e,
801
+ tabs: o.value,
802
+ preview: e.preview
803
+ }, {
804
+ default: M(() => [a.value === "account" ? (y(), i(St, {
805
+ key: 0,
806
+ preview: e.preview
807
+ }, null, 8, ["preview"])) : (y(), i(kt, { key: 1 }))]),
73
808
  _: 1
74
- })]));
75
- }
76
- }), [["__scopeId", "data-v-a58555ed"]]), D = class {
77
- state;
78
- listeners = /* @__PURE__ */ new Set();
79
- constructor(e) {
80
- this.state = e;
81
- }
82
- get() {
83
- return this.state;
84
- }
85
- set(e) {
86
- let t = typeof e == "function" ? e(this.state) : e;
87
- this.state = {
88
- ...this.state,
89
- ...t
90
- }, this.listeners.forEach((e) => e(this.state));
91
- }
92
- subscribe(e) {
93
- return this.listeners.add(e), () => {
94
- this.listeners.delete(e);
95
- };
809
+ }, 8, [
810
+ "active",
811
+ "tabs",
812
+ "preview"
813
+ ]));
96
814
  }
97
- }, O = new D({ list: [] }), Ne = 0;
98
- function k(e) {
99
- let t = ++Ne;
100
- return O.set((n) => ({ list: [...n.list, {
101
- ...e,
102
- id: t
103
- }] })), t;
104
- }
105
- function A(e) {
106
- O.set((t) => ({ list: t.list.filter((t) => t.id !== e) }));
107
- }
108
- function Pe() {
109
- O.set({ list: [] });
110
- }
111
- function j(e, t, n) {
112
- return typeof t == "function" ? {
113
- title: e,
114
- content: "",
115
- onConfirm: t
116
- } : t === void 0 ? { content: e } : {
117
- title: e,
118
- content: t,
119
- onConfirm: n
120
- };
815
+ });
816
+ // packages/core/src/security.ts
817
+ function jt(e) {
818
+ return e.environment ? e.environment : "production";
121
819
  }
122
- function M(e, t, n) {
123
- let { title: r, content: i, onConfirm: a } = j(e, t, n);
124
- k({
125
- variant: "alert",
126
- title: r,
127
- content: i,
128
- confirmText: "确定",
129
- onConfirm: a
820
+ function Mt(e) {
821
+ if (jt(e) === "production" && typeof e.auth.captcha != "function") throw Error("[campus] 生产环境必须在 auth 中提供 captcha()(图形验证码);测试环境可设置 environment: 'test' 跳过");
822
+ }
823
+ function Nt(e, t) {
824
+ return t === "test" || e.length >= 8 && /[A-Za-z]/.test(e) && /\d/.test(e);
825
+ }
826
+ // packages/core/src/services/feedback.ts
827
+ var Q = (e) => e;
828
+ function Pt(e) {
829
+ Q = e;
830
+ }
831
+ async function Ft(e, t = {}) {
832
+ await me.alert(e, t.title ?? Q("campus.common.tip"), {
833
+ type: t.type ?? "info",
834
+ confirmButtonText: t.confirmText ?? Q("campus.common.ok")
130
835
  });
131
836
  }
132
- function N(e, t, n) {
133
- let { title: r, content: i } = j(e, t, n);
134
- return new Promise((e) => {
135
- k({
136
- variant: "confirm",
137
- title: r ?? "提示",
138
- content: i,
139
- confirmText: "确定",
140
- cancelText: "取消",
141
- onConfirm: () => e(!0),
142
- onCancel: () => e(!1)
143
- });
837
+ async function It(e, t = {}) {
838
+ try {
839
+ return await me.confirm(e, t.title ?? Q("campus.common.tip"), {
840
+ type: t.type ?? "warning",
841
+ confirmButtonText: t.confirmText ?? Q("campus.common.confirm"),
842
+ cancelButtonText: t.cancelText ?? Q("campus.common.cancel")
843
+ }), !0;
844
+ } catch (e) {
845
+ if (e === "cancel" || e === "close") return !1;
846
+ throw e;
847
+ }
848
+ }
849
+ var Lt = {
850
+ info: (e) => void pe({
851
+ message: e,
852
+ type: "info"
853
+ }),
854
+ success: (e) => void pe({
855
+ message: e,
856
+ type: "success"
857
+ }),
858
+ warning: (e) => void pe({
859
+ message: e,
860
+ type: "warning"
861
+ }),
862
+ error: (e) => void pe({
863
+ message: e,
864
+ type: "error"
865
+ })
866
+ }, Rt = fe.service;
867
+ function zt(e, t, n = {}) {
868
+ let r = he({
869
+ ...n,
870
+ title: n.title ?? Q(`campus.notify.${e}`),
871
+ message: t,
872
+ type: e
144
873
  });
874
+ return m(() => he.updateOffsets(n.position)), r;
145
875
  }
146
- //#endregion
147
- //#region src/components/overlay/ca-overlay-list.vue?vue&type=script&setup=true&lang.ts
148
- var Fe = { class: "ca-overlay-root" }, Ie = ["onClick"], Le = ["aria-label"], Re = {
876
+ // packages/core/src/services/ca.ts
877
+ var $ = {
878
+ alert: Ft,
879
+ confirm: It,
880
+ toast: Lt,
881
+ loading: Rt,
882
+ notify: {
883
+ success: (e, t) => zt("success", e, t),
884
+ info: (e, t) => zt("info", e, t),
885
+ warning: (e, t) => zt("warning", e, t),
886
+ error: (e, t) => zt("error", e, t)
887
+ }
888
+ }, Bt = { class: "ca-auth-row" }, Vt = ["disabled"], Ht = 60, Ut = /* @__PURE__ */ d({
889
+ __name: "SmsField",
890
+ props: /*@__PURE__*/ p({ send: { type: Function } }, {
891
+ modelValue: { default: "" },
892
+ modelModifiers: {}
893
+ }),
894
+ emits: ["update:modelValue"],
895
+ setup(e) {
896
+ let t = e, n = O(e, "modelValue"), { t: r } = W(), i = x(0), a = x(!1), c;
897
+ function l() {
898
+ c && clearInterval(c), c = void 0;
899
+ }
900
+ async function d() {
901
+ if (!(i.value > 0 || a.value)) {
902
+ a.value = !0;
903
+ try {
904
+ await t.send();
905
+ } catch {
906
+ return;
907
+ } finally {
908
+ a.value = !1;
909
+ }
910
+ i.value = Ht, l(), c = setInterval(() => {
911
+ --i.value, i.value <= 0 && l();
912
+ }, 1e3);
913
+ }
914
+ }
915
+ return _(l), (e, t) => {
916
+ let c = w("ca-input");
917
+ return y(), o("div", Bt, [u(c, {
918
+ modelValue: n.value,
919
+ "onUpdate:modelValue": t[0] ||= (e) => n.value = e,
920
+ placeholder: D(r)("campus.auth.smsPlaceholder"),
921
+ "aria-label": D(r)("campus.auth.smsCode"),
922
+ autocomplete: "one-time-code",
923
+ maxlength: "8"
924
+ }, {
925
+ prefix: M(() => [u(Z, { name: "message" })]),
926
+ _: 1
927
+ }, 8, [
928
+ "modelValue",
929
+ "placeholder",
930
+ "aria-label"
931
+ ]), s("button", {
932
+ type: "button",
933
+ class: "ca-auth-sms",
934
+ disabled: i.value > 0 || a.value,
935
+ onClick: d
936
+ }, E(i.value > 0 ? D(r)("campus.auth.resend", { n: i.value }) : D(r)("campus.auth.getCode")), 9, Vt)]);
937
+ };
938
+ }
939
+ }), Wt = {
149
940
  key: 0,
150
- class: "ca-overlay__header"
151
- }, ze = { class: "ca-overlay__title" }, Be = {
941
+ class: "ca-auth-hint"
942
+ }, Gt = { class: "ca-auth-agreements" }, Kt = ["href"], qt = /* @__PURE__ */ d({
943
+ __name: "RegisterForm",
944
+ props: { preview: { type: Boolean } },
945
+ setup(t) {
946
+ let r = t, c = V(), { t: d, label: f } = W(), p = Ue(), m = jt(G()), g = K(), _ = g.agreements ?? [], v = b({
947
+ phone: "",
948
+ captcha: "",
949
+ code: "",
950
+ password: "",
951
+ confirm: "",
952
+ agree: !1
953
+ }), C = x(""), T = x(), O = x(), k = x(!1), A = x(""), j = x("error"), N = n(() => ({
954
+ phone: [{
955
+ required: !0,
956
+ message: d("campus.auth.phonePlaceholder"),
957
+ trigger: "blur"
958
+ }, {
959
+ pattern: He,
960
+ message: d("campus.auth.phoneInvalid"),
961
+ trigger: "blur"
962
+ }],
963
+ captcha: p.captcha ? [{
964
+ required: !0,
965
+ message: d("campus.auth.captchaRequired"),
966
+ trigger: "blur"
967
+ }] : [],
968
+ code: [{
969
+ required: !0,
970
+ message: d("campus.login.required", { label: d("campus.auth.smsCode") }),
971
+ trigger: "blur"
972
+ }],
973
+ password: [{
974
+ required: !0,
975
+ message: d("campus.auth.registerPasswordPlaceholder"),
976
+ trigger: "blur"
977
+ }, {
978
+ validator: (e, t, n) => n(Nt(t, m) ? void 0 : Error(d("campus.auth.passwordPolicy"))),
979
+ trigger: "blur"
980
+ }],
981
+ confirm: [{
982
+ required: !0,
983
+ message: d("campus.auth.confirmPlaceholder"),
984
+ trigger: "blur"
985
+ }, {
986
+ validator: (e, t, n) => n(t === v.password ? void 0 : Error(d("campus.auth.passwordMismatch"))),
987
+ trigger: "blur"
988
+ }],
989
+ agree: _.length ? [{
990
+ validator: (e, t, n) => n(t ? void 0 : Error(d("campus.auth.agreeRequired"))),
991
+ trigger: "change"
992
+ }] : []
993
+ })), F = n(() => !!(v.phone && v.code && v.password && v.confirm) && (!p.captcha || !!v.captcha) && (!_.length || v.agree));
994
+ function I(e, t) {
995
+ j.value = "error", A.value = e instanceof Error && e.message ? e.message : t;
996
+ }
997
+ async function L() {
998
+ let e = p.captcha ? ["phone", "captcha"] : ["phone"];
999
+ try {
1000
+ await O.value?.validateField(e);
1001
+ } catch {
1002
+ throw Error("invalid");
1003
+ }
1004
+ if (A.value = "", r.preview) j.value = "info", A.value = d("campus.auth.previewNote");
1005
+ else try {
1006
+ await G().auth.sendSmsCode({
1007
+ phone: v.phone,
1008
+ scene: "register",
1009
+ captcha: p.captcha ? {
1010
+ key: C.value,
1011
+ code: v.captcha
1012
+ } : void 0
1013
+ }), $.toast.success(d("campus.auth.smsSent"));
1014
+ } catch (e) {
1015
+ throw I(e, d("campus.login.failed")), T.value?.refresh(), e;
1016
+ }
1017
+ }
1018
+ async function ee() {
1019
+ if (F.value) {
1020
+ try {
1021
+ await O.value?.validate();
1022
+ } catch {
1023
+ return;
1024
+ }
1025
+ if (r.preview) j.value = "info", A.value = d("campus.auth.previewNote");
1026
+ else {
1027
+ k.value = !0, A.value = "";
1028
+ try {
1029
+ await G().auth.register({
1030
+ phone: v.phone,
1031
+ code: v.code,
1032
+ password: v.password,
1033
+ captcha: p.captcha ? {
1034
+ key: C.value,
1035
+ code: v.captcha
1036
+ } : void 0
1037
+ }), $.toast.success(d("campus.auth.registerOk")), await c.replace("/login");
1038
+ } catch (e) {
1039
+ I(e, d("campus.login.failed")), T.value?.refresh();
1040
+ } finally {
1041
+ k.value = !1;
1042
+ }
1043
+ }
1044
+ }
1045
+ }
1046
+ return (t, n) => {
1047
+ let r = w("ca-alert"), c = w("ca-input"), m = w("ca-form-item"), b = w("ca-checkbox"), x = w("ca-button"), I = w("ca-form");
1048
+ return y(), o(e, null, [A.value ? (y(), i(r, {
1049
+ key: 0,
1050
+ title: A.value,
1051
+ type: j.value,
1052
+ "show-icon": "",
1053
+ closable: !1,
1054
+ class: "ca-auth-alert"
1055
+ }, null, 8, ["title", "type"])) : a("v-if", !0), u(I, {
1056
+ ref_key: "formRef",
1057
+ ref: O,
1058
+ model: v,
1059
+ rules: N.value,
1060
+ size: "large",
1061
+ class: "ca-auth-form",
1062
+ onSubmit: P(ee, ["prevent"])
1063
+ }, {
1064
+ default: M(() => [
1065
+ u(m, { prop: "phone" }, {
1066
+ default: M(() => [u(c, {
1067
+ modelValue: v.phone,
1068
+ "onUpdate:modelValue": n[0] ||= (e) => v.phone = e,
1069
+ placeholder: D(d)("campus.auth.phonePlaceholder"),
1070
+ "aria-label": D(d)("campus.auth.phone"),
1071
+ autocomplete: "tel",
1072
+ maxlength: "11"
1073
+ }, {
1074
+ prefix: M(() => [u(Z, { name: "phone" })]),
1075
+ _: 1
1076
+ }, 8, [
1077
+ "modelValue",
1078
+ "placeholder",
1079
+ "aria-label"
1080
+ ])]),
1081
+ _: 1
1082
+ }),
1083
+ D(p).captcha ? (y(), i(m, {
1084
+ key: 0,
1085
+ prop: "captcha"
1086
+ }, {
1087
+ default: M(() => [u(yt, {
1088
+ ref_key: "captchaRef",
1089
+ ref: T,
1090
+ code: v.captcha,
1091
+ "onUpdate:code": n[1] ||= (e) => v.captcha = e,
1092
+ "captcha-key": C.value,
1093
+ "onUpdate:captchaKey": n[2] ||= (e) => C.value = e,
1094
+ scene: "register"
1095
+ }, null, 8, ["code", "captcha-key"])]),
1096
+ _: 1
1097
+ })) : a("v-if", !0),
1098
+ u(m, { prop: "code" }, {
1099
+ default: M(() => [u(Ut, {
1100
+ modelValue: v.code,
1101
+ "onUpdate:modelValue": n[3] ||= (e) => v.code = e,
1102
+ send: L
1103
+ }, null, 8, ["modelValue"]), D(g).smsHint ? (y(), o("p", Wt, E(D(f)(D(g).smsHint)), 1)) : a("v-if", !0)]),
1104
+ _: 1
1105
+ }),
1106
+ u(m, { prop: "password" }, {
1107
+ default: M(() => [u(c, {
1108
+ modelValue: v.password,
1109
+ "onUpdate:modelValue": n[4] ||= (e) => v.password = e,
1110
+ type: "password",
1111
+ "show-password": "",
1112
+ placeholder: D(d)("campus.auth.registerPasswordPlaceholder"),
1113
+ "aria-label": D(d)("campus.auth.registerPassword"),
1114
+ autocomplete: "new-password"
1115
+ }, {
1116
+ prefix: M(() => [u(Z, { name: "lock" })]),
1117
+ _: 1
1118
+ }, 8, [
1119
+ "modelValue",
1120
+ "placeholder",
1121
+ "aria-label"
1122
+ ])]),
1123
+ _: 1
1124
+ }),
1125
+ u(m, { prop: "confirm" }, {
1126
+ default: M(() => [u(c, {
1127
+ modelValue: v.confirm,
1128
+ "onUpdate:modelValue": n[5] ||= (e) => v.confirm = e,
1129
+ type: "password",
1130
+ "show-password": "",
1131
+ placeholder: D(d)("campus.auth.confirmPlaceholder"),
1132
+ "aria-label": D(d)("campus.auth.confirmPlaceholder"),
1133
+ autocomplete: "new-password"
1134
+ }, {
1135
+ prefix: M(() => [u(Z, { name: "lock" })]),
1136
+ _: 1
1137
+ }, 8, [
1138
+ "modelValue",
1139
+ "placeholder",
1140
+ "aria-label"
1141
+ ])]),
1142
+ _: 1
1143
+ }),
1144
+ D(_).length ? (y(), i(m, {
1145
+ key: 1,
1146
+ prop: "agree"
1147
+ }, {
1148
+ default: M(() => [u(b, {
1149
+ modelValue: v.agree,
1150
+ "onUpdate:modelValue": n[6] ||= (e) => v.agree = e
1151
+ }, {
1152
+ default: M(() => [l(E(D(d)("campus.auth.agreePrefix")), 1)]),
1153
+ _: 1
1154
+ }, 8, ["modelValue"]), s("span", Gt, [(y(!0), o(e, null, S(D(_), (e) => (y(), o("a", {
1155
+ key: e.href,
1156
+ href: e.href,
1157
+ target: "_blank",
1158
+ rel: "noopener noreferrer"
1159
+ }, E(D(f)(e.text)), 9, Kt))), 128))])]),
1160
+ _: 1
1161
+ })) : a("v-if", !0),
1162
+ u(x, {
1163
+ type: "primary",
1164
+ "native-type": "submit",
1165
+ size: "large",
1166
+ loading: k.value,
1167
+ disabled: !F.value,
1168
+ class: h(["ca-auth-submit", { "ca-auth-submit--off": !F.value }])
1169
+ }, {
1170
+ default: M(() => [l(E(D(d)("campus.common.ok")), 1)]),
1171
+ _: 1
1172
+ }, 8, [
1173
+ "loading",
1174
+ "disabled",
1175
+ "class"
1176
+ ])
1177
+ ]),
1178
+ _: 1
1179
+ }, 8, ["model", "rules"])], 64);
1180
+ };
1181
+ }
1182
+ }), Jt = {
152
1183
  key: 1,
153
- class: "ca-overlay__body"
154
- }, P = { class: "ca-overlay__footer" }, Ve = ["disabled", "onClick"], He = ["disabled", "onClick"], F = /*#__PURE__*/ w(/* @__PURE__ */ p({
155
- name: "CaOverlayList",
156
- __name: "ca-overlay-list",
157
- props: { items: { default: () => [] } },
1184
+ class: "ca-auth-off",
1185
+ role: "status"
1186
+ }, Yt = /* @__PURE__ */ d({
1187
+ __name: "RegisterPage",
1188
+ props: { preview: { type: Boolean } },
1189
+ setup(e) {
1190
+ let { t } = W(), r = Ue().register, a = n(() => [{
1191
+ key: "register",
1192
+ label: t("campus.auth.tabRegister")
1193
+ }, {
1194
+ key: "login",
1195
+ label: t("campus.auth.backLogin"),
1196
+ to: "/login"
1197
+ }]);
1198
+ return (n, c) => (y(), i(ct, {
1199
+ active: "register",
1200
+ tabs: a.value,
1201
+ preview: e.preview
1202
+ }, {
1203
+ default: M(() => [D(r) ? (y(), i(qt, {
1204
+ key: 0,
1205
+ preview: e.preview
1206
+ }, null, 8, ["preview"])) : (y(), o("div", Jt, [s("h3", null, E(D(t)("campus.auth.unavailableTitle")), 1), s("p", null, E(D(t)("campus.auth.unavailableDesc")), 1)]))]),
1207
+ _: 1
1208
+ }, 8, ["tabs", "preview"]));
1209
+ }
1210
+ }), Xt = {
1211
+ key: 0,
1212
+ class: "ca-auth-hint"
1213
+ }, Zt = /* @__PURE__ */ d({
1214
+ __name: "ForgotForm",
1215
+ props: { preview: { type: Boolean } },
158
1216
  setup(t) {
159
- let n = _(null), r = null;
160
- S(() => document.activeElement instanceof HTMLElement ? document.activeElement : null, () => {}, { immediate: !1 });
161
- async function i(e) {
162
- if (n.value !== e.id) {
163
- n.value = e.id;
1217
+ let r = t, s = V(), { t: c, label: d } = W(), f = Ue(), p = jt(G()), m = K(), g = b({
1218
+ account: "",
1219
+ captcha: "",
1220
+ code: "",
1221
+ password: "",
1222
+ confirm: ""
1223
+ }), _ = x(""), v = x(), S = x(), C = x(!1), T = x(""), O = x("error"), k = n(() => ({
1224
+ account: [{
1225
+ required: !0,
1226
+ message: c("campus.auth.accountRequired"),
1227
+ trigger: "blur"
1228
+ }],
1229
+ captcha: f.captcha ? [{
1230
+ required: !0,
1231
+ message: c("campus.auth.captchaRequired"),
1232
+ trigger: "blur"
1233
+ }] : [],
1234
+ code: [{
1235
+ required: !0,
1236
+ message: c("campus.login.required", { label: c("campus.auth.smsCode") }),
1237
+ trigger: "blur"
1238
+ }],
1239
+ password: [{
1240
+ required: !0,
1241
+ message: c("campus.auth.newPasswordPlaceholder"),
1242
+ trigger: "blur"
1243
+ }, {
1244
+ validator: (e, t, n) => n(Nt(t, p) ? void 0 : Error(c("campus.auth.passwordPolicy"))),
1245
+ trigger: "blur"
1246
+ }],
1247
+ confirm: [{
1248
+ required: !0,
1249
+ message: c("campus.auth.confirmPlaceholder"),
1250
+ trigger: "blur"
1251
+ }, {
1252
+ validator: (e, t, n) => n(t === g.password ? void 0 : Error(c("campus.auth.passwordMismatch"))),
1253
+ trigger: "blur"
1254
+ }]
1255
+ })), A = n(() => !!(g.account && g.code && g.password && g.confirm) && (!f.captcha || !!g.captcha));
1256
+ function j(e, t) {
1257
+ O.value = "error", T.value = e instanceof Error && e.message ? e.message : t;
1258
+ }
1259
+ async function N() {
1260
+ let e = f.captcha ? ["account", "captcha"] : ["account"];
1261
+ try {
1262
+ await S.value?.validateField(e);
1263
+ } catch {
1264
+ throw Error("invalid");
1265
+ }
1266
+ if (T.value = "", r.preview) O.value = "info", T.value = c("campus.auth.previewNote");
1267
+ else try {
1268
+ await G().auth.sendSmsCode({
1269
+ ...He.test(g.account) ? { phone: g.account } : { username: g.account },
1270
+ scene: "forgot",
1271
+ captcha: f.captcha ? {
1272
+ key: _.value,
1273
+ code: g.captcha
1274
+ } : void 0
1275
+ }), $.toast.success(c("campus.auth.smsSent"));
1276
+ } catch (e) {
1277
+ throw j(e, c("campus.login.failed")), v.value?.refresh(), e;
1278
+ }
1279
+ }
1280
+ async function F() {
1281
+ if (A.value) {
164
1282
  try {
165
- await e.onConfirm?.();
166
- } finally {
167
- n.value = null, A(e.id), r?.focus(), r = null;
1283
+ await S.value?.validate();
1284
+ } catch {
1285
+ return;
1286
+ }
1287
+ if (r.preview) O.value = "info", T.value = c("campus.auth.previewNote");
1288
+ else {
1289
+ C.value = !0, T.value = "";
1290
+ try {
1291
+ await G().auth.resetPassword({
1292
+ account: g.account,
1293
+ code: g.code,
1294
+ password: g.password,
1295
+ captcha: f.captcha ? {
1296
+ key: _.value,
1297
+ code: g.captcha
1298
+ } : void 0
1299
+ }), $.toast.success(c("campus.auth.resetOk")), await s.replace("/login");
1300
+ } catch (e) {
1301
+ j(e, c("campus.login.failed")), v.value?.refresh();
1302
+ } finally {
1303
+ C.value = !1;
1304
+ }
168
1305
  }
169
1306
  }
170
1307
  }
171
- function a(e) {
172
- e.onCancel?.(), A(e.id), r?.focus(), r = null;
173
- }
174
- function o() {
175
- r ||= document.activeElement instanceof HTMLElement ? document.activeElement : null;
176
- }
177
- return (r, u) => (g(), c("div", Fe, [(g(!0), c(e, null, v(t.items, (e) => (g(), c("div", {
178
- key: e.id,
179
- class: "ca-overlay",
180
- onClick: fe((t) => e.variant === "confirm" && a(e), ["self"]),
181
- onVnodeMounted: o
182
- }, [l("section", {
183
- class: "ca-overlay__panel",
184
- role: "dialog",
185
- "aria-modal": "true",
186
- "aria-label": e.title ?? e.content
187
- }, [
188
- e.title ? (g(), c("header", Re, [l("h2", ze, b(e.title), 1)])) : s("", !0),
189
- e.content ? (g(), c("div", Be, b(e.content), 1)) : s("", !0),
190
- l("footer", P, [e.variant === "confirm" ? (g(), c("button", {
1308
+ return (t, n) => {
1309
+ let r = w("ca-alert"), s = w("ca-input"), p = w("ca-form-item"), b = w("ca-button"), x = w("ca-form");
1310
+ return y(), o(e, null, [T.value ? (y(), i(r, {
191
1311
  key: 0,
192
- class: "ca-overlay__button",
193
- type: "button",
194
- disabled: x(n) === e.id,
195
- onClick: (t) => a(e)
196
- }, b(e.cancelText ?? "取消"), 9, Ve)) : s("", !0), l("button", {
197
- class: "ca-overlay__button ca-overlay__button--primary",
198
- type: "button",
199
- disabled: x(n) === e.id,
200
- onClick: (t) => i(e)
201
- }, b(x(n) === e.id ? "处理中…" : e.confirmText), 9, He)])
202
- ], 8, Le)], 8, Ie))), 128))]));
203
- }
204
- }), [["__scopeId", "data-v-c8314f57"]]), I = class {
205
- entries = /* @__PURE__ */ new Map();
206
- bind(e, t) {
207
- this.entries.set(e, t);
208
- }
209
- singleton(e, t) {
210
- this.bind(e, t);
211
- }
212
- make(e) {
213
- if (!this.entries.has(e)) return;
214
- let t = this.entries.get(e);
215
- if (typeof t == "function") {
216
- let n = t();
217
- return this.entries.set(e, n), n;
218
- }
219
- return t;
220
- }
221
- resolve(e) {
222
- let t = this.make(e);
223
- if (t === void 0) throw Error(`[campus] 服务未注册: ${e}`);
224
- return t;
225
- }
226
- has(e) {
227
- return this.entries.has(e);
228
- }
229
- forget(e) {
230
- this.entries.delete(e);
231
- }
232
- };
233
- function L(e) {
234
- return typeof e == "object" && !!e && typeof e.name == "string";
235
- }
236
- //#endregion
237
- //#region src/context.ts
238
- var R = class {
239
- config;
240
- container;
241
- constructor(e, t) {
242
- this.config = e, this.container = t;
243
- }
244
- get(e, t) {
245
- let n = e.split("."), r = this.config;
246
- for (let e of n) if (typeof r != "object" || !r || (r = r[e], r === void 0)) return t;
247
- return r;
248
- }
249
- set(e, t) {
250
- let n = e.split("."), r = this.config;
251
- n.slice(0, -1).forEach((e) => {
252
- let t = r[e];
253
- (typeof t != "object" || !t) && (r[e] = {}), r = r[e];
254
- }), r[n[n.length - 1]] = t;
255
- }
256
- bind(e, t) {
257
- this.container.bind(e, t);
258
- }
259
- make(e) {
260
- return this.container.make(e);
261
- }
262
- resolve(e) {
263
- return this.container.resolve(e);
264
- }
265
- }, z = class {
266
- container = new I();
267
- context;
268
- providers = [];
269
- plugins = [];
270
- state = "created";
271
- bootedProviders = /* @__PURE__ */ new WeakSet();
272
- constructor(e = {}) {
273
- let t = {
274
- name: e.name ?? "Campus Admin",
275
- version: e.version ?? "0.0.0",
276
- ...e.config
1312
+ title: T.value,
1313
+ type: O.value,
1314
+ "show-icon": "",
1315
+ closable: !1,
1316
+ class: "ca-auth-alert"
1317
+ }, null, 8, ["title", "type"])) : a("v-if", !0), u(x, {
1318
+ ref_key: "formRef",
1319
+ ref: S,
1320
+ model: g,
1321
+ rules: k.value,
1322
+ size: "large",
1323
+ class: "ca-auth-form",
1324
+ onSubmit: P(F, ["prevent"])
1325
+ }, {
1326
+ default: M(() => [
1327
+ u(p, { prop: "account" }, {
1328
+ default: M(() => [u(s, {
1329
+ modelValue: g.account,
1330
+ "onUpdate:modelValue": n[0] ||= (e) => g.account = e,
1331
+ placeholder: D(c)("campus.auth.accountPlaceholder"),
1332
+ "aria-label": D(c)("campus.auth.account"),
1333
+ autocomplete: "username"
1334
+ }, {
1335
+ prefix: M(() => [u(Z, { name: "user" })]),
1336
+ _: 1
1337
+ }, 8, [
1338
+ "modelValue",
1339
+ "placeholder",
1340
+ "aria-label"
1341
+ ])]),
1342
+ _: 1
1343
+ }),
1344
+ D(f).captcha ? (y(), i(p, {
1345
+ key: 0,
1346
+ prop: "captcha"
1347
+ }, {
1348
+ default: M(() => [u(yt, {
1349
+ ref_key: "captchaRef",
1350
+ ref: v,
1351
+ code: g.captcha,
1352
+ "onUpdate:code": n[1] ||= (e) => g.captcha = e,
1353
+ "captcha-key": _.value,
1354
+ "onUpdate:captchaKey": n[2] ||= (e) => _.value = e,
1355
+ scene: "forgot"
1356
+ }, null, 8, ["code", "captcha-key"])]),
1357
+ _: 1
1358
+ })) : a("v-if", !0),
1359
+ u(p, { prop: "code" }, {
1360
+ default: M(() => [u(Ut, {
1361
+ modelValue: g.code,
1362
+ "onUpdate:modelValue": n[3] ||= (e) => g.code = e,
1363
+ send: N
1364
+ }, null, 8, ["modelValue"]), D(m).smsHint ? (y(), o("p", Xt, E(D(d)(D(m).smsHint)), 1)) : a("v-if", !0)]),
1365
+ _: 1
1366
+ }),
1367
+ u(p, { prop: "password" }, {
1368
+ default: M(() => [u(s, {
1369
+ modelValue: g.password,
1370
+ "onUpdate:modelValue": n[4] ||= (e) => g.password = e,
1371
+ type: "password",
1372
+ "show-password": "",
1373
+ placeholder: D(c)("campus.auth.newPasswordPlaceholder"),
1374
+ "aria-label": D(c)("campus.auth.newPasswordPlaceholder"),
1375
+ autocomplete: "new-password"
1376
+ }, {
1377
+ prefix: M(() => [u(Z, { name: "lock" })]),
1378
+ _: 1
1379
+ }, 8, [
1380
+ "modelValue",
1381
+ "placeholder",
1382
+ "aria-label"
1383
+ ])]),
1384
+ _: 1
1385
+ }),
1386
+ u(p, { prop: "confirm" }, {
1387
+ default: M(() => [u(s, {
1388
+ modelValue: g.confirm,
1389
+ "onUpdate:modelValue": n[5] ||= (e) => g.confirm = e,
1390
+ type: "password",
1391
+ "show-password": "",
1392
+ placeholder: D(c)("campus.auth.confirmPlaceholder"),
1393
+ "aria-label": D(c)("campus.auth.confirmPlaceholder"),
1394
+ autocomplete: "new-password"
1395
+ }, {
1396
+ prefix: M(() => [u(Z, { name: "lock" })]),
1397
+ _: 1
1398
+ }, 8, [
1399
+ "modelValue",
1400
+ "placeholder",
1401
+ "aria-label"
1402
+ ])]),
1403
+ _: 1
1404
+ }),
1405
+ u(b, {
1406
+ type: "primary",
1407
+ "native-type": "submit",
1408
+ size: "large",
1409
+ loading: C.value,
1410
+ disabled: !A.value,
1411
+ class: h(["ca-auth-submit", { "ca-auth-submit--off": !A.value }])
1412
+ }, {
1413
+ default: M(() => [l(E(D(c)("campus.common.ok")), 1)]),
1414
+ _: 1
1415
+ }, 8, [
1416
+ "loading",
1417
+ "disabled",
1418
+ "class"
1419
+ ])
1420
+ ]),
1421
+ _: 1
1422
+ }, 8, ["model", "rules"])], 64);
277
1423
  };
278
- e.config?.name && (t.name = String(e.config.name)), e.config?.version && (t.version = String(e.config.version)), this.context = new R(t, this.container), e.providers?.forEach((e) => this.register(e)), e.plugins?.forEach((e) => this.use(e));
279
1424
  }
280
- get lifecycle() {
281
- return this.state;
1425
+ }), Qt = {
1426
+ key: 1,
1427
+ class: "ca-auth-off",
1428
+ role: "status"
1429
+ }, $t = /* @__PURE__ */ d({
1430
+ __name: "ForgotPage",
1431
+ props: { preview: { type: Boolean } },
1432
+ setup(e) {
1433
+ let { t } = W(), r = Ue().forgot, a = n(() => [{
1434
+ key: "forgot",
1435
+ label: t("campus.auth.tabForgot")
1436
+ }, {
1437
+ key: "login",
1438
+ label: t("campus.auth.backLogin"),
1439
+ to: "/login"
1440
+ }]);
1441
+ return (n, c) => (y(), i(ct, {
1442
+ active: "forgot",
1443
+ tabs: a.value,
1444
+ preview: e.preview
1445
+ }, {
1446
+ default: M(() => [D(r) ? (y(), i(Zt, {
1447
+ key: 0,
1448
+ preview: e.preview
1449
+ }, null, 8, ["preview"])) : (y(), o("div", Qt, [s("h3", null, E(D(t)("campus.auth.unavailableTitle")), 1), s("p", null, E(D(t)("campus.auth.unavailableDesc")), 1)]))]),
1450
+ _: 1
1451
+ }, 8, ["tabs", "preview"]));
282
1452
  }
283
- get name() {
284
- return this.context.config.name;
1453
+ }), en = /* @__PURE__ */ d({
1454
+ __name: "AuthPreview",
1455
+ props: { kind: {} },
1456
+ setup(e) {
1457
+ return (t, n) => e.kind === "login" ? (y(), i(At, {
1458
+ key: 0,
1459
+ preview: ""
1460
+ })) : e.kind === "register" ? (y(), i(Yt, {
1461
+ key: 1,
1462
+ preview: ""
1463
+ })) : (y(), i($t, {
1464
+ key: 2,
1465
+ preview: ""
1466
+ }));
285
1467
  }
286
- get version() {
287
- return this.context.config.version;
1468
+ }), tn = { class: "ca-header" }, nn = ["aria-label", "aria-expanded"], rn = { class: "ca-header__brand" }, an = ["src"], on = { class: "ca-header__titles" }, sn = { class: "ca-header__name" }, cn = {
1469
+ key: 0,
1470
+ class: "ca-header__subtitle"
1471
+ }, ln = ["aria-label"], un = ["onClick"], dn = { class: "ca-header__tools" }, fn = { class: "ca-header__search-text" }, pn = [
1472
+ "title",
1473
+ "aria-label",
1474
+ "aria-pressed"
1475
+ ], mn = ["title", "aria-label"], hn = { class: "ca-header__icon-text" }, gn = ["title", "aria-label"], _n = ["title", "aria-label"], vn = ["title", "aria-label"], yn = ["title", "aria-label"], bn = { class: "ca-header__avatar" }, xn = { class: "ca-settings__group" }, Sn = { class: "ca-settings__title" }, Cn = ["aria-label"], wn = ["aria-checked", "onClick"], Tn = {
1476
+ key: 0,
1477
+ class: "ca-settings__group"
1478
+ }, En = { class: "ca-settings__title" }, Dn = ["aria-label"], On = [
1479
+ "aria-label",
1480
+ "aria-checked",
1481
+ "onClick"
1482
+ ], kn = ["title"], An = ["value", "aria-label"], jn = ["disabled"], Mn = { class: "ca-settings__group" }, Nn = { class: "ca-settings__title" }, Pn = ["aria-label"], Fn = ["aria-checked", "onClick"], In = /*#__PURE__*/ q(/* @__PURE__ */ d({
1483
+ __name: "HeaderBar",
1484
+ setup(t) {
1485
+ let r = B(), c = V(), d = X(), f = J(), p = Be(), { t: m, label: b, locale: C } = W(), T = G(), O = x(!1), k = [{
1486
+ value: "border",
1487
+ label: "campus.settings.boxBorder"
1488
+ }, {
1489
+ value: "shadow",
1490
+ label: "campus.settings.boxShadow"
1491
+ }], A = n(() => b(p.theme.siteName ?? T.brand.name)), j = n(() => p.theme.logo ?? T.brand.logo), N = n(() => (T.shortcuts ?? []).filter((e) => d.can(e.permission)));
1492
+ function P(e) {
1493
+ r.path !== e && c.push(e);
1494
+ }
1495
+ let F = [
1496
+ {
1497
+ value: "light",
1498
+ icon: "sunny"
1499
+ },
1500
+ {
1501
+ value: "dark",
1502
+ icon: "moon"
1503
+ },
1504
+ {
1505
+ value: "auto",
1506
+ icon: "monitor"
1507
+ }
1508
+ ], I = [
1509
+ "#1677ff",
1510
+ "#364fc7",
1511
+ "#6b1d7a",
1512
+ "#d6336c",
1513
+ "#e8590c",
1514
+ "#f59f00",
1515
+ "#0f9d58",
1516
+ "#0ca678"
1517
+ ], L = n(() => p.theme.primary);
1518
+ function ee(e, t) {
1519
+ let n = t.currentTarget?.getBoundingClientRect();
1520
+ p.setMode(e, n ? {
1521
+ x: n.left + n.width / 2,
1522
+ y: n.top + n.height / 2
1523
+ } : void 0);
1524
+ }
1525
+ function ne(e) {
1526
+ C.value = e, Ee(e);
1527
+ }
1528
+ async function re(e) {
1529
+ e === "account" ? T.accountPath && P(T.accountPath) : (await d.logout(), await c.replace({ name: "login" }));
1530
+ }
1531
+ let R = x(!1);
1532
+ function z() {
1533
+ R.value = !!document.fullscreenElement;
1534
+ }
1535
+ async function ie() {
1536
+ try {
1537
+ document.fullscreenElement ? await document.exitFullscreen() : await document.documentElement.requestFullscreen();
1538
+ } catch {}
1539
+ }
1540
+ v(() => document.addEventListener("fullscreenchange", z)), _(() => document.removeEventListener("fullscreenchange", z));
1541
+ function ae(e) {
1542
+ T.headerTools?.[e]?.();
1543
+ }
1544
+ return (t, n) => {
1545
+ let c = w("ca-icon"), _ = w("ca-dropdown-item"), v = w("ca-dropdown-menu"), x = w("ca-dropdown"), z = w("ca-drawer");
1546
+ return y(), o("header", tn, [
1547
+ s("button", {
1548
+ type: "button",
1549
+ class: "ca-header__hamburger ca-header__icon",
1550
+ "aria-label": D(m)("campus.side.openMenu"),
1551
+ "aria-expanded": D(f).mobileMenuOpen,
1552
+ onClick: n[0] ||= (e) => D(f).openMobileMenu()
1553
+ }, [...n[8] ||= [s("svg", {
1554
+ width: "20",
1555
+ height: "20",
1556
+ viewBox: "0 0 24 24",
1557
+ fill: "none",
1558
+ stroke: "currentColor",
1559
+ "stroke-width": "2",
1560
+ "stroke-linecap": "round",
1561
+ "aria-hidden": "true"
1562
+ }, [s("path", { d: "M4 6h16M4 12h16M4 18h16" })], -1)]], 8, nn),
1563
+ s("div", rn, [j.value ? (y(), o("img", {
1564
+ key: 0,
1565
+ src: j.value,
1566
+ alt: "",
1567
+ class: "ca-header__logo"
1568
+ }, null, 8, an)) : (y(), o(e, { key: 1 }, [a(" 没有配置 logo 时用框架默认标志(学士帽),颜色跟随头部前景色 "), n[9] ||= s("svg", {
1569
+ class: "ca-header__logo",
1570
+ viewBox: "0 0 32 32",
1571
+ fill: "none",
1572
+ stroke: "currentColor",
1573
+ "stroke-width": "2",
1574
+ "stroke-linecap": "round",
1575
+ "stroke-linejoin": "round",
1576
+ "aria-hidden": "true"
1577
+ }, [
1578
+ s("path", { d: "M16 6 3 12.5 16 19l13-6.5L16 6Z" }),
1579
+ s("path", { d: "M9 16.5v5.2c0 1.6 3.1 3.3 7 3.3s7-1.7 7-3.3v-5.2" }),
1580
+ s("path", { d: "M29 12.5V20" })
1581
+ ], -1)], 2112)), s("div", on, [s("strong", sn, E(A.value), 1), D(T).brand.subtitle ? (y(), o("span", cn, E(D(b)(D(T).brand.subtitle)), 1)) : a("v-if", !0)])]),
1582
+ s("nav", {
1583
+ class: "ca-header__nav",
1584
+ "aria-label": D(m)("campus.header.shortcuts")
1585
+ }, [(y(!0), o(e, null, S(N.value, (e) => (y(), o("button", {
1586
+ key: e.key,
1587
+ class: h(["ca-header__nav-item", { "is-active": D(r).path === e.path }]),
1588
+ type: "button",
1589
+ onClick: (t) => P(e.path)
1590
+ }, E(D(b)(e.title)), 11, un))), 128))], 8, ln),
1591
+ s("div", dn, [
1592
+ s("button", {
1593
+ type: "button",
1594
+ class: "ca-header__search",
1595
+ onClick: n[1] ||= (e) => ae("search")
1596
+ }, [
1597
+ u(c, { name: "search" }),
1598
+ s("span", fn, E(D(m)("campus.header.search")), 1),
1599
+ n[10] ||= s("kbd", { class: "ca-header__kbd" }, "⌘ K", -1)
1600
+ ]),
1601
+ s("button", {
1602
+ type: "button",
1603
+ class: "ca-header__icon ca-header__desktop-tool",
1604
+ title: R.value ? D(m)("campus.header.exitFullscreen") : D(m)("campus.header.fullscreen"),
1605
+ "aria-label": R.value ? D(m)("campus.header.exitFullscreen") : D(m)("campus.header.fullscreen"),
1606
+ "aria-pressed": R.value,
1607
+ onClick: ie
1608
+ }, [u(c, {
1609
+ name: R.value ? "exitFullscreen" : "fullscreen",
1610
+ size: 18
1611
+ }, null, 8, ["name"])], 8, pn),
1612
+ u(x, {
1613
+ trigger: "click",
1614
+ onCommand: ne
1615
+ }, {
1616
+ dropdown: M(() => [u(v, null, {
1617
+ default: M(() => [(y(!0), o(e, null, S(D(te), (e) => (y(), i(_, {
1618
+ key: e.code,
1619
+ command: e.code,
1620
+ class: h({ "is-current": D(C) === e.code })
1621
+ }, {
1622
+ default: M(() => [l(E(e.code === "zh-CN" ? "简体中文" : "English"), 1)]),
1623
+ _: 2
1624
+ }, 1032, ["command", "class"]))), 128))]),
1625
+ _: 1
1626
+ })]),
1627
+ default: M(() => [s("button", {
1628
+ type: "button",
1629
+ class: "ca-header__icon",
1630
+ title: D(m)("campus.header.language"),
1631
+ "aria-label": D(m)("campus.header.language")
1632
+ }, [s("span", hn, E(D(te).find((e) => e.code === D(C))?.label), 1)], 8, mn)]),
1633
+ _: 1
1634
+ }),
1635
+ s("button", {
1636
+ type: "button",
1637
+ class: "ca-header__icon ca-header__desktop-tool",
1638
+ title: D(m)("campus.header.notifications"),
1639
+ "aria-label": D(m)("campus.header.notifications"),
1640
+ onClick: n[2] ||= (e) => ae("notifications")
1641
+ }, [u(c, {
1642
+ name: "bell",
1643
+ size: 18
1644
+ }), n[11] ||= s("i", {
1645
+ class: "ca-header__dot is-danger",
1646
+ "aria-hidden": "true"
1647
+ }, null, -1)], 8, gn),
1648
+ s("button", {
1649
+ type: "button",
1650
+ class: "ca-header__icon ca-header__desktop-tool",
1651
+ title: D(m)("campus.header.assistant"),
1652
+ "aria-label": D(m)("campus.header.assistant"),
1653
+ onClick: n[3] ||= (e) => ae("assistant")
1654
+ }, [u(c, {
1655
+ name: "chat",
1656
+ size: 18
1657
+ }), n[12] ||= s("i", {
1658
+ class: "ca-header__dot is-success",
1659
+ "aria-hidden": "true"
1660
+ }, null, -1)], 8, _n),
1661
+ s("button", {
1662
+ type: "button",
1663
+ class: "ca-header__icon",
1664
+ title: D(m)("campus.header.settings"),
1665
+ "aria-label": D(m)("campus.header.settings"),
1666
+ onClick: n[4] ||= (e) => O.value = !0
1667
+ }, [u(c, {
1668
+ name: "setting",
1669
+ size: 18
1670
+ })], 8, vn),
1671
+ u(x, {
1672
+ trigger: "click",
1673
+ onCommand: re
1674
+ }, {
1675
+ dropdown: M(() => [u(v, null, {
1676
+ default: M(() => [D(T).accountPath ? (y(), i(_, {
1677
+ key: 0,
1678
+ command: "account"
1679
+ }, {
1680
+ default: M(() => [l(E(D(m)("campus.header.myAccount")), 1)]),
1681
+ _: 1
1682
+ })) : a("v-if", !0), u(_, {
1683
+ command: "logout",
1684
+ divided: ""
1685
+ }, {
1686
+ default: M(() => [l(E(D(m)("campus.header.logout")), 1)]),
1687
+ _: 1
1688
+ })]),
1689
+ _: 1
1690
+ })]),
1691
+ default: M(() => [s("button", {
1692
+ type: "button",
1693
+ class: "ca-header__user",
1694
+ title: D(m)("campus.header.account"),
1695
+ "aria-label": D(d).user?.name
1696
+ }, [s("span", bn, E(D(d).user?.name.slice(0, 1)), 1), u(c, {
1697
+ name: "arrowDown",
1698
+ size: 12
1699
+ })], 8, yn)]),
1700
+ _: 1
1701
+ })
1702
+ ]),
1703
+ u(z, {
1704
+ modelValue: O.value,
1705
+ "onUpdate:modelValue": n[7] ||= (e) => O.value = e,
1706
+ title: D(m)("campus.settings.title"),
1707
+ size: "320px",
1708
+ "append-to-body": "",
1709
+ class: "ca-settings"
1710
+ }, {
1711
+ default: M(() => [
1712
+ s("section", xn, [s("h3", Sn, [s("span", null, E(D(m)("campus.settings.themeMode")), 1)]), s("div", {
1713
+ class: "ca-settings__segment is-three",
1714
+ role: "radiogroup",
1715
+ "aria-label": D(m)("campus.settings.themeMode")
1716
+ }, [(y(), o(e, null, S(F, (e) => s("button", {
1717
+ key: e.value,
1718
+ type: "button",
1719
+ role: "radio",
1720
+ "aria-checked": D(p).mode === e.value,
1721
+ class: h({ "is-active": D(p).mode === e.value }),
1722
+ onClick: (t) => ee(e.value, t)
1723
+ }, [u(c, {
1724
+ name: e.icon,
1725
+ size: 16
1726
+ }, null, 8, ["name"]), l(E(D(m)(`campus.mode.${e.value}`)), 1)], 10, wn)), 64))], 8, Cn)]),
1727
+ D(p).primaryLocked ? a("v-if", !0) : (y(), o("section", Tn, [
1728
+ s("h3", En, [s("span", null, E(D(m)("campus.settings.themeColor")), 1)]),
1729
+ s("div", {
1730
+ class: "ca-settings__swatches",
1731
+ role: "radiogroup",
1732
+ "aria-label": D(m)("campus.settings.themeColor")
1733
+ }, [(y(), o(e, null, S(I, (e) => s("button", {
1734
+ key: e,
1735
+ type: "button",
1736
+ role: "radio",
1737
+ class: h(["ca-settings__swatch", { "is-active": D(p).userPrimary?.toLowerCase() === e }]),
1738
+ style: g({ background: e }),
1739
+ "aria-label": e,
1740
+ "aria-checked": D(p).userPrimary?.toLowerCase() === e,
1741
+ onClick: (t) => D(p).setPrimary(e)
1742
+ }, null, 14, On)), 64)), s("label", {
1743
+ class: "ca-settings__swatch is-custom",
1744
+ title: D(m)("campus.settings.themeColorCustom")
1745
+ }, [s("input", {
1746
+ type: "color",
1747
+ value: L.value,
1748
+ "aria-label": D(m)("campus.settings.themeColorCustom"),
1749
+ onInput: n[5] ||= (e) => D(p).setPrimary(e.target.value)
1750
+ }, null, 40, An)], 8, kn)], 8, Dn),
1751
+ s("button", {
1752
+ type: "button",
1753
+ class: "ca-settings__reset",
1754
+ disabled: !D(p).userPrimary,
1755
+ onClick: n[6] ||= (e) => D(p).setPrimary(void 0)
1756
+ }, E(D(m)("campus.settings.themeColorReset")), 9, jn)
1757
+ ])),
1758
+ s("section", Mn, [s("h3", Nn, [s("span", null, E(D(m)("campus.settings.boxStyle")), 1)]), s("div", {
1759
+ class: "ca-settings__segment",
1760
+ role: "radiogroup",
1761
+ "aria-label": D(m)("campus.settings.boxStyle")
1762
+ }, [(y(), o(e, null, S(k, (e) => s("button", {
1763
+ key: e.value,
1764
+ type: "button",
1765
+ role: "radio",
1766
+ "aria-checked": D(p).boxStyle === e.value,
1767
+ class: h({ "is-active": D(p).boxStyle === e.value }),
1768
+ onClick: (t) => D(p).setBoxStyle(e.value)
1769
+ }, E(D(m)(e.label)), 11, Fn)), 64))], 8, Pn)])
1770
+ ]),
1771
+ _: 1
1772
+ }, 8, ["modelValue", "title"])
1773
+ ]);
1774
+ };
288
1775
  }
289
- register(e) {
290
- return (Array.isArray(e) ? e : [e]).forEach((e) => {
291
- if (!L(e)) throw Error("[campus] 无效的服务提供者");
292
- this.providers.some((t) => t.name === e.name) || (this.providers.push(e), e.register?.(this.context));
293
- }), this.state = this.state === "created" ? "registered" : this.state, this;
1776
+ }), [["__scopeId", "data-v-534bb61b"]]), Ln = {
1777
+ key: 0,
1778
+ class: "ca-page-header"
1779
+ }, Rn = { class: "ca-page-header__top" }, zn = { class: "ca-page-header__crumb" }, Bn = ["title", "aria-label"], Vn = { class: "ca-page-header__date" }, Hn = /*#__PURE__*/ q(/* @__PURE__ */ d({
1780
+ __name: "PageHeader",
1781
+ setup(t) {
1782
+ let r = B(), { t: c, label: d, locale: f } = W(), p = Y(), m = new Map(Me(G().menus).map((e) => [e.key, e])), h = n(() => r.meta.pageKey ? m.get(r.meta.pageKey) : void 0), g = n(() => {
1783
+ let e = h.value ? je(h.value.key) : void 0;
1784
+ if (!e) return [];
1785
+ let t = e.titles.map((e) => d(e));
1786
+ return h.value?.affix ? t.filter((e, n) => e !== t[n - 1]) : t;
1787
+ }), v = x(/* @__PURE__ */ new Date()), b = setInterval(() => v.value = /* @__PURE__ */ new Date(), 6e4);
1788
+ _(() => clearInterval(b));
1789
+ let C = n(() => {
1790
+ let e = v.value;
1791
+ if (f.value === "zh-CN") {
1792
+ let t = new Intl.DateTimeFormat("zh-CN", { weekday: "long" }).format(e);
1793
+ return `${e.getFullYear()} 年 ${e.getMonth() + 1} 月 ${e.getDate()} 日 · ${t}`;
1794
+ }
1795
+ return new Intl.DateTimeFormat(f.value, { dateStyle: "full" }).format(e);
1796
+ });
1797
+ return (t, n) => {
1798
+ let r = w("ca-icon"), d = w("ca-breadcrumb-item"), f = w("ca-breadcrumb");
1799
+ return h.value ? (y(), o("header", Ln, [s("div", Rn, [s("div", zn, [
1800
+ u(r, {
1801
+ name: "location",
1802
+ class: "ca-page-header__icon"
1803
+ }),
1804
+ s("span", null, E(D(c)("campus.breadcrumb.current")), 1),
1805
+ u(f, { separator: ">" }, {
1806
+ default: M(() => [(y(!0), o(e, null, S(g.value, (e, t) => (y(), i(d, { key: t }, {
1807
+ default: M(() => [l(E(e), 1)]),
1808
+ _: 2
1809
+ }, 1024))), 128))]),
1810
+ _: 1
1811
+ }),
1812
+ a(" 刷新当前页面:重新创建页面组件,等于重新进入 "),
1813
+ s("button", {
1814
+ type: "button",
1815
+ class: "ca-page-header__refresh",
1816
+ title: D(c)("campus.tabs.refresh"),
1817
+ "aria-label": D(c)("campus.tabs.refresh"),
1818
+ onClick: n[0] ||= (e) => h.value && D(p).refresh(h.value.key)
1819
+ }, [u(r, { name: "refresh" })], 8, Bn)
1820
+ ]), s("time", Vn, E(C.value), 1)])])) : a("v-if", !0);
1821
+ };
294
1822
  }
295
- use(e) {
296
- return (Array.isArray(e) ? e : [e]).forEach((e) => {
297
- e && typeof e.install == "function" && (e.install(this.context), this.plugins.push(e));
298
- }), this;
1823
+ }), [["__scopeId", "data-v-e0f9b42f"]]), Un = {
1824
+ key: 0,
1825
+ class: "ca-page-header__main"
1826
+ }, Wn = { class: "ca-page-header__titles" }, Gn = { class: "ca-page-header__title" }, Kn = ["title"], qn = /*#__PURE__*/ q(/* @__PURE__ */ d({
1827
+ __name: "PageTitle",
1828
+ setup(e) {
1829
+ let t = B(), { label: r } = W(), i = new Map(Me(G().menus).map((e) => [e.key, e])), c = n(() => t.meta.pageKey ? i.get(t.meta.pageKey) : void 0), l = n(() => c.value ? r(c.value.title) : ""), u = n(() => c.value?.description ? r(c.value.description) : "");
1830
+ return (e, t) => c.value ? (y(), o("header", Un, [
1831
+ s("div", Wn, [
1832
+ s("h2", Gn, E(l.value), 1),
1833
+ a(" 说明和标题同一行,放不下时省略;窗口较矮时直接隐藏,把高度留给内容 "),
1834
+ u.value ? (y(), o("p", {
1835
+ key: 0,
1836
+ class: "ca-page-header__desc",
1837
+ title: u.value
1838
+ }, E(u.value), 9, Kn)) : a("v-if", !0)
1839
+ ]),
1840
+ a(" 页面通过 <ca-page-actions> 把按钮放到这里 "),
1841
+ t[0] ||= s("div", {
1842
+ id: "ca-page-actions",
1843
+ class: "ca-page-header__actions"
1844
+ }, null, -1)
1845
+ ])) : a("v-if", !0);
299
1846
  }
300
- start() {
301
- return this.state === "started" ? this : (this.providers.forEach((e) => this.bootProvider(e)), this.state = "started", this.container.make("campus.started")?.forEach((e) => e()), this);
1847
+ }), [["__scopeId", "data-v-e63e651d"]]), Jn = ["aria-label"], Yn = ["onClick"], Xn = { class: "ca-side__rail-list" }, Zn = ["aria-current", "title"], Qn = [
1848
+ "aria-current",
1849
+ "title",
1850
+ "onClick"
1851
+ ], $n = {
1852
+ key: 0,
1853
+ class: "ca-side__badge"
1854
+ }, er = { class: "ca-side__tools" }, tr = [
1855
+ "title",
1856
+ "aria-label",
1857
+ "aria-pressed"
1858
+ ], nr = [
1859
+ "title",
1860
+ "aria-label",
1861
+ "aria-expanded"
1862
+ ], rr = ["title", "aria-label"], ir = { class: "ca-side__avatar" }, ar = ["inert"], or = { class: "ca-side__panel-inner" }, sr = {
1863
+ key: 0,
1864
+ class: "ca-side__title"
1865
+ }, cr = {
1866
+ key: 1,
1867
+ class: "ca-side__group-badge"
1868
+ }, lr = /*#__PURE__*/ q(/* @__PURE__ */ d({
1869
+ __name: "SideMenu",
1870
+ setup(t) {
1871
+ let r = B(), c = V(), d = X(), f = J(), { t: p, label: m } = W(), g = G(), _ = x(H("side-collapsed") === "1");
1872
+ function v() {
1873
+ _.value = !_.value, U("side-collapsed", _.value ? "1" : "0");
1874
+ }
1875
+ let b = x(H("side-text-hidden") === "1");
1876
+ function C() {
1877
+ b.value = !b.value, U("side-text-hidden", b.value ? "1" : "0");
1878
+ }
1879
+ async function T(e) {
1880
+ e === "account" ? g.accountPath && r.path !== g.accountPath && await c.push(g.accountPath) : (await d.logout(), await c.replace({ name: "login" }));
1881
+ }
1882
+ let O = n(() => g.menus.flatMap((e) => e.children.flatMap((e) => Oe(e) ? e.children : [e])).find((e) => e.affix && d.can(e.permission))), j = (e) => d.can(e.permission) && e.key !== O.value?.key, P = n(() => g.menus.map((e) => ({
1883
+ ...e,
1884
+ children: e.children.map((e) => Oe(e) ? {
1885
+ ...e,
1886
+ children: e.children.filter(j)
1887
+ } : e).filter((e) => Oe(e) ? e.children.length > 0 : j(e))
1888
+ })).filter((e) => e.children.length > 0)), F = x(), I = n(() => !!O.value && r.path === O.value.path);
1889
+ A(() => [r.path, r.meta.appKey], () => {
1890
+ F.value = I.value ? void 0 : r.meta.appKey ?? P.value[0]?.key;
1891
+ }, { immediate: !0 });
1892
+ let L = n(() => P.value.find((e) => e.key === F.value)), ee = n(() => (f.mode === "pad" ? !f.padPanelOpen : _.value) || !L.value), te = x();
1893
+ A(L, (e) => e && (te.value = e), { immediate: !0 });
1894
+ let ne = n(() => L.value ?? te.value);
1895
+ function re(e) {
1896
+ let t = typeof e.badge == "function" ? e.badge() : e.badge ?? 0;
1897
+ return t > 0 ? t : 0;
1898
+ }
1899
+ function R(e) {
1900
+ return e.children.reduce((e, t) => e + (Oe(t) ? re(t) : 0), 0);
1901
+ }
1902
+ let z = n(() => r.meta.groupKey ? [r.meta.groupKey] : []);
1903
+ function ie(e) {
1904
+ f.mode === "pad" ? f.padPanelOpen && F.value === e ? f.closePadPanel() : (F.value = e, f.openPadPanel()) : F.value = e;
1905
+ }
1906
+ let ae = n(() => (g.shortcuts ?? []).filter((e) => d.can(e.permission)));
1907
+ function oe(e) {
1908
+ f.closeOverlays(), r.path !== e && c.push(e);
1909
+ }
1910
+ return (t, n) => {
1911
+ let c = w("ca-icon"), x = w("ca-dropdown-item"), A = w("ca-dropdown-menu"), j = w("ca-dropdown"), F = w("ca-menu-item"), te = w("ca-sub-menu"), B = w("ca-menu");
1912
+ return y(), o("aside", { class: h(["ca-side", { "is-pad-open": D(f).mode === "pad" && D(f).padPanelOpen }]) }, [
1913
+ ae.value.length ? (y(), o("nav", {
1914
+ key: 0,
1915
+ class: "ca-side__shortcuts",
1916
+ "aria-label": D(p)("campus.header.shortcuts")
1917
+ }, [(y(!0), o(e, null, S(ae.value, (e) => (y(), o("button", {
1918
+ key: e.key,
1919
+ type: "button",
1920
+ class: h({ "is-active": D(r).path === e.path }),
1921
+ onClick: (t) => oe(e.path)
1922
+ }, E(D(m)(e.title)), 11, Yn))), 128))], 8, Jn)) : a("v-if", !0),
1923
+ s("nav", { class: h(["ca-side__rail", { "is-compact": b.value }]) }, [
1924
+ a(" 入口列表单独滚动;底部工具按钮固定在外面,窗口再矮也不会被挤出屏幕 "),
1925
+ s("div", Xn, [O.value ? (y(), o("button", {
1926
+ key: 0,
1927
+ type: "button",
1928
+ class: h(["ca-side__rail-item", { "is-active": I.value }]),
1929
+ "aria-current": I.value ? "page" : void 0,
1930
+ title: b.value ? D(p)("campus.side.home") : void 0,
1931
+ onClick: n[0] ||= (e) => oe(O.value.path)
1932
+ }, [u(c, {
1933
+ name: "home",
1934
+ size: 20
1935
+ }), N(s("span", { class: "ca-side__rail-text" }, E(D(p)("campus.side.home")), 513), [[k, !b.value || D(f).mobileMenuOpen]])], 10, Zn)) : a("v-if", !0), (y(!0), o(e, null, S(P.value, (e) => (y(), o("button", {
1936
+ key: e.key,
1937
+ type: "button",
1938
+ class: h(["ca-side__rail-item", { "is-active": e.key === L.value?.key }]),
1939
+ "aria-current": e.key === L.value?.key ? "true" : void 0,
1940
+ title: b.value ? D(m)(e.title) : void 0,
1941
+ onClick: (t) => ie(e.key)
1942
+ }, [
1943
+ u(c, {
1944
+ name: e.icon ?? "grid",
1945
+ size: 20
1946
+ }, null, 8, ["name"]),
1947
+ N(s("span", { class: "ca-side__rail-text" }, E(D(m)(e.title)), 513), [[k, !b.value || D(f).mobileMenuOpen]]),
1948
+ R(e) ? (y(), o("span", $n, E(R(e)), 1)) : a("v-if", !0)
1949
+ ], 10, Qn))), 128))]),
1950
+ s("div", er, [
1951
+ s("button", {
1952
+ type: "button",
1953
+ class: "ca-side__tool",
1954
+ title: b.value ? D(p)("campus.side.showText") : D(p)("campus.side.hideText"),
1955
+ "aria-label": b.value ? D(p)("campus.side.showText") : D(p)("campus.side.hideText"),
1956
+ "aria-pressed": b.value,
1957
+ onClick: C
1958
+ }, [u(c, {
1959
+ name: b.value ? "view" : "hide",
1960
+ size: 18
1961
+ }, null, 8, ["name"])], 8, tr),
1962
+ s("button", {
1963
+ type: "button",
1964
+ class: "ca-side__tool ca-side__tool--collapse",
1965
+ title: _.value ? D(p)("campus.side.expand") : D(p)("campus.side.collapse"),
1966
+ "aria-label": _.value ? D(p)("campus.side.expand") : D(p)("campus.side.collapse"),
1967
+ "aria-expanded": !_.value,
1968
+ onClick: v
1969
+ }, [u(c, {
1970
+ name: _.value ? "expand" : "fold",
1971
+ size: 18
1972
+ }, null, 8, ["name"])], 8, nr),
1973
+ u(j, {
1974
+ trigger: "click",
1975
+ placement: "right-end",
1976
+ onCommand: T
1977
+ }, {
1978
+ dropdown: M(() => [u(A, null, {
1979
+ default: M(() => [D(g).accountPath ? (y(), i(x, {
1980
+ key: 0,
1981
+ command: "account"
1982
+ }, {
1983
+ default: M(() => [l(E(D(p)("campus.header.myAccount")), 1)]),
1984
+ _: 1
1985
+ })) : a("v-if", !0), u(x, {
1986
+ command: "logout",
1987
+ divided: ""
1988
+ }, {
1989
+ default: M(() => [l(E(D(p)("campus.header.logout")), 1)]),
1990
+ _: 1
1991
+ })]),
1992
+ _: 1
1993
+ })]),
1994
+ default: M(() => [s("button", {
1995
+ type: "button",
1996
+ class: "ca-side__tool",
1997
+ title: D(d).user?.name,
1998
+ "aria-label": D(d).user?.name
1999
+ }, [s("span", ir, E(D(d).user?.name.slice(0, 1)), 1)], 8, rr)]),
2000
+ _: 1
2001
+ })
2002
+ ])
2003
+ ], 2),
2004
+ a(" 第二栏:隐藏时宽度渐变到 0(而不是直接消失),首页与其他页之间切换时内容区不会突然跳动 "),
2005
+ s("div", {
2006
+ class: h(["ca-side__panel", { "is-hidden": ee.value }]),
2007
+ inert: ee.value && !D(f).mobileMenuOpen
2008
+ }, [s("div", or, [
2009
+ ne.value ? (y(), o("div", sr, E(D(m)(ne.value.title)), 1)) : a("v-if", !0),
2010
+ a(" key 绑定场景:切换场景时重建菜单,展开状态不会串到别的场景 "),
2011
+ (y(), i(B, {
2012
+ key: ne.value?.key,
2013
+ "default-active": D(r).path,
2014
+ "default-openeds": z.value,
2015
+ router: "",
2016
+ class: "ca-side__menu",
2017
+ onSelect: n[1] ||= (e) => D(f).closeOverlays()
2018
+ }, {
2019
+ default: M(() => [(y(!0), o(e, null, S(ne.value?.children ?? [], (t) => (y(), o(e, { key: t.key }, [a(" 二级是菜单组:可展开,下面是三级页面 "), D(Oe)(t) ? (y(), i(te, {
2020
+ key: 0,
2021
+ index: t.key
2022
+ }, {
2023
+ title: M(() => [
2024
+ t.icon ? (y(), i(c, {
2025
+ key: 0,
2026
+ name: t.icon
2027
+ }, null, 8, ["name"])) : a("v-if", !0),
2028
+ s("span", null, E(D(m)(t.title)), 1),
2029
+ re(t) ? (y(), o("span", cr, E(re(t)), 1)) : a("v-if", !0)
2030
+ ]),
2031
+ default: M(() => [(y(!0), o(e, null, S(t.children, (e) => (y(), i(F, {
2032
+ key: e.key,
2033
+ index: e.path
2034
+ }, {
2035
+ default: M(() => [s("span", null, E(D(m)(e.title)), 1)]),
2036
+ _: 2
2037
+ }, 1032, ["index"]))), 128))]),
2038
+ _: 2
2039
+ }, 1032, ["index"])) : (y(), o(e, { key: 1 }, [a(" 二级直接是页面 "), u(F, { index: t.path }, {
2040
+ default: M(() => [t.icon ? (y(), i(c, {
2041
+ key: 0,
2042
+ name: t.icon
2043
+ }, null, 8, ["name"])) : a("v-if", !0), s("span", null, E(D(m)(t.title)), 1)]),
2044
+ _: 2
2045
+ }, 1032, ["index"])], 2112))], 64))), 128))]),
2046
+ _: 1
2047
+ }, 8, ["default-active", "default-openeds"]))
2048
+ ])], 10, ar)
2049
+ ], 2);
2050
+ };
302
2051
  }
303
- started(e) {
304
- let t = this.container.make("campus.started") ?? [];
305
- return t.push(e), this.container.bind("campus.started", t), this;
2052
+ }), [["__scopeId", "data-v-4ddc6313"]]), ur = {
2053
+ key: 0,
2054
+ class: "ca-copyright"
2055
+ }, dr = ["href"], fr = /*#__PURE__*/ q(/* @__PURE__ */ d({
2056
+ __name: "CaCopyright",
2057
+ setup(t) {
2058
+ let r = G().brand, { label: i } = W(), c = n(() => r.copyright ? Ve(i(r.copyright)) : ""), l = n(() => r.copyrightLinks ?? []);
2059
+ return (t, n) => c.value ? (y(), o("footer", ur, [s("span", null, E(c.value), 1), (y(!0), o(e, null, S(l.value, (t) => (y(), o(e, { key: t.href }, [n[0] ||= s("span", {
2060
+ class: "ca-copyright__dot",
2061
+ "aria-hidden": "true"
2062
+ }, "·", -1), s("a", {
2063
+ href: t.href,
2064
+ target: "_blank",
2065
+ rel: "noopener noreferrer"
2066
+ }, E(t.text), 9, dr)], 64))), 128))])) : a("v-if", !0);
306
2067
  }
307
- bootProvider(e) {
308
- this.bootedProviders.has(e) || (e.boot?.(this.context), this.bootedProviders.add(e), this.state = "booted");
2068
+ }), [["__scopeId", "data-v-c51879e8"]]), pr = { class: "ca-tabs" }, mr = ["onClick"], hr = { class: "ca-tabs__more" }, gr = [
2069
+ "title",
2070
+ "aria-label",
2071
+ "aria-pressed"
2072
+ ], _r = /*#__PURE__*/ q(/* @__PURE__ */ d({
2073
+ __name: "TabsBar",
2074
+ setup(t) {
2075
+ let r = B(), c = V(), d = Y(), f = J(), { t: p, label: g } = W(), _ = new Map(Me(G().menus).map((e) => [e.key, e])), b = n(() => d.visited.map((e) => _.get(e)).filter((e) => !!e).map((e) => ({
2076
+ key: e.key,
2077
+ path: e.path,
2078
+ title: g(e.title),
2079
+ closable: !e.affix,
2080
+ icon: e.affix ? e.icon : void 0
2081
+ }))), C = n(() => r.meta.pageKey), T = n(() => [{
2082
+ name: "fixed",
2083
+ scroll: !1,
2084
+ items: b.value.filter((e) => !e.closable)
2085
+ }, {
2086
+ name: "list",
2087
+ scroll: !0,
2088
+ items: b.value.filter((e) => e.closable)
2089
+ }]), O = x();
2090
+ function k() {
2091
+ m(() => {
2092
+ O.value?.querySelector(".is-active")?.scrollIntoView({
2093
+ inline: "nearest",
2094
+ block: "nearest",
2095
+ behavior: "smooth"
2096
+ });
2097
+ });
2098
+ }
2099
+ A([C, () => b.value.length], k), v(k);
2100
+ function j(e) {
2101
+ let t = d.close(e);
2102
+ if (e !== C.value) return;
2103
+ let n = t ? _.get(t)?.path : void 0;
2104
+ c.push(n ?? "/");
2105
+ }
2106
+ let N = n(() => {
2107
+ let e = d.visited.indexOf(C.value ?? "");
2108
+ return d.visited.some((t, n) => n < e && !d.affixKeys.includes(t));
2109
+ }), F = n(() => {
2110
+ let e = d.visited.indexOf(C.value ?? "");
2111
+ return e !== -1 && d.visited.some((t, n) => n > e && !d.affixKeys.includes(t));
2112
+ });
2113
+ function I(e) {
2114
+ let t = C.value;
2115
+ e === "closeAll" ? (d.closeAll(), c.push(_.get(d.affixKeys[0] ?? "")?.path ?? "/")) : t && (e === "close" ? j(t) : e === "closeLeft" ? d.closeLeft(t) : e === "closeRight" ? d.closeRight(t) : d.closeOthers(t));
2116
+ }
2117
+ return (t, n) => {
2118
+ let r = w("ca-icon"), d = w("ca-dropdown-item"), m = w("ca-dropdown-menu"), g = w("ca-dropdown");
2119
+ return y(), o("div", pr, [
2120
+ (y(!0), o(e, null, S(T.value, (t) => (y(), o("div", {
2121
+ key: t.name,
2122
+ ref_for: !0,
2123
+ ref: (e) => {
2124
+ t.scroll && (O.value = e);
2125
+ },
2126
+ class: h(t.scroll ? "ca-tabs__list" : "ca-tabs__fixed")
2127
+ }, [(y(!0), o(e, null, S(t.items, (e) => (y(), o("div", {
2128
+ key: e.key,
2129
+ class: h(["ca-tabs__item", { "is-active": e.key === C.value }]),
2130
+ onClick: (t) => D(c).push(e.path)
2131
+ }, [
2132
+ e.icon ? (y(), i(r, {
2133
+ key: 0,
2134
+ name: e.icon
2135
+ }, null, 8, ["name"])) : a("v-if", !0),
2136
+ s("span", null, E(e.title), 1),
2137
+ e.closable ? (y(), i(r, {
2138
+ key: 1,
2139
+ name: "close",
2140
+ class: "ca-tabs__close",
2141
+ onClick: P((t) => j(e.key), ["stop"])
2142
+ }, null, 8, ["onClick"])) : a("v-if", !0)
2143
+ ], 10, mr))), 128))], 2))), 128)),
2144
+ u(g, {
2145
+ trigger: "click",
2146
+ onCommand: I
2147
+ }, {
2148
+ dropdown: M(() => [u(m, null, {
2149
+ default: M(() => [
2150
+ u(d, { command: "close" }, {
2151
+ default: M(() => [l(E(D(p)("campus.tabs.close")), 1)]),
2152
+ _: 1
2153
+ }),
2154
+ N.value ? (y(), i(d, {
2155
+ key: 0,
2156
+ command: "closeLeft"
2157
+ }, {
2158
+ default: M(() => [l(E(D(p)("campus.tabs.closeLeft")), 1)]),
2159
+ _: 1
2160
+ })) : a("v-if", !0),
2161
+ F.value ? (y(), i(d, {
2162
+ key: 1,
2163
+ command: "closeRight"
2164
+ }, {
2165
+ default: M(() => [l(E(D(p)("campus.tabs.closeRight")), 1)]),
2166
+ _: 1
2167
+ })) : a("v-if", !0),
2168
+ u(d, { command: "closeOthers" }, {
2169
+ default: M(() => [l(E(D(p)("campus.tabs.closeOthers")), 1)]),
2170
+ _: 1
2171
+ }),
2172
+ u(d, { command: "closeAll" }, {
2173
+ default: M(() => [l(E(D(p)("campus.tabs.closeAll")), 1)]),
2174
+ _: 1
2175
+ })
2176
+ ]),
2177
+ _: 1
2178
+ })]),
2179
+ default: M(() => [s("span", hr, [u(r, { name: "arrowDown" })])]),
2180
+ _: 1
2181
+ }),
2182
+ a(" 内容全屏:隐藏头部和侧栏,再点一次恢复 "),
2183
+ s("button", {
2184
+ type: "button",
2185
+ class: "ca-tabs__more ca-tabs__fullscreen",
2186
+ title: D(f).contentFullscreen ? D(p)("campus.tabs.exitFullscreen") : D(p)("campus.tabs.fullscreen"),
2187
+ "aria-label": D(f).contentFullscreen ? D(p)("campus.tabs.exitFullscreen") : D(p)("campus.tabs.fullscreen"),
2188
+ "aria-pressed": D(f).contentFullscreen,
2189
+ onClick: n[0] ||= (e) => D(f).toggleContentFullscreen()
2190
+ }, [u(r, { name: D(f).contentFullscreen ? "exitFullscreen" : "fullscreen" }, null, 8, ["name"])], 8, gr)
2191
+ ]);
2192
+ };
309
2193
  }
310
- };
311
- function Ue(e = {}) {
312
- return new z(e);
313
- }
314
- function We(e) {
315
- return e;
316
- }
317
- function Ge(e) {
318
- return e;
2194
+ }), [["__scopeId", "data-v-1d7ba823"]]), vr = 1200, yr = "(max-width: 768px)", br = `(min-width: 769px) and (max-width: ${vr}px)`, xr = ["aria-label"], Sr = ["aria-label"], Cr = { class: "ca-main" }, wr = { class: "ca-content" }, Tr = { class: "ca-content__page" }, Er = /*#__PURE__*/ q(/* @__PURE__ */ d({
2195
+ __name: "CaLayout",
2196
+ setup(e) {
2197
+ let n = B(), r = Y(), c = J(), { t: l } = W(), d = window.matchMedia(yr), f = window.matchMedia(br), p = "";
2198
+ function m() {
2199
+ let e = d.matches ? "phone" : f.matches ? "pad" : "desktop";
2200
+ c.setMode(e);
2201
+ }
2202
+ m(), A(() => c.mode === "phone" && c.mobileMenuOpen, (e) => {
2203
+ e ? (p = document.body.style.overflow, document.body.style.overflow = "hidden") : document.body.style.overflow = p;
2204
+ }), A(() => n.fullPath, () => c.closeOverlays());
2205
+ function g(e) {
2206
+ e.key === "Escape" && (c.mobileMenuOpen || c.padPanelOpen ? c.closeOverlays() : c.contentFullscreen && c.toggleContentFullscreen());
2207
+ }
2208
+ v(() => {
2209
+ m(), d.addEventListener("change", m), f.addEventListener("change", m), window.addEventListener("keydown", g);
2210
+ }), _(() => {
2211
+ d.removeEventListener("change", m), f.removeEventListener("change", m), window.removeEventListener("keydown", g), document.body.style.overflow = p;
2212
+ });
2213
+ function b() {
2214
+ let e = n.meta.pageKey;
2215
+ return e ? `${e}:${r.versions[e] ?? 0}` : n.fullPath;
2216
+ }
2217
+ return (e, n) => {
2218
+ let d = w("router-view");
2219
+ return y(), o("div", { class: h(["ca-shell", { "is-fullscreen": D(c).contentFullscreen }]) }, [N(u(In, null, null, 512), [[k, !D(c).contentFullscreen]]), s("div", { class: h(["ca-body", { "is-fullscreen": D(c).contentFullscreen }]) }, [
2220
+ D(c).mode === "phone" && D(c).mobileMenuOpen ? (y(), o("button", {
2221
+ key: 0,
2222
+ type: "button",
2223
+ class: "ca-mobile-scrim",
2224
+ "aria-label": D(l)("campus.side.closeMenu"),
2225
+ onClick: n[0] ||= (e) => D(c).closeMobileMenu()
2226
+ }, null, 8, xr)) : a("v-if", !0),
2227
+ D(c).mode === "pad" && D(c).padPanelOpen ? (y(), o("button", {
2228
+ key: 1,
2229
+ type: "button",
2230
+ class: "ca-pad-scrim",
2231
+ "aria-label": D(l)("campus.side.closeMenu"),
2232
+ onClick: n[1] ||= (e) => D(c).closePadPanel()
2233
+ }, null, 8, Sr)) : a("v-if", !0),
2234
+ N(u(lr, {
2235
+ class: h({ "is-mobile-open": D(c).mobileMenuOpen }),
2236
+ inert: D(c).mode === "phone" && !D(c).mobileMenuOpen
2237
+ }, null, 8, ["class", "inert"]), [[k, !D(c).contentFullscreen]]),
2238
+ s("main", Cr, [
2239
+ u(_r),
2240
+ u(Hn),
2241
+ s("div", wr, [
2242
+ u(qn),
2243
+ a(" 页面区撑满剩余高度,版权在其后:内容少时贴窗口底,内容长时滚到最底才出现 "),
2244
+ s("div", Tr, [u(d, null, {
2245
+ default: M(({ Component: e }) => [a(" include 与标签名单同步;缓存容量包含固定标签。 "), (y(), i(t, {
2246
+ include: D(r).cached,
2247
+ max: D(r).maxTabs + D(r).affixKeys.length
2248
+ }, [e ? (y(), i(T(e), { key: b() })) : a("v-if", !0)], 1032, ["include", "max"]))]),
2249
+ _: 1
2250
+ })]),
2251
+ u(fr)
2252
+ ])
2253
+ ])
2254
+ ], 2)], 2);
2255
+ };
2256
+ }
2257
+ }), [["__scopeId", "data-v-3a849ce7"]]), Dr = { class: "ca-exception" }, Or = { class: "ca-exception__code" }, kr = { class: "ca-exception__text" }, Ar = /*#__PURE__*/ q(/* @__PURE__ */ d({
2258
+ __name: "ExceptionPage",
2259
+ props: { kind: {} },
2260
+ setup(e) {
2261
+ let t = e, r = V(), { t: i } = W(), a = n(() => t.kind === "forbidden" ? "403" : "404"), c = n(() => i(t.kind === "forbidden" ? "campus.error.forbidden" : "campus.error.notFound"));
2262
+ return (e, t) => {
2263
+ let n = w("ca-button");
2264
+ return y(), o("div", Dr, [
2265
+ s("div", Or, E(a.value), 1),
2266
+ s("p", kr, E(c.value), 1),
2267
+ u(n, {
2268
+ type: "primary",
2269
+ onClick: t[0] ||= (e) => D(r).replace("/")
2270
+ }, {
2271
+ default: M(() => [l(E(D(i)("campus.error.backHome")), 1)]),
2272
+ _: 1
2273
+ })
2274
+ ]);
2275
+ };
2276
+ }
2277
+ }), [["__scopeId", "data-v-ffcb23b0"]]), jr = { class: "ca-login" }, Mr = { class: "ca-login__main" }, Nr = { class: "ca-login__card" }, Pr = { class: "ca-login__brand" }, Fr = ["src"], Ir = { class: "ca-login__name" }, Lr = {
2278
+ key: 1,
2279
+ class: "ca-login__subtitle"
2280
+ }, Rr = /*#__PURE__*/ q(/* @__PURE__ */ d({
2281
+ __name: "LoginPage",
2282
+ setup(e) {
2283
+ let t = B(), r = V(), c = X(), d = Be(), { t: f, label: p } = W(), m = G().brand, h = n(() => p(d.theme.siteName ?? m.name)), g = n(() => d.theme.logo ?? m.logo), _ = Ue(), v = b({
2284
+ username: "",
2285
+ password: "",
2286
+ captcha: ""
2287
+ }), S = x(""), C = x(), T = x(), O = x(!1), k = x(""), A = n(() => ({
2288
+ username: [{
2289
+ required: !0,
2290
+ message: f("campus.login.required", { label: f("campus.login.username") }),
2291
+ trigger: "blur"
2292
+ }],
2293
+ password: [{
2294
+ required: !0,
2295
+ message: f("campus.login.required", { label: f("campus.login.password") }),
2296
+ trigger: "blur"
2297
+ }],
2298
+ captcha: _.captcha ? [{
2299
+ required: !0,
2300
+ message: f("campus.auth.captchaRequired"),
2301
+ trigger: "blur"
2302
+ }] : []
2303
+ }));
2304
+ async function j() {
2305
+ try {
2306
+ await T.value?.validate();
2307
+ } catch {
2308
+ return;
2309
+ }
2310
+ O.value = !0, k.value = "";
2311
+ try {
2312
+ await c.login({
2313
+ username: v.username,
2314
+ password: v.password,
2315
+ captcha: _.captcha ? {
2316
+ key: S.value,
2317
+ code: v.captcha
2318
+ } : void 0
2319
+ }), await r.replace(We(t.query.redirect));
2320
+ } catch (e) {
2321
+ k.value = e instanceof Error && e.message ? e.message : f("campus.login.failed"), C.value?.refresh();
2322
+ } finally {
2323
+ O.value = !1;
2324
+ }
2325
+ }
2326
+ return (e, t) => {
2327
+ let n = w("ca-alert"), r = w("ca-input"), c = w("ca-form-item"), d = w("ca-button"), b = w("ca-form");
2328
+ return y(), o("div", jr, [s("div", Mr, [s("div", Nr, [
2329
+ s("div", Pr, [
2330
+ g.value ? (y(), o("img", {
2331
+ key: 0,
2332
+ src: g.value,
2333
+ alt: "",
2334
+ class: "ca-login__logo"
2335
+ }, null, 8, Fr)) : a("v-if", !0),
2336
+ s("h1", Ir, E(h.value), 1),
2337
+ D(m).subtitle ? (y(), o("p", Lr, E(D(p)(D(m).subtitle)), 1)) : a("v-if", !0)
2338
+ ]),
2339
+ k.value ? (y(), i(n, {
2340
+ key: 0,
2341
+ title: k.value,
2342
+ type: "error",
2343
+ "show-icon": "",
2344
+ closable: !1,
2345
+ class: "ca-login__error"
2346
+ }, null, 8, ["title"])) : a("v-if", !0),
2347
+ u(b, {
2348
+ ref_key: "formRef",
2349
+ ref: T,
2350
+ model: v,
2351
+ rules: A.value,
2352
+ size: "large",
2353
+ class: "ca-auth-form",
2354
+ onSubmit: P(j, ["prevent"])
2355
+ }, {
2356
+ default: M(() => [
2357
+ u(c, { prop: "username" }, {
2358
+ default: M(() => [u(r, {
2359
+ modelValue: v.username,
2360
+ "onUpdate:modelValue": t[0] ||= (e) => v.username = e,
2361
+ placeholder: D(f)("campus.login.username"),
2362
+ autocomplete: "username"
2363
+ }, null, 8, ["modelValue", "placeholder"])]),
2364
+ _: 1
2365
+ }),
2366
+ u(c, { prop: "password" }, {
2367
+ default: M(() => [u(r, {
2368
+ modelValue: v.password,
2369
+ "onUpdate:modelValue": t[1] ||= (e) => v.password = e,
2370
+ type: "password",
2371
+ "show-password": "",
2372
+ placeholder: D(f)("campus.login.password"),
2373
+ autocomplete: "current-password"
2374
+ }, null, 8, ["modelValue", "placeholder"])]),
2375
+ _: 1
2376
+ }),
2377
+ D(_).captcha ? (y(), i(c, {
2378
+ key: 0,
2379
+ prop: "captcha"
2380
+ }, {
2381
+ default: M(() => [u(yt, {
2382
+ ref_key: "captchaRef",
2383
+ ref: C,
2384
+ code: v.captcha,
2385
+ "onUpdate:code": t[2] ||= (e) => v.captcha = e,
2386
+ "captcha-key": S.value,
2387
+ "onUpdate:captchaKey": t[3] ||= (e) => S.value = e,
2388
+ scene: "login"
2389
+ }, null, 8, ["code", "captcha-key"])]),
2390
+ _: 1
2391
+ })) : a("v-if", !0),
2392
+ u(d, {
2393
+ type: "primary",
2394
+ "native-type": "submit",
2395
+ loading: O.value,
2396
+ class: "ca-login__submit"
2397
+ }, {
2398
+ default: M(() => [l(E(D(f)("campus.login.submit")), 1)]),
2399
+ _: 1
2400
+ }, 8, ["loading"])
2401
+ ]),
2402
+ _: 1
2403
+ }, 8, ["model", "rules"])
2404
+ ])]), u(fr, { class: "ca-login__copyright" })]);
2405
+ };
2406
+ }
2407
+ }), [["__scopeId", "data-v-ddf636fd"]]);
2408
+ // packages/core/src/router.ts
2409
+ function zr(e) {
2410
+ return async () => {
2411
+ let t = await e.component();
2412
+ return d({
2413
+ name: e.key,
2414
+ setup: () => () => f(t.default)
2415
+ });
2416
+ };
319
2417
  }
320
- //#endregion
321
- //#region src/facade.ts
322
- var B;
323
- function V(e) {
324
- B = e;
325
- }
326
- function H() {
327
- return B;
328
- }
329
- function Ke(e) {
330
- if (!B) throw Error("[campus] 应用尚未创建,请先调用 createCampusAdmin");
331
- return e ? B.context.resolve(e) : B;
332
- }
333
- //#endregion
334
- //#region src/vue-application.ts
335
- function U(e) {
336
- let t = /* @__PURE__ */ new Map(), n, r = {
337
- campus: e,
338
- get vue() {
339
- return n;
340
- },
341
- component(e, i) {
342
- return t.set(e, i), n && n.component(e, i), r;
343
- },
344
- register(t) {
345
- return e.register(t), r;
2418
+ var Br = d({
2419
+ name: "CaForbidden",
2420
+ setup: () => () => f(Ar, { kind: "forbidden" })
2421
+ }), Vr = d({
2422
+ name: "CaNotFound",
2423
+ setup: () => () => f(Ar, { kind: "notFound" })
2424
+ });
2425
+ function Hr(e, t) {
2426
+ let n = Me(e.menus);
2427
+ if (!n.length) throw Error("[campus] 菜单里至少需要一个页面");
2428
+ Ne(e.accountPath, n);
2429
+ let r = [
2430
+ {
2431
+ path: "/login",
2432
+ name: "login",
2433
+ component: e.login?.style === "split" ? At : Rr,
2434
+ meta: { public: !0 }
346
2435
  },
347
- use(t) {
348
- return e.use(t), r;
2436
+ {
2437
+ path: "/register",
2438
+ name: "register",
2439
+ component: Yt,
2440
+ meta: { public: !0 }
349
2441
  },
350
- start() {
351
- return e.start(), V(e), r;
2442
+ {
2443
+ path: "/forgot",
2444
+ name: "forgot",
2445
+ component: $t,
2446
+ meta: { public: !0 }
352
2447
  },
353
- install(e) {
354
- n = e, t.forEach((t, n) => e.component(n, t));
2448
+ {
2449
+ path: "/",
2450
+ component: Er,
2451
+ redirect: n.some((e) => e.path === "/") ? void 0 : () => {
2452
+ let e = X(t);
2453
+ return n.find((t) => e.can(t.permission))?.path ?? "/403";
2454
+ },
2455
+ children: [
2456
+ ...n.map((e) => ({
2457
+ path: e.path,
2458
+ name: e.key,
2459
+ component: zr(e),
2460
+ meta: {
2461
+ pageKey: e.key,
2462
+ appKey: e.appKey,
2463
+ groupKey: e.groupKey,
2464
+ permission: e.permission
2465
+ }
2466
+ })),
2467
+ {
2468
+ path: "/403",
2469
+ name: "forbidden",
2470
+ component: Br
2471
+ },
2472
+ {
2473
+ path: "/:pathMatch(.*)*",
2474
+ name: "not-found",
2475
+ component: Vr
2476
+ }
2477
+ ]
355
2478
  }
356
- };
357
- return r;
358
- }
359
- //#endregion
360
- //#region src/campus.ts
361
- var W = Symbol("campus");
362
- function qe() {
363
- return m(W, void 0) ?? H();
364
- }
365
- //#endregion
366
- //#region src/services/loading.ts
367
- var G = new D({
368
- visible: !1,
369
- text: ""
370
- });
371
- function K(e = "") {
372
- return G.set({
373
- visible: !0,
374
- text: e
375
- }), { hide: () => q() };
376
- }
377
- function q() {
378
- G.set({
379
- visible: !1,
380
- text: ""
2479
+ ], i = ie({
2480
+ history: e.history === "web" ? oe() : ae(),
2481
+ routes: r
381
2482
  });
2483
+ return i.beforeEach((e) => {
2484
+ let n = X(t);
2485
+ return e.meta.public ? n.isLoggedIn && e.name === "login" ? { path: "/" } : !0 : n.isLoggedIn ? n.can(e.meta.permission) ? !0 : { name: "forbidden" } : {
2486
+ name: "login",
2487
+ query: e.fullPath === "/" ? void 0 : { redirect: e.fullPath }
2488
+ };
2489
+ }), i.afterEach((e) => {
2490
+ e.meta.pageKey && Y(t).open(e.meta.pageKey);
2491
+ }), i;
382
2492
  }
383
- //#endregion
384
- //#region src/services/toast.ts
385
- var J = new D({ list: [] });
386
- ue(Se, (e) => {
387
- J.set({ list: [...e] });
388
- }, { immediate: !0 });
389
- function Y(e, t = !0, n = 2e3, r) {
390
- return xe.show({
391
- title: e,
392
- tone: t ? "success" : "danger",
393
- duration: n,
394
- description: r
395
- });
2493
+ // packages/core/src/services/auth.ts
2494
+ var Ur, Wr;
2495
+ function Gr(e, t) {
2496
+ Ur = e, Wr = t;
396
2497
  }
397
- //#endregion
398
- //#region src/services/use-store.ts
399
- function X(e) {
400
- let t = y(e.get()), n = e.subscribe((e) => {
401
- t.value = e;
2498
+ async function Kr(e) {
2499
+ if (G(), !Ur || !Wr) return;
2500
+ let t = X(Wr);
2501
+ if (!t.isLoggedIn) return;
2502
+ t.expire(), $.toast.warning(e || Te("campus.auth.sessionExpired"));
2503
+ let n = Ur.currentRoute.value;
2504
+ n.name !== "login" && await Ur.replace({
2505
+ name: "login",
2506
+ query: n.fullPath === "/" ? void 0 : { redirect: n.fullPath }
402
2507
  });
403
- return h(n), t;
404
- }
405
- //#endregion
406
- //#region src/components/overlay/ca-overlay-host.vue
407
- var Z = /* @__PURE__ */ p({
408
- name: "CaOverlayHost",
409
- __name: "ca-overlay-host",
410
- setup(t) {
411
- let n = X(G), i = X(J), a = X(O), o = r(() => n.value.visible), s = r(() => n.value.text);
412
- return (t, n) => (g(), c(e, null, [
413
- d(T, {
414
- visible: x(o),
415
- text: x(s)
416
- }, null, 8, ["visible", "text"]),
417
- d(E, { items: x(i).list }, null, 8, ["items"]),
418
- d(F, { items: x(a).list }, null, 8, ["items"])
419
- ], 64));
420
- }
421
- }), Q = {
422
- loading: (e) => K(e),
423
- toast: (e, t = !0) => Y(e, t),
424
- alert: (e, t, n) => M(e, t, n),
425
- confirm: (e, t) => N(e, t),
426
- modal: (e) => {
427
- O.set((t) => ({ list: [...t.list, {
428
- id: Date.now(),
429
- variant: "alert",
430
- title: e.title,
431
- content: e.content,
432
- confirmText: "确定",
433
- onConfirm: e.onConfirm
434
- }] }));
435
- },
436
- hideLoading: q
437
- }, Je = { CaOverlayHost: Z };
438
- function Ye() {
439
- if (typeof document > "u") return () => {};
440
- let e = document.createElement("div");
441
- e.setAttribute("data-ca-overlay", ""), document.body.appendChild(e);
442
- let t = a(Z);
443
- return t.mount(e), () => {
444
- t.unmount(), e.remove();
445
- };
446
2508
  }
447
- function Xe() {
448
- if (typeof window > "u") return;
449
- let e = window;
450
- e.ca ||= Q;
2509
+ // packages/core/src/app.ts
2510
+ function qr(e) {
2511
+ Mt(e), Ae(e);
2512
+ let t = r(De), n = F();
2513
+ t.use(n);
2514
+ let i = Ce(e);
2515
+ t.use(i);
2516
+ let a = (e, t) => i.global.t(e, t ?? {});
2517
+ t.provide(ee, a), Pt(a), t.config.globalProperties.$ca = $, L(t), t.component("CaAuthPreview", en);
2518
+ let o = Hr(e, n);
2519
+ return Gr(o, n), t.use(o), Be(n).boot(), t;
451
2520
  }
452
- function $(e = {}) {
453
- let t = new z(e), n = U(t), r = Ce(e.config?.locale ?? {});
454
- Object.entries(_e).forEach(([e, t]) => n.component(e, t)), Object.entries(Je).forEach(([e, t]) => n.component(e, t)), n.register(e.providers ?? []), n.use(e.plugins ?? []);
455
- let i = null;
456
- return {
457
- ...n,
458
- name: "campus-admin",
459
- locale: r,
460
- install(e) {
461
- n.start(), e.provide(W, t), we(e, r), n.install(e), i = Ye(), Xe();
462
- },
463
- unmount() {
464
- i?.(), i = null;
465
- }
466
- };
2521
+ // packages/core/src/index.ts
2522
+ function Jr(e) {
2523
+ return e;
467
2524
  }
468
- //#endregion
469
- //#region src/index.ts
470
- var Ze = { install(e) {
471
- $().install(e);
472
- } };
473
- //#endregion
474
- export { W as CAMPUS_KEY, T as CaLoadingOverlay, Z as CaOverlayHost, F as CaOverlayList, E as CaToastList, z as CampusApplication, I as CampusContainer, R as CampusContext, D as CampusStore, M as alert, Q as ca, Ke as campus, Pe as clearOverlays, ve as clearToasts, A as closeOverlay, ye as closeToast, r as computed, N as confirm, i as createApp, Ue as createCampus, $ as createCampusAdmin, U as createVueApplication, Ze as default, f as defineAsyncComponent, ee as defineComponent, Ge as definePlugin, We as defineProvider, H as getCurrentCampus, q as hideLoading, m as inject, L as isCampusProvider, G as loadingStore, te as nextTick, re as onBeforeUnmount, ie as onMounted, h as onScopeDispose, ae as onUnmounted, O as overlayStore, oe as provide, se as readonly, _ as ref, V as setCurrentCampus, y as shallowRef, K as showLoading, Y as showToast, ce as toRef, le as toRefs, be as toast, J as toastStore, qe as useCampus, S as watch, de as watchEffect };
2525
+ export { $ as ca, qr as createCampusApp, Jr as defineMenus, Kr as handleUnauthorized, jt as resolveEnvironment, Te as t, W as useCampusT, J as useLayoutStore, X as useSessionStore, Y as useTabsStore, Be as useThemeStore };