@vtj/web 0.9.10 → 0.9.12
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,18 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vtj/web",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.9.
|
4
|
+
"version": "0.9.12",
|
5
5
|
"type": "module",
|
6
6
|
"sideEffects": false,
|
7
7
|
"dependencies": {
|
8
8
|
"core-js": "~3.39.0",
|
9
9
|
"regenerator-runtime": "~0.14.1",
|
10
|
-
"@vtj/
|
11
|
-
"@vtj/
|
12
|
-
"@vtj/
|
13
|
-
"@vtj/ui": "~0.9.
|
14
|
-
"@vtj/
|
15
|
-
"@vtj/
|
10
|
+
"@vtj/icons": "~0.9.12",
|
11
|
+
"@vtj/core": "~0.9.12",
|
12
|
+
"@vtj/renderer": "~0.9.12",
|
13
|
+
"@vtj/ui": "~0.9.12",
|
14
|
+
"@vtj/charts": "~0.9.12",
|
15
|
+
"@vtj/utils": "~0.9.12"
|
16
16
|
},
|
17
17
|
"devDependencies": {
|
18
18
|
"@vtj/cli": "~0.9.6"
|
@@ -15,6 +15,8 @@ import {
|
|
15
15
|
} from '../renderer';
|
16
16
|
import { createModules } from '../modules';
|
17
17
|
|
18
|
+
type VtjModules = ReturnType<typeof createModules>;
|
19
|
+
|
18
20
|
export interface SetupElementAdminOptions {
|
19
21
|
id: string;
|
20
22
|
app: App;
|
@@ -32,12 +34,20 @@ function toElIcon(icon?: string) {
|
|
32
34
|
return icon ? `vi-ep:${kebabCase(icon)}` : undefined;
|
33
35
|
}
|
34
36
|
|
35
|
-
function
|
37
|
+
async function getComponent(path: string, modules: VtjModules) {
|
38
|
+
// const rawPath = `.vtj/vue/${id}.vue`;
|
39
|
+
const rawModule = modules[path];
|
40
|
+
if (rawModule) {
|
41
|
+
return ((await rawModule()) as any)?.default;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
function createPageRoute(page: PageFile, modules: VtjModules) {
|
36
46
|
const { id, title, icon, hidden, cache = false, meta = {} } = page;
|
37
47
|
return {
|
38
48
|
path: `page/${id}`,
|
39
49
|
name: `Page_${id}`,
|
40
|
-
component: () =>
|
50
|
+
component: () => getComponent(`.vtj/vue/${id}.vue`, modules),
|
41
51
|
meta: {
|
42
52
|
title,
|
43
53
|
hidden,
|
@@ -48,11 +58,11 @@ function createPageRoute(page: PageFile) {
|
|
48
58
|
};
|
49
59
|
}
|
50
60
|
|
51
|
-
function createNoMaskRoute(page: PageFile) {
|
61
|
+
function createNoMaskRoute(page: PageFile, modules: VtjModules) {
|
52
62
|
const { id, title, icon, cache = false, meta = {} } = page;
|
53
63
|
return {
|
54
64
|
path: `/page/${id}`,
|
55
|
-
component: () =>
|
65
|
+
component: () => getComponent(`.vtj/vue/${id}.vue`, modules),
|
56
66
|
meta: {
|
57
67
|
title,
|
58
68
|
icon: toElIcon(icon),
|
@@ -65,7 +75,8 @@ function createNoMaskRoute(page: PageFile) {
|
|
65
75
|
|
66
76
|
function childrenToRoutes(
|
67
77
|
children: PageFile[] = [],
|
68
|
-
noMask: any[]
|
78
|
+
noMask: any[],
|
79
|
+
modules: VtjModules
|
69
80
|
): RouteRecordRaw[] {
|
70
81
|
return children.map((child) => {
|
71
82
|
const { id, dir, mask = true, title, icon, hidden } = child;
|
@@ -80,23 +91,23 @@ function childrenToRoutes(
|
|
80
91
|
alwaysShow: true,
|
81
92
|
icon: toElIcon(icon)
|
82
93
|
},
|
83
|
-
children: childrenToRoutes(child.children, noMask)
|
94
|
+
children: childrenToRoutes(child.children, noMask, modules)
|
84
95
|
};
|
85
96
|
}
|
86
97
|
if (!mask) {
|
87
|
-
noMask.push(createNoMaskRoute(child));
|
98
|
+
noMask.push(createNoMaskRoute(child, modules));
|
88
99
|
}
|
89
|
-
return createPageRoute(child);
|
100
|
+
return createPageRoute(child, modules);
|
90
101
|
});
|
91
102
|
}
|
92
103
|
|
93
|
-
function pagesToRoutes(pages: PageFile[], layout: any) {
|
104
|
+
function pagesToRoutes(pages: PageFile[], layout: any, modules: VtjModules) {
|
94
105
|
const noMask: any[] = [];
|
95
106
|
const items: any[] = [];
|
96
107
|
for (const page of pages) {
|
97
108
|
const { id, dir, mask = true, title, icon, hidden, children = [] } = page;
|
98
109
|
if (!dir && !mask) {
|
99
|
-
noMask.push(createNoMaskRoute(page));
|
110
|
+
noMask.push(createNoMaskRoute(page, modules));
|
100
111
|
}
|
101
112
|
|
102
113
|
if (children.length) {
|
@@ -110,7 +121,7 @@ function pagesToRoutes(pages: PageFile[], layout: any) {
|
|
110
121
|
alwaysShow: true,
|
111
122
|
icon: toElIcon(icon)
|
112
123
|
},
|
113
|
-
children: childrenToRoutes(children, noMask)
|
124
|
+
children: childrenToRoutes(children, noMask, modules)
|
114
125
|
});
|
115
126
|
} else {
|
116
127
|
items.push({
|
@@ -123,7 +134,7 @@ function pagesToRoutes(pages: PageFile[], layout: any) {
|
|
123
134
|
alwaysShow: !!dir,
|
124
135
|
icon: toElIcon(icon)
|
125
136
|
},
|
126
|
-
children: dir ? [] : [createPageRoute(page)]
|
137
|
+
children: dir ? [] : [createPageRoute(page, modules)]
|
127
138
|
});
|
128
139
|
}
|
129
140
|
}
|
@@ -169,8 +180,7 @@ export async function setupElementAdminRoutes(
|
|
169
180
|
if (loader) {
|
170
181
|
const project = ((await loader()) as any).default as ProjectSchema;
|
171
182
|
const pages = project.pages || [];
|
172
|
-
const pageRoutes = pagesToRoutes(pages, layout);
|
173
|
-
console.log(pageRoutes);
|
183
|
+
const pageRoutes = pagesToRoutes(pages, layout, modules);
|
174
184
|
routes.unshift(...pageRoutes);
|
175
185
|
routes.forEach((item) => {
|
176
186
|
router.addRoute(item);
|