From f6885a06b6f4c646cfb99f595c59e95cef548927 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Thu, 19 Sep 2024 20:12:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(data-source):=20=E9=81=BF=E5=85=8Dhttp?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E5=9C=A8=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=93=8D=E5=BA=94=E8=A3=81=E5=89=AA=E4=B8=AD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B0mock=E9=85=8D=E7=BD=AE=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/data-source/src/data-sources/Http.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/data-source/src/data-sources/Http.ts b/packages/data-source/src/data-sources/Http.ts index 3b8c02a3..cce05736 100644 --- a/packages/data-source/src/data-sources/Http.ts +++ b/packages/data-source/src/data-sources/Http.ts @@ -15,6 +15,8 @@ * 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'; @@ -139,7 +141,7 @@ export default class HttpDataSource extends DataSource { } // 注意:在编辑器中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) { await method({ res, options: reqOptions, params: {}, dataSource: this, app: this.app });