diff --git a/src/common/component/GithubLoginButton.tsx b/src/common/component/GithubLoginButton.tsx index c78c71ee..b498579c 100644 --- a/src/common/component/GithubLoginButton.tsx +++ b/src/common/component/GithubLoginButton.tsx @@ -18,9 +18,15 @@ const GithubLoginButton: FC = ({ type = "login", source = "webapp", clien if (key == 'widget' && !!newValue) { console.log("github logged in"); localStorage.removeItem("widget"); - const parentWindow = window.parent; - if (parentWindow) { - parentWindow.postMessage("RELOAD_WITH_OPEN", '*'); + if (window.location !== window.parent.location) { + // in iframe + const parentWindow = window.parent; + if (parentWindow) { + parentWindow.postMessage("RELOAD_WITH_OPEN", '*'); + } + } else { + // 刷新页面 + location.reload(); } } }; diff --git a/src/common/component/GoogleLoginButton.tsx b/src/common/component/GoogleLoginButton.tsx index a345f0c8..95cdc80e 100644 --- a/src/common/component/GoogleLoginButton.tsx +++ b/src/common/component/GoogleLoginButton.tsx @@ -1,4 +1,4 @@ -import { FC, useEffect, useState } from "react"; +import { FC, Suspense, useEffect, useState } from "react"; import { GoogleLogin, GoogleOAuthProvider } from "@react-oauth/google"; import toast from "react-hot-toast"; import { KEY_LOCAL_MAGIC_TOKEN } from "../../app/config"; @@ -39,7 +39,6 @@ const GoogleLoginInner: FC = ({ type = "login", loaded, loadError }) => { toast.error("Something Error"); break; } - return; } }, [error]); @@ -74,17 +73,19 @@ const GoogleLoginButton: FC = ({ type = "login", clientId }) => { const [hasError, setHasError] = useState(false); if (!clientId) return null; return ( - { - setHasError(true); - }} - onScriptLoadSuccess={() => { - setScriptLoaded(true); - }} - clientId={clientId} - > - - + loading...}> + { + setHasError(true); + }} + onScriptLoadSuccess={() => { + setScriptLoaded(true); + }} + clientId={clientId} + > + + + ); };