mirror of
https://gitee.com/newgateway/vtj.git
synced 2026-06-30 23:45:12 +08:00
fix: 🐛 生成环境动态加载依赖
This commit is contained in:
@@ -14,15 +14,15 @@ const { provider, onReady } = createProvider({
|
||||
service,
|
||||
router,
|
||||
dependencies: {
|
||||
// Vue: () => import('vue'),
|
||||
// VueRouter: () => import('vue-router'),
|
||||
Vue: () => import('vue'),
|
||||
VueRouter: () => import('vue-router'),
|
||||
VtjUI: () => import('@vtj/ui')
|
||||
// ElementPlus: () => import('element-plus')
|
||||
},
|
||||
project: {
|
||||
id: name
|
||||
}
|
||||
});
|
||||
|
||||
onReady(async () => {
|
||||
app.use(router);
|
||||
app.use(provider);
|
||||
|
||||
@@ -130,6 +130,8 @@ export class Provider extends Base {
|
||||
|
||||
if (this.nodeEnv !== 'production') {
|
||||
await this.loadAssets(_window);
|
||||
} else {
|
||||
await this.loadDependencies(_window);
|
||||
}
|
||||
|
||||
this.apis = createSchemaApis(apis, meta, this.adapter);
|
||||
@@ -142,6 +144,15 @@ export class Provider extends Base {
|
||||
this.triggerReady();
|
||||
}
|
||||
|
||||
private async loadDependencies(_window: any) {
|
||||
const entries = Object.entries(this.dependencies);
|
||||
for (const [name, raw] of entries) {
|
||||
if (!_window[name]) {
|
||||
_window[name] = await raw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async loadAssets(_window: any) {
|
||||
const { dependencies: deps = [] } = this.project as ProjectSchema;
|
||||
const { dependencies, library, components, materialPath } = this;
|
||||
|
||||
Reference in New Issue
Block a user