@done-coding/admin-core 0.10.0 → 0.10.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/es/bridge/config-hook.mjs +32 -26
  2. package/es/bridge/index.mjs +129 -83
  3. package/es/bridge/theme/index.mjs +103 -0
  4. package/es/bridge/theme/persist.mjs +14 -0
  5. package/es/bridge/theme/system-dark.mjs +11 -0
  6. package/es/components/app-layout/AppAside.vue.mjs +7 -0
  7. package/es/components/app-layout/AppAside.vue2.mjs +22 -0
  8. package/es/components/app-layout/AppFooter.vue.mjs +2 -2
  9. package/es/components/app-layout/AppHeader.vue.mjs +2 -2
  10. package/es/components/app-layout/AppHeader.vue2.mjs +35 -41
  11. package/es/components/app-layout/AppLayout.vue.mjs +2 -2
  12. package/es/components/app-layout/AppLayout.vue2.mjs +106 -88
  13. package/es/components/app-layout/AppShell.vue.mjs +60 -0
  14. package/es/components/app-layout/AppShell.vue2.mjs +4 -0
  15. package/es/components/app-layout/AppSidebar.vue.mjs +2 -2
  16. package/es/components/app-layout/AppSidebar.vue2.mjs +44 -47
  17. package/es/components/app-layout/AppTheme.vue.mjs +2 -2
  18. package/es/components/app-layout/AppTheme.vue2.mjs +55 -25
  19. package/es/components/app-layout/viewport.mjs +5 -0
  20. package/es/components/form/FormItemNestForm.vue.mjs +1 -1
  21. package/es/components/form/FormItemNestFormList.vue.mjs +1 -1
  22. package/es/components/form/FormSearch.vue.mjs +2 -2
  23. package/es/components/form/FormSearch.vue2.mjs +1 -1
  24. package/es/hooks/use-admin-theme-apply.mjs +16 -15
  25. package/es/hooks/use-admin-viewport-apply.mjs +29 -17
  26. package/es/index.mjs +182 -175
  27. package/es/store/app.mjs +133 -77
  28. package/es/style.css +1 -1
  29. package/package.json +2 -2
  30. package/types/bridge/config-hook.d.ts +10 -2
  31. package/types/bridge/index.d.ts +105 -5
  32. package/types/bridge/theme/index.d.ts +10 -0
  33. package/types/bridge/theme/persist.d.ts +23 -0
  34. package/types/bridge/theme/system-dark.d.ts +14 -0
  35. package/types/bridge/theme/types.d.ts +258 -0
  36. package/types/components/app-layout/AppAside.vue.d.ts +21 -0
  37. package/types/components/app-layout/AppLayout.vue.d.ts +2 -7
  38. package/types/components/app-layout/AppShell.vue.d.ts +27 -0
  39. package/types/components/app-layout/index.d.ts +4 -1
  40. package/types/components/app-layout/types.d.ts +117 -1
  41. package/types/components/app-layout/viewport.d.ts +30 -0
  42. package/types/hooks/use-admin-viewport-apply.d.ts +6 -1
  43. package/types/store/app.d.ts +24 -83
  44. package/types/types/route.d.ts +2 -0
  45. package/es/bridge/theme.mjs +0 -65
  46. package/types/bridge/theme.d.ts +0 -85
@@ -1,3 +1,4 @@
1
+ import { CSSProperties } from 'vue';
1
2
  import { AdminBridge } from '../bridge';
2
3
  /**
3
4
  * createAppStore 工厂依赖(#A 期,与 createUserStore deps 收敛单字段 `{ bridge }` 范式对齐)。
@@ -51,39 +52,19 @@ export declare function createAppStore<UserInfo = unknown, LoginParams = unknown
51
52
  readonly focusRing?: string | undefined;
52
53
  readonly surface?: string | undefined;
53
54
  }>;
54
- extractLevel1ToHeader: import('vue').Ref<boolean, boolean>;
55
55
  showHeader: import('vue').ComputedRef<boolean>;
56
56
  showFooter: import('vue').ComputedRef<boolean>;
57
57
  showSidebar: import('vue').ComputedRef<boolean>;
58
+ showAside: import('vue').ComputedRef<boolean>;
58
59
  showBreadcrumb: import('vue').ComputedRef<boolean>;
59
60
  keepAlive: import('vue').ComputedRef<boolean | undefined>;
60
- headerStyle: import('vue').ComputedRef<{
61
- height: string;
62
- backgroundColor: string;
63
- color: string;
64
- }>;
65
- footerStyle: import('vue').ComputedRef<{
66
- height: string;
67
- backgroundColor: string;
68
- }>;
69
- sidebarStyle: import('vue').ComputedRef<{
70
- width: string;
71
- paddingTop: string;
72
- backgroundColor: string;
73
- color: string;
74
- }>;
75
- bodyStyle: import('vue').ComputedRef<{
76
- paddingLeft: string;
77
- paddingTop: string;
78
- paddingRight: string;
79
- paddingBottom: string;
80
- backgroundColor: string;
81
- }>;
61
+ headerStyle: import('vue').ComputedRef<CSSProperties>;
62
+ footerStyle: import('vue').ComputedRef<CSSProperties>;
63
+ sidebarStyle: import('vue').ComputedRef<CSSProperties>;
64
+ asideStyle: import('vue').ComputedRef<CSSProperties>;
65
+ bodyStyle: import('vue').ComputedRef<CSSProperties>;
82
66
  bodyShimPadding: import('vue').ComputedRef<number>;
83
- bodyShimStyle: import('vue').ComputedRef<{
84
- minHeight: string;
85
- padding: string;
86
- }>;
67
+ bodyShimStyle: import('vue').ComputedRef<CSSProperties>;
87
68
  viewportPadding: import('vue').ComputedRef<{
88
69
  top: string;
89
70
  right: string;
@@ -94,7 +75,7 @@ export declare function createAppStore<UserInfo = unknown, LoginParams = unknown
94
75
  changeSidebarCollapseStatus: (status: boolean) => void;
95
76
  changeSidebarHasMenusStatus: (status: boolean) => void;
96
77
  changeIsDarkTheme: (status: boolean) => void;
97
- }, "extractLevel1ToHeader">, Pick<{
78
+ }, never>, Pick<{
98
79
  name: import('vue').ComputedRef<string>;
99
80
  isDarkTheme: import('vue').ComputedRef<boolean>;
100
81
  theme: import('vue').ComputedRef<{
@@ -116,39 +97,19 @@ export declare function createAppStore<UserInfo = unknown, LoginParams = unknown
116
97
  readonly focusRing?: string | undefined;
117
98
  readonly surface?: string | undefined;
118
99
  }>;
119
- extractLevel1ToHeader: import('vue').Ref<boolean, boolean>;
120
100
  showHeader: import('vue').ComputedRef<boolean>;
121
101
  showFooter: import('vue').ComputedRef<boolean>;
122
102
  showSidebar: import('vue').ComputedRef<boolean>;
103
+ showAside: import('vue').ComputedRef<boolean>;
123
104
  showBreadcrumb: import('vue').ComputedRef<boolean>;
124
105
  keepAlive: import('vue').ComputedRef<boolean | undefined>;
125
- headerStyle: import('vue').ComputedRef<{
126
- height: string;
127
- backgroundColor: string;
128
- color: string;
129
- }>;
130
- footerStyle: import('vue').ComputedRef<{
131
- height: string;
132
- backgroundColor: string;
133
- }>;
134
- sidebarStyle: import('vue').ComputedRef<{
135
- width: string;
136
- paddingTop: string;
137
- backgroundColor: string;
138
- color: string;
139
- }>;
140
- bodyStyle: import('vue').ComputedRef<{
141
- paddingLeft: string;
142
- paddingTop: string;
143
- paddingRight: string;
144
- paddingBottom: string;
145
- backgroundColor: string;
146
- }>;
106
+ headerStyle: import('vue').ComputedRef<CSSProperties>;
107
+ footerStyle: import('vue').ComputedRef<CSSProperties>;
108
+ sidebarStyle: import('vue').ComputedRef<CSSProperties>;
109
+ asideStyle: import('vue').ComputedRef<CSSProperties>;
110
+ bodyStyle: import('vue').ComputedRef<CSSProperties>;
147
111
  bodyShimPadding: import('vue').ComputedRef<number>;
148
- bodyShimStyle: import('vue').ComputedRef<{
149
- minHeight: string;
150
- padding: string;
151
- }>;
112
+ bodyShimStyle: import('vue').ComputedRef<CSSProperties>;
152
113
  viewportPadding: import('vue').ComputedRef<{
153
114
  top: string;
154
115
  right: string;
@@ -159,7 +120,7 @@ export declare function createAppStore<UserInfo = unknown, LoginParams = unknown
159
120
  changeSidebarCollapseStatus: (status: boolean) => void;
160
121
  changeSidebarHasMenusStatus: (status: boolean) => void;
161
122
  changeIsDarkTheme: (status: boolean) => void;
162
- }, "name" | "theme" | "showHeader" | "keepAlive" | "bodyShimPadding" | "isDarkTheme" | "showFooter" | "showSidebar" | "showBreadcrumb" | "headerStyle" | "footerStyle" | "sidebarStyle" | "bodyStyle" | "bodyShimStyle" | "viewportPadding" | "sidebarIsCollapse">, Pick<{
123
+ }, "name" | "theme" | "showHeader" | "keepAlive" | "bodyShimPadding" | "isDarkTheme" | "showFooter" | "showSidebar" | "showAside" | "showBreadcrumb" | "headerStyle" | "footerStyle" | "sidebarStyle" | "asideStyle" | "bodyStyle" | "bodyShimStyle" | "viewportPadding" | "sidebarIsCollapse">, Pick<{
163
124
  name: import('vue').ComputedRef<string>;
164
125
  isDarkTheme: import('vue').ComputedRef<boolean>;
165
126
  theme: import('vue').ComputedRef<{
@@ -181,39 +142,19 @@ export declare function createAppStore<UserInfo = unknown, LoginParams = unknown
181
142
  readonly focusRing?: string | undefined;
182
143
  readonly surface?: string | undefined;
183
144
  }>;
184
- extractLevel1ToHeader: import('vue').Ref<boolean, boolean>;
185
145
  showHeader: import('vue').ComputedRef<boolean>;
186
146
  showFooter: import('vue').ComputedRef<boolean>;
187
147
  showSidebar: import('vue').ComputedRef<boolean>;
148
+ showAside: import('vue').ComputedRef<boolean>;
188
149
  showBreadcrumb: import('vue').ComputedRef<boolean>;
189
150
  keepAlive: import('vue').ComputedRef<boolean | undefined>;
190
- headerStyle: import('vue').ComputedRef<{
191
- height: string;
192
- backgroundColor: string;
193
- color: string;
194
- }>;
195
- footerStyle: import('vue').ComputedRef<{
196
- height: string;
197
- backgroundColor: string;
198
- }>;
199
- sidebarStyle: import('vue').ComputedRef<{
200
- width: string;
201
- paddingTop: string;
202
- backgroundColor: string;
203
- color: string;
204
- }>;
205
- bodyStyle: import('vue').ComputedRef<{
206
- paddingLeft: string;
207
- paddingTop: string;
208
- paddingRight: string;
209
- paddingBottom: string;
210
- backgroundColor: string;
211
- }>;
151
+ headerStyle: import('vue').ComputedRef<CSSProperties>;
152
+ footerStyle: import('vue').ComputedRef<CSSProperties>;
153
+ sidebarStyle: import('vue').ComputedRef<CSSProperties>;
154
+ asideStyle: import('vue').ComputedRef<CSSProperties>;
155
+ bodyStyle: import('vue').ComputedRef<CSSProperties>;
212
156
  bodyShimPadding: import('vue').ComputedRef<number>;
213
- bodyShimStyle: import('vue').ComputedRef<{
214
- minHeight: string;
215
- padding: string;
216
- }>;
157
+ bodyShimStyle: import('vue').ComputedRef<CSSProperties>;
217
158
  viewportPadding: import('vue').ComputedRef<{
218
159
  top: string;
219
160
  right: string;
@@ -32,6 +32,8 @@ export interface AppRouteMeta {
32
32
  layout?: Partial<{
33
33
  header: boolean;
34
34
  sidebar: boolean;
35
+ /** 右侧 aside 补充区显隐(additive;默认 false,仅自定义 shell 渲染) */
36
+ aside: boolean;
35
37
  footer: boolean;
36
38
  breadcrumb: boolean;
37
39
  bodyShimPadding: number;
@@ -1,65 +0,0 @@
1
- import { ref as f, readonly as d } from "vue";
2
- const o = "default", E = "默认", b = "admin-core-theme", I = (t) => ({
3
- light: { ...t.light },
4
- dark: { ...t.dark }
5
- }), A = (t, c) => {
6
- const r = t.getItem(c);
7
- if (!r) return null;
8
- try {
9
- const s = JSON.parse(r);
10
- return s && typeof s == "object" ? s : null;
11
- } catch {
12
- return null;
13
- }
14
- };
15
- function _(t) {
16
- const c = t.storageKey ?? b, r = /* @__PURE__ */ new Map(), s = f(o), u = f(!1), g = f([]), n = f({});
17
- let i = o;
18
- const a = A(t.storage, c);
19
- a && (typeof a.themeStyle == "string" && a.themeStyle && (i = a.themeStyle), typeof a.themeIsDark == "boolean" && (u.value = a.themeIsDark));
20
- const h = () => {
21
- t.storage.setItem(
22
- c,
23
- JSON.stringify({
24
- themeStyle: s.value,
25
- themeIsDark: u.value
26
- })
27
- );
28
- }, v = () => {
29
- g.value = Array.from(r.keys());
30
- }, m = (e) => {
31
- t.update("APP_THEME_CONFIG", { light: e.light, dark: e.dark });
32
- }, y = (e) => {
33
- const l = r.get(e);
34
- if (!l) {
35
- const k = r.get(o);
36
- if (!k) return;
37
- m(k), s.value = o, h();
38
- return;
39
- }
40
- m(l), s.value = e, h();
41
- }, S = (e) => {
42
- u.value = !!e, h();
43
- }, p = (e, l) => {
44
- r.set(e, I(l.config)), n.value = { ...n.value, [e]: l.label ?? e }, v(), e === i && s.value !== i && y(e);
45
- }, L = (e) => {
46
- if (e === o || !r.delete(e)) return;
47
- const l = { ...n.value };
48
- delete l[e], n.value = l, v(), s.value === e && y(o);
49
- }, D = (e) => n.value[e] ?? e;
50
- return p(o, { config: t.initConfig, label: E }), {
51
- theme: {
52
- add: p,
53
- remove: L,
54
- setStyle: y,
55
- setDark: S,
56
- list: d(g),
57
- labelOf: D
58
- },
59
- themeStyle: d(s),
60
- themeIsDark: d(u)
61
- };
62
- }
63
- export {
64
- _ as createBridgeThemeHook
65
- };
@@ -1,85 +0,0 @@
1
- import { DeepReadonly, Ref } from 'vue';
2
- import { AppThemeConfig, StorageLike } from './index';
3
- /**
4
- * 风格切换真相源在 bridge——core 之于主题 = core 之于 userInfo:core 是
5
- * 「无知容器 + 切换能力暴露者」,不持有 dark 真相、不关心主题内容,谁实现谁注册
6
- * (core 默认一对 / 插件扩展 core 均不关心)。
7
- *
8
- * 本模块从 `bridge/index.ts` 按耦合度拆出(core CLAUDE.md 规则:bridge 可独立能力
9
- * [MUST NOT] 都耦合进 index.ts)。维护风格 map(name → 快照 config)+ 顶层响应式
10
- * `themeStyle` / `themeIsDark`,对外 `theme.{add,remove,setStyle,setDark,list}`。
11
- * setStyle 复用注入的 `update("APP_THEME_CONFIG", {light,dark})` 把当前风格 config
12
- * 灌进 bridge 响应式 APP_THEME_CONFIG(故 init 后响应式 APP_THEME_CONFIG 随切换变,
13
- * 不再恒等于初始值);用注入的 `storage` 持久化 `{themeStyle,themeIsDark}` 并 init 恢复。
14
- */
15
- /**
16
- * 主题注册项(`bridge.theme.add` 第 2 参)——core 侧主题「preset」结构。
17
- *
18
- * core 不依赖 plugin,故自定义此最小注册形;plugin-theme 的 `AdminThemePreset`
19
- * (含 id/label/description/config)是其结构超集,可整坨直接透传:
20
- * `bridge.theme.add(preset.id, preset)`(多出的 id/description 作 excess 字段被忽略)。
21
- */
22
- export interface AdminThemeEntry {
23
- /**
24
- * 风格色值(light/dark 两套 `AppThemeColor`)。
25
- *
26
- * 内部做浅快照(`{light:{...},dark:{...}}`)——与调用方对象解耦,且与 bridge
27
- * 响应式 APP_THEME_CONFIG 的 proxy target 解耦(避免切走后反写注册值)。
28
- */
29
- config: AppThemeConfig;
30
- /** 展示名(供 `AppTheme.vue` 下拉显示,如中文「柔光悬浮」);缺省回退注册 name 自身。 */
31
- label?: string;
32
- }
33
- /** 主题模块对外能力。 */
34
- export interface AdminThemeModule {
35
- /**
36
- * 注册/覆盖一个风格(插件 install 经 `bridge.theme.add` 调;同名覆盖)。
37
- *
38
- * 第 2 参收 {@link AdminThemeEntry}(`{config,label?}`);config 内部浅快照解耦。
39
- * 若新注册 name 命中持久化恢复的目标风格(init 时尚未注册),自动 `setStyle(name)`。
40
- */
41
- add: (name: string, preset: AdminThemeEntry) => void;
42
- /** 注销一个风格(`'default'` 不可注销;注销当前风格则回退 `'default'`)。 */
43
- remove: (name: string) => void;
44
- /** 切换风格(未注册回退 `'default'`):同步 APP_THEME_CONFIG + 持久化。 */
45
- setStyle: (name: string) => void;
46
- /** 切换暗色:写 `themeIsDark` + 持久化。 */
47
- setDark: (isDark: boolean) => void;
48
- /** 响应式风格名列表(只读,供 `AppTheme.vue` 下拉;`length>1` 才显示选择)。 */
49
- list: DeepReadonly<Ref<string[]>>;
50
- /** 取风格展示名(`add` 注册的 label;缺省回退 name 自身)。 */
51
- labelOf: (name: string) => string;
52
- }
53
- /** 主题 hook 对外契约:模块 + 两个顶层响应式只读真相源。 */
54
- export interface BridgeThemeHook {
55
- /** 主题模块(add/remove/setStyle/setDark/list) */
56
- theme: AdminThemeModule;
57
- /** 当前风格名(响应式只读;切换真相源,appStore / AppTheme.vue 读此) */
58
- themeStyle: DeepReadonly<Ref<string>>;
59
- /** 是否暗色(响应式只读;切换真相源,appStore.isDarkTheme 读此、挂值 composable toggle .dark 读此) */
60
- themeIsDark: DeepReadonly<Ref<boolean>>;
61
- }
62
- /** `createBridgeThemeHook` 入参。 */
63
- export interface BridgeThemeInit {
64
- /** init 默认风格 config(= bridge init 传入的 APP_THEME_CONFIG);core 自动 add 为 `'default'` */
65
- initConfig: AppThemeConfig;
66
- /**
67
- * 注入的 config 更新器(= configHook.update 收窄到 APP_THEME_CONFIG)。
68
- *
69
- * setStyle 经此把当前风格 config 灌进 bridge 响应式 APP_THEME_CONFIG(一级浅合并
70
- * 整体替换 light/dark)。复用既有 update 通道,[MUST NOT] 另持一份主题响应式。
71
- */
72
- update: (key: "APP_THEME_CONFIG", partial: Partial<AppThemeConfig>) => void;
73
- /** 注入的命名空间 storage(= bridge.getStorage());持久化 `{themeStyle,themeIsDark}` */
74
- storage: StorageLike;
75
- /** 持久化 key(命名空间已由 storage 加前缀);缺省 `"admin-core-theme"` */
76
- storageKey?: string;
77
- }
78
- /**
79
- * bridge 主题 hook 工厂。
80
- *
81
- * 每次 `createAdminBridge` 调用各自闭包内构造一份(零模块级单例,守实例隔离)。
82
- * init:自动 `add('default', initConfig)`;读持久化恢复 `themeIsDark` 即时生效、
83
- * `themeStyle` 走「desiredStyle 命中再 apply」时序(插件后注册风格亦能恢复)。
84
- */
85
- export declare function createBridgeThemeHook(init: BridgeThemeInit): BridgeThemeHook;