|
|
@@ -25,13 +25,17 @@
|
|
|
import useApis from "@/apis";
|
|
|
import {useStore} from "@/store";
|
|
|
import router from "@/router"
|
|
|
- import {onMounted, reactive, ref, watchEffect} from "vue";
|
|
|
+ import {onMounted, onUnmounted, reactive, ref, watchEffect} from "vue";
|
|
|
import type {engagementVO} from "@/types/vo";
|
|
|
import type {IDialogue} from "@/types/dialogue.ts";
|
|
|
import Edit from "@/views/Home/component/Edit/index.vue";
|
|
|
import Slider from '@/views/Home/component/Silder/index.vue'
|
|
|
import "./index.scss"
|
|
|
import {useRoute} from 'vue-router'
|
|
|
+ import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+ import emitter from "@/utils/emitter";
|
|
|
+ import IndexedDB from "@/utils/indexedDBUtil";
|
|
|
+ import {isModified, registerAllEventListeners, removeAllEventListeners} from "@/views/EditPage/userWritingRecord";
|
|
|
|
|
|
// 获得路由中的assignmentId
|
|
|
const route = useRoute()
|
|
|
@@ -39,6 +43,8 @@
|
|
|
|
|
|
const apis = useApis()
|
|
|
const store = useStore()
|
|
|
+ const indexedDB = new IndexedDB()
|
|
|
+ // let isModified = ref(false)
|
|
|
|
|
|
const dataForm = reactive<{
|
|
|
messages: IDialogue[],
|
|
|
@@ -51,7 +57,27 @@
|
|
|
})
|
|
|
|
|
|
const handleBack = () => {
|
|
|
- router.push(`/home/homeworkDetail/${assignmentId}`)
|
|
|
+ // console.log(isModified.value)
|
|
|
+ if(isModified.value){
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '您编辑的信息尚未保存,您确定要离开吗?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ center: true,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ router.push(`/home/homeworkDetail/${assignmentId}`)
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ return
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ router.push(`/home/homeworkDetail/${assignmentId}`)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 获取数据
|
|
|
@@ -82,8 +108,31 @@
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ // // 接收word是否修改后未保存,用于决定是否提醒用户
|
|
|
+ // emitter.on("is-modified", () => {
|
|
|
+ // isModified.value = true
|
|
|
+ // })
|
|
|
+ //
|
|
|
+ // // 接收AI对话点击发送按钮的行为信息
|
|
|
+ // emitter.on("click-ai-send-button", (event:any) => {
|
|
|
+ // indexedDB.addData(event)
|
|
|
+ // console.log(event)
|
|
|
+ // })
|
|
|
+
|
|
|
+
|
|
|
onMounted( () => {
|
|
|
fetchData()
|
|
|
+ indexedDB.initDB("eventId")
|
|
|
+ registerAllEventListeners(indexedDB);
|
|
|
+ })
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ indexedDB.clearDB()
|
|
|
+ indexedDB.closeDB()
|
|
|
+ indexedDB.deleteDBAll()
|
|
|
+ // emitter.off("click-ai-send-button")
|
|
|
+ // emitter.off('is-modified')
|
|
|
+ removeAllEventListeners();
|
|
|
})
|
|
|
|
|
|
</script>
|