create-librex 1.0.3 → 1.0.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-librex",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "LibreX — 积木式后台管理框架项目脚手架",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,31 @@
1
+ import { definePageConfig, useContext } from 'librex'
2
+
3
+ export default definePageConfig({
4
+ title: '仪表盘',
5
+ path: '/dashboard',
6
+ icon: 'LayoutDashboard',
7
+ navOrder: 1,
8
+
9
+ builtinBricks: ['LStatsBar', 'LSearchBar', 'LDataTable', 'LRowActionBar'],
10
+
11
+ setup({ setTableColumns, setTableData, setStats, setStatsLabels }) {
12
+ const store = useContext()
13
+
14
+ setStats({ total: 12800, primary: 5632, junior: 23, senior: 7145 })
15
+ setStatsLabels({ total: '访问量', primary: '订单量', junior: '待处理', senior: '已完成' })
16
+
17
+ setTableColumns([
18
+ { key: 'id', label: 'ID', sortable: true, width: 60 },
19
+ { key: 'name', label: '项目名称', sortable: true },
20
+ { key: 'progress', label: '进度', sortable: true },
21
+ { key: 'status', label: '状态', sortable: true },
22
+ ])
23
+
24
+ setTableData([
25
+ { id: 1, name: 'LibreX 框架', progress: '85%', status: '进行中' },
26
+ { id: 2, name: '用户中心', progress: '100%', status: '已完成' },
27
+ { id: 3, name: '数据分析', progress: '30%', status: '规划中' },
28
+ { id: 4, name: '消息推送', progress: '60%', status: '开发中' },
29
+ ])
30
+ },
31
+ })
@@ -11,6 +11,8 @@
11
11
 
12
12
  <style scoped>
13
13
  .not-found-page {
14
+ grid-area: main;
15
+ grid-column: 1 / -1;
14
16
  display: flex; align-items: center; justify-content: center;
15
17
  width: 100%; height: 100%;
16
18
  background: var(--color-bg-viewport, #f0f2f5);
@@ -0,0 +1,47 @@
1
+ import { definePageConfig, useContext, useConfirm } from 'librex'
2
+
3
+ export default definePageConfig({
4
+ title: '用户管理',
5
+ path: '/users',
6
+ icon: 'Users',
7
+ navOrder: 2,
8
+
9
+ builtinBricks: ['LSearchBar', 'LDataTable', 'LRowActionBar', 'LBatchActionBar'],
10
+
11
+ setup({ setTableColumns, setTableData, setPageHooks }) {
12
+ const store = useContext()
13
+ const confirmStore = useConfirm()
14
+
15
+ setTableColumns([
16
+ { key: 'id', label: 'ID', sortable: true, width: 60 },
17
+ { key: 'username', label: '用户名', sortable: true },
18
+ { key: 'role', label: '角色', sortable: true },
19
+ { key: 'email', label: '邮箱' },
20
+ { key: 'createdAt', label: '创建时间', sortable: true },
21
+ ])
22
+
23
+ setTableData([
24
+ { id: 1, username: 'admin', role: '管理员', email: 'admin@librex.dev', createdAt: '2025-01-15' },
25
+ { id: 2, username: 'zhangsan', role: '编辑者', email: 'zhangsan@librex.dev', createdAt: '2025-03-20' },
26
+ { id: 3, username: 'lisi', role: '观察者', email: 'lisi@librex.dev', createdAt: '2025-04-10' },
27
+ { id: 4, username: 'wangwu', role: '编辑者', email: 'wangwu@librex.dev', createdAt: '2025-05-08' },
28
+ { id: 5, username: 'zhaoliu', role: '观察者', email: 'zhaoliu@librex.dev', createdAt: '2025-06-01' },
29
+ ])
30
+
31
+ setPageHooks({
32
+ onDelete: async (row) => {
33
+ const confirmed = await confirmStore.confirmDelete([row.id as number])
34
+ if (!confirmed) return
35
+ store.setTableData((store.tableData as any[]).filter((r: any) => r.id !== row.id))
36
+ store.pushNotification({ type: 'success', title: `已删除 ${row.username}` })
37
+ },
38
+ onBatchDelete: async (ids) => {
39
+ const confirmed = await confirmStore.confirmDelete(ids)
40
+ if (!confirmed) return
41
+ store.removeRows(ids)
42
+ store.clearSelection()
43
+ store.pushNotification({ type: 'success', title: `已删除 ${ids.length} 条` })
44
+ },
45
+ })
46
+ },
47
+ })
@@ -13,6 +13,7 @@ const allConfigs: PageConfig[] = brickRoutes
13
13
  .filter(Boolean) as PageConfig[]
14
14
 
15
15
  const routes: RouteRecordRaw[] = [
16
+ { path: '/', redirect: '/dashboard' },
16
17
  { path: '/login', name: 'login', component: LoginPage },
17
18
  ...brickRoutes,
18
19
  { path: '/:pathMatch(.*)*', name: 'not-found', component: NotFound },