From 342b60b09a0f5e37d7667cc3e2cee140163671ef Mon Sep 17 00:00:00 2001 From: yms Date: Wed, 24 Jul 2024 10:56:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8F=82=E6=95=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/main.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/pages/main.tsx b/src/pages/main.tsx index 7564e79..be20e5b 100644 --- a/src/pages/main.tsx +++ b/src/pages/main.tsx @@ -21,25 +21,22 @@ const Main = () => { useEffect(() => { try { - alert(`${loginInfo?.token},${window.location.search}`); + const params = new URLSearchParams(window.location.search); + /** 不存在先直接跳转 */ - if (!loginInfo?.token && !window.location.search) { + if (!loginInfo?.token && !params.get("code")) { window.location.href = `${config.thirdPartyFrontEndPageUrl}/authorizedLogin.html?client_id=OM90JPKW&response_type=code&redirect_uri=${config.devAppUrl}`; return; } - if (!loginInfo?.token && window.location.search) { - const params = new URLSearchParams(window.location.search); - - if (params.get("code")) { - getToken(params.get("code") as string) - .then((res) => { - setLoginInfo(res.data); - }) - .catch((err) => { - alert(JSON.stringify(err)); - }); - } + if (!loginInfo?.token && params.get("code")) { + getToken(params.get("code") as string) + .then((res) => { + setLoginInfo(res.data); + }) + .catch((err) => { + alert(JSON.stringify(err)); + }); } } catch (error) { alert(error); -- GitLab