befly-admin 3.5.32 → 3.5.33
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 +32 -32
- package/package.json +20 -20
- package/src/App.vue +3 -3
- package/src/components/DetailPanel.vue +6 -6
- package/src/layouts/default.vue +139 -24
- package/src/main.js +13 -21
- package/src/plugins/config.js +29 -0
- package/src/plugins/global.js +1 -1
- package/src/plugins/http.js +11 -19
- package/src/plugins/router.js +45 -0
- package/src/plugins/storage.js +5 -12
- package/src/styles/global.scss +1 -1
- package/src/types/auto-imports.d.ts +5 -10
- package/src/types/components.d.ts +0 -27
- package/src/types/typed-router.d.ts +75 -23
- package/src/types/unplugin-vue-router-client.d.ts +3 -0
- package/src/views/dashboard/index.vue +117 -0
- package/src/views/index2.vue +9 -6
- package/vite.config.js +6 -5
- package/src/config/index.js +0 -20
- package/src/router/index.js +0 -86
- package/src/utils/index.js +0 -130
- package/src/views/index3.vue +0 -707
package/src/router/index.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { createRouter, createWebHashHistory } from 'vue-router';
|
|
2
|
-
import { routes } from 'vue-router/auto-routes';
|
|
3
|
-
import { $Storage } from '@/plugins/storage';
|
|
4
|
-
import { Layouts } from 'befly-shared/layouts';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('befly-shared').LayoutConfig} LayoutConfig
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 将布局配置转换为实际的路由配置
|
|
12
|
-
* 在这里执行实际的布局组件导入
|
|
13
|
-
* @param {LayoutConfig[]} configs
|
|
14
|
-
* @returns {import('vue-router').RouteRecordRaw[]}
|
|
15
|
-
*/
|
|
16
|
-
function applyLayouts(configs) {
|
|
17
|
-
return configs.map((config) => {
|
|
18
|
-
// 根据布局名称加载对应的布局组件
|
|
19
|
-
const layoutComponent = config.layoutName === 'default' ? () => import('@/layouts/default.vue') : () => import(`@/layouts/${config.layoutName}.vue`);
|
|
20
|
-
|
|
21
|
-
// 所有配置都是叶子节点(Layouts 函数已经扁平化处理)
|
|
22
|
-
// 直接包裹布局
|
|
23
|
-
return {
|
|
24
|
-
path: config.path,
|
|
25
|
-
component: layoutComponent,
|
|
26
|
-
meta: config.meta,
|
|
27
|
-
children: [
|
|
28
|
-
{
|
|
29
|
-
path: '',
|
|
30
|
-
component: config.component
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 应用自定义布局系统
|
|
38
|
-
const layoutRoutes = applyLayouts(Layouts(routes));
|
|
39
|
-
|
|
40
|
-
// 添加根路径重定向
|
|
41
|
-
const finalRoutes = [
|
|
42
|
-
{
|
|
43
|
-
path: '/',
|
|
44
|
-
redirect: '/addon/admin'
|
|
45
|
-
},
|
|
46
|
-
...layoutRoutes
|
|
47
|
-
];
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 创建并导出路由实例
|
|
51
|
-
* 可直接在 main.js 中使用 app.use(router)
|
|
52
|
-
*/
|
|
53
|
-
export const router = createRouter({
|
|
54
|
-
history: createWebHashHistory(import.meta.env.BASE_URL),
|
|
55
|
-
routes: finalRoutes
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// 路由守卫 - 基础验证
|
|
59
|
-
router.beforeEach(async (to, from, next) => {
|
|
60
|
-
const token = $Storage.local.get('token');
|
|
61
|
-
|
|
62
|
-
// 0. 根路径重定向
|
|
63
|
-
if (to.path === '/') {
|
|
64
|
-
return next(token ? '/addon/admin' : '/addon/admin/login');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// 1. 未登录且访问非公开路由 → 跳转登录
|
|
68
|
-
if (!token && to.meta?.public !== true && to.path !== '/addon/admin/login') {
|
|
69
|
-
return next('/addon/admin/login');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 2. 已登录访问登录页 → 跳转首页
|
|
73
|
-
if (token && to.path === '/addon/admin/login') {
|
|
74
|
-
return next('/addon/admin');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
next();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// 路由就绪后处理
|
|
81
|
-
router.afterEach((to) => {
|
|
82
|
-
// 可以在这里添加页面访问统计等
|
|
83
|
-
if (import.meta.env.DEV) {
|
|
84
|
-
console.log(`[Router] 导航到: ${to.path}`);
|
|
85
|
-
}
|
|
86
|
-
});
|
package/src/utils/index.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将一维数组转换为树形结构
|
|
3
|
-
* @template T
|
|
4
|
-
* @param {T[]} items - 一维数组
|
|
5
|
-
* @param {number} [pid=0] - 父节点ID,默认为0
|
|
6
|
-
* @returns {T[]} 树形结构数组
|
|
7
|
-
*/
|
|
8
|
-
export function arrayToTree(items, pid = 0) {
|
|
9
|
-
const tree = [];
|
|
10
|
-
|
|
11
|
-
for (const item of items) {
|
|
12
|
-
if (item.pid === pid) {
|
|
13
|
-
const children = arrayToTree(items, item.id);
|
|
14
|
-
const node = { ...item };
|
|
15
|
-
|
|
16
|
-
if (children.length > 0) {
|
|
17
|
-
node.children = children;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
tree.push(node);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return tree;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 表格列默认配置
|
|
29
|
-
* 统一设置超出显示省略号等通用配置
|
|
30
|
-
*/
|
|
31
|
-
const defaultColumnConfig = {
|
|
32
|
-
ellipsis: true,
|
|
33
|
-
ellipsisTitle: true
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 常用字段默认宽度映射
|
|
38
|
-
* 根据 colKey 自动设置宽度,页面可覆盖
|
|
39
|
-
*/
|
|
40
|
-
const columnWidthMap = {
|
|
41
|
-
'row-select': 50,
|
|
42
|
-
id: 150,
|
|
43
|
-
index: 60,
|
|
44
|
-
state: 100,
|
|
45
|
-
operation: 100,
|
|
46
|
-
username: 150,
|
|
47
|
-
nickname: 150,
|
|
48
|
-
name: 150,
|
|
49
|
-
title: 150,
|
|
50
|
-
code: 150,
|
|
51
|
-
roleCode: 120,
|
|
52
|
-
path: 250,
|
|
53
|
-
icon: 120,
|
|
54
|
-
value: 200,
|
|
55
|
-
description: 200,
|
|
56
|
-
createdAt: 170,
|
|
57
|
-
updatedAt: 170,
|
|
58
|
-
deletedAt: 170,
|
|
59
|
-
email: 200,
|
|
60
|
-
phone: 130,
|
|
61
|
-
sort: 80,
|
|
62
|
-
pid: 80
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 特定字段的默认配置
|
|
67
|
-
* 某些字段需要特殊的 ellipsis、align 等配置
|
|
68
|
-
*/
|
|
69
|
-
const columnDefaultProps = {
|
|
70
|
-
'row-select': { ellipsis: false },
|
|
71
|
-
id: { align: 'center' },
|
|
72
|
-
index: { align: 'center' },
|
|
73
|
-
state: { ellipsis: false, align: 'center' },
|
|
74
|
-
operation: { ellipsis: false, align: 'center', fixed: 'right' },
|
|
75
|
-
sort: { align: 'center' }
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 为表格列添加默认配置
|
|
80
|
-
* @param {Array} columns - 列配置数组
|
|
81
|
-
* @returns {Array} 添加默认配置后的列数组
|
|
82
|
-
*/
|
|
83
|
-
export function withDefaultColumns(columns) {
|
|
84
|
-
return columns.map((col) => {
|
|
85
|
-
const defaultWidth = columnWidthMap[col.colKey];
|
|
86
|
-
const defaultProps = columnDefaultProps[col.colKey] || {};
|
|
87
|
-
return {
|
|
88
|
-
...defaultColumnConfig,
|
|
89
|
-
...(defaultWidth && !col.width ? { width: defaultWidth } : {}),
|
|
90
|
-
...defaultProps,
|
|
91
|
-
...col
|
|
92
|
-
};
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 表格通用属性配置
|
|
98
|
-
* 统一管理 height、row-key、active-row-type 等通用配置
|
|
99
|
-
*/
|
|
100
|
-
const defaultTableProps = {
|
|
101
|
-
rowKey: 'id',
|
|
102
|
-
height: '100%',
|
|
103
|
-
activeRowType: 'single'
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 树形表格默认配置
|
|
108
|
-
*/
|
|
109
|
-
const defaultTreeConfig = {
|
|
110
|
-
childrenKey: 'children',
|
|
111
|
-
treeNodeColumnIndex: 0,
|
|
112
|
-
defaultExpandAll: true
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* 生成树形表格通用属性
|
|
117
|
-
* @param {Object} treeOverrides - 树形配置覆盖
|
|
118
|
-
* @param {Object} tableOverrides - 表格属性覆盖
|
|
119
|
-
* @returns {Object} 合并后的树形表格属性
|
|
120
|
-
*/
|
|
121
|
-
export function withTreeTableProps(treeOverrides = {}, tableOverrides = {}) {
|
|
122
|
-
return {
|
|
123
|
-
...defaultTableProps,
|
|
124
|
-
...tableOverrides,
|
|
125
|
-
tree: {
|
|
126
|
-
...defaultTreeConfig,
|
|
127
|
-
...treeOverrides
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|