@campus-admin/core 1.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +26 -157
  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 +356 -0
  6. package/dist/index.d.ts +23 -32
  7. package/dist/index.js +2572 -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 +6 -0
  30. package/dist/pages/auth/options.d.ts +16 -0
  31. package/dist/pages/auth/wechat-host.d.ts +10 -0
  32. package/dist/router.d.ts +15 -0
  33. package/dist/security.d.ts +15 -0
  34. package/dist/services/auth.d.ts +21 -0
  35. package/dist/services/ca.d.ts +48 -0
  36. package/dist/services/feedback.d.ts +54 -0
  37. package/dist/services/login.d.ts +8 -0
  38. package/dist/storage.d.ts +12 -0
  39. package/dist/stores/layout.d.ts +41 -0
  40. package/dist/stores/session.d.ts +65 -0
  41. package/dist/stores/tabs.d.ts +49 -0
  42. package/dist/stores/theme.d.ts +280 -0
  43. package/dist/style.css +2 -0
  44. package/dist/tabs-policy.d.ts +4 -0
  45. package/dist/types.d.ts +259 -0
  46. package/package.json +23 -61
  47. package/dist/application.d.ts +0 -51
  48. package/dist/campus.d.ts +0 -9
  49. package/dist/components/overlay/index.d.ts +0 -6
  50. package/dist/components/overlay/style/index.d.ts +0 -10
  51. package/dist/container.d.ts +0 -21
  52. package/dist/contracts/config.d.ts +0 -13
  53. package/dist/contracts/provider.d.ts +0 -24
  54. package/dist/core.css +0 -2
  55. package/dist/facade.d.ts +0 -15
  56. package/dist/index.umd.cjs +0 -1
  57. package/dist/plugin.d.ts +0 -49
  58. package/dist/services/index.d.ts +0 -7
  59. package/dist/services/loading.d.ts +0 -21
  60. package/dist/services/modal.d.ts +0 -47
  61. package/dist/services/store.d.ts +0 -20
  62. package/dist/services/toast.d.ts +0 -19
  63. package/dist/services/use-store.d.ts +0 -9
  64. package/dist/vue-application.d.ts +0 -21
  65. package/dist/vue.d.ts +0 -8
  66. package/types/ca.d.ts +0 -22
  67. /package/dist/{components/overlay/ca-overlay-host.vue.d.ts → CampusRoot.vue.d.ts} +0 -0
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 布局的三个量(用户确认“先这样定,后面不合适再调”)。
3
+ *
4
+ * 三档:手机 ≤ PHONE_MAX_WIDTH;平板 PHONE_MAX_WIDTH+1 ~ PAD_MAX_WIDTH;电脑 ≥ PAD_MAX_WIDTH+1。
5
+ *
6
+ * 如何调整(CSS 媒体查询不能引用 JS 常量,所以下面这些位置必须一起改,test/breakpoints.test.ts 会逐项检查并指出文件):
7
+ * 1. 手机上限 PHONE_MAX_WIDTH:本文件常量;layout/*.vue 里所有 `max-width: 768px`(手机)与 `min-width: 769px`(平板起点)。
8
+ * 2. 平板上限 PAD_MAX_WIDTH:本文件常量;layout/*.vue 里所有 `max-width: 1200px`(平板终点)与 `min-width: 1201px`(电脑起点)。
9
+ * 3. 电脑档没有最低视口:1201 起两栏并排,内容区随窗口收缩,整页不出现横向滚动条(2026-10-26 用户取消原 1280 最低宽)。
10
+ * 侧栏宽度改动时同步 RAIL_WIDTH / SIDE_PANEL_WIDTH 与 CaLayout.vue 的同名变量。
11
+ */
12
+ export declare const PHONE_MAX_WIDTH = 768;
13
+ export declare const PAD_MAX_WIDTH = 1200;
14
+ /** 与 CaLayout.vue 的 --ca-rail-width / --ca-side-panel-width 同步(测试检查) */
15
+ export declare const RAIL_WIDTH = 84;
16
+ export declare const SIDE_PANEL_WIDTH = 200;
17
+ export type LayoutMode = 'phone' | 'pad' | 'desktop';
18
+ /** 三档的媒体查询,JS 判断与 CSS 使用同一组数字 */
19
+ export declare const PHONE_QUERY = "(max-width: 768px)";
20
+ export declare const PAD_QUERY = "(min-width: 769px) and (max-width: 1200px)";
21
+ export declare function layoutModeOf(width: number): LayoutMode;
@@ -1,10 +1,6 @@
1
1
  type __VLS_Props = {
2
- visible?: boolean;
3
- text?: string;
2
+ kind: 'login' | 'register' | 'forgot';
4
3
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- visible: boolean;
7
- text: string;
8
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
5
  declare const _default: typeof __VLS_export;
10
6
  export default _default;
@@ -1,9 +1,6 @@
1
- import type { ToastItem } from '@campus-admin/ui';
2
1
  type __VLS_Props = {
3
- items?: ToastItem[];
2
+ kind: 'forbidden' | 'notFound';
4
3
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- items: ToastItem[];
7
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
5
  declare const _default: typeof __VLS_export;
9
6
  export default _default;
@@ -1,9 +1,6 @@
1
- import type { OverlayItem } from '../../services/modal';
2
1
  type __VLS_Props = {
3
- items?: OverlayItem[];
2
+ preview?: boolean;
4
3
  };
5
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
- items: OverlayItem[];
7
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
5
  declare const _default: typeof __VLS_export;
9
6
  export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 登录类页面输入框前面的小图标。
3
+ * 通用图标注册表里没有锁、手机这类图标,这几个只在登录类页面用,所以就近内联,不去扩充全局注册表。
4
+ */
5
+ type __VLS_Props = {
6
+ name: 'user' | 'lock' | 'phone' | 'shield' | 'message';
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,29 @@
1
+ export interface AuthTab {
2
+ key: string;
3
+ label: string;
4
+ /** 有 to 的标签是跳转链接(如“返回登录”),没有则是在本页切换 */
5
+ to?: string;
6
+ }
7
+ type __VLS_Props = {
8
+ tabs: AuthTab[];
9
+ active: string;
10
+ /** 在后台内容区里预览:不占满整个窗口 */
11
+ preview?: boolean;
12
+ };
13
+ declare var __VLS_10: {};
14
+ type __VLS_Slots = {} & {
15
+ default?: (props: typeof __VLS_10) => any;
16
+ };
17
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
+ "update:active": (key: string) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ "onUpdate:active"?: ((key: string) => any) | undefined;
21
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
25
+ type __VLS_WithSlots<T, S> = T & {
26
+ new (): {
27
+ $slots: S;
28
+ };
29
+ };
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ scene: 'login' | 'register' | 'forgot';
3
+ };
4
+ declare function refresh(): Promise<void>;
5
+ type __VLS_ModelProps = {
6
+ 'code'?: string;
7
+ 'captchaKey'?: string;
8
+ };
9
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
11
+ refresh: typeof refresh;
12
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ "update:code": (value: string) => any;
14
+ "update:captchaKey": (value: string) => any;
15
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:code"?: ((value: string) => any) | undefined;
17
+ "onUpdate:captchaKey"?: ((value: string) => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ type __VLS_Props = {
2
+ send: () => Promise<void>;
3
+ };
4
+ type __VLS_ModelProps = {
5
+ modelValue?: string;
6
+ };
7
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ "update:modelValue": (value: string) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
11
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
@@ -0,0 +1,6 @@
1
+ type __VLS_Props = {
2
+ preview?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
5
+ declare const _default: typeof __VLS_export;
6
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { expandYear } from '../../copyright.js';
2
+ import type { LoginOptions } from '../../types.js';
3
+ /** 中国大陆手机号:1 开头,第二位 3–9,共 11 位 */
4
+ export declare const PHONE_PATTERN: RegExp;
5
+ /** 登录页配置;没配置时返回空对象,各处按默认值处理 */
6
+ export declare function loginOptions(): LoginOptions;
7
+ /** 平台提供了哪些能力:没提供的入口不显示,直接访问路由显示“未开通” */
8
+ export declare function authCapabilities(): {
9
+ captcha: boolean;
10
+ register: boolean;
11
+ wechat: boolean;
12
+ forgot: boolean;
13
+ };
14
+ /** 回跳地址只接受站内路径,防止被构造成跳到外站的开放重定向 */
15
+ export declare function safeRedirectOf(target: unknown): string;
16
+ export { expandYear };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 微信登录标签的容器生命周期(不依赖 Vue,方便测试):
3
+ * 标签可见时 mountWechat 把容器交给平台的 mount(el);标签隐藏、离开登录页时调用 release,
4
+ * 执行 mount 返回的清理函数。清理只执行一次,清理抛错不外抛;mount 抛错返回 ok:false 且不留残余。
5
+ */
6
+ export interface WechatHost {
7
+ ok: boolean;
8
+ release(): void;
9
+ }
10
+ export declare function mountWechat(mount: (el: HTMLElement) => void | (() => void), el: HTMLElement): WechatHost;
@@ -0,0 +1,15 @@
1
+ import { type Router } from 'vue-router';
2
+ import type { Pinia } from 'pinia';
3
+ import type { CampusOptions } from './types.js';
4
+ /** 给路由元信息加类型,守卫和布局里读取时有提示 */
5
+ declare module 'vue-router' {
6
+ interface RouteMeta {
7
+ /** 公开页面(不需要登录) */
8
+ public?: boolean;
9
+ pageKey?: string;
10
+ appKey?: string;
11
+ groupKey?: string;
12
+ permission?: string;
13
+ }
14
+ }
15
+ export declare function createCampusRouter(options: CampusOptions, pinia: Pinia): Router;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 运行环境与安全策略:测试环境不设限,生产环境收紧。
3
+ *
4
+ * 环境默认取构建模式(`vite build` 为生产,`vite dev` 为测试),平台可用 `CampusOptions.environment` 显式指定,
5
+ * 例如“测试服务器也用生产构建”时写 `environment: 'test'`。
6
+ * 生产环境:必须提供图形验证码;注册、找回密码的新密码至少 8 位且同时含字母和数字。
7
+ * 这只是前端的第一道关,强度和验证码的最终校验必须由后端做。
8
+ */
9
+ import type { CampusOptions } from './types.js';
10
+ export type CampusEnvironment = 'test' | 'production';
11
+ export declare function resolveEnvironment(options: Pick<CampusOptions, 'environment'>): CampusEnvironment;
12
+ /** 生产环境启动检查:缺验证码直接报错,而不是上线后才发现登录页没有验证码 */
13
+ export declare function assertProductionReady(options: CampusOptions): void;
14
+ /** 新密码是否合格:测试环境不限制,生产环境至少 8 位且同时含字母和数字 */
15
+ export declare function isPasswordAllowed(password: string, env: CampusEnvironment): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 401 统一出口:平台请求层收到“未登录 / 令牌失效”(通常是 HTTP 401)时调用 `handleUnauthorized()`。
3
+ *
4
+ * 做三件事:清掉本地登录态、提示“登录已失效”、跳到登录页并记下当前地址,登录后回跳。
5
+ * 已经是未登录状态时什么都不做,所以同时有多个请求返回 401 也只会提示、跳转一次。
6
+ */
7
+ import type { Pinia } from 'pinia';
8
+ import type { Router } from 'vue-router';
9
+ import type { SessionUser } from '../types.js';
10
+ /** 创建应用时绑定路由和 Pinia,供组件树之外的请求层使用 */
11
+ export declare function bindAuthContext(router: Router, pinia: Pinia): void;
12
+ export declare function handleUnauthorized(message?: string): Promise<void>;
13
+ /**
14
+ * 平台自己完成登录后把会话交给框架(如微信官方登录整页跳转回来,在回调里拿到令牌):
15
+ * 写入登录态,并回跳 `redirect`(只接受站内路径,缺省首页)。账号登录页提交也是同样的落地方式。
16
+ * 需要在应用创建之后调用。
17
+ */
18
+ export declare function completeLogin(result: {
19
+ token: string;
20
+ user: SessionUser;
21
+ }, redirect?: string): Promise<void>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 全局命令式接口的统一命名空间:`ca`。
3
+ *
4
+ * 约定:所有“不在模板里声明、直接调用函数”的框架能力,都挂在 `ca` 下面,
5
+ * 平台只需要记住一个入口:
6
+ *
7
+ * import { ca } from '@campus-admin/core'
8
+ * await ca.alert('保存成功')
9
+ * if (await ca.confirm('确定删除吗?')) { ... }
10
+ * ca.toast.success('已复制')
11
+ *
12
+ * 模板里也可以直接写 $ca.toast.success('…')(由 createCampusApp 注册)。
13
+ * 不挂到 window 上:避免全局污染,也让依赖关系在代码里一目了然。
14
+ *
15
+ * 以后新增命令式能力(如全局加载、命令式弹窗)都在这里增加一项,
16
+ * 具体实现放在 services/ 下各自的文件,保持本文件只做“汇总与命名”。
17
+ */
18
+ import { alertDialog, confirmDialog } from './feedback.js';
19
+ export declare const ca: {
20
+ /** 警告:只有“确定”按钮 */
21
+ alert: typeof alertDialog;
22
+ /** 确认:返回 true/false,取消不抛异常 */
23
+ confirm: typeof confirmDialog;
24
+ /** 轻提示:ca.toast.success / error / warning / info */
25
+ toast: {
26
+ info: (message: string) => undefined;
27
+ success: (message: string) => undefined;
28
+ warning: (message: string) => undefined;
29
+ error: (message: string) => undefined;
30
+ };
31
+ loading: {
32
+ (options?: import("element-plus").LoadingOptions, context?: import("vue").AppContext | null): import("element-plus").LoadingInstance;
33
+ _context: import("vue").AppContext | null;
34
+ };
35
+ notify: {
36
+ success: (message: string, options?: import("./feedback.js").NotifyOptions) => import("element-plus").NotificationHandle;
37
+ info: (message: string, options?: import("./feedback.js").NotifyOptions) => import("element-plus").NotificationHandle;
38
+ warning: (message: string, options?: import("./feedback.js").NotifyOptions) => import("element-plus").NotificationHandle;
39
+ error: (message: string, options?: import("./feedback.js").NotifyOptions) => import("element-plus").NotificationHandle;
40
+ };
41
+ };
42
+ export type Ca = typeof ca;
43
+ /** 让模板里的 $ca 有类型提示 */
44
+ declare module 'vue' {
45
+ interface ComponentCustomProperties {
46
+ $ca: Ca;
47
+ }
48
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 反馈服务的实现:警告、确认、轻提示、通知与加载。
3
+ *
4
+ * 平台不直接使用本文件,而是通过全局命令式命名空间 `ca` 调用(见 ./ca.ts):
5
+ * ca.alert('保存成功')、ca.confirm('确定删除?')、ca.toast.success('已复制')
6
+ *
7
+ * 这是“升级不改平台”的关键一环:平台只说“要什么”(弹一个确认、提示成功),
8
+ * 具体用什么组件、什么样式、什么动画由这里决定。以后改样式只改这里,所有平台自动跟随。
9
+ * 平台不应直接引用基座的 MessageBox / Message。
10
+ */
11
+ import { type NotificationOptions } from 'element-plus';
12
+ import 'element-plus/es/components/loading/style/css';
13
+ import 'element-plus/es/components/notification/style/css';
14
+ import 'element-plus/es/components/message/style/css';
15
+ import 'element-plus/es/components/message-box/style/css';
16
+ import type { Translate } from '@campus-admin/ui';
17
+ type Level = 'info' | 'success' | 'warning' | 'error';
18
+ export interface DialogOptions {
19
+ /** 标题,缺省为“提示”(随语言) */
20
+ title?: string;
21
+ /** 图标与颜色语义:alert 缺省 info,confirm 缺省 warning */
22
+ type?: Level;
23
+ confirmText?: string;
24
+ cancelText?: string;
25
+ }
26
+ export declare function bindFeedback(t: Translate): void;
27
+ /** 警告:只有一个确认按钮,用户点掉后 resolve */
28
+ export declare function alertDialog(message: string, options?: DialogOptions): Promise<void>;
29
+ /**
30
+ * 确认:用户确认返回 true,取消或关闭返回 false。
31
+ * 取消不抛异常,调用方直接 if (await ca.confirm(...)) 即可,不用到处 try/catch。
32
+ */
33
+ export declare function confirmDialog(message: string, options?: DialogOptions): Promise<boolean>;
34
+ /** 轻提示:几秒后自动消失,不打断操作 */
35
+ export declare const toast: {
36
+ info: (message: string) => undefined;
37
+ success: (message: string) => undefined;
38
+ warning: (message: string) => undefined;
39
+ error: (message: string) => undefined;
40
+ };
41
+ /** 保留基座加载选项与 close(),调用方在 finally 中关闭。 */
42
+ export declare const loading: {
43
+ (options?: import("element-plus").LoadingOptions, context?: import("vue").AppContext | null): import("element-plus").LoadingInstance;
44
+ _context: import("vue").AppContext | null;
45
+ };
46
+ export type NotifyOptions = Omit<Partial<NotificationOptions>, 'message' | 'type'>;
47
+ /** 通知与 toast 使用相同的级别入口,可通过返回实例主动关闭。 */
48
+ export declare const notify: {
49
+ success: (message: string, options?: NotifyOptions) => import("element-plus").NotificationHandle;
50
+ info: (message: string, options?: NotifyOptions) => import("element-plus").NotificationHandle;
51
+ warning: (message: string, options?: NotifyOptions) => import("element-plus").NotificationHandle;
52
+ error: (message: string, options?: NotifyOptions) => import("element-plus").NotificationHandle;
53
+ };
54
+ export {};
@@ -0,0 +1,8 @@
1
+ /** 登录落地:写入登录态并回跳。从 auth.ts 拆出,不依赖界面组件,Node 测试可直接导入 */
2
+ import type { Router } from 'vue-router';
3
+ import { useSessionStore } from '../stores/session.js';
4
+ import type { SessionUser } from '../types.js';
5
+ export declare function finishLogin(session: Pick<ReturnType<typeof useSessionStore>, 'signIn'>, router: Pick<Router, 'replace'>, result: {
6
+ token: string;
7
+ user: SessionUser;
8
+ }, redirect?: string): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 浏览器存储的安全读写。
3
+ *
4
+ * 隐私模式、被禁用存储、容量满等情况下 localStorage 会抛异常。
5
+ * 这里统一捕获:读失败当作“没有”,写失败静默放弃——这些数据(主题缓存、语言、标签页)
6
+ * 都只是体验增强,丢了不影响功能,页面必须在没有存储时照常工作。
7
+ */
8
+ export declare function readStorage(key: string, area?: 'local' | 'session'): string | null;
9
+ export declare function writeStorage(key: string, value: string | null, area?: 'local' | 'session'): void;
10
+ /** 读取 JSON;内容损坏时返回 undefined,而不是让整个应用启动失败 */
11
+ export declare function readJson<T>(key: string, area?: 'local' | 'session'): T | undefined;
12
+ export declare function writeJson(key: string, value: unknown, area?: 'local' | 'session'): void;
@@ -0,0 +1,41 @@
1
+ import type { LayoutMode } from '../layout/breakpoints.js';
2
+ export declare const useLayoutStore: import("pinia").StoreDefinition<"campus-layout", Pick<{
3
+ reset: () => void;
4
+ contentFullscreen: import("vue").Ref<boolean, boolean>;
5
+ mode: import("vue").Ref<LayoutMode, LayoutMode>;
6
+ mobileMenuOpen: import("vue").Ref<boolean, boolean>;
7
+ padPanelOpen: import("vue").Ref<boolean, boolean>;
8
+ toggleContentFullscreen: () => void;
9
+ setMode: (next: LayoutMode) => void;
10
+ closeMobileMenu: () => void;
11
+ openMobileMenu: () => void;
12
+ closePadPanel: () => void;
13
+ openPadPanel: () => void;
14
+ closeOverlays: () => void;
15
+ }, "mode" | "contentFullscreen" | "mobileMenuOpen" | "padPanelOpen">, Pick<{
16
+ reset: () => void;
17
+ contentFullscreen: import("vue").Ref<boolean, boolean>;
18
+ mode: import("vue").Ref<LayoutMode, LayoutMode>;
19
+ mobileMenuOpen: import("vue").Ref<boolean, boolean>;
20
+ padPanelOpen: import("vue").Ref<boolean, boolean>;
21
+ toggleContentFullscreen: () => void;
22
+ setMode: (next: LayoutMode) => void;
23
+ closeMobileMenu: () => void;
24
+ openMobileMenu: () => void;
25
+ closePadPanel: () => void;
26
+ openPadPanel: () => void;
27
+ closeOverlays: () => void;
28
+ }, never>, Pick<{
29
+ reset: () => void;
30
+ contentFullscreen: import("vue").Ref<boolean, boolean>;
31
+ mode: import("vue").Ref<LayoutMode, LayoutMode>;
32
+ mobileMenuOpen: import("vue").Ref<boolean, boolean>;
33
+ padPanelOpen: import("vue").Ref<boolean, boolean>;
34
+ toggleContentFullscreen: () => void;
35
+ setMode: (next: LayoutMode) => void;
36
+ closeMobileMenu: () => void;
37
+ openMobileMenu: () => void;
38
+ closePadPanel: () => void;
39
+ openPadPanel: () => void;
40
+ closeOverlays: () => void;
41
+ }, "reset" | "setMode" | "toggleContentFullscreen" | "closeMobileMenu" | "openMobileMenu" | "closePadPanel" | "openPadPanel" | "closeOverlays">>;
@@ -0,0 +1,65 @@
1
+ import type { AuthProvider, SessionUser } from '../types.js';
2
+ export declare const useSessionStore: import("pinia").StoreDefinition<"campus-session", Pick<{
3
+ token: import("vue").Ref<string, string>;
4
+ user: import("vue").Ref<{
5
+ name: string;
6
+ avatar?: string | undefined;
7
+ permissions?: string[] | "*" | undefined;
8
+ } | undefined, SessionUser | {
9
+ name: string;
10
+ avatar?: string | undefined;
11
+ permissions?: string[] | "*" | undefined;
12
+ } | undefined>;
13
+ isLoggedIn: import("vue").ComputedRef<boolean>;
14
+ can: (permission?: string) => boolean;
15
+ setPermissions: (permissions: SessionUser["permissions"]) => void;
16
+ login: (form: Parameters<AuthProvider["login"]>[0]) => Promise<void>;
17
+ signIn: (result: {
18
+ token: string;
19
+ user: SessionUser;
20
+ }) => void;
21
+ logout: () => Promise<void>;
22
+ expire: () => void;
23
+ }, "user" | "token">, Pick<{
24
+ token: import("vue").Ref<string, string>;
25
+ user: import("vue").Ref<{
26
+ name: string;
27
+ avatar?: string | undefined;
28
+ permissions?: string[] | "*" | undefined;
29
+ } | undefined, SessionUser | {
30
+ name: string;
31
+ avatar?: string | undefined;
32
+ permissions?: string[] | "*" | undefined;
33
+ } | undefined>;
34
+ isLoggedIn: import("vue").ComputedRef<boolean>;
35
+ can: (permission?: string) => boolean;
36
+ setPermissions: (permissions: SessionUser["permissions"]) => void;
37
+ login: (form: Parameters<AuthProvider["login"]>[0]) => Promise<void>;
38
+ signIn: (result: {
39
+ token: string;
40
+ user: SessionUser;
41
+ }) => void;
42
+ logout: () => Promise<void>;
43
+ expire: () => void;
44
+ }, "isLoggedIn">, Pick<{
45
+ token: import("vue").Ref<string, string>;
46
+ user: import("vue").Ref<{
47
+ name: string;
48
+ avatar?: string | undefined;
49
+ permissions?: string[] | "*" | undefined;
50
+ } | undefined, SessionUser | {
51
+ name: string;
52
+ avatar?: string | undefined;
53
+ permissions?: string[] | "*" | undefined;
54
+ } | undefined>;
55
+ isLoggedIn: import("vue").ComputedRef<boolean>;
56
+ can: (permission?: string) => boolean;
57
+ setPermissions: (permissions: SessionUser["permissions"]) => void;
58
+ login: (form: Parameters<AuthProvider["login"]>[0]) => Promise<void>;
59
+ signIn: (result: {
60
+ token: string;
61
+ user: SessionUser;
62
+ }) => void;
63
+ logout: () => Promise<void>;
64
+ expire: () => void;
65
+ }, "login" | "can" | "setPermissions" | "signIn" | "logout" | "expire">>;
@@ -0,0 +1,49 @@
1
+ export declare const useTabsStore: import("pinia").StoreDefinition<"campus-tabs", Pick<{
2
+ reset: () => void;
3
+ visited: import("vue").Ref<string[], string[]>;
4
+ versions: import("vue").Ref<Record<string, number>, Record<string, number>>;
5
+ cached: import("vue").ComputedRef<string[]>;
6
+ affixKeys: import("vue").ComputedRef<string[]>;
7
+ activeAt: import("vue").Ref<Record<string, number>, Record<string, number>>;
8
+ maxTabs: number;
9
+ open: (key: string) => void;
10
+ close: (key: string) => string | undefined;
11
+ closeLeft: (keep: string) => void;
12
+ closeRight: (keep: string) => void;
13
+ closeOthers: (keep: string) => void;
14
+ closeAll: () => void;
15
+ refresh: (key: string) => Promise<void>;
16
+ setAffix: (key: string, affixed: boolean) => boolean;
17
+ }, "visited" | "versions" | "activeAt" | "maxTabs">, Pick<{
18
+ reset: () => void;
19
+ visited: import("vue").Ref<string[], string[]>;
20
+ versions: import("vue").Ref<Record<string, number>, Record<string, number>>;
21
+ cached: import("vue").ComputedRef<string[]>;
22
+ affixKeys: import("vue").ComputedRef<string[]>;
23
+ activeAt: import("vue").Ref<Record<string, number>, Record<string, number>>;
24
+ maxTabs: number;
25
+ open: (key: string) => void;
26
+ close: (key: string) => string | undefined;
27
+ closeLeft: (keep: string) => void;
28
+ closeRight: (keep: string) => void;
29
+ closeOthers: (keep: string) => void;
30
+ closeAll: () => void;
31
+ refresh: (key: string) => Promise<void>;
32
+ setAffix: (key: string, affixed: boolean) => boolean;
33
+ }, "cached" | "affixKeys">, Pick<{
34
+ reset: () => void;
35
+ visited: import("vue").Ref<string[], string[]>;
36
+ versions: import("vue").Ref<Record<string, number>, Record<string, number>>;
37
+ cached: import("vue").ComputedRef<string[]>;
38
+ affixKeys: import("vue").ComputedRef<string[]>;
39
+ activeAt: import("vue").Ref<Record<string, number>, Record<string, number>>;
40
+ maxTabs: number;
41
+ open: (key: string) => void;
42
+ close: (key: string) => string | undefined;
43
+ closeLeft: (keep: string) => void;
44
+ closeRight: (keep: string) => void;
45
+ closeOthers: (keep: string) => void;
46
+ closeAll: () => void;
47
+ refresh: (key: string) => Promise<void>;
48
+ setAffix: (key: string, affixed: boolean) => boolean;
49
+ }, "refresh" | "close" | "reset" | "open" | "closeLeft" | "closeRight" | "closeOthers" | "closeAll" | "setAffix">>;