feat: 修改谷歌登录api
This commit is contained in:
@@ -50,11 +50,11 @@ export const LogOut = (): Promise<ApiResponse> => {
|
|||||||
|
|
||||||
// Google登录/注册参数类型
|
// Google登录/注册参数类型
|
||||||
interface GoogleAuthParamsType {
|
interface GoogleAuthParamsType {
|
||||||
credential?: string // Google ID Token (用于One Tap登录)
|
accessToken?: string // Google ID Token (用于One Tap登录)
|
||||||
}
|
}
|
||||||
export const googleAuth = (data: GoogleAuthParamsType): Promise<LoginResponse> => {
|
export const googleAuth = (data: GoogleAuthParamsType): Promise<LoginResponse> => {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/auth/parseGoogleCredential',
|
url: '/api/auth/parseGoogleAccessToken',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: data
|
params: data
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ const clickGooleLogin = () => {
|
|||||||
googleLoginRef.value?.login()
|
googleLoginRef.value?.login()
|
||||||
}
|
}
|
||||||
// 处理Google登录
|
// 处理Google登录
|
||||||
const handleGoogleLogin = async (credential: string) => {
|
const handleGoogleLogin = async (accessToken: string) => {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
const result = await googleAuth({ credential })
|
const result = await googleAuth({ accessToken })
|
||||||
// console.log('result', result)
|
// console.log('result', result)
|
||||||
userInfoStore.setToken(result.token)
|
userInfoStore.setToken(result.token)
|
||||||
userInfoStore.setUserInfo(result.user)
|
userInfoStore.setUserInfo(result.user)
|
||||||
|
|||||||
@@ -135,10 +135,10 @@ const clickGooleLogin = () => {
|
|||||||
googleSignupRef.value?.login()
|
googleSignupRef.value?.login()
|
||||||
}
|
}
|
||||||
// 处理Google注册
|
// 处理Google注册
|
||||||
const handleGoogleSignup = async (credential: string) => {
|
const handleGoogleSignup = async (accessToken: string) => {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
const result = await googleAuth({ credential })
|
const result = await googleAuth({ accessToken })
|
||||||
userInfoStore.setToken(result.token)
|
userInfoStore.setToken(result.token)
|
||||||
userInfoStore.setUserInfo(result.user)
|
userInfoStore.setUserInfo(result.user)
|
||||||
showToast('Google sign up successful')
|
showToast('Google sign up successful')
|
||||||
|
|||||||
Reference in New Issue
Block a user