Add fallback for identity detail when server crashes on /api/v1/identity/:uuid
This commit is contained in:
@@ -115,9 +115,29 @@ const loadDetail = async () => {
|
|||||||
detail.value = result
|
detail.value = result
|
||||||
profile.value = result.profile || {}
|
profile.value = result.profile || {}
|
||||||
videos.value = result.videos || []
|
videos.value = result.videos || []
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.error('Failed to load identity detail:', error)
|
// Fallback: some API servers crash on /api/v1/identity/:uuid
|
||||||
alert('載入失敗: ' + error)
|
try {
|
||||||
|
const config = getCurrentConfig()
|
||||||
|
const result = await httpFetch<any>(`${config.api_base_url}/api/v1/identities?uuid=${identityId.value}&page_size=1`)
|
||||||
|
const identity = (result.identities || [])[0]
|
||||||
|
if (identity) {
|
||||||
|
detail.value = identity
|
||||||
|
const meta = identity.metadata || {}
|
||||||
|
profile.value = {
|
||||||
|
name: identity.name,
|
||||||
|
character_name: meta.tmdb_character,
|
||||||
|
aliases: meta.tmdb_aliases,
|
||||||
|
gender: meta.tmdb_gender === 1 ? 'Female' : meta.tmdb_gender === 2 ? 'Male' : undefined,
|
||||||
|
age: meta.tmdb_birthday ? `${new Date().getFullYear() - new Date(meta.tmdb_birthday).getFullYear()} yrs` : undefined,
|
||||||
|
}
|
||||||
|
videos.value = []
|
||||||
|
} else {
|
||||||
|
throw new Error('Identity not found')
|
||||||
|
}
|
||||||
|
} catch (fallbackError) {
|
||||||
|
console.error('Failed to load identity detail:', fallbackError)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user