代码优化

This commit is contained in:
bob
2025-03-15 19:51:02 +08:00
parent 12b9024ed2
commit dbb33640a4
2 changed files with 5 additions and 8 deletions

View File

@@ -508,12 +508,9 @@ const handleSendMessage = (content, resendSeq = '') => {
setTimeout(() => {
if (msg.status === 'pending') {
messageData.removeMsgRecord(selectedSessionId.value, msg.msgId)
// 这里需要在nextTick执行add操作否则computed没有触发更新
nextTick(() => {
msg.status = 'failed'
messageData.addMsgRecords(selectedSessionId.value, [msg])
ElMessage.error('消息发送失败')
})
msg.status = 'failed'
messageData.addMsgRecords(selectedSessionId.value, [msg])
ElMessage.error('消息发送失败')
}
}, resendInterval)
}

View File

@@ -1,5 +1,5 @@
<script setup>
import { computed, onMounted, h, createApp, watch, nextTick } from 'vue'
import { computed, onMounted, h, createApp, watch, nextTick, reactive } from 'vue'
import { ElImage } from 'element-plus'
import { WarningFilled } from '@element-plus/icons-vue'
import { MsgType } from '@/proto/msg'
@@ -109,7 +109,7 @@ const renderComponent = async (content) => {
}
const msg = computed(() => {
return messageData.getMsg(props.sessionId, props.msgId)
return reactive({ ...messageData.getMsg(props.sessionId, props.msgId) })
})
const msgStatus = computed(() => {