@@ -681,7 +681,7 @@ onMounted(() => {
\ No newline at end of file
diff --git a/apps/frontend/src/components/auth/GoogleOAuthButton.vue b/apps/frontend/src/components/auth/GoogleOAuthButton.vue
index ebe6d10..7037320 100644
--- a/apps/frontend/src/components/auth/GoogleOAuthButton.vue
+++ b/apps/frontend/src/components/auth/GoogleOAuthButton.vue
@@ -41,8 +41,9 @@
import { ref } from 'vue'
import { useAuthStore } from '@/stores/auth'
import { useI18n } from 'vue-i18n'
+import { requestUtils,clientApi } from '@deotaland/utils'
+const authStore = useAuthStore()
const { t } = useI18n()
-
const emit = defineEmits(['success', 'error'])
const props = defineProps({
loading: {
@@ -72,21 +73,46 @@ const handleGoogleLogin = async () => {
if (isProcessing.value ) return
isProcessing.value = true
await loadGoogleScript()
- const clientId = '680509991778-f5qgqbampabs1atblvm1jkoi4itl1nni.apps.googleusercontent.com'
+ // const clientId = '680509991778-f5qgqbampabs1atblvm1jkoi4itl1nni.apps.googleusercontent.com'
+ const clientId = '1087356879940-kcdvstc2pgoim27gffl67qrs297avdmb.apps.googleusercontent.com'
const callback = async (response) => {
+ console.log(response,'responseresponseresponseresponse');
const idToken = response && response.credential
if (!idToken) {
errorMessage.value = '未获取到 Google 身份凭证'
return
}
- console.log(idToken,'idTokenidToken');
+ await loginWithidToken(idToken)
}
- console.log('window.google');
// 初始化并触发 One Tap 或弹出
window.google.accounts.id.initialize({ client_id: clientId, callback })
// 尝试弹出一键登录(如果浏览器允许)
window.google.accounts.id.prompt()
}
+const loginWithidToken = async (idToken) => {
+ try {clientApi
+ const res = await requestUtils.common(clientApi.default.OAUTH_GOOGLE,{
+ googleIdToken:idToken
+ })
+ if(res.code === 200){
+ // 登录成功,保存token和用户信息
+ let data = res.data;
+ authStore.loginSuccess(data,()=>{
+ emit('success', res.data.user)
+ })
+ return
+ emit('success', res.data.user)
+ return res
+ }
+ return res
+ } catch (error) {
+ console.error('登录失败:', error)
+ emit('error', error)
+ throw error
+ } finally {
+ isProcessing.value = false
+ }
+}
onMounted(() => {
loadGoogleScript()
})
diff --git a/apps/frontend/src/components/auth/LoginForm.vue b/apps/frontend/src/components/auth/LoginForm.vue
index abb5b00..9dc44ce 100644
--- a/apps/frontend/src/components/auth/LoginForm.vue
+++ b/apps/frontend/src/components/auth/LoginForm.vue
@@ -255,15 +255,7 @@ const handleLogin = async () => {
font-size: 16px;
}
-/* 错误消息 */
-.error-message {
- font-size: 13px;
- color: #EF4444;
- margin-left: 4px;
- display: flex;
- align-items: center;
- gap: 4px;
-}
+
/* 登录提交按钮 */
.login-submit-button {
diff --git a/apps/frontend/src/components/auth/RegisterForm.vue b/apps/frontend/src/components/auth/RegisterForm.vue
index c0d69f3..6ebe6e4 100644
--- a/apps/frontend/src/components/auth/RegisterForm.vue
+++ b/apps/frontend/src/components/auth/RegisterForm.vue
@@ -22,7 +22,42 @@
{{ emailError }}