create-librex 1.0.4 → 1.0.6
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/package.json
CHANGED
|
@@ -3,8 +3,9 @@ import { definePageConfig, useContext } from 'librex'
|
|
|
3
3
|
export default definePageConfig({
|
|
4
4
|
title: '仪表盘',
|
|
5
5
|
path: '/dashboard',
|
|
6
|
-
icon: '
|
|
6
|
+
icon: 'layout-dashboard',
|
|
7
7
|
navOrder: 1,
|
|
8
|
+
navGroup: '📊 数据概览',
|
|
8
9
|
|
|
9
10
|
builtinBricks: ['LStatsBar', 'LSearchBar', 'LDataTable', 'LRowActionBar'],
|
|
10
11
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { definePageConfig } from 'librex'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 隐藏详情页 — 路径含 /:id,自动标记 hasParams=true,不出现在导航中。
|
|
5
|
+
*
|
|
6
|
+
* 从列表页跳转: router.push('/users/' + row.id)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default definePageConfig({
|
|
10
|
+
title: '用户详情',
|
|
11
|
+
path: '/users/detail/:id',
|
|
12
|
+
|
|
13
|
+
// 路径有 /: → hasParams 自动 true → IconRail 不显示
|
|
14
|
+
// icon + navGroup 可省略,因为不在导航中出现
|
|
15
|
+
|
|
16
|
+
builtinBricks: ['LForm'],
|
|
17
|
+
|
|
18
|
+
defaultState: 'reviewing',
|
|
19
|
+
|
|
20
|
+
setup({ setFormFields, setTableData }) {
|
|
21
|
+
setFormFields([
|
|
22
|
+
{ key: 'id', label: 'ID', fieldType: 'input' },
|
|
23
|
+
{ key: 'username', label: '用户名', fieldType: 'input', required: true },
|
|
24
|
+
{ key: 'role', label: '角色', fieldType: 'select', props: {
|
|
25
|
+
options: [
|
|
26
|
+
{ label: '管理员', value: 'admin' },
|
|
27
|
+
{ label: '编辑者', value: 'editor' },
|
|
28
|
+
{ label: '观察者', value: 'viewer' },
|
|
29
|
+
],
|
|
30
|
+
}},
|
|
31
|
+
{ key: 'email', label: '邮箱', fieldType: 'input' },
|
|
32
|
+
{ key: 'phone', label: '电话', fieldType: 'input' },
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
// 模拟从 API 加载数据
|
|
36
|
+
setTableData([
|
|
37
|
+
{ id: 1, username: 'admin', role: 'admin', email: 'admin@librex.dev', phone: '13800000001' },
|
|
38
|
+
])
|
|
39
|
+
},
|
|
40
|
+
})
|
|
@@ -3,11 +3,15 @@ import { definePageConfig, useContext, useConfirm } from 'librex'
|
|
|
3
3
|
export default definePageConfig({
|
|
4
4
|
title: '用户管理',
|
|
5
5
|
path: '/users',
|
|
6
|
-
icon: '
|
|
6
|
+
icon: 'users',
|
|
7
7
|
navOrder: 2,
|
|
8
|
+
navGroup: '📊 数据概览',
|
|
8
9
|
|
|
9
10
|
builtinBricks: ['LSearchBar', 'LDataTable', 'LRowActionBar', 'LBatchActionBar'],
|
|
10
11
|
|
|
12
|
+
// 行操作 — "查看"按钮跳隐藏详情页 /users/detail/:id
|
|
13
|
+
rowActions: [{ label: '查看', subView: 'detail' }],
|
|
14
|
+
|
|
11
15
|
setup({ setTableColumns, setTableData, setPageHooks }) {
|
|
12
16
|
const store = useContext()
|
|
13
17
|
const confirmStore = useConfirm()
|
|
@@ -96,10 +96,12 @@ export function vitePluginLibrex(): Plugin {
|
|
|
96
96
|
for (const route of r) {
|
|
97
97
|
const lastSlash = route.path.lastIndexOf('/')
|
|
98
98
|
if (lastSlash <= 0) continue
|
|
99
|
-
|
|
99
|
+
let parentPath = route.path.slice(0, lastSlash)
|
|
100
|
+
// 剥离参数段 (:id) 再匹配 — 如 /unit/detail/:id → 匹配 /unit
|
|
100
101
|
const parent = r.find(rr => rr.path === parentPath)
|
|
102
|
+
?? r.find(rr => rr.path === parentPath.replace(/\/[^/]*:[^/]+$/, ''))
|
|
101
103
|
if (!parent) continue
|
|
102
|
-
const groupName = parent.navGroup || `${parent.
|
|
104
|
+
const groupName = parent.navGroup || `${parent.title}`
|
|
103
105
|
if (!route.navGroup) route.navGroup = groupName
|
|
104
106
|
if (!parent.navGroup) parent.navGroup = groupName
|
|
105
107
|
}
|