From cd2c8ca05492b193e2740c35581c335ee5609f0b Mon Sep 17 00:00:00 2001 From: xingyuv Date: Sat, 25 Mar 2023 22:13:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E6=97=B6=E9=97=B4=E5=8C=BA?= =?UTF-8?q?=E9=97=B4=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closed #I6PWSR --- src/utils/http/axios/index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 0238124..0bcb205 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -125,6 +125,24 @@ const transform: AxiosTransform = { if (!isString(params)) { // 给 get 请求加上时间戳参数,避免从缓存中拿数据。 config.params = Object.assign(params || {}, joinTimestamp(joinTime, false)) + let url = config.url + '?' + for (const propName of Object.keys(config.params)) { + const value = config.params[propName] + if (value !== void 0 && value !== null && typeof value !== 'undefined') { + if (typeof value === 'object') { + for (const val of Object.keys(value)) { + const paramss = propName + '[' + val + ']' + const subPart = encodeURIComponent(paramss) + '=' + url += subPart + encodeURIComponent(value[val]) + '&' + } + } else { + url += `${propName}=${encodeURIComponent(value)}&` + } + } + } + url = url.slice(0, -1) + config.params = {} + config.url = url } else { // 兼容restful风格 config.url = config.url + params + `${joinTimestamp(joinTime, true)}`