From 19734e96b1b9c25a6112b8779def2c488bed2857 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E9=B9=8F?= <2916022834@qq.com>
Date: Wed, 5 Nov 2025 14:00:36 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=B7=E6=AD=8C=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
env.d.ts | 7 +++++
src/views/login/SignupPage.vue | 7 +++--
src/views/login/components/GoogleLogin.vue | 32 +++++++++++-----------
3 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/env.d.ts b/env.d.ts
index 4d291ae..1b51202 100644
--- a/env.d.ts
+++ b/env.d.ts
@@ -19,6 +19,13 @@ interface GoogleAccounts {
logo_alignment?: 'left' | 'center'
}) => void
}
+ oauth2: {
+ initTokenClient: (config: {
+ client_id: string
+ callback: (response: { access_token: string }) => void
+ scope?: string
+ }) => void
+ }
}
}
diff --git a/src/views/login/SignupPage.vue b/src/views/login/SignupPage.vue
index ab0b56e..9f7fcf9 100644
--- a/src/views/login/SignupPage.vue
+++ b/src/views/login/SignupPage.vue
@@ -30,7 +30,7 @@
-
+
@@ -130,7 +130,10 @@ const handleConfirm = async () => {
isLoading.value = false
})
}
-
+const googleSignupRef = ref(null)
+const clickGooleLogin = () => {
+ googleSignupRef.value?.login()
+}
// 处理Google注册
const handleGoogleSignup = async (credential: string) => {
try {
diff --git a/src/views/login/components/GoogleLogin.vue b/src/views/login/components/GoogleLogin.vue
index 01fc123..e85ce0a 100644
--- a/src/views/login/components/GoogleLogin.vue
+++ b/src/views/login/components/GoogleLogin.vue
@@ -25,23 +25,23 @@ const emit = defineEmits<{
}>()
// 处理 Google 登录回调
-const handleCredentialResponse = async (response: { access_token: string }) => {
+const handleCredentialResponse = async (response: { access_token: string, credential: string }) => {
console.log('Google 登录响应:', response)
- fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
- headers: {
- 'Authorization': `Bearer ${response.access_token}`
- }
- })
- .then(response => response.json())
- .then(userInfo => {
- console.log('User info:', userInfo);
- })
- .catch(error => {
- console.error('Error fetching user info:', error);
- });
-// const code = response.credential
-// emit('googelLogin', code)
-// window.isAddGmail = false
+// fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
+// headers: {
+// 'Authorization': `Bearer ${response.access_token}`
+// }
+// })
+// .then(response => response.json())
+// .then(userInfo => {
+// console.log('User info:', userInfo);
+// })
+// .catch(error => {
+// console.error('Error fetching user info:', error);
+// });
+ const code = response.access_token
+ emit('googelLogin', code)
+ window.isAddGmail = false
}
// 配置数据