1
0
mirror of synced 2026-04-14 13:09:13 +08:00

fix(data-source): 编辑器的runtime不能对数据源的mock配置有影响

This commit is contained in:
roymondchen
2024-08-06 14:33:21 +08:00
parent 69f3cb2f12
commit fa2d00ba36
2 changed files with 11 additions and 16 deletions

View File

@@ -111,28 +111,21 @@ class DataSourceManager extends EventEmitter {
return;
}
const beforeInit: ((...args: any[]) => any)[] = [];
const afterInit: ((...args: any[]) => any)[] = [];
ds.methods.forEach((method) => {
for (const method of ds.methods) {
if (typeof method.content !== 'function') return;
if (method.timing === 'beforeInit') {
beforeInit.push(method.content);
method.content({ params: {}, dataSource: ds, app: this.app });
}
if (method.timing === 'afterInit') {
afterInit.push(method.content);
}
});
for (const method of beforeInit) {
await method({ params: {}, dataSource: ds, app: this.app });
}
await ds.init();
for (const method of afterInit) {
await method({ params: {}, dataSource: ds, app: this.app });
}
ds.methods.forEach((method) => {
if (typeof method.content !== 'function') return;
if (method.timing === 'afterInit') {
method.content({ params: {}, dataSource: ds, app: this.app });
}
});
}
public get(id: string) {