|
|
|
|
@ -553,12 +553,20 @@ export const useAppStore = defineStore('app', () => { |
|
|
|
|
function pushImageMessage({ localId, imageUrl, fileName = '' } = {}) { |
|
|
|
|
if (!localId || !imageUrl) return null |
|
|
|
|
|
|
|
|
|
const messageTimestamp = Date.now() |
|
|
|
|
const message = { |
|
|
|
|
localId, |
|
|
|
|
type: 'user', |
|
|
|
|
system: 'IMAGE', |
|
|
|
|
isSendSuccess: true, |
|
|
|
|
uploadStatus: 'uploading', |
|
|
|
|
// liics 协议字段:chat-content 的 v-show 与用户图片分支依赖 msgText/fromFlag/reqAndResType
|
|
|
|
|
fromFlag: '1', |
|
|
|
|
reqAndResType: '2', // 1文本 2图片
|
|
|
|
|
msgType: '02', |
|
|
|
|
msgText: imageUrl, // 本地预览(data URL),与 liics 上传时的 base64 预览一致
|
|
|
|
|
timestamp: messageTimestamp, |
|
|
|
|
VIEW_ID: 'msg' + messageTimestamp, |
|
|
|
|
imageUrl, |
|
|
|
|
imageKey: '', |
|
|
|
|
fileName, |
|
|
|
|
@ -579,6 +587,10 @@ export const useAppStore = defineStore('app', () => { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
chatArr.value.push(message) |
|
|
|
|
// 与 addSendMessageList 保持一致:记录当前发送的消息并展示上传 loading
|
|
|
|
|
timestamp.value = messageTimestamp |
|
|
|
|
sendLoading.value = true |
|
|
|
|
isChatLoading.value = true |
|
|
|
|
return message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -590,6 +602,13 @@ export const useAppStore = defineStore('app', () => { |
|
|
|
|
if (payload.uploadStatus === 'failed') message.isSendSuccess = false |
|
|
|
|
if (payload.uploadStatus === 'success') message.isSendSuccess = true |
|
|
|
|
|
|
|
|
|
// 上传结束(成功/失败)关闭气泡上的上传 loading
|
|
|
|
|
if (payload.uploadStatus === 'success' || payload.uploadStatus === 'failed') { |
|
|
|
|
message.sendLoading = false |
|
|
|
|
sendLoading.value = false |
|
|
|
|
if (payload.uploadStatus === 'failed') isChatLoading.value = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const options = message.message?.[0]?.options |
|
|
|
|
if (options && payload.imageUrl) options.imageUrl = payload.imageUrl |
|
|
|
|
if (options && payload.imageKey) options.imageKey = payload.imageKey |
|
|
|
|
|