fix(data-source): 编辑器的runtime不能对数据源的mock配置有影响
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
import EventEmitter from 'events';
|
||||
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import type { AppCore, CodeBlockContent, DataSchema, DataSourceSchema } from '@tmagic/schema';
|
||||
import { getDefaultValueFromFields } from '@tmagic/utils';
|
||||
|
||||
@@ -62,7 +64,7 @@ export default class DataSource<T extends DataSourceSchema = DataSourceSchema> e
|
||||
if (this.app.platform === 'editor') {
|
||||
// 编辑器中有mock使用mock,没有使用默认值
|
||||
this.mockData = options.schema.mocks?.find((mock) => mock.useInEditor)?.data || this.getDefaultData();
|
||||
data = this.mockData;
|
||||
data = cloneDeep(this.mockData);
|
||||
} else if (typeof options.useMock === 'boolean' && options.useMock) {
|
||||
// 设置了使用mock就使用mock数据
|
||||
this.mockData = options.schema.mocks?.find((mock) => mock.enable)?.data || this.getDefaultData();
|
||||
|
||||
Reference in New Issue
Block a user