Skip to content

Commit

Permalink
fix: 修复粘贴图片 2 次的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
Evansy authored Jul 24, 2023
1 parent 77df00c commit fd3636b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/views/Home/components/ChatBox/PasteImageDialog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ watchEffect(() => {
visible.value = false
}
})
const onClear = () =>{
imageBody.value.url && URL.revokeObjectURL(imageBody.value.url)
pasteFile.value = undefined
imageBody.value = {
url: '',
}
}
const onSend = async () => {
if (!pasteFile?.value) return
// FIXME 如下逻辑可以尝试抽为 hook
onChangeMsgType?.(MsgEnum.IMAGE) // 设置上传类型为图片
await onChangeFile?.([pasteFile?.value]) // 上传文件并发送消息
visible.value = false // 关闭弹窗
URL.revokeObjectURL(imageBody.value.url)
pasteFile.value = undefined
imageBody.value = {
url: '',
}
onClear()
}
</script>

<template>
Expand All @@ -56,6 +60,7 @@ const onSend = async () => {
v-model="visible"
:close-on-click-modal="false"
center
@close="onClear"
>
<img v-if="imageBody.url" :src="imageBody.url" />

Expand Down

0 comments on commit fd3636b

Please sign in to comment.