切换录音时保存草稿

This commit is contained in:
bob
2025-03-27 09:40:54 +08:00
parent 12a1e27081
commit 7532cda953

View File

@@ -1,7 +1,7 @@
<script setup>
import { QuillEditor, Delta, Quill } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'
import { onMounted, onUnmounted, ref, watch } from 'vue'
import { onMounted, onUnmounted, onBeforeUnmount, ref, watch } from 'vue'
import { v4 as uuidv4 } from 'uuid'
import { messageStore, imageStore } from '@/stores'
import { ElMessage, ElLoading } from 'element-plus'
@@ -36,6 +36,17 @@ onMounted(async () => {
})
})
onBeforeUnmount(async () => {
let content = await getContent()
// 草稿若没发生变动,则不触发存储
if (content !== messageData.sessionList[props.sessionId].draft) {
messageData.updateSession({
sessionId: props.sessionId,
draft: content
})
}
})
onUnmounted(() => {
if (editorRef.value) {
document.querySelector('.ql-editor').classList.remove('my-scrollbar')