From 3fcbf3c6d5b83aee8f5ad731f687b7df5184ee6a Mon Sep 17 00:00:00 2001 From: yuanjinwie <990991552@qq.com> Date: Wed, 4 Sep 2024 14:47:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(runtime-web):=20=E4=BF=AE=E5=A4=8D=20Pa?= =?UTF-8?q?geComponent=20=E8=8E=B7=E5=8F=96url=E5=8F=82=E6=95=B0=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-web/src/runtime/public/page.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/runtime-web/src/runtime/public/page.tsx b/packages/runtime-web/src/runtime/public/page.tsx index ec14c11c..167a27a3 100644 --- a/packages/runtime-web/src/runtime/public/page.tsx +++ b/packages/runtime-web/src/runtime/public/page.tsx @@ -16,10 +16,9 @@ export function getQueryParams(url) { const params = {} if (url.indexOf('?') !== -1) { - const str = url.substr(url.indexOf('?') + 1) - const strs = str.split('&') - for (let i = 0; i < strs.length; i++) { - params[strs[i].split('=')[0]] = decodeURIComponent(strs[i].split('=')[1]) + const searchParams = new URLSearchParams(url) + for(const [key, value] of searchParams.entries()){ + params[key] = decodeURIComponent(value) } } return params From 1498257bd94d44fc0a43f1062c895e5a8dc77435 Mon Sep 17 00:00:00 2001 From: yuanjinwie <990991552@qq.com> Date: Thu, 5 Sep 2024 11:59:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E5=A4=84=E7=90=86=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-web/src/runtime/public/page.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/runtime-web/src/runtime/public/page.tsx b/packages/runtime-web/src/runtime/public/page.tsx index 167a27a3..855c174d 100644 --- a/packages/runtime-web/src/runtime/public/page.tsx +++ b/packages/runtime-web/src/runtime/public/page.tsx @@ -16,10 +16,13 @@ export function getQueryParams(url) { const params = {} if (url.indexOf('?') !== -1) { - const searchParams = new URLSearchParams(url) - for(const [key, value] of searchParams.entries()){ - params[key] = decodeURIComponent(value) - } + const pairs = url.split('&') + pairs.forEach(pair => { + const [key, value] = pair.split('='); + const decodedKey = decodeURIComponent(key); + const decodedValue = decodeURIComponent(value); + params[decodedKey] = decodedValue + }); } return params }