jianghu-ui 1.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.
- package/README.md +376 -0
- package/dist/jianghu-ui.css +2318 -0
- package/dist/jianghu-ui.js +2 -0
- package/dist/jianghu-ui.js.LICENSE.txt +1 -0
- package/package.json +56 -0
- package/src/Design.stories.mdx +195 -0
- package/src/Introduction.stories.mdx +148 -0
- package/src/components/JhAddressSelect/JhAddressSelect.md +250 -0
- package/src/components/JhAddressSelect/JhAddressSelect.stories.js +282 -0
- package/src/components/JhAddressSelect/JhAddressSelect.vue +261 -0
- package/src/components/JhCard/JhCard.md +246 -0
- package/src/components/JhCard/JhCard.stories.js +688 -0
- package/src/components/JhCard/JhCard.vue +604 -0
- package/src/components/JhCheckCard/JhCheckCard.md +245 -0
- package/src/components/JhCheckCard/JhCheckCard.stories.js +750 -0
- package/src/components/JhCheckCard/JhCheckCard.vue +476 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.md +70 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.stories.js +550 -0
- package/src/components/JhConfirmDialog/JhConfirmDialog.vue +181 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.md +56 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.stories.js +320 -0
- package/src/components/JhDateRangePicker/JhDateRangePicker.vue +307 -0
- package/src/components/JhDescriptions/JhDescriptions.md +724 -0
- package/src/components/JhDescriptions/JhDescriptions.stories.js +858 -0
- package/src/components/JhDescriptions/JhDescriptions.vue +933 -0
- package/src/components/JhDraggable/JhDraggable.md +66 -0
- package/src/components/JhDraggable/JhDraggable.stories.js +161 -0
- package/src/components/JhDraggable/JhDraggable.vue +254 -0
- package/src/components/JhDrawer/JhDrawer.md +68 -0
- package/src/components/JhDrawer/JhDrawer.stories.js +478 -0
- package/src/components/JhDrawer/JhDrawer.vue +281 -0
- package/src/components/JhDrawerForm/JhDrawerForm.md +69 -0
- package/src/components/JhDrawerForm/JhDrawerForm.stories.js +492 -0
- package/src/components/JhDrawerForm/JhDrawerForm.vue +297 -0
- package/src/components/JhEditableTable/JhEditableTable.md +507 -0
- package/src/components/JhEditableTable/JhEditableTable.stories.js +615 -0
- package/src/components/JhEditableTable/JhEditableTable.vue +685 -0
- package/src/components/JhFileInput/JhFileInput.md +56 -0
- package/src/components/JhFileInput/JhFileInput.stories.js +103 -0
- package/src/components/JhFileInput/JhFileInput.vue +253 -0
- package/src/components/JhForm/JhForm.md +676 -0
- package/src/components/JhForm/JhForm.stories.js +1375 -0
- package/src/components/JhForm/JhForm.vue +657 -0
- package/src/components/JhFormField/JhFormField.stories.js +217 -0
- package/src/components/JhFormField/JhFormField.vue +439 -0
- package/src/components/JhFormFields/JhFormFields.md +647 -0
- package/src/components/JhFormFields/JhFormFields.stories.js +922 -0
- package/src/components/JhFormFields/JhFormFields.vue +998 -0
- package/src/components/JhFormList/JhFormList.md +303 -0
- package/src/components/JhFormList/JhFormList.stories.js +661 -0
- package/src/components/JhFormList/JhFormList.vue +1127 -0
- package/src/components/JhJsonEditor/JhJsonEditor.md +54 -0
- package/src/components/JhJsonEditor/JhJsonEditor.stories.js +157 -0
- package/src/components/JhJsonEditor/JhJsonEditor.vue +178 -0
- package/src/components/JhLayout/JhLayout.md +580 -0
- package/src/components/JhLayout/JhLayout.stories.js +414 -0
- package/src/components/JhLayout/JhLayout.vue +387 -0
- package/src/components/JhList/JhList.md +441 -0
- package/src/components/JhList/JhList.stories.js +524 -0
- package/src/components/JhList/JhList.vue +571 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.md +56 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.stories.js +191 -0
- package/src/components/JhMarkdownEditor/JhMarkdownEditor.vue +188 -0
- package/src/components/JhMask/JhMask.md +62 -0
- package/src/components/JhMask/JhMask.stories.js +270 -0
- package/src/components/JhMask/JhMask.vue +123 -0
- package/src/components/JhMenu/JhMenu.md +85 -0
- package/src/components/JhMenu/JhMenu.stories.js +384 -0
- package/src/components/JhMenu/JhMenu.vue +545 -0
- package/src/components/JhModal/JhModal.md +68 -0
- package/src/components/JhModal/JhModal.stories.js +562 -0
- package/src/components/JhModal/JhModal.vue +235 -0
- package/src/components/JhModalForm/JhModalForm.md +69 -0
- package/src/components/JhModalForm/JhModalForm.stories.js +592 -0
- package/src/components/JhModalForm/JhModalForm.vue +298 -0
- package/src/components/JhPageContainer/JhPageContainer.md +409 -0
- package/src/components/JhPageContainer/JhPageContainer.stories.js +209 -0
- package/src/components/JhPageContainer/JhPageContainer.vue +72 -0
- package/src/components/JhQueryFilter/JhQueryFilter.md +77 -0
- package/src/components/JhQueryFilter/JhQueryFilter.stories.js +684 -0
- package/src/components/JhQueryFilter/JhQueryFilter.vue +429 -0
- package/src/components/JhScene/JhScene.md +64 -0
- package/src/components/JhScene/JhScene.stories.js +317 -0
- package/src/components/JhScene/JhScene.vue +376 -0
- package/src/components/JhStatisticCard/JhStatisticCard.md +363 -0
- package/src/components/JhStatisticCard/JhStatisticCard.stories.js +847 -0
- package/src/components/JhStatisticCard/JhStatisticCard.vue +459 -0
- package/src/components/JhStepsForm/JhStepsForm.md +666 -0
- package/src/components/JhStepsForm/JhStepsForm.stories.js +1224 -0
- package/src/components/JhStepsForm/JhStepsForm.vue +749 -0
- package/src/components/JhTable/JhTable.md +730 -0
- package/src/components/JhTable/JhTable.stories.js +1444 -0
- package/src/components/JhTable/JhTable.vue +2298 -0
- package/src/components/JhTableAttachment/JhTableAttachment.md +70 -0
- package/src/components/JhTableAttachment/JhTableAttachment.stories.js +198 -0
- package/src/components/JhTableAttachment/JhTableAttachment.vue +264 -0
- package/src/components/JhToast/JhToast.md +67 -0
- package/src/components/JhToast/JhToast.stories.js +386 -0
- package/src/components/JhToast/JhToast.vue +239 -0
- package/src/components/JhTreeSelect/JhTreeSelect.md +82 -0
- package/src/components/JhTreeSelect/JhTreeSelect.stories.js +391 -0
- package/src/components/JhTreeSelect/JhTreeSelect.vue +727 -0
- package/src/components/JhWaterMark/JhWaterMark.md +190 -0
- package/src/components/JhWaterMark/JhWaterMark.stories.js +675 -0
- package/src/components/JhWaterMark/JhWaterMark.vue +351 -0
- package/src/components/README.md +52 -0
- package/src/index.js +135 -0
- package/src/style/globalCSSJHV4.css +348 -0
- package/src/style/globalCSSVuetifyV4.css +637 -0
- package/src/style/storybook.css +4 -0
- package/src/tailwind.css +3 -0
- package/src/utils/vuetify.js +31 -0
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
# JhLayout - 页面布局组件
|
|
2
|
+
|
|
3
|
+
基于 Ant Design Pro 的 ProLayout 设计的企业级页面布局组件,提供完整的中后台布局解决方案。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
### 🎨 多种布局模式
|
|
8
|
+
|
|
9
|
+
- **侧边布局 (side)**: 经典的侧边栏导航布局,适合菜单项较多的场景
|
|
10
|
+
- **顶部布局 (top)**: 顶部导航栏布局,适合菜单项较少的场景
|
|
11
|
+
- **混合布局 (mix)**: 顶部 + 侧边栏混合布局,适合复杂的导航结构
|
|
12
|
+
|
|
13
|
+
### 🎯 核心功能
|
|
14
|
+
|
|
15
|
+
- ✅ **响应式设计**: 自动适配移动端和桌面端
|
|
16
|
+
- ✅ **可折叠侧边栏**: 支持侧边栏折叠/展开,节省空间
|
|
17
|
+
- ✅ **自动面包屑**: 根据路由自动生成面包屑导航
|
|
18
|
+
- ✅ **多级菜单**: 支持三级菜单嵌套
|
|
19
|
+
- ✅ **主题切换**: 支持亮色/暗色主题
|
|
20
|
+
- ✅ **页面头部**: 可选的页面标题和描述区域
|
|
21
|
+
- ✅ **底部区域**: 可自定义的页脚内容
|
|
22
|
+
- ✅ **用户菜单**: 内置用户头像和下拉菜单
|
|
23
|
+
- ✅ **设置面板**: 实时调整布局配置
|
|
24
|
+
|
|
25
|
+
## 基础用法
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<template>
|
|
29
|
+
<jh-layout
|
|
30
|
+
title="我的应用"
|
|
31
|
+
logo="mdi-view-dashboard"
|
|
32
|
+
:menu-data="menuData"
|
|
33
|
+
:current-path="currentPath"
|
|
34
|
+
@menu-click="handleMenuClick"
|
|
35
|
+
>
|
|
36
|
+
<!-- 主内容区域 -->
|
|
37
|
+
<v-container>
|
|
38
|
+
<h1>欢迎使用 JhLayout</h1>
|
|
39
|
+
</v-container>
|
|
40
|
+
</jh-layout>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
export default {
|
|
45
|
+
data() {
|
|
46
|
+
return {
|
|
47
|
+
currentPath: '/dashboard',
|
|
48
|
+
menuData: [
|
|
49
|
+
{
|
|
50
|
+
name: '工作台',
|
|
51
|
+
path: '/dashboard',
|
|
52
|
+
icon: 'mdi-view-dashboard'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: '用户管理',
|
|
56
|
+
icon: 'mdi-account-group',
|
|
57
|
+
children: [
|
|
58
|
+
{
|
|
59
|
+
name: '用户列表',
|
|
60
|
+
path: '/users/list',
|
|
61
|
+
icon: 'mdi-account-multiple'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
handleMenuClick(item) {
|
|
70
|
+
this.currentPath = item.path;
|
|
71
|
+
// 路由跳转逻辑
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
</script>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Props
|
|
79
|
+
|
|
80
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
81
|
+
|------|------|------|--------|
|
|
82
|
+
| title | 应用标题 | String | 'JianghuJS' |
|
|
83
|
+
| logo | Logo 图标名称(Material Design Icons) | String | '' |
|
|
84
|
+
| menuData | 菜单数据 | Array | [] |
|
|
85
|
+
| currentPath | 当前路由路径 | String | '' |
|
|
86
|
+
| layout | 布局模式:side/top/mix | String | 'side' |
|
|
87
|
+
| sidebarWidth | 侧边栏宽度 | Number | 256 |
|
|
88
|
+
| headerHeight | 头部高度 | Number | 64 |
|
|
89
|
+
| headerTheme | 头部主题:light/dark | String | 'light' |
|
|
90
|
+
| sidebarTheme | 侧边栏主题:light/dark | String | 'dark' |
|
|
91
|
+
| footerTheme | 底部主题:light/dark | String | 'light' |
|
|
92
|
+
| showBreadcrumb | 是否显示面包屑 | Boolean | true |
|
|
93
|
+
| breadcrumbs | 自定义面包屑数据 | Array | [] |
|
|
94
|
+
| showPageHeader | 是否显示页面头部 | Boolean | false |
|
|
95
|
+
| pageTitle | 页面标题 | String | '' |
|
|
96
|
+
| pageDescription | 页面描述 | String | '' |
|
|
97
|
+
| showFooter | 是否显示底部 | Boolean | false |
|
|
98
|
+
| footerText | 底部文字 | String | '' |
|
|
99
|
+
| contentBackground | 内容区域背景色 | String | '#f5f5f5' |
|
|
100
|
+
| contentPadding | 内容区域是否有内边距 | Boolean | true |
|
|
101
|
+
| showAvatar | 是否显示用户头像 | Boolean | true |
|
|
102
|
+
| userInfo | 用户信息对象 | Object | { username: 'Guest', email: '' } |
|
|
103
|
+
| avatarMenuList | 用户菜单列表 | Array | [] |
|
|
104
|
+
| showLogout | 是否显示退出登录 | Boolean | true |
|
|
105
|
+
| showSettings | 是否显示设置按钮 | Boolean | false |
|
|
106
|
+
| defaultCollapsed | 初始折叠状态 | Boolean | false |
|
|
107
|
+
|
|
108
|
+
## 菜单数据结构
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
const menuData = [
|
|
112
|
+
{
|
|
113
|
+
name: '菜单名称',
|
|
114
|
+
path: '/path', // 菜单路径
|
|
115
|
+
icon: 'mdi-icon-name', // 图标(可选)
|
|
116
|
+
children: [ // 子菜单(可选)
|
|
117
|
+
{
|
|
118
|
+
name: '子菜单',
|
|
119
|
+
path: '/path/child',
|
|
120
|
+
icon: 'mdi-icon-name',
|
|
121
|
+
children: [ // 三级菜单(可选)
|
|
122
|
+
{
|
|
123
|
+
name: '三级菜单',
|
|
124
|
+
path: '/path/child/grandchild'
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 插槽
|
|
134
|
+
|
|
135
|
+
### logo
|
|
136
|
+
自定义 Logo 区域
|
|
137
|
+
|
|
138
|
+
```vue
|
|
139
|
+
<jh-layout>
|
|
140
|
+
<template v-slot:logo>
|
|
141
|
+
<div class="d-flex align-center">
|
|
142
|
+
<v-avatar color="primary" size="32" class="mr-2">
|
|
143
|
+
<span class="white--text">JH</span>
|
|
144
|
+
</v-avatar>
|
|
145
|
+
<span class="text-h6">JianghuJS</span>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
</jh-layout>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### headerRight
|
|
152
|
+
自定义头部右侧内容
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<jh-layout>
|
|
156
|
+
<template v-slot:headerRight>
|
|
157
|
+
<v-btn icon>
|
|
158
|
+
<v-badge content="5" color="error">
|
|
159
|
+
<v-icon>mdi-bell</v-icon>
|
|
160
|
+
</v-badge>
|
|
161
|
+
</v-btn>
|
|
162
|
+
</template>
|
|
163
|
+
</jh-layout>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### pageHeader
|
|
167
|
+
自定义页面头部
|
|
168
|
+
|
|
169
|
+
```vue
|
|
170
|
+
<jh-layout show-page-header>
|
|
171
|
+
<template v-slot:pageHeader>
|
|
172
|
+
<div>
|
|
173
|
+
<h2>自定义页面头部</h2>
|
|
174
|
+
<p>这里可以放置统计数据、图表等内容</p>
|
|
175
|
+
</div>
|
|
176
|
+
</template>
|
|
177
|
+
</jh-layout>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### pageHeaderExtra
|
|
181
|
+
页面头部额外操作区
|
|
182
|
+
|
|
183
|
+
```vue
|
|
184
|
+
<jh-layout show-page-header>
|
|
185
|
+
<template v-slot:pageHeaderExtra>
|
|
186
|
+
<v-btn color="primary">新增</v-btn>
|
|
187
|
+
</template>
|
|
188
|
+
</jh-layout>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### default
|
|
192
|
+
主内容区域(默认插槽)
|
|
193
|
+
|
|
194
|
+
```vue
|
|
195
|
+
<jh-layout>
|
|
196
|
+
<v-container>
|
|
197
|
+
<!-- 您的页面内容 -->
|
|
198
|
+
</v-container>
|
|
199
|
+
</jh-layout>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### footer
|
|
203
|
+
自定义底部内容
|
|
204
|
+
|
|
205
|
+
```vue
|
|
206
|
+
<jh-layout show-footer>
|
|
207
|
+
<template v-slot:footer>
|
|
208
|
+
<div class="text-center">
|
|
209
|
+
© 2024 My Company
|
|
210
|
+
</div>
|
|
211
|
+
</template>
|
|
212
|
+
</jh-layout>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### sidebarFooter
|
|
216
|
+
侧边栏底部内容
|
|
217
|
+
|
|
218
|
+
```vue
|
|
219
|
+
<jh-layout>
|
|
220
|
+
<template v-slot:sidebarFooter>
|
|
221
|
+
<v-btn block small>帮助文档</v-btn>
|
|
222
|
+
</template>
|
|
223
|
+
</jh-layout>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 事件
|
|
227
|
+
|
|
228
|
+
| 事件名 | 说明 | 回调参数 |
|
|
229
|
+
|--------|------|----------|
|
|
230
|
+
| menu-click | 菜单点击事件 | (item: MenuItem) |
|
|
231
|
+
| breadcrumb-click | 面包屑点击事件 | (item: BreadcrumbItem) |
|
|
232
|
+
| avatar-menu-click | 用户菜单点击事件 | (item: MenuItem) |
|
|
233
|
+
| logout | 退出登录事件 | - |
|
|
234
|
+
| sidebar-toggle | 侧边栏切换事件 | { collapsed: Boolean, visible: Boolean } |
|
|
235
|
+
| update:layout | 布局模式更新 | (layout: String) |
|
|
236
|
+
| update:headerTheme | 头部主题更新 | (theme: String) |
|
|
237
|
+
| update:sidebarTheme | 侧边栏主题更新 | (theme: String) |
|
|
238
|
+
| update:showBreadcrumb | 面包屑显示更新 | (show: Boolean) |
|
|
239
|
+
| update:showFooter | 底部显示更新 | (show: Boolean) |
|
|
240
|
+
| update:contentPadding | 内容内边距更新 | (padding: Boolean) |
|
|
241
|
+
|
|
242
|
+
## 使用示例
|
|
243
|
+
|
|
244
|
+
### 侧边布局
|
|
245
|
+
|
|
246
|
+
```vue
|
|
247
|
+
<template>
|
|
248
|
+
<jh-layout
|
|
249
|
+
title="管理系统"
|
|
250
|
+
logo="mdi-view-dashboard"
|
|
251
|
+
layout="side"
|
|
252
|
+
:menu-data="menuData"
|
|
253
|
+
:current-path="currentPath"
|
|
254
|
+
sidebar-theme="dark"
|
|
255
|
+
header-theme="light"
|
|
256
|
+
show-breadcrumb
|
|
257
|
+
show-page-header
|
|
258
|
+
:page-title="pageTitle"
|
|
259
|
+
@menu-click="handleMenuClick"
|
|
260
|
+
>
|
|
261
|
+
<v-container>
|
|
262
|
+
<!-- 页面内容 -->
|
|
263
|
+
</v-container>
|
|
264
|
+
</jh-layout>
|
|
265
|
+
</template>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### 顶部布局
|
|
269
|
+
|
|
270
|
+
```vue
|
|
271
|
+
<template>
|
|
272
|
+
<jh-layout
|
|
273
|
+
title="管理系统"
|
|
274
|
+
layout="top"
|
|
275
|
+
:menu-data="menuData"
|
|
276
|
+
header-theme="dark"
|
|
277
|
+
>
|
|
278
|
+
<v-container>
|
|
279
|
+
<!-- 页面内容 -->
|
|
280
|
+
</v-container>
|
|
281
|
+
</jh-layout>
|
|
282
|
+
</template>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 混合布局
|
|
286
|
+
|
|
287
|
+
```vue
|
|
288
|
+
<template>
|
|
289
|
+
<jh-layout
|
|
290
|
+
title="管理系统"
|
|
291
|
+
layout="mix"
|
|
292
|
+
:menu-data="menuData"
|
|
293
|
+
sidebar-theme="light"
|
|
294
|
+
>
|
|
295
|
+
<v-container>
|
|
296
|
+
<!-- 页面内容 -->
|
|
297
|
+
</v-container>
|
|
298
|
+
</jh-layout>
|
|
299
|
+
</template>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 完整示例(带表格)
|
|
303
|
+
|
|
304
|
+
```vue
|
|
305
|
+
<template>
|
|
306
|
+
<jh-layout
|
|
307
|
+
title="用户管理系统"
|
|
308
|
+
logo="mdi-account-group"
|
|
309
|
+
:menu-data="menuData"
|
|
310
|
+
:current-path="currentPath"
|
|
311
|
+
show-breadcrumb
|
|
312
|
+
show-page-header
|
|
313
|
+
page-title="用户列表"
|
|
314
|
+
page-description="管理系统中的所有用户"
|
|
315
|
+
show-footer
|
|
316
|
+
footer-text="Copyright © 2024 My Company"
|
|
317
|
+
:user-info="userInfo"
|
|
318
|
+
:avatar-menu-list="avatarMenuList"
|
|
319
|
+
show-settings
|
|
320
|
+
@menu-click="handleMenuClick"
|
|
321
|
+
@logout="handleLogout"
|
|
322
|
+
>
|
|
323
|
+
<template v-slot:pageHeaderExtra>
|
|
324
|
+
<v-btn color="primary" @click="handleAdd">
|
|
325
|
+
<v-icon left>mdi-plus</v-icon>
|
|
326
|
+
新增用户
|
|
327
|
+
</v-btn>
|
|
328
|
+
</template>
|
|
329
|
+
|
|
330
|
+
<v-card>
|
|
331
|
+
<v-data-table
|
|
332
|
+
:headers="headers"
|
|
333
|
+
:items="users"
|
|
334
|
+
:loading="loading"
|
|
335
|
+
>
|
|
336
|
+
<!-- 表格内容 -->
|
|
337
|
+
</v-data-table>
|
|
338
|
+
</v-card>
|
|
339
|
+
</jh-layout>
|
|
340
|
+
</template>
|
|
341
|
+
|
|
342
|
+
<script>
|
|
343
|
+
export default {
|
|
344
|
+
data() {
|
|
345
|
+
return {
|
|
346
|
+
currentPath: '/users/list',
|
|
347
|
+
menuData: [
|
|
348
|
+
{
|
|
349
|
+
name: '工作台',
|
|
350
|
+
path: '/dashboard',
|
|
351
|
+
icon: 'mdi-view-dashboard'
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: '用户管理',
|
|
355
|
+
icon: 'mdi-account-group',
|
|
356
|
+
children: [
|
|
357
|
+
{
|
|
358
|
+
name: '用户列表',
|
|
359
|
+
path: '/users/list',
|
|
360
|
+
icon: 'mdi-account-multiple'
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: '角色管理',
|
|
364
|
+
path: '/users/roles',
|
|
365
|
+
icon: 'mdi-shield-account'
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
userInfo: {
|
|
371
|
+
username: '管理员',
|
|
372
|
+
email: 'admin@example.com'
|
|
373
|
+
},
|
|
374
|
+
avatarMenuList: [
|
|
375
|
+
{
|
|
376
|
+
name: '个人中心',
|
|
377
|
+
icon: 'mdi-account-circle',
|
|
378
|
+
path: '/profile'
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: '账户设置',
|
|
382
|
+
icon: 'mdi-cog',
|
|
383
|
+
path: '/settings'
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
headers: [
|
|
387
|
+
{ text: 'ID', value: 'id' },
|
|
388
|
+
{ text: '用户名', value: 'username' },
|
|
389
|
+
{ text: '邮箱', value: 'email' }
|
|
390
|
+
],
|
|
391
|
+
users: [],
|
|
392
|
+
loading: false
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
methods: {
|
|
396
|
+
handleMenuClick(item) {
|
|
397
|
+
if (item.path) {
|
|
398
|
+
this.currentPath = item.path;
|
|
399
|
+
// 路由跳转
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
handleLogout() {
|
|
403
|
+
// 退出登录逻辑
|
|
404
|
+
},
|
|
405
|
+
handleAdd() {
|
|
406
|
+
// 新增用户逻辑
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
</script>
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## 响应式设计
|
|
414
|
+
|
|
415
|
+
JhLayout 组件会自动适配不同屏幕尺寸:
|
|
416
|
+
|
|
417
|
+
- **桌面端(>= 960px)**: 显示完整的侧边栏和菜单
|
|
418
|
+
- **移动端(< 960px)**: 侧边栏自动转换为抽屉式,通过按钮控制显示/隐藏
|
|
419
|
+
|
|
420
|
+
## 主题定制
|
|
421
|
+
|
|
422
|
+
### 使用内置主题
|
|
423
|
+
|
|
424
|
+
```vue
|
|
425
|
+
<jh-layout
|
|
426
|
+
header-theme="dark"
|
|
427
|
+
sidebar-theme="dark"
|
|
428
|
+
footer-theme="dark"
|
|
429
|
+
>
|
|
430
|
+
</jh-layout>
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### 自定义背景色
|
|
434
|
+
|
|
435
|
+
```vue
|
|
436
|
+
<jh-layout
|
|
437
|
+
content-background="#ffffff"
|
|
438
|
+
>
|
|
439
|
+
</jh-layout>
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
## 最佳实践
|
|
443
|
+
|
|
444
|
+
1. **菜单数据管理**: 建议将菜单数据统一管理,可以从后端获取或在配置文件中定义
|
|
445
|
+
2. **路由同步**: 使用 `currentPath` 属性与路由保持同步
|
|
446
|
+
3. **权限控制**: 在菜单数据中添加权限字段,根据用户权限动态过滤菜单
|
|
447
|
+
4. **面包屑**: 如果路由结构复杂,建议自定义 `breadcrumbs` 数据
|
|
448
|
+
5. **移动端优化**: 在移动端建议隐藏页面头部和底部,保持界面简洁
|
|
449
|
+
|
|
450
|
+
## 与其他组件配合
|
|
451
|
+
|
|
452
|
+
JhLayout 可以与其他 JianghuJS 组件完美配合:
|
|
453
|
+
|
|
454
|
+
- **JhPageContainer**: 推荐在 JhLayout 的内容区域使用 JhPageContainer 作为页面容器,提供统一的页面头部和内容布局
|
|
455
|
+
- **JhTable**: 在内容区域展示数据表格
|
|
456
|
+
- **JhForm**: 在内容区域展示表单
|
|
457
|
+
- **JhQueryFilter**: 在页面头部额外操作区添加搜索过滤
|
|
458
|
+
- **JhDrawer**: 作为侧边抽屉使用
|
|
459
|
+
- **JhModal**: 作为弹窗使用
|
|
460
|
+
|
|
461
|
+
### 推荐的组件组合
|
|
462
|
+
|
|
463
|
+
**JhLayout + JhPageContainer + JhTable**
|
|
464
|
+
|
|
465
|
+
这是最常用的页面结构组合,适用于大多数列表页面:
|
|
466
|
+
|
|
467
|
+
```vue
|
|
468
|
+
<template>
|
|
469
|
+
<jh-layout
|
|
470
|
+
title="管理系统"
|
|
471
|
+
:menu-data="menuData"
|
|
472
|
+
:current-path="currentPath"
|
|
473
|
+
show-breadcrumb
|
|
474
|
+
:content-padding="false"
|
|
475
|
+
>
|
|
476
|
+
<jh-page-container
|
|
477
|
+
page-name="用户管理"
|
|
478
|
+
:show-help-button="true"
|
|
479
|
+
>
|
|
480
|
+
<template v-slot:search-bar>
|
|
481
|
+
<jh-query-filter
|
|
482
|
+
:keyword.sync="keyword"
|
|
483
|
+
:keywordFieldList.sync="keywordFieldList"
|
|
484
|
+
:headers="headers"
|
|
485
|
+
@search="handleSearch"
|
|
486
|
+
/>
|
|
487
|
+
</template>
|
|
488
|
+
|
|
489
|
+
<template v-slot:content>
|
|
490
|
+
<jh-table
|
|
491
|
+
:headers="headers"
|
|
492
|
+
:items="items"
|
|
493
|
+
:loading="loading"
|
|
494
|
+
/>
|
|
495
|
+
</template>
|
|
496
|
+
</jh-page-container>
|
|
497
|
+
</jh-layout>
|
|
498
|
+
</template>
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**说明**:
|
|
502
|
+
- `JhLayout` 提供应用级布局(导航、头部、侧边栏)
|
|
503
|
+
- `JhPageContainer` 提供页面级容器(页面标题、搜索栏)
|
|
504
|
+
- `JhTable` 提供数据表格展示
|
|
505
|
+
- 当使用 `JhPageContainer` 时,建议设置 `JhLayout` 的 `content-padding="false"` 和 `show-page-header="false"`,避免重复的内边距和头部
|
|
506
|
+
|
|
507
|
+
## 常见问题
|
|
508
|
+
|
|
509
|
+
### 如何自定义面包屑?
|
|
510
|
+
|
|
511
|
+
通过 `breadcrumbs` 属性传入自定义面包屑数据:
|
|
512
|
+
|
|
513
|
+
```vue
|
|
514
|
+
<jh-layout
|
|
515
|
+
:breadcrumbs="[
|
|
516
|
+
{ text: '首页', path: '/', icon: 'mdi-home' },
|
|
517
|
+
{ text: '用户管理', path: '/users' },
|
|
518
|
+
{ text: '用户列表', disabled: true }
|
|
519
|
+
]"
|
|
520
|
+
>
|
|
521
|
+
</jh-layout>
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 如何隐藏某些功能?
|
|
525
|
+
|
|
526
|
+
通过对应的 `show*` 属性控制:
|
|
527
|
+
|
|
528
|
+
```vue
|
|
529
|
+
<jh-layout
|
|
530
|
+
:show-breadcrumb="false"
|
|
531
|
+
:show-page-header="false"
|
|
532
|
+
:show-footer="false"
|
|
533
|
+
:show-avatar="false"
|
|
534
|
+
:show-settings="false"
|
|
535
|
+
>
|
|
536
|
+
</jh-layout>
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### 如何实现路由跳转?
|
|
540
|
+
|
|
541
|
+
在 `menu-click` 事件中处理路由跳转:
|
|
542
|
+
|
|
543
|
+
```javascript
|
|
544
|
+
handleMenuClick(item) {
|
|
545
|
+
if (item.path) {
|
|
546
|
+
this.$router.push(item.path);
|
|
547
|
+
this.currentPath = item.path;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### 如何保存用户的布局设置?
|
|
553
|
+
|
|
554
|
+
监听 `update:*` 事件,将设置保存到 localStorage 或后端:
|
|
555
|
+
|
|
556
|
+
```vue
|
|
557
|
+
<jh-layout
|
|
558
|
+
@update:layout="saveLayoutSetting"
|
|
559
|
+
@update:headerTheme="saveThemeSetting"
|
|
560
|
+
>
|
|
561
|
+
</jh-layout>
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## 更新日志
|
|
565
|
+
|
|
566
|
+
### v1.0.0 (2024-01-01)
|
|
567
|
+
|
|
568
|
+
- ✨ 初始版本发布
|
|
569
|
+
- ✨ 支持侧边、顶部、混合三种布局模式
|
|
570
|
+
- ✨ 支持亮色/暗色主题
|
|
571
|
+
- ✨ 自动生成面包屑导航
|
|
572
|
+
- ✨ 响应式设计
|
|
573
|
+
- ✨ 设置面板
|
|
574
|
+
- ✨ 多级菜单支持
|
|
575
|
+
|
|
576
|
+
## 参考资料
|
|
577
|
+
|
|
578
|
+
- [Ant Design Pro - ProLayout](https://procomponents.ant.design/components/layout)
|
|
579
|
+
- [Vuetify - Application](https://vuetifyjs.com/en/components/application/)
|
|
580
|
+
- [Material Design Icons](https://materialdesignicons.com/)
|