mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
同步了密语的头像处理
This commit is contained in:
@@ -1613,33 +1613,10 @@ class ExportService {
|
|||||||
const result = new Map<string, string>()
|
const result = new Map<string, string>()
|
||||||
if (members.length === 0) return result
|
if (members.length === 0) return result
|
||||||
|
|
||||||
|
// 直接使用 URL,不转换为 base64(与 ciphertalk 保持一致)
|
||||||
for (const member of members) {
|
for (const member of members) {
|
||||||
const fileInfo = this.resolveAvatarFile(member.avatarUrl)
|
if (member.avatarUrl) {
|
||||||
if (!fileInfo) continue
|
result.set(member.username, member.avatarUrl)
|
||||||
try {
|
|
||||||
let data: Buffer | null = null
|
|
||||||
let mime = fileInfo.mime
|
|
||||||
if (fileInfo.data) {
|
|
||||||
data = fileInfo.data
|
|
||||||
} else if (fileInfo.sourcePath && fs.existsSync(fileInfo.sourcePath)) {
|
|
||||||
data = await fs.promises.readFile(fileInfo.sourcePath)
|
|
||||||
} else if (fileInfo.sourceUrl) {
|
|
||||||
const downloaded = await this.downloadToBuffer(fileInfo.sourceUrl)
|
|
||||||
if (downloaded) {
|
|
||||||
data = downloaded.data
|
|
||||||
mime = downloaded.mime || mime
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!data) continue
|
|
||||||
|
|
||||||
// 优先使用内容检测出的 MIME 类型
|
|
||||||
const detectedMime = this.detectMimeType(data)
|
|
||||||
const finalMime = detectedMime || mime || this.inferImageMime(fileInfo.ext)
|
|
||||||
|
|
||||||
const base64 = data.toString('base64')
|
|
||||||
result.set(member.username, `data:${finalMime};base64,${base64}`)
|
|
||||||
} catch {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user