fix: github login
This commit is contained in:
@@ -18,10 +18,16 @@ const GithubLoginButton: FC<Props> = ({ type = "login", source = "webapp", clien
|
||||
if (key == 'widget' && !!newValue) {
|
||||
console.log("github logged in");
|
||||
localStorage.removeItem("widget");
|
||||
if (window.location !== window.parent.location) {
|
||||
// in iframe
|
||||
const parentWindow = window.parent;
|
||||
if (parentWindow) {
|
||||
parentWindow.postMessage("RELOAD_WITH_OPEN", '*');
|
||||
}
|
||||
} else {
|
||||
// 刷新页面
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (source == "widget") {
|
||||
|
||||
@@ -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<Props> = ({ type = "login", loaded, loadError }) => {
|
||||
toast.error("Something Error");
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}, [error]);
|
||||
|
||||
@@ -74,6 +73,7 @@ const GoogleLoginButton: FC<Props> = ({ type = "login", clientId }) => {
|
||||
const [hasError, setHasError] = useState(false);
|
||||
if (!clientId) return null;
|
||||
return (
|
||||
<Suspense fallback={<span>loading...</span>}>
|
||||
<GoogleOAuthProvider
|
||||
onScriptLoadError={() => {
|
||||
setHasError(true);
|
||||
@@ -85,6 +85,7 @@ const GoogleLoginButton: FC<Props> = ({ type = "login", clientId }) => {
|
||||
>
|
||||
<GoogleLoginInner type={type} loaded={scriptLoaded} loadError={hasError} />
|
||||
</GoogleOAuthProvider>
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user