From 618e82bc952c1e604b9db3a06fbe7f6a72131598 Mon Sep 17 00:00:00 2001 From: zhangyahui Date: Wed, 5 Nov 2025 11:40:17 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E5=8F=96=E6=B6=88onetap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env.d.ts | 3 +++ src/views/login/components/GoogleLogin.vue | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/env.d.ts b/env.d.ts index 4d291ae..8e17362 100644 --- a/env.d.ts +++ b/env.d.ts @@ -8,8 +8,10 @@ interface GoogleAccounts { client_id: string auto_select?: boolean callback: (response: { credential: string }) => void + context?: 'signin' | 'signup' | 'use' ux_mode?: 'popup' | 'redirect' itp_support?: boolean + cancel_on_tap_outside?: boolean }) => void renderButton: (element: Element | null, config: { type?: 'standard' | 'icon' @@ -18,6 +20,7 @@ interface GoogleAccounts { size?: 'large' | 'medium' | 'small' logo_alignment?: 'left' | 'center' }) => void + disableAutoSelect?: () => void } } } diff --git a/src/views/login/components/GoogleLogin.vue b/src/views/login/components/GoogleLogin.vue index e0a9581..bbe04f5 100644 --- a/src/views/login/components/GoogleLogin.vue +++ b/src/views/login/components/GoogleLogin.vue @@ -56,15 +56,17 @@ const createGmailLogin = async () => { script.src = data.scriptSrc }) } - window.google.accounts.id.initialize({ - // 主要就是填写client_id + // 初始化Google登录,禁用One Tap自动提示 + const initConfig: Parameters[0] = { client_id: GOOGLE_CLIENT_ID, - auto_select: false, + auto_select: false, // 禁用自动选择,避免显示One Tap提示 callback: handleCredentialResponse, - // context:"signin", + context: 'signin', // 设置为signin模式,避免显示个性化One Tap提示 ux_mode: 'popup', - itp_support: true - }) + itp_support: true, + cancel_on_tap_outside: true // 点击外部时取消One Tap提示 + } + window.google.accounts.id.initialize(initConfig as any) console.log('创建谷歌登录按钮:', document.querySelector('.Container #g_id_signin')) window.google.accounts.id.renderButton(document.querySelector('.Container #g_id_signin'), { type: 'standard', //icon为只有一个icon