bugfix: 取消onetap
This commit is contained in:
3
env.d.ts
vendored
3
env.d.ts
vendored
@@ -8,8 +8,10 @@ interface GoogleAccounts {
|
|||||||
client_id: string
|
client_id: string
|
||||||
auto_select?: boolean
|
auto_select?: boolean
|
||||||
callback: (response: { credential: string }) => void
|
callback: (response: { credential: string }) => void
|
||||||
|
context?: 'signin' | 'signup' | 'use'
|
||||||
ux_mode?: 'popup' | 'redirect'
|
ux_mode?: 'popup' | 'redirect'
|
||||||
itp_support?: boolean
|
itp_support?: boolean
|
||||||
|
cancel_on_tap_outside?: boolean
|
||||||
}) => void
|
}) => void
|
||||||
renderButton: (element: Element | null, config: {
|
renderButton: (element: Element | null, config: {
|
||||||
type?: 'standard' | 'icon'
|
type?: 'standard' | 'icon'
|
||||||
@@ -18,6 +20,7 @@ interface GoogleAccounts {
|
|||||||
size?: 'large' | 'medium' | 'small'
|
size?: 'large' | 'medium' | 'small'
|
||||||
logo_alignment?: 'left' | 'center'
|
logo_alignment?: 'left' | 'center'
|
||||||
}) => void
|
}) => void
|
||||||
|
disableAutoSelect?: () => void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,15 +56,17 @@ const createGmailLogin = async () => {
|
|||||||
script.src = data.scriptSrc
|
script.src = data.scriptSrc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.google.accounts.id.initialize({
|
// 初始化Google登录,禁用One Tap自动提示
|
||||||
// 主要就是填写client_id
|
const initConfig: Parameters<typeof window.google.accounts.id.initialize>[0] = {
|
||||||
client_id: GOOGLE_CLIENT_ID,
|
client_id: GOOGLE_CLIENT_ID,
|
||||||
auto_select: false,
|
auto_select: false, // 禁用自动选择,避免显示One Tap提示
|
||||||
callback: handleCredentialResponse,
|
callback: handleCredentialResponse,
|
||||||
// context:"signin",
|
context: 'signin', // 设置为signin模式,避免显示个性化One Tap提示
|
||||||
ux_mode: 'popup',
|
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'))
|
console.log('创建谷歌登录按钮:', document.querySelector('.Container #g_id_signin'))
|
||||||
window.google.accounts.id.renderButton(document.querySelector('.Container #g_id_signin'), {
|
window.google.accounts.id.renderButton(document.querySelector('.Container #g_id_signin'), {
|
||||||
type: 'standard', //icon为只有一个icon
|
type: 'standard', //icon为只有一个icon
|
||||||
|
|||||||
Reference in New Issue
Block a user