Skip to content
Snippets Groups Projects
Commit 342b60b0 authored by yms's avatar yms
Browse files

fix: 解决参数bug

parent d8aa0eb5
No related branches found
Tags 0.1.5
No related merge requests found
...@@ -21,25 +21,22 @@ const Main = () => { ...@@ -21,25 +21,22 @@ const Main = () => {
useEffect(() => { useEffect(() => {
try { 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}`; window.location.href = `${config.thirdPartyFrontEndPageUrl}/authorizedLogin.html?client_id=OM90JPKW&response_type=code&redirect_uri=${config.devAppUrl}`;
return; return;
} }
if (!loginInfo?.token && window.location.search) { if (!loginInfo?.token && params.get("code")) {
const params = new URLSearchParams(window.location.search); getToken(params.get("code") as string)
.then((res) => {
if (params.get("code")) { setLoginInfo(res.data);
getToken(params.get("code") as string) })
.then((res) => { .catch((err) => {
setLoginInfo(res.data); alert(JSON.stringify(err));
}) });
.catch((err) => {
alert(JSON.stringify(err));
});
}
} }
} catch (error) { } catch (error) {
alert(error); alert(error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment