每当我刷新或保存代码更改(自动重新加载)时,都会弹出登录弹出窗口,直到我通过单击关闭按钮手动关闭它。
我正在使用 angularx-social-login 包并通过 GoogleSigninButtonModule 按钮和 SocialAuthService 登录用户。
app.module.ts
providers: [
{
provide: 'SocialAuthServiceConfig',
useValue: {
autoLogin: false,
providers: [
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider(
myclientid
)
}
]
} as SocialAuthServiceConfig,
}
]
app.component.ts
import { SocialAuthService, SocialUser } from '@abacritt/angularx-social-login';
@Component...
export class AppComponent{
constructor(private socialAuthService: SocialAuthService) {
}
ngOnInit() {
this.socialAuthService.authState.subscribe({
next:
(user: SocialUser) => {
if (user != null) {
//My Logic
}
},
error:
() => {
}
})
}
}
app.component.html
<asl-google-signin-button size='large' class="google-button" type="standard" text="continue_with" width="400"></asl-google-signin-button>
我知道这很旧,但我通过将
{ oneTapEnabled: false }
添加到 SocialAuthServiceConfig 来修复此问题
provide: 'SocialAuthServiceConfig',
useValue: {
autoLogin: false,
providers: [{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider('<ID>', { oneTapEnabled: false })
}]