@xilonglab/vue-main 1.0.6 → 1.0.7
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 +1 -1
- package/packages/index.js +14 -29
package/package.json
CHANGED
package/packages/index.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
const modules = import.meta.glob('./**/*.vue');
|
|
1
|
+
const components = import.meta.glob('./**/*.vue', { eager: true });
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const install = async (app) => {
|
|
11
|
-
for (const path in modules) {
|
|
12
|
-
const mod = await modules[path](); // 浏览器端动态导入
|
|
13
|
-
const comp = mod.default;
|
|
14
|
-
const name = getComponentName(path, comp);
|
|
15
|
-
if (!name) {
|
|
16
|
-
console.warn(`组件注册失败: ${path} 缺少 name`);
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
app.component(name, comp);
|
|
20
|
-
}
|
|
3
|
+
const install = (app) => {
|
|
4
|
+
Object.values(components).forEach((component) => {
|
|
5
|
+
app.component(component.default.name, component.default);
|
|
6
|
+
});
|
|
21
7
|
};
|
|
22
8
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
9
|
+
let componentsJson = {}
|
|
10
|
+
for (const key in components) {
|
|
11
|
+
const component = components[key].default
|
|
12
|
+
const componentName = component.name
|
|
13
|
+
component.install = function (app) {
|
|
14
|
+
app.component(componentName, component)
|
|
15
|
+
}
|
|
16
|
+
componentsJson[componentName] = component
|
|
32
17
|
}
|
|
33
18
|
|
|
34
19
|
export default {
|
|
35
20
|
install,
|
|
36
21
|
...componentsJson
|
|
37
|
-
}
|
|
22
|
+
}
|