From 6649e0615b5141fe8fccfeaa0565b961ba360fde Mon Sep 17 00:00:00 2001 From: winixt Date: Fri, 14 Mar 2025 17:57:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20request=20=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=8C=82=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-request/package.json | 2 +- packages/fes-plugin-request/src/template/request.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/fes-plugin-request/package.json b/packages/fes-plugin-request/package.json index 79f8c401..a4dc4e0c 100644 --- a/packages/fes-plugin-request/package.json +++ b/packages/fes-plugin-request/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "@fesjs/utils": "^3.0.3", - "@qlin/request": "^0.3.0" + "@qlin/request": "^0.3.1" }, "typings": "./types.d.ts" } diff --git a/packages/fes-plugin-request/src/template/request.js b/packages/fes-plugin-request/src/template/request.js index 88cebb4f..cebde7ee 100644 --- a/packages/fes-plugin-request/src/template/request.js +++ b/packages/fes-plugin-request/src/template/request.js @@ -15,16 +15,14 @@ function getRequestInstance() { return createRequest(defaultConfig); } +// 不能立马初始化,用户配置可能还没准备好 let currentRequest; export function rawRequest(url, data, options = {}) { - if (typeof options === 'string') { - options = { - method: options, - }; - } if (!currentRequest) { currentRequest = getRequestInstance(); + // 将 request 实例上的属性挂在到 rawRequest 上。 + Object.assign(rawRequest, currentRequest); } return currentRequest(url, data, options); }