mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(data-source): http数据源中mock数据应该是数据源定义好的数据,不再是请求的数据源
This commit is contained in:
parent
8b7dca8e23
commit
25646317ae
@ -15,8 +15,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import type { HttpOptions, RequestFunction } from '@tmagic/core';
|
||||
import { getValueByKeyPath } from '@tmagic/core';
|
||||
|
||||
@ -141,7 +139,10 @@ export default class HttpDataSource extends DataSource<HttpDataSourceSchema> {
|
||||
}
|
||||
|
||||
// 注意:在编辑器中mockData不会为空,至少是默认值,不会发起请求
|
||||
let res = this.mockData ? cloneDeep(this.mockData) : await this.#fetch?.(reqOptions);
|
||||
if (this.mockData) {
|
||||
this.setData(this.mockData);
|
||||
} else {
|
||||
let res = await this.#fetch?.(reqOptions);
|
||||
|
||||
for (const method of this.#afterRequest) {
|
||||
await method({ res, options: reqOptions, params: {}, dataSource: this, app: this.app });
|
||||
@ -157,6 +158,7 @@ export default class HttpDataSource extends DataSource<HttpDataSourceSchema> {
|
||||
} else {
|
||||
this.setData(res);
|
||||
}
|
||||
}
|
||||
|
||||
this.error = undefined;
|
||||
} catch (error: any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user