mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-15 17:43:43 +08:00
feat(data-source): timing改成串行
This commit is contained in:
parent
1c6c9ab3e8
commit
28b3d2e4b3
@ -94,11 +94,15 @@ class DataSourceManager extends EventEmitter {
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(beforeInit.map((method) => method({ params: {}, dataSource: ds, app: this.app })));
|
||||
for (const method of beforeInit) {
|
||||
await method({ params: {}, dataSource: ds, app: this.app });
|
||||
}
|
||||
|
||||
await ds.init();
|
||||
|
||||
await Promise.all(afterInit.map((method) => method({ params: {}, dataSource: ds, app: this.app })));
|
||||
for (const method of afterInit) {
|
||||
await method({ params: {}, dataSource: ds, app: this.app });
|
||||
}
|
||||
|
||||
this.setData(ds);
|
||||
|
||||
|
@ -119,18 +119,18 @@ export default class HttpDataSource extends DataSource {
|
||||
|
||||
public async request(options: HttpOptions) {
|
||||
try {
|
||||
await Promise.all(
|
||||
this.beforeRequest.map((method) => method({ options, params: {}, dataSource: this, app: this.app })),
|
||||
);
|
||||
for (const method of this.beforeRequest) {
|
||||
await method({ options, params: {}, dataSource: this, app: this.app });
|
||||
}
|
||||
|
||||
const res = await this.fetch?.({
|
||||
...this.httpOptions,
|
||||
...options,
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
this.afterRequest.map((method) => method({ res, options, params: {}, dataSource: this, app: this.app })),
|
||||
);
|
||||
for (const method of this.afterRequest) {
|
||||
await method({ res, options, params: {}, dataSource: this, app: this.app });
|
||||
}
|
||||
|
||||
if (this.schema.responseOptions?.dataPath) {
|
||||
const data = getValueByKeyPath(this.schema.responseOptions.dataPath, res);
|
||||
|
Loading…
x
Reference in New Issue
Block a user