@robot-admin/layout 2.3.2 → 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 +92 -61
- 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 +794 -109
- package/dist/index.js +1455 -1316
- package/dist/index.js.map +1 -1
- package/package.json +37 -14
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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@robot-admin/layout)
|
|
6
6
|
[](https://github.com/ChenyCHENYU/robot-admin-packages/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
-
当前版本:`
|
|
8
|
+
当前版本:`3.0.0`。
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -110,10 +110,13 @@ src/
|
|
|
110
110
|
## 📦 安装
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
bun add @robot-admin/layout
|
|
113
|
+
bun add @robot-admin/layout naive-ui
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
**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 视图适配器。
|
|
117
120
|
|
|
118
121
|
---
|
|
119
122
|
|
|
@@ -126,18 +129,15 @@ bun add @robot-admin/layout @robot-admin/theme naive-ui
|
|
|
126
129
|
import { createApp } from "vue";
|
|
127
130
|
import { createPinia } from "pinia";
|
|
128
131
|
import { setupLayout } from "@robot-admin/layout";
|
|
129
|
-
import
|
|
130
|
-
import "@robot-admin/layout/style"; // 导入样式
|
|
132
|
+
import "@robot-admin/layout/style"; // 导入样式
|
|
131
133
|
import App from "./App.vue";
|
|
132
134
|
|
|
133
135
|
const app = createApp(App);
|
|
134
136
|
app.use(createPinia());
|
|
135
137
|
|
|
136
|
-
const themeStore = useThemeStore();
|
|
137
|
-
themeStore.init();
|
|
138
|
-
|
|
139
138
|
setupLayout(app, {
|
|
140
|
-
|
|
139
|
+
// 可选:同步到宿主自己的主题系统
|
|
140
|
+
onThemeModeChange: (mode) => syncAppTheme(mode),
|
|
141
141
|
defaults: {
|
|
142
142
|
layoutMode: "side",
|
|
143
143
|
primaryColor: "#409eff",
|
|
@@ -154,7 +154,9 @@ app.mount("#app");
|
|
|
154
154
|
<template>
|
|
155
155
|
<C_LayoutContainer>
|
|
156
156
|
<template #logo><AppLogo /></template>
|
|
157
|
-
<template #menu="{ collapsed }"
|
|
157
|
+
<template #menu="{ collapsed }"
|
|
158
|
+
><AppMenu :collapsed="collapsed"
|
|
159
|
+
/></template>
|
|
158
160
|
<template #header><AppHeader /></template>
|
|
159
161
|
<template #tags-view><AppTags /></template>
|
|
160
162
|
<template #footer><AppFooter /></template>
|
|
@@ -174,39 +176,51 @@ import { ref } from "vue";
|
|
|
174
176
|
import { SettingsDrawer } from "@robot-admin/layout";
|
|
175
177
|
|
|
176
178
|
const visible = ref(false);
|
|
179
|
+
const settingsActions = {
|
|
180
|
+
clearCache: () => localStorage.removeItem("my-app-disposable-cache"),
|
|
181
|
+
};
|
|
177
182
|
</script>
|
|
178
183
|
|
|
179
184
|
<template>
|
|
180
185
|
<button @click="visible = true">⚙️ 设置</button>
|
|
181
|
-
<SettingsDrawer v-model:show="visible"
|
|
186
|
+
<SettingsDrawer v-model:show="visible" :actions="settingsActions">
|
|
187
|
+
<template #appearance-prepend>
|
|
188
|
+
<AppThemeExtension />
|
|
189
|
+
</template>
|
|
190
|
+
</SettingsDrawer>
|
|
182
191
|
</template>
|
|
183
192
|
```
|
|
184
193
|
|
|
194
|
+
`SettingsDrawer` 不再自行清空 `localStorage` / `sessionStorage`。缓存清理由宿主通过
|
|
195
|
+
`actions.clearCache` 明确实现,避免误删登录态、语言和业务数据。可用扩展插槽:
|
|
196
|
+
`appearance-prepend/append`、`layout-prepend/after-mode/append`、
|
|
197
|
+
`features-prepend/append`;插槽均暴露当前 `settings`。
|
|
198
|
+
|
|
185
199
|
---
|
|
186
200
|
|
|
187
201
|
## 📐 布局模式
|
|
188
202
|
|
|
189
|
-
| 模式
|
|
190
|
-
|
|
191
|
-
| **左侧菜单** | `side`
|
|
192
|
-
| **顶部菜单** | `top`
|
|
193
|
-
| **混合布局** | `mix`
|
|
194
|
-
| **顶部混合** | `mix-top`
|
|
195
|
-
| **反转混合** | `reverse-horizontal-mix` | 顶部横向
|
|
196
|
-
| **卡片布局** | `card-layout`
|
|
203
|
+
| 模式 | 常量值 | 一级菜单 | 二级菜单 | 适用场景 |
|
|
204
|
+
| ------------ | ------------------------ | ---------- | -------------- | ------------------------ |
|
|
205
|
+
| **左侧菜单** | `side` | 左侧栏 | 左侧栏(折叠) | 经典后台管理(ERP、CRM) |
|
|
206
|
+
| **顶部菜单** | `top` | 顶部横向 | 顶部下拉 | 菜单少,需更宽内容区 |
|
|
207
|
+
| **混合布局** | `mix` | 左侧图标栏 | 悬浮弹出 | 一级菜单少,二级多 |
|
|
208
|
+
| **顶部混合** | `mix-top` | 左侧图标栏 | 顶部横向 | 全局导航 + 侧边详情 |
|
|
209
|
+
| **反转混合** | `reverse-horizontal-mix` | 顶部横向 | 右侧栏 | 特殊需求,右手操作 |
|
|
210
|
+
| **卡片布局** | `card-layout` | hover 抽屉 | 网格铺开 | 应用首页 / 工作台 |
|
|
197
211
|
|
|
198
212
|
---
|
|
199
213
|
|
|
200
214
|
## 🎨 主题预设
|
|
201
215
|
|
|
202
|
-
| 预设
|
|
203
|
-
|
|
204
|
-
| 科技蓝 | `#409eff` | 💙
|
|
205
|
-
| 清新绿 | `#52c41a` | 💚
|
|
206
|
-
| 商务灰 | `#595959` | 🖤
|
|
207
|
-
| 活力橙 | `#fa8c16` | 🧡
|
|
208
|
-
| 优雅紫 | `#722ed1` | 💜
|
|
209
|
-
| 经典红 | `#f5222d` | ❤️
|
|
216
|
+
| 预设 | 主题色 | 图标 |
|
|
217
|
+
| ------ | --------- | ---- |
|
|
218
|
+
| 科技蓝 | `#409eff` | 💙 |
|
|
219
|
+
| 清新绿 | `#52c41a` | 💚 |
|
|
220
|
+
| 商务灰 | `#595959` | 🖤 |
|
|
221
|
+
| 活力橙 | `#fa8c16` | 🧡 |
|
|
222
|
+
| 优雅紫 | `#722ed1` | 💜 |
|
|
223
|
+
| 经典红 | `#f5222d` | ❤️ |
|
|
210
224
|
|
|
211
225
|
---
|
|
212
226
|
|
|
@@ -220,10 +234,10 @@ import { useSettingsStore } from "@robot-admin/layout";
|
|
|
220
234
|
const settings = useSettingsStore();
|
|
221
235
|
|
|
222
236
|
// 读取
|
|
223
|
-
settings.layoutMode;
|
|
224
|
-
settings.menuExpandMode;
|
|
225
|
-
settings.primaryColor;
|
|
226
|
-
settings.themeMode;
|
|
237
|
+
settings.layoutMode; // 'side' | 'top' | 'mix' | ...
|
|
238
|
+
settings.menuExpandMode; // 'inline' | 'panel'
|
|
239
|
+
settings.primaryColor; // '#409eff'
|
|
240
|
+
settings.themeMode; // 'light' | 'dark' | 'system'
|
|
227
241
|
|
|
228
242
|
// 修改
|
|
229
243
|
settings.layoutMode = "mix";
|
|
@@ -235,21 +249,21 @@ settings.resetSettings();
|
|
|
235
249
|
|
|
236
250
|
### 设置属性一览
|
|
237
251
|
|
|
238
|
-
| 属性
|
|
239
|
-
|
|
240
|
-
| `themeMode`
|
|
241
|
-
| `primaryColor`
|
|
242
|
-
| `layoutMode`
|
|
243
|
-
| `menuExpandMode`
|
|
244
|
-
| `borderRadius`
|
|
245
|
-
| `transitionType`
|
|
246
|
-
| `fixedHeader`
|
|
247
|
-
| `showBreadcrumb`
|
|
248
|
-
| `showTagsView`
|
|
249
|
-
| `showFooter`
|
|
250
|
-
| `sidebarWidth`
|
|
251
|
-
| `sidebarCollapsedWidth` | `number`
|
|
252
|
-
| `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) |
|
|
253
267
|
|
|
254
268
|
### CSS 变量
|
|
255
269
|
|
|
@@ -270,32 +284,37 @@ settings.resetSettings();
|
|
|
270
284
|
|
|
271
285
|
## 🧩 C_LayoutContainer Slots
|
|
272
286
|
|
|
273
|
-
| Slot 名称
|
|
274
|
-
|
|
275
|
-
| `#logo`
|
|
276
|
-
| `#menu`
|
|
277
|
-
| `#header`
|
|
287
|
+
| Slot 名称 | 说明 | 适用布局 |
|
|
288
|
+
| --------------- | -------------- | ----------------------------- |
|
|
289
|
+
| `#logo` | 品牌 Logo | 全部 |
|
|
290
|
+
| `#menu` | 垂直菜单 | Side |
|
|
291
|
+
| `#header` | 完整头部 | Side / Mix |
|
|
278
292
|
| `#header-extra` | 头部右侧操作区 | Top / MixTop / Reverse / Card |
|
|
279
|
-
| `#top-menu`
|
|
280
|
-
| `#tags-view`
|
|
281
|
-
| `#footer`
|
|
282
|
-
| `#brand`
|
|
283
|
-
| `#menu-trigger` | 菜单触发区
|
|
284
|
-
| `#drawer-menu`
|
|
293
|
+
| `#top-menu` | 水平菜单 | Top / MixTop / Reverse |
|
|
294
|
+
| `#tags-view` | 标签页 | 全部 |
|
|
295
|
+
| `#footer` | 页脚 | 全部 |
|
|
296
|
+
| `#brand` | 顶部品牌区 | MixTop |
|
|
297
|
+
| `#menu-trigger` | 菜单触发区 | Card |
|
|
298
|
+
| `#drawer-menu` | 抽屉菜单 | Card |
|
|
285
299
|
|
|
286
300
|
---
|
|
287
301
|
|
|
288
302
|
## 📖 类型定义
|
|
289
303
|
|
|
290
304
|
```typescript
|
|
291
|
-
type LayoutMode =
|
|
305
|
+
type LayoutMode =
|
|
306
|
+
"side" | "top" | "mix" | "mix-top" | "reverse-horizontal-mix" | "card-layout";
|
|
292
307
|
type MenuExpandMode = "inline" | "panel";
|
|
293
308
|
type TransitionType = "fade" | "slide" | "zoom" | "none";
|
|
294
309
|
type BorderRadiusSize = "small" | "medium" | "large";
|
|
295
310
|
type TagsViewStyle = "default" | "card" | "smart";
|
|
296
311
|
type ThemeMode = "light" | "dark" | "system";
|
|
297
312
|
|
|
298
|
-
interface ThemePreset {
|
|
313
|
+
interface ThemePreset {
|
|
314
|
+
name: string;
|
|
315
|
+
icon: string;
|
|
316
|
+
primaryColor: string;
|
|
317
|
+
}
|
|
299
318
|
interface SettingsStoreOptions {
|
|
300
319
|
id?: string;
|
|
301
320
|
defaults?: Partial<SettingsState>;
|
|
@@ -328,10 +347,13 @@ export const useSettingsStore = createSettingsStore({
|
|
|
328
347
|
从文件、URL 或远端接口加载的设置属于不可信输入,写入 Store 前应先校验:
|
|
329
348
|
|
|
330
349
|
```typescript
|
|
331
|
-
import {
|
|
350
|
+
import { sanitizeLayoutSettingsConfig } from "@robot-admin/layout/core";
|
|
351
|
+
import { useSettingsStore } from "@robot-admin/layout";
|
|
332
352
|
|
|
333
353
|
const imported = JSON.parse(await file.text());
|
|
334
|
-
|
|
354
|
+
// 一次校验完整文件,失败时不会产生部分状态写入。
|
|
355
|
+
const config = sanitizeLayoutSettingsConfig(imported);
|
|
356
|
+
const safePatch = config.settings ?? {};
|
|
335
357
|
const settings = useSettingsStore();
|
|
336
358
|
|
|
337
359
|
if (safePatch.themeMode !== undefined) {
|
|
@@ -347,6 +369,15 @@ settings.$patch(safePatch);
|
|
|
347
369
|
`useLayoutCache()` 默认不会输出开发日志,也不会向 `window` 暴露调试函数;仅在
|
|
348
370
|
受控的本地开发场景显式设置 `enableDevLog` / `exposeToWindow`。
|
|
349
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
|
+
|
|
350
381
|
### 单独使用布局骨架
|
|
351
382
|
|
|
352
383
|
```typescript
|