@befly-addon/admin 1.0.26 → 1.0.27

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/util.ts +0 -77
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@befly-addon/admin",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Befly - 管理后台功能组件",
5
5
  "type": "module",
6
6
  "private": false,
@@ -18,8 +18,8 @@
18
18
  "apis/",
19
19
  "tables/",
20
20
  "views/",
21
+ "util",
21
22
  "addon.config.json",
22
- "util.ts",
23
23
  "README.md",
24
24
  "package.json",
25
25
  "menu.json"
@@ -39,7 +39,7 @@
39
39
  "url": "https://github.com/chenbimo/befly.git",
40
40
  "directory": "packages/addon-admin"
41
41
  },
42
- "gitHead": "ca96814c3b67376809086cd8bef8e7816b736483",
42
+ "gitHead": "ccd0726d53a6902503bbfa58164f0644f28b8d5b",
43
43
  "dependencies": {
44
44
  "befly": "3.8.12"
45
45
  }
package/util.ts DELETED
@@ -1,77 +0,0 @@
1
- import type { RouteRecordRaw, Component } from 'vue-router';
2
-
3
- /**
4
- * 布局配置接口
5
- */
6
- export interface LayoutConfig {
7
- path: string;
8
- layoutName: string;
9
- component: Component;
10
- children?: LayoutConfig[];
11
- meta?: Record<string, any>;
12
- }
13
-
14
- /**
15
- * 自定义布局处理函数
16
- * 根据文件名后缀判断使用哪个布局
17
- * @param routes - 原始路由配置
18
- * @param inheritLayout - 继承的布局名称(来自父级目录)
19
- * @returns 处理后的布局配置(不包含实际的布局组件导入)
20
- */
21
- export function Layouts(routes: RouteRecordRaw[], inheritLayout = ''): LayoutConfig[] {
22
- const result: LayoutConfig[] = [];
23
-
24
- for (const route of routes) {
25
- const currentPath = route.path || '';
26
-
27
- // 检查当前路径是否有 _数字 格式
28
- const pathMatch = currentPath.match(/_(\d+)$/);
29
- const currentLayout = pathMatch ? pathMatch[1] : inheritLayout;
30
-
31
- // 如果有子路由,递归处理(传递当前布局给子级)
32
- if (route.children && route.children.length > 0) {
33
- // 清理路径:如果是 xxx_数字 格式,去掉 _数字
34
- const cleanPath = pathMatch ? currentPath.replace(/_\d+$/, '') : currentPath;
35
-
36
- result.push({
37
- path: cleanPath,
38
- layoutName: currentLayout || 'default',
39
- component: route.component!,
40
- children: Layouts(route.children, currentLayout),
41
- meta: route.meta
42
- });
43
- continue;
44
- }
45
-
46
- // 没有子路由的叶子节点,需要包裹布局
47
- const lastPart = currentPath;
48
-
49
- // 匹配 _数字 格式(如 index_1, news_2)
50
- const match = lastPart.match(/_(\d+)$/);
51
- // 优先使用文件自己的布局,其次使用继承的布局,最后使用 default
52
- const layoutName = match ? match[1] : currentLayout || 'default';
53
-
54
- // 计算清理后的路径
55
- let cleanPath: string;
56
- if (lastPart === 'index' || (lastPart.startsWith('index_') && match)) {
57
- // index 或 index_数字 → 改为空路径(由父级路径表示)
58
- cleanPath = '';
59
- } else if (match) {
60
- // xxx_数字 → 去掉 _数字 后缀
61
- cleanPath = lastPart.replace(/_\d+$/, '');
62
- } else {
63
- // 其他 → 保持原样
64
- cleanPath = lastPart;
65
- }
66
-
67
- // 返回布局配置(不执行实际导入)
68
- result.push({
69
- path: cleanPath,
70
- layoutName: layoutName,
71
- component: route.component!,
72
- meta: route.meta
73
- });
74
- }
75
-
76
- return result;
77
- }