@@ -2,25 +2,26 @@ import "./index.less";
2
2
3
3
import React , { useCallback , useContext , useEffect , useRef , useState } from "react" ;
4
4
import { constants } from "flat-types" ;
5
+ import { useTranslation } from "react-i18next" ;
5
6
import { observer } from "mobx-react-lite" ;
6
- import { ipcAsyncByMainWindow , ipcSyncByApp } from "../../utils/ipc " ;
7
+ import { message } from "antd " ;
7
8
import { LoginPanel , LoginButton , LoginButtonProviderType } from "flat-components" ;
8
- import { LoginDisposer } from "./utils" ;
9
9
import { 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" ;
10
14
import { RouteNameType , usePushHistory } from "../../utils/routes" ;
11
15
import { GlobalStoreContext } from "../../components/StoreProvider" ;
12
16
import { AppUpgradeModal , AppUpgradeModalProps } from "../../components/AppUpgradeModal" ;
13
17
import { runtime } from "../../utils/runtime" ;
14
18
import { useSafePromise } from "../../utils/hooks/lifecycle" ;
15
- import { useTranslation } from "react-i18next" ;
16
19
import {
17
20
PRIVACY_URL_EN ,
18
21
PRIVACY_URL_CN ,
19
22
SERVICE_URL_EN ,
20
23
SERVICE_URL_CN ,
21
24
} from "../../constants/process" ;
22
- import { message } from "antd" ;
23
- import WeChatLogin from "./WeChatLogin" ;
24
25
25
26
export const LoginPage = observer ( function LoginPage ( ) {
26
27
const { i18n } = useTranslation ( ) ;
@@ -81,6 +82,13 @@ export const LoginPage = observer(function LoginPage() {
81
82
} ) ;
82
83
return ;
83
84
}
85
+ case "google" : {
86
+ loginDisposer . current = googleLogin ( async authData => {
87
+ globalStore . updateUserInfo ( authData ) ;
88
+ pushHistory ( RouteNameType . HomePage ) ;
89
+ } ) ;
90
+ return ;
91
+ }
84
92
case "wechat" : {
85
93
setWeChatLogin ( true ) ;
86
94
return ;
@@ -105,11 +113,19 @@ export const LoginPage = observer(function LoginPage() {
105
113
function renderButtonList ( ) : React . ReactNode {
106
114
return (
107
115
< >
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
+ ) }
113
129
< LoginButton
114
130
provider = "github"
115
131
text = { i18n . t ( "login-github" ) }
0 commit comments