@robot-admin/layout 2.3.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +144 -0
- package/LICENSE +21 -0
- package/README.md +124 -59
- package/dist/core/index.cjs +310 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +121 -0
- package/dist/core/index.d.ts +121 -0
- package/dist/core/index.js +273 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.cts +1750 -0
- package/dist/index.d.ts +803 -109
- package/dist/index.js +1191 -882
- package/dist/index.js.map +1 -1
- package/package.json +39 -15
- package/src/styles/settings.scss +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Release the 3.0 architecture upgrade while preserving the existing Naive UI layouts, interactions, slots, and visual styling.
|
|
8
|
+
|
|
9
|
+
- Add a UI-independent `@robot-admin/layout/core` entrypoint for validated settings and shared contracts.
|
|
10
|
+
- Make layout/store injection and collapsed state work reliably with custom stores and multi-instance hosts.
|
|
11
|
+
- Replace destructive built-in storage clearing with explicit host actions and add stable SettingsDrawer extension slots.
|
|
12
|
+
- Validate complete imported configuration files before applying state and restore host-owned global classes on teardown.
|
|
13
|
+
- Respect the transition enable switch, harden route caching and responsive measurement, and improve built-in menu keyboard semantics.
|
|
14
|
+
- Verify all six layout modes in SSR and validate both ESM and CommonJS package entrypoints before publishing.
|
|
15
|
+
|
|
16
|
+
## 2.3.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Validate imported settings at runtime, support short hex colors safely, and preserve invalid color input instead of silently turning it black.
|
|
21
|
+
- Use route-segment-aware menu matching so `/users` no longer activates `/users-admin`.
|
|
22
|
+
- Disable cache debug logging and global window helpers by default; add configurable Settings Store ids.
|
|
23
|
+
- Standardize the automatic theme value on `system` and roll back settings if asynchronous theme synchronization fails.
|
|
24
|
+
- Improve menu/drawer keyboard navigation, focus restoration and ARIA state; guard browser and Canvas APIs for SSR or unsupported environments.
|
|
25
|
+
- Synchronize the exported version constant with package version 2.3.2 and add regression tests for the critical settings and routing contracts.
|
|
26
|
+
|
|
27
|
+
## 2.2.0
|
|
28
|
+
|
|
29
|
+
### 🐛 Bug 修复
|
|
30
|
+
|
|
31
|
+
- **ReverseHorizontalMixLayout 右侧菜单错位**: 修复右侧菜单显示在底部而非右侧的问题(`.main-area` 添加 `flex-direction: row`)
|
|
32
|
+
- **MixLayout 二级菜单消失**: 修复鼠标离开后二级菜单内容消失的问题(新增 `displayMenuItem` 作为 `hoveredMenuItem` 的 fallback)
|
|
33
|
+
- **MixTopLayout 全局 CSS 泄漏**: 修复 `.main-area`、`.content-layout` 等选择器污染其他布局的问题(嵌套到 `.mix-top-layout-container` 内)
|
|
34
|
+
|
|
35
|
+
### ✨ 功能优化
|
|
36
|
+
|
|
37
|
+
- **ResponsiveMenu 字符宽度估算**: 区分 CJK 字符(15px)和 ASCII 字符(8px),顶部菜单文字完整显示不截断
|
|
38
|
+
- **ReverseHorizontalMixLayout 折叠动画**: 用 width 过渡替代 Transition,避免黑色闪烁,动画更流畅(0.35s cubic-bezier)
|
|
39
|
+
- **MixLayout 交互模式**: 从悬停触发改为纯点击模式,点击同一菜单切换展开/折叠,点击不同菜单切换内容不关闭
|
|
40
|
+
|
|
41
|
+
### 🎨 视觉设计
|
|
42
|
+
|
|
43
|
+
- **ReverseHorizontalMixLayout 玻璃质感**: 参考搜索组件样式,应用 indigo 渐变玻璃设计(`linear-gradient` + `backdrop-filter` + 顶部高光线)
|
|
44
|
+
- **pure CSS 图标**: 替换所有 UnoCSS 图标(`i-ri:*`)为纯 CSS 实现(dots-icon、grid-icon、hamburger-icon、collapse-arrow),减少外部依赖
|
|
45
|
+
|
|
46
|
+
### 📦 依赖
|
|
47
|
+
|
|
48
|
+
- 移除对 UnoCSS 图标的依赖,提升包的独立性
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 2.1.0
|
|
53
|
+
|
|
54
|
+
### Minor Changes
|
|
55
|
+
|
|
56
|
+
- 重构目录结构 + 代码优化
|
|
57
|
+
|
|
58
|
+
- **目录重构**: 6 种布局骨架迁入 `components/layouts/` 子目录,层次更清晰
|
|
59
|
+
- **文件分离**: 每个布局的样式从 `<style>` 标签提取到独立的 `index.scss` 文件
|
|
60
|
+
- **注释统一**: 所有组件注释标准化为 `@robot-admin/layout - ComponentName` 格式
|
|
61
|
+
- **文档优化**: 重写 README,精简核心内容、添加目录树、API 参考更清晰
|
|
62
|
+
|
|
63
|
+
All notable changes to this project will be documented in this file.
|
|
64
|
+
|
|
65
|
+
## [2.0.2] - 2026-02-11
|
|
66
|
+
|
|
67
|
+
### 🗑️ Removed
|
|
68
|
+
|
|
69
|
+
- **Dead files**: Removed unused `tsup.config.ts` (actual build uses Vite)
|
|
70
|
+
- **Empty directories**: Removed `composables/`, `core/`, `layouts/` (8 empty directories total)
|
|
71
|
+
- **Unused dependencies**: Removed `vue-router` from peerDependencies and devDependencies (never used in source code)
|
|
72
|
+
|
|
73
|
+
### 🔧 Fixed
|
|
74
|
+
|
|
75
|
+
- **package.json**:
|
|
76
|
+
- Refined `sideEffects` to `["*.css", "*.scss"]` for better tree-shaking
|
|
77
|
+
- Removed blocking patterns `"*.vue"` and `"src/index.ts"`
|
|
78
|
+
- **Source code**:
|
|
79
|
+
|
|
80
|
+
- `constants/index.ts`: Removed commented-out code, fixed version from `"1.0.0"` to `"2.0.2"`
|
|
81
|
+
- `types/index.ts`: Removed unimplemented `storageKey` option from `SettingsStoreOptions`
|
|
82
|
+
- `stores/settings.ts`:
|
|
83
|
+
- Exported `adjustColor` utility function (was private)
|
|
84
|
+
- Removed redundant `|| false` in collapsed state initialization
|
|
85
|
+
- `data.ts`:
|
|
86
|
+
- Fixed `COLOR_SWATCHES` duplication (now imports from constants)
|
|
87
|
+
- Renamed `LAYOUT_MODES` to `LAYOUT_MODE_OPTIONS` to avoid naming conflict
|
|
88
|
+
|
|
89
|
+
- **SettingsDrawer component**:
|
|
90
|
+
|
|
91
|
+
- Removed unimplemented `storageKey` prop
|
|
92
|
+
- Fixed hardcoded timezone `"XIAn"` → `Intl.DateTimeFormat().resolvedOptions().timeZone`
|
|
93
|
+
- Fixed `handleResetLayout` missing `fixedHeader` and `tagsViewStyle` resets
|
|
94
|
+
- Fixed `handleImportConfig` to use `$patch` instead of `Object.assign` for proper reactivity
|
|
95
|
+
|
|
96
|
+
- **Styles (`settings.scss`)**:
|
|
97
|
+
|
|
98
|
+
- Replaced hardcoded `#409EFF` with `var(--primary-color, #409eff)` for theme color support
|
|
99
|
+
- Replaced hardcoded `rgba(32, 128, 240)` shadows with CSS variable fallbacks
|
|
100
|
+
|
|
101
|
+
- **Build config**:
|
|
102
|
+
- Removed unused `globals` from `vite.config.ts` (no UMD output)
|
|
103
|
+
|
|
104
|
+
### 📖 Documentation
|
|
105
|
+
|
|
106
|
+
- **README.md**: Fixed multiple inconsistencies with actual code:
|
|
107
|
+
- `themeMode` default: `'system'` → `'light'`
|
|
108
|
+
- `transitionType` default: `'fade'` → `'slide'`
|
|
109
|
+
- `tagsViewHeight` default: `40` → `44`
|
|
110
|
+
- `showFooter` default: `false` → `true`
|
|
111
|
+
- Removed non-existent store properties: `enableWatermark`, `watermarkText`, `enableGrayMode`, `enableColorWeakMode`
|
|
112
|
+
- Removed non-existent methods: `exportSettings()`, `importSettings()`
|
|
113
|
+
- Removed unimplemented feature: "持久化存储"
|
|
114
|
+
- Removed all `storageKey` parameter references
|
|
115
|
+
- Added `adjustColor` utility function documentation
|
|
116
|
+
- Fixed `ThemeMode` type: `'system'` → `'auto'`
|
|
117
|
+
|
|
118
|
+
### ✨ Enhanced
|
|
119
|
+
|
|
120
|
+
- Exported `adjustColor` utility function for external use
|
|
121
|
+
- Improved CSS variable support for theme customization
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## [2.0.1] - 2026-02-09
|
|
126
|
+
|
|
127
|
+
### ✨ Added
|
|
128
|
+
|
|
129
|
+
- Initial v2.0 release with decoupled architecture
|
|
130
|
+
- Complete settings management system
|
|
131
|
+
- SettingsDrawer UI component
|
|
132
|
+
- 6 layout mode presets
|
|
133
|
+
- Theme customization with CSS variables
|
|
134
|
+
- Full TypeScript support
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## [2.0.0] - 2026-02-09
|
|
139
|
+
|
|
140
|
+
### 🎉 Initial Release
|
|
141
|
+
|
|
142
|
+
- Layout and settings management system
|
|
143
|
+
- Integration with @robot-admin/theme
|
|
144
|
+
- Naive UI components support
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CHENY
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
> 布局和设置管理系统 - 为 Robot Admin 提供完整的布局配置管理能力(含 UI 组件)
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@robot-admin/layout)
|
|
6
|
+
[](https://github.com/ChenyCHENYU/robot-admin-packages/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
当前版本:`3.0.0`。
|
|
9
|
+
|
|
5
10
|
---
|
|
6
11
|
|
|
7
12
|
## ✨ 特性
|
|
@@ -13,6 +18,8 @@
|
|
|
13
18
|
- 🧭 **菜单展开方式** - 内置传统展开 / 右侧面板两种菜单展开模式配置
|
|
14
19
|
- 🔌 **插槽系统** - 灵活的 slot 机制,主项目仅关注业务组件
|
|
15
20
|
- 🎨 **CSS 变量同步** - 配置变更自动同步到 CSS 变量,样式实时响应
|
|
21
|
+
- ♿ **键盘与焦点可访问性** - 抽屉/菜单支持 Escape、方向键、焦点恢复与语义属性
|
|
22
|
+
- 🛡️ **安全设置导入** - 对枚举、布尔值、数值范围与主题色进行运行时校验
|
|
16
23
|
- 🚀 **TypeScript** - 完整类型支持
|
|
17
24
|
|
|
18
25
|
---
|
|
@@ -103,10 +110,13 @@ src/
|
|
|
103
110
|
## 📦 安装
|
|
104
111
|
|
|
105
112
|
```bash
|
|
106
|
-
bun add @robot-admin/layout
|
|
113
|
+
bun add @robot-admin/layout naive-ui
|
|
107
114
|
```
|
|
108
115
|
|
|
109
|
-
**Peer Dependencies**: `vue ^3.4` · `vue-router ^4.0` · `pinia ^2.0 || ^3.0` · `naive-ui ^2.38`
|
|
116
|
+
**Peer Dependencies**: `vue ^3.4` · `vue-router ^4.0` · `pinia ^2.0 || ^3.0` · `naive-ui ^2.38`
|
|
117
|
+
|
|
118
|
+
> 3.0 仍完整保留现有 Naive UI 组件、交互和样式。状态校验等无 UI 能力可从
|
|
119
|
+
> `@robot-admin/layout/core` 独立导入,为后续适配其他 UI 框架预留稳定边界;当前版本不包含 Element Plus 视图适配器。
|
|
110
120
|
|
|
111
121
|
---
|
|
112
122
|
|
|
@@ -119,18 +129,15 @@ bun add @robot-admin/layout @robot-admin/theme naive-ui
|
|
|
119
129
|
import { createApp } from "vue";
|
|
120
130
|
import { createPinia } from "pinia";
|
|
121
131
|
import { setupLayout } from "@robot-admin/layout";
|
|
122
|
-
import
|
|
123
|
-
import "@robot-admin/layout/style"; // 导入样式
|
|
132
|
+
import "@robot-admin/layout/style"; // 导入样式
|
|
124
133
|
import App from "./App.vue";
|
|
125
134
|
|
|
126
135
|
const app = createApp(App);
|
|
127
136
|
app.use(createPinia());
|
|
128
137
|
|
|
129
|
-
const themeStore = useThemeStore();
|
|
130
|
-
themeStore.init();
|
|
131
|
-
|
|
132
138
|
setupLayout(app, {
|
|
133
|
-
|
|
139
|
+
// 可选:同步到宿主自己的主题系统
|
|
140
|
+
onThemeModeChange: (mode) => syncAppTheme(mode),
|
|
134
141
|
defaults: {
|
|
135
142
|
layoutMode: "side",
|
|
136
143
|
primaryColor: "#409eff",
|
|
@@ -147,7 +154,9 @@ app.mount("#app");
|
|
|
147
154
|
<template>
|
|
148
155
|
<C_LayoutContainer>
|
|
149
156
|
<template #logo><AppLogo /></template>
|
|
150
|
-
<template #menu="{ collapsed }"
|
|
157
|
+
<template #menu="{ collapsed }"
|
|
158
|
+
><AppMenu :collapsed="collapsed"
|
|
159
|
+
/></template>
|
|
151
160
|
<template #header><AppHeader /></template>
|
|
152
161
|
<template #tags-view><AppTags /></template>
|
|
153
162
|
<template #footer><AppFooter /></template>
|
|
@@ -167,39 +176,51 @@ import { ref } from "vue";
|
|
|
167
176
|
import { SettingsDrawer } from "@robot-admin/layout";
|
|
168
177
|
|
|
169
178
|
const visible = ref(false);
|
|
179
|
+
const settingsActions = {
|
|
180
|
+
clearCache: () => localStorage.removeItem("my-app-disposable-cache"),
|
|
181
|
+
};
|
|
170
182
|
</script>
|
|
171
183
|
|
|
172
184
|
<template>
|
|
173
185
|
<button @click="visible = true">⚙️ 设置</button>
|
|
174
|
-
<SettingsDrawer v-model:show="visible"
|
|
186
|
+
<SettingsDrawer v-model:show="visible" :actions="settingsActions">
|
|
187
|
+
<template #appearance-prepend>
|
|
188
|
+
<AppThemeExtension />
|
|
189
|
+
</template>
|
|
190
|
+
</SettingsDrawer>
|
|
175
191
|
</template>
|
|
176
192
|
```
|
|
177
193
|
|
|
194
|
+
`SettingsDrawer` 不再自行清空 `localStorage` / `sessionStorage`。缓存清理由宿主通过
|
|
195
|
+
`actions.clearCache` 明确实现,避免误删登录态、语言和业务数据。可用扩展插槽:
|
|
196
|
+
`appearance-prepend/append`、`layout-prepend/after-mode/append`、
|
|
197
|
+
`features-prepend/append`;插槽均暴露当前 `settings`。
|
|
198
|
+
|
|
178
199
|
---
|
|
179
200
|
|
|
180
201
|
## 📐 布局模式
|
|
181
202
|
|
|
182
|
-
| 模式
|
|
183
|
-
|
|
184
|
-
| **左侧菜单** | `side`
|
|
185
|
-
| **顶部菜单** | `top`
|
|
186
|
-
| **混合布局** | `mix`
|
|
187
|
-
| **顶部混合** | `mix-top`
|
|
188
|
-
| **反转混合** | `reverse-horizontal-mix` | 顶部横向
|
|
189
|
-
| **卡片布局** | `card-layout`
|
|
203
|
+
| 模式 | 常量值 | 一级菜单 | 二级菜单 | 适用场景 |
|
|
204
|
+
| ------------ | ------------------------ | ---------- | -------------- | ------------------------ |
|
|
205
|
+
| **左侧菜单** | `side` | 左侧栏 | 左侧栏(折叠) | 经典后台管理(ERP、CRM) |
|
|
206
|
+
| **顶部菜单** | `top` | 顶部横向 | 顶部下拉 | 菜单少,需更宽内容区 |
|
|
207
|
+
| **混合布局** | `mix` | 左侧图标栏 | 悬浮弹出 | 一级菜单少,二级多 |
|
|
208
|
+
| **顶部混合** | `mix-top` | 左侧图标栏 | 顶部横向 | 全局导航 + 侧边详情 |
|
|
209
|
+
| **反转混合** | `reverse-horizontal-mix` | 顶部横向 | 右侧栏 | 特殊需求,右手操作 |
|
|
210
|
+
| **卡片布局** | `card-layout` | hover 抽屉 | 网格铺开 | 应用首页 / 工作台 |
|
|
190
211
|
|
|
191
212
|
---
|
|
192
213
|
|
|
193
214
|
## 🎨 主题预设
|
|
194
215
|
|
|
195
|
-
| 预设
|
|
196
|
-
|
|
197
|
-
| 科技蓝 | `#409eff` | 💙
|
|
198
|
-
| 清新绿 | `#52c41a` | 💚
|
|
199
|
-
| 商务灰 | `#595959` | 🖤
|
|
200
|
-
| 活力橙 | `#fa8c16` | 🧡
|
|
201
|
-
| 优雅紫 | `#722ed1` | 💜
|
|
202
|
-
| 经典红 | `#f5222d` | ❤️
|
|
216
|
+
| 预设 | 主题色 | 图标 |
|
|
217
|
+
| ------ | --------- | ---- |
|
|
218
|
+
| 科技蓝 | `#409eff` | 💙 |
|
|
219
|
+
| 清新绿 | `#52c41a` | 💚 |
|
|
220
|
+
| 商务灰 | `#595959` | 🖤 |
|
|
221
|
+
| 活力橙 | `#fa8c16` | 🧡 |
|
|
222
|
+
| 优雅紫 | `#722ed1` | 💜 |
|
|
223
|
+
| 经典红 | `#f5222d` | ❤️ |
|
|
203
224
|
|
|
204
225
|
---
|
|
205
226
|
|
|
@@ -213,10 +234,10 @@ import { useSettingsStore } from "@robot-admin/layout";
|
|
|
213
234
|
const settings = useSettingsStore();
|
|
214
235
|
|
|
215
236
|
// 读取
|
|
216
|
-
settings.layoutMode;
|
|
217
|
-
settings.menuExpandMode;
|
|
218
|
-
settings.primaryColor;
|
|
219
|
-
settings.themeMode;
|
|
237
|
+
settings.layoutMode; // 'side' | 'top' | 'mix' | ...
|
|
238
|
+
settings.menuExpandMode; // 'inline' | 'panel'
|
|
239
|
+
settings.primaryColor; // '#409eff'
|
|
240
|
+
settings.themeMode; // 'light' | 'dark' | 'system'
|
|
220
241
|
|
|
221
242
|
// 修改
|
|
222
243
|
settings.layoutMode = "mix";
|
|
@@ -228,21 +249,21 @@ settings.resetSettings();
|
|
|
228
249
|
|
|
229
250
|
### 设置属性一览
|
|
230
251
|
|
|
231
|
-
| 属性
|
|
232
|
-
|
|
233
|
-
| `themeMode`
|
|
234
|
-
| `primaryColor`
|
|
235
|
-
| `layoutMode`
|
|
236
|
-
| `menuExpandMode`
|
|
237
|
-
| `borderRadius`
|
|
238
|
-
| `transitionType`
|
|
239
|
-
| `fixedHeader`
|
|
240
|
-
| `showBreadcrumb`
|
|
241
|
-
| `showTagsView`
|
|
242
|
-
| `showFooter`
|
|
243
|
-
| `sidebarWidth`
|
|
244
|
-
| `sidebarCollapsedWidth` | `number`
|
|
245
|
-
| `headerHeight`
|
|
252
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
253
|
+
| ----------------------- | ------------------ | ----------- | --------------- |
|
|
254
|
+
| `themeMode` | `ThemeMode` | `'light'` | 主题模式 |
|
|
255
|
+
| `primaryColor` | `string` | `'#409eff'` | 主题色 |
|
|
256
|
+
| `layoutMode` | `LayoutMode` | `'side'` | 布局模式 |
|
|
257
|
+
| `menuExpandMode` | `MenuExpandMode` | `'inline'` | 菜单展开方式 |
|
|
258
|
+
| `borderRadius` | `BorderRadiusSize` | `'medium'` | 圆角大小 |
|
|
259
|
+
| `transitionType` | `TransitionType` | `'slide'` | 页面动画 |
|
|
260
|
+
| `fixedHeader` | `boolean` | `true` | 固定头部 |
|
|
261
|
+
| `showBreadcrumb` | `boolean` | `true` | 显示面包屑 |
|
|
262
|
+
| `showTagsView` | `boolean` | `true` | 显示标签页 |
|
|
263
|
+
| `showFooter` | `boolean` | `true` | 显示页脚 |
|
|
264
|
+
| `sidebarWidth` | `number` | `220` | 侧边栏宽度 (px) |
|
|
265
|
+
| `sidebarCollapsedWidth` | `number` | `64` | 折叠宽度 (px) |
|
|
266
|
+
| `headerHeight` | `number` | `56` | 头部高度 (px) |
|
|
246
267
|
|
|
247
268
|
### CSS 变量
|
|
248
269
|
|
|
@@ -263,33 +284,39 @@ settings.resetSettings();
|
|
|
263
284
|
|
|
264
285
|
## 🧩 C_LayoutContainer Slots
|
|
265
286
|
|
|
266
|
-
| Slot 名称
|
|
267
|
-
|
|
268
|
-
| `#logo`
|
|
269
|
-
| `#menu`
|
|
270
|
-
| `#header`
|
|
287
|
+
| Slot 名称 | 说明 | 适用布局 |
|
|
288
|
+
| --------------- | -------------- | ----------------------------- |
|
|
289
|
+
| `#logo` | 品牌 Logo | 全部 |
|
|
290
|
+
| `#menu` | 垂直菜单 | Side |
|
|
291
|
+
| `#header` | 完整头部 | Side / Mix |
|
|
271
292
|
| `#header-extra` | 头部右侧操作区 | Top / MixTop / Reverse / Card |
|
|
272
|
-
| `#top-menu`
|
|
273
|
-
| `#tags-view`
|
|
274
|
-
| `#footer`
|
|
275
|
-
| `#brand`
|
|
276
|
-
| `#menu-trigger` | 菜单触发区
|
|
277
|
-
| `#drawer-menu`
|
|
293
|
+
| `#top-menu` | 水平菜单 | Top / MixTop / Reverse |
|
|
294
|
+
| `#tags-view` | 标签页 | 全部 |
|
|
295
|
+
| `#footer` | 页脚 | 全部 |
|
|
296
|
+
| `#brand` | 顶部品牌区 | MixTop |
|
|
297
|
+
| `#menu-trigger` | 菜单触发区 | Card |
|
|
298
|
+
| `#drawer-menu` | 抽屉菜单 | Card |
|
|
278
299
|
|
|
279
300
|
---
|
|
280
301
|
|
|
281
302
|
## 📖 类型定义
|
|
282
303
|
|
|
283
304
|
```typescript
|
|
284
|
-
type LayoutMode =
|
|
305
|
+
type LayoutMode =
|
|
306
|
+
"side" | "top" | "mix" | "mix-top" | "reverse-horizontal-mix" | "card-layout";
|
|
285
307
|
type MenuExpandMode = "inline" | "panel";
|
|
286
308
|
type TransitionType = "fade" | "slide" | "zoom" | "none";
|
|
287
309
|
type BorderRadiusSize = "small" | "medium" | "large";
|
|
288
310
|
type TagsViewStyle = "default" | "card" | "smart";
|
|
289
|
-
type ThemeMode = "light" | "dark" | "
|
|
311
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
290
312
|
|
|
291
|
-
interface ThemePreset {
|
|
313
|
+
interface ThemePreset {
|
|
314
|
+
name: string;
|
|
315
|
+
icon: string;
|
|
316
|
+
primaryColor: string;
|
|
317
|
+
}
|
|
292
318
|
interface SettingsStoreOptions {
|
|
319
|
+
id?: string;
|
|
293
320
|
defaults?: Partial<SettingsState>;
|
|
294
321
|
onThemeModeChange?: (mode: ThemeMode) => void | Promise<void>;
|
|
295
322
|
}
|
|
@@ -305,6 +332,8 @@ interface SettingsStoreOptions {
|
|
|
305
332
|
import { createSettingsStore } from "@robot-admin/layout";
|
|
306
333
|
|
|
307
334
|
export const useSettingsStore = createSettingsStore({
|
|
335
|
+
// 多实例或微前端中必须保证唯一;单实例可省略
|
|
336
|
+
id: "workspace-settings",
|
|
308
337
|
defaults: { layoutMode: "mix", primaryColor: "#722ed1" },
|
|
309
338
|
onThemeModeChange: async (mode) => {
|
|
310
339
|
const themeStore = useThemeStore();
|
|
@@ -313,6 +342,42 @@ export const useSettingsStore = createSettingsStore({
|
|
|
313
342
|
});
|
|
314
343
|
```
|
|
315
344
|
|
|
345
|
+
### 校验外部设置
|
|
346
|
+
|
|
347
|
+
从文件、URL 或远端接口加载的设置属于不可信输入,写入 Store 前应先校验:
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
import { sanitizeLayoutSettingsConfig } from "@robot-admin/layout/core";
|
|
351
|
+
import { useSettingsStore } from "@robot-admin/layout";
|
|
352
|
+
|
|
353
|
+
const imported = JSON.parse(await file.text());
|
|
354
|
+
// 一次校验完整文件,失败时不会产生部分状态写入。
|
|
355
|
+
const config = sanitizeLayoutSettingsConfig(imported);
|
|
356
|
+
const safePatch = config.settings ?? {};
|
|
357
|
+
const settings = useSettingsStore();
|
|
358
|
+
|
|
359
|
+
if (safePatch.themeMode !== undefined) {
|
|
360
|
+
await settings.updateThemeMode(safePatch.themeMode);
|
|
361
|
+
delete safePatch.themeMode;
|
|
362
|
+
}
|
|
363
|
+
settings.$patch(safePatch);
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
未知字段会被忽略以便向前兼容;已知字段类型错误、越界值、非法主题色或旧的
|
|
367
|
+
`themeMode: "auto"` 会抛出明确错误。设置抽屉内置的导入功能已执行同一校验。
|
|
368
|
+
|
|
369
|
+
`useLayoutCache()` 默认不会输出开发日志,也不会向 `window` 暴露调试函数;仅在
|
|
370
|
+
受控的本地开发场景显式设置 `enableDevLog` / `exposeToWindow`。
|
|
371
|
+
|
|
372
|
+
### 3.0 升级说明
|
|
373
|
+
|
|
374
|
+
- 现有根入口、6 种布局、组件名、slot 名和 CSS 入口保持兼容。
|
|
375
|
+
- `LayoutContext.collapsed` 为可选的双向状态;提供后,侧栏与宿主头部共享同一折叠状态。
|
|
376
|
+
- 自定义 Store 可通过 `setupLayout()` 注入,也可用 `SettingsDrawer :store="store"` 显式传入。
|
|
377
|
+
- `enableTransition: false` 现在会真正关闭路由过渡,但保留已选择的动画类型。
|
|
378
|
+
- 缓存清理改为宿主白名单动作;从 2.x 升级时请传入 `actions.clearCache`。
|
|
379
|
+
- `@robot-admin/theme` 不再是 peer dependency;需要主题联动时使用 `onThemeModeChange`。
|
|
380
|
+
|
|
316
381
|
### 单独使用布局骨架
|
|
317
382
|
|
|
318
383
|
```typescript
|