@@ -2,25 +2,26 @@ import "./index.less";
22
33import React , { useCallback , useContext , useEffect , useRef , useState } from "react" ;
44import { constants } from "flat-types" ;
5+ import { useTranslation } from "react-i18next" ;
56import { observer } from "mobx-react-lite" ;
6- import { ipcAsyncByMainWindow , ipcSyncByApp } from "../../utils/ipc " ;
7+ import { message } from "antd " ;
78import { LoginPanel , LoginButton , LoginButtonProviderType } from "flat-components" ;
8- import { LoginDisposer } from "./utils" ;
99import { githubLogin } from "./githubLogin" ;
10+ import WeChatLogin from "./WeChatLogin" ;
11+ import { googleLogin } from "./googleLogin" ;
12+ import { ipcAsyncByMainWindow , ipcSyncByApp } from "../../utils/ipc" ;
13+ import { LoginDisposer } from "./utils" ;
1014import { RouteNameType , usePushHistory } from "../../utils/routes" ;
1115import { GlobalStoreContext } from "../../components/StoreProvider" ;
1216import { AppUpgradeModal , AppUpgradeModalProps } from "../../components/AppUpgradeModal" ;
1317import { runtime } from "../../utils/runtime" ;
1418import { useSafePromise } from "../../utils/hooks/lifecycle" ;
15- import { useTranslation } from "react-i18next" ;
1619import {
1720 PRIVACY_URL_EN ,
1821 PRIVACY_URL_CN ,
1922 SERVICE_URL_EN ,
2023 SERVICE_URL_CN ,
2124} from "../../constants/process" ;
22- import { message } from "antd" ;
23- import WeChatLogin from "./WeChatLogin" ;
2425
2526export const LoginPage = observer ( function LoginPage ( ) {
2627 const { i18n } = useTranslation ( ) ;
@@ -81,6 +82,13 @@ export const LoginPage = observer(function LoginPage() {
8182 } ) ;
8283 return ;
8384 }
85+ case "google" : {
86+ loginDisposer . current = googleLogin ( async authData => {
87+ globalStore . updateUserInfo ( authData ) ;
88+ pushHistory ( RouteNameType . HomePage ) ;
89+ } ) ;
90+ return ;
91+ }
8492 case "wechat" : {
8593 setWeChatLogin ( true ) ;
8694 return ;
@@ -105,11 +113,19 @@ export const LoginPage = observer(function LoginPage() {
105113 function renderButtonList ( ) : React . ReactNode {
106114 return (
107115 < >
108- < LoginButton
109- provider = "wechat"
110- text = { i18n . t ( "login-wechat" ) }
111- onLogin = { handleLogin }
112- />
116+ { process . env . FLAT_REGION === "America" ? (
117+ < LoginButton
118+ provider = "google"
119+ text = { i18n . t ( "login-google" ) }
120+ onLogin = { handleLogin }
121+ />
122+ ) : (
123+ < LoginButton
124+ provider = "wechat"
125+ text = { i18n . t ( "login-wechat" ) }
126+ onLogin = { handleLogin }
127+ />
128+ ) }
113129 < LoginButton
114130 provider = "github"
115131 text = { i18n . t ( "login-github" ) }
0 commit comments