Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 56f56d127d |
@@ -193,9 +193,19 @@ export async function uploadAvatarToCasdoor(
|
||||
throw new CasdoorSyncError('连接认证服务失败,请稍后重试', 'NETWORK')
|
||||
}
|
||||
|
||||
let json: { status?: string; msg?: string; data?: unknown[] } | null = null
|
||||
let json: {
|
||||
status?: string
|
||||
msg?: string
|
||||
data?: unknown
|
||||
data2?: unknown
|
||||
} | null = null
|
||||
try {
|
||||
json = (await res.json()) as { status?: string; msg?: string; data?: unknown[] }
|
||||
json = (await res.json()) as {
|
||||
status?: string
|
||||
msg?: string
|
||||
data?: unknown
|
||||
data2?: unknown
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
@@ -208,8 +218,15 @@ export async function uploadAvatarToCasdoor(
|
||||
)
|
||||
}
|
||||
|
||||
const fileUrl = String(Array.isArray(json.data) ? json.data[0] : '')
|
||||
const objectKey = String(Array.isArray(json.data) ? json.data[1] : '')
|
||||
// Casimir 返回 data = fileUrl(字符串)、data2 = objectKey;兼容 data 为数组的旧格式
|
||||
const fileUrl = Array.isArray(json.data) ? String(json.data[0] || '') : String(json.data || '')
|
||||
const objectKey = Array.isArray(json.data2)
|
||||
? String(json.data2[0] || '')
|
||||
: json.data2 !== undefined
|
||||
? String(json.data2 || '')
|
||||
: Array.isArray(json.data)
|
||||
? String(json.data[1] || '')
|
||||
: ''
|
||||
if (!fileUrl) throw new CasdoorSyncError('认证服务未返回头像地址', 'UNKNOWN')
|
||||
return { fileUrl, objectKey }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user