🐛 fix(im): 上传 URL 取错字段,粘贴图片 / 文件 / 语音消息加载失败

axios 配置里 request.upload 直接返回完整 axios response(不是 res.data,
跟 get/post/put 不一致),原代码 (await updateFile(form)) as unknown as string
把整个 {data, status, headers, ...} 对象当成 URL 塞进消息 JSON,接收端
<el-image src> 拿到的是序列化串自然加载失败。

uploadAndSendImage / uploadAndSendFile / onVoiceSend 三处统一改成 .data 取值:
  ((await updateFile(form)) as { data?: string })?.data
跟 mall PictureSelectUpload / bpm SignDialog 等其它业务代码取 URL 的方式一致。
im
YunaiV 2026-04-28 01:14:24 +08:00
parent 9c5b11e551
commit 4c8898b6f5
1 changed files with 4 additions and 3 deletions

View File

@ -620,7 +620,7 @@ async function uploadAndSendImage(file: File) {
try {
const form = new FormData()
form.append('file', file)
const url = (await updateFile(form)) as unknown as string
const url = ((await updateFile(form)) as { data?: string })?.data
if (!url) {
return
}
@ -636,7 +636,7 @@ async function uploadAndSendFile(file: File) {
try {
const form = new FormData()
form.append('file', file)
const url = (await updateFile(form)) as unknown as string
const url = ((await updateFile(form)) as { data?: string })?.data
if (!url) {
return
}
@ -678,7 +678,8 @@ async function onVoiceSend(payload: { blob: Blob; duration: number }) {
const file = new File([payload.blob], `voice-${Date.now()}.webm`, { type: payload.blob.type })
const form = new FormData()
form.append('file', file)
const url = (await updateFile(form)) as unknown as string
// request.upload axios response res.data get/post/put URL .data
const url = ((await updateFile(form)) as { data?: string })?.data
if (!url) {
return
}