Revert "Expose Google client ID via API config and use dynamically"

This reverts commit 76c2771b7b.
This commit is contained in:
tim
2025-07-15 19:57:19 +08:00
parent 43f4e03586
commit 5fe10d770a
3 changed files with 5 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ export const API_PORT = 8081
// export const API_BASE_URL = API_PORT ? `${API_DOMAIN}:${API_PORT}` : API_DOMAIN
export const API_BASE_URL = "";
export const config = { googleClientId: '' }
export const GOOGLE_CLIENT_ID = '777830451304-nt8afkkap18gui4f9entcha99unal744.apps.googleusercontent.com'
export const toast = useToast()
initTheme()
@@ -32,10 +32,3 @@ checkToken().then(valid => {
clearToken()
}
})
fetch(`${API_BASE_URL}/api/config`).then(async res => {
if (res.ok) {
const data = await res.json()
config.googleClientId = data.googleClientId || ''
}
}).catch(() => {/* ignore */})

View File

@@ -1,28 +1,17 @@
import { API_BASE_URL, config, toast } from '../main'
import { API_BASE_URL, GOOGLE_CLIENT_ID, toast } from '../main'
import { setToken, loadCurrentUser } from './auth'
export async function googleGetIdToken() {
if (!config.googleClientId) {
try {
const res = await fetch(`${API_BASE_URL}/api/config`)
if (res.ok) {
const data = await res.json()
if (data.googleClientId) {
config.googleClientId = data.googleClientId
}
}
} catch { /* ignore */ }
}
return new Promise((resolve, reject) => {
if (!window.google || !config.googleClientId) {
if (!window.google || !GOOGLE_CLIENT_ID) {
toast.error('Google 登录不可用')
reject()
return
}
window.google.accounts.id.initialize({
client_id: config.googleClientId,
client_id: GOOGLE_CLIENT_ID,
callback: ({ credential }) => resolve(credential),
use_fedcm: true
use_fedcm: true
})
window.google.accounts.id.prompt()
})