From c463dc67961a611d2559482e9e9e57bd00da485c Mon Sep 17 00:00:00 2001 From: yms Date: Fri, 19 Jan 2024 14:27:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/main.tsx | 46 ++++++++++++++++++++++---------------------- src/pages/report.tsx | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/pages/main.tsx b/src/pages/main.tsx index 3d6b951..567f211 100644 --- a/src/pages/main.tsx +++ b/src/pages/main.tsx @@ -12,31 +12,31 @@ const Main = () => { }, []); const { loginInfo, user, setUser, setLoginInfo } = useModel("global"); - // useEffect(() => { - // try { - // /** 不存在先直接跳转 */ - // if (!loginInfo?.token && !window.location.search) { - // window.location.href = `${config.thirdPartyFrontEndPageUrl}/authorizedLogin.html?client_id=OM90JPKW&response_type=code&redirect_uri=${config.devAppUrl}`; - // return; - // } + useEffect(() => { + try { + /** 不存在先直接跳转 */ + if (!loginInfo?.token && !window.location.search) { + 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 (!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)); - // }); - // } - // } - // } catch (error) { - // alert(error); - // } - // }, []); + if (params.get("code")) { + getToken(params.get("code") as string) + .then((res) => { + setLoginInfo(res.data); + }) + .catch((err) => { + alert(JSON.stringify(err)); + }); + } + } + } catch (error) { + alert(error); + } + }, []); useEffect(() => { if (!user && loginInfo?.token) { diff --git a/src/pages/report.tsx b/src/pages/report.tsx index 8ac9ab8..8db98d1 100644 --- a/src/pages/report.tsx +++ b/src/pages/report.tsx @@ -109,8 +109,8 @@ const Report = () => { setLoading(false); } }); - } catch (error) { - Notify.show({ type: "danger", message: "上报失败!" }); + } catch (error: any) { + Notify.show({ type: "danger", message: error }); setLoading(false); } -- GitLab