From 08a1fa603783489ce68bc1e891e33f95316a3db2 Mon Sep 17 00:00:00 2001 From: "@edwin-ye" Date: Tue, 2 Mar 2021 16:41:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20h5=E9=A1=B9=E7=9B=AEget=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=20=E5=8F=82=E6=95=B0=E6=8B=BC=E6=8E=A5bug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../H5/template/src/utils/http/https.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts b/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts index 4921311..45794f8 100644 --- a/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts +++ b/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts @@ -34,6 +34,19 @@ export function handleData(params: T): T { return data; } +/** + * get请求参数拼接 + * @param params 请求接口的传参 + */ +export function changeParamsToString(params: T): string { + let param = '?'; + Object.keys(handleData(params)).forEach((key) => { + param += `${key}=${handleData(params)[key]}&`; + }); + if (param.length !== 1) param = param.slice(0, param.length - 1); + return param; +} + /** * Get请求 * @export @@ -48,13 +61,8 @@ export function apiGet( params: Common.PlainObject = {}, headers: Common.PlainObject = {}, ): Promise> { - // handleHeader - let param = '?'; - Object.keys(handleData(params)).forEach((key) => { - param += handleData(params)[key]; - }); return service - .get(`${url}${param}`, { headers }) + .get(`${url}${changeParamsToString(params)}`, { headers }) .then((res) => res) .catch((err) => { throw err; From 8951c147124caff0a797e000fdc808e7c568c4e5 Mon Sep 17 00:00:00 2001 From: "@edwin-ye" Date: Thu, 4 Mar 2021 10:12:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9ACLI/H5=20https.ts=20get=20param?= =?UTF-8?q?eter=20concatenation=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/H5/template/src/utils/http/https.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts b/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts index 45794f8..806334f 100644 --- a/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts +++ b/packages/@w6s/cli/templates/H5/template/src/utils/http/https.ts @@ -34,19 +34,6 @@ export function handleData(params: T): T { return data; } -/** - * get请求参数拼接 - * @param params 请求接口的传参 - */ -export function changeParamsToString(params: T): string { - let param = '?'; - Object.keys(handleData(params)).forEach((key) => { - param += `${key}=${handleData(params)[key]}&`; - }); - if (param.length !== 1) param = param.slice(0, param.length - 1); - return param; -} - /** * Get请求 * @export @@ -62,7 +49,7 @@ export function apiGet( headers: Common.PlainObject = {}, ): Promise> { return service - .get(`${url}${changeParamsToString(params)}`, { headers }) + .get(url, { params, headers }) .then((res) => res) .catch((err) => { throw err;