diff --git a/src/pages/main.tsx b/src/pages/main.tsx index 3d6b951a22c442fb7443eb26a5a915fa1d424d59..567f2112e23590d10704d8d8663e8148a7833a87 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 8ac9ab80a5dd9e25edc8b9f52e5e405218102167..8db98d12d3752a9e34bcb9969b04192dd63c44ba 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); }