mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-15 16:39:45 +08:00
fix(data-source): 避免http数据源在编辑器中的响应裁剪中修改到mock配置的数据
This commit is contained in:
parent
eb8126c32f
commit
f6885a06b6
@ -15,6 +15,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
import type { HttpOptions, RequestFunction } from '@tmagic/core';
|
import type { HttpOptions, RequestFunction } from '@tmagic/core';
|
||||||
import { getValueByKeyPath } from '@tmagic/core';
|
import { getValueByKeyPath } from '@tmagic/core';
|
||||||
|
|
||||||
@ -139,7 +141,7 @@ export default class HttpDataSource extends DataSource<HttpDataSourceSchema> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 注意:在编辑器中mockData不会为空,至少是默认值,不会发起请求
|
// 注意:在编辑器中mockData不会为空,至少是默认值,不会发起请求
|
||||||
let res = this.mockData ? this.mockData : await this.#fetch?.(reqOptions);
|
let res = this.mockData ? cloneDeep(this.mockData) : await this.#fetch?.(reqOptions);
|
||||||
|
|
||||||
for (const method of this.#afterRequest) {
|
for (const method of this.#afterRequest) {
|
||||||
await method({ res, options: reqOptions, params: {}, dataSource: this, app: this.app });
|
await method({ res, options: reqOptions, params: {}, dataSource: this, app: this.app });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user