|
@@ -125,7 +125,7 @@
|
|
|
|
|
|
<script setup lang="ts" name="MessageList">
|
|
<script setup lang="ts" name="MessageList">
|
|
/** 消息列表*/
|
|
/** 消息列表*/
|
|
-import { ref, watch, onUnmounted, computed, nextTick, unref } from 'vue'
|
|
|
|
|
|
+import { ref, watch, onUnmounted, computed, nextTick, unref, onMounted } from 'vue'
|
|
import { ElButton, ElIcon, ElMessage } from 'element-plus'
|
|
import { ElButton, ElIcon, ElMessage } from 'element-plus'
|
|
import { Close } from '@element-plus/icons-vue'
|
|
import { Close } from '@element-plus/icons-vue'
|
|
import useFetch from '@/hooks/useFetch'
|
|
import useFetch from '@/hooks/useFetch'
|
|
@@ -136,6 +136,7 @@ import { setLastMsgs } from '@/hooks/useMessageLoop'
|
|
import bus from '@/utils/bus'
|
|
import bus from '@/utils/bus'
|
|
import type { ExtractApiResponse } from '@/api/api'
|
|
import type { ExtractApiResponse } from '@/api/api'
|
|
import ContentEditAble from '@/components/common/ContentEditAble.vue'
|
|
import ContentEditAble from '@/components/common/ContentEditAble.vue'
|
|
|
|
+import { getUserConfigByType, setUserConfigByType } from '@/utils/common'
|
|
type MessageType = ExtractArrayValue<ExtractApiResponse<'getMessageList'>>
|
|
type MessageType = ExtractArrayValue<ExtractApiResponse<'getMessageList'>>
|
|
const historyMsgWrap = ref()
|
|
const historyMsgWrap = ref()
|
|
const mainStore = useMainStore()
|
|
const mainStore = useMainStore()
|
|
@@ -170,7 +171,7 @@ const sendCurrentPaper = () => {
|
|
|
|
|
|
/** 消息内容 */
|
|
/** 消息内容 */
|
|
const messageContent = ref<string>('')
|
|
const messageContent = ref<string>('')
|
|
-watch(messageContent, () => {
|
|
|
|
|
|
+watch(messageContent, (val: string) => {
|
|
// let reg = /<span class=\"pointer inline link-button\" contenteditable=\"false\" data-path=.*>查看试卷<\/span>/g
|
|
// let reg = /<span class=\"pointer inline link-button\" contenteditable=\"false\" data-path=.*>查看试卷<\/span>/g
|
|
// let arr = messageContent.value.match(reg)
|
|
// let arr = messageContent.value.match(reg)
|
|
// let text = messageContent.value.replace(reg, '【查看试卷临时替换字符】')
|
|
// let text = messageContent.value.replace(reg, '【查看试卷临时替换字符】')
|
|
@@ -183,6 +184,11 @@ watch(messageContent, () => {
|
|
const paperButton = document.querySelector(`.content-edit-able [data-path="${props.paperPath}"]`)
|
|
const paperButton = document.querySelector(`.content-edit-able [data-path="${props.paperPath}"]`)
|
|
sendedPaper.value = !!paperButton
|
|
sendedPaper.value = !!paperButton
|
|
})
|
|
})
|
|
|
|
+ if (sendTargetId.value) {
|
|
|
|
+ let config: any = getUserConfigByType('draft')
|
|
|
|
+ config[sendTargetId.value] = val || ''
|
|
|
|
+ setUserConfigByType('draft', config)
|
|
|
|
+ }
|
|
})
|
|
})
|
|
/** 图片路径 */
|
|
/** 图片路径 */
|
|
const paperPath = ref<string>('')
|
|
const paperPath = ref<string>('')
|
|
@@ -221,40 +227,25 @@ watch(historyReverse, (newVal: any, oldVal: any) => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+const sendTargetId = computed(() => {
|
|
|
|
+ return currentMessage.value?.sendUserId == mainStore?.myUserInfo?.id
|
|
|
|
+ ? currentMessage.value?.receiveUserId
|
|
|
|
+ : currentMessage.value?.sendUserId
|
|
|
|
+})
|
|
watch(currentMessage, (newVal: any, oldVal: any) => {
|
|
watch(currentMessage, (newVal: any, oldVal: any) => {
|
|
if (currentMessage.value) {
|
|
if (currentMessage.value) {
|
|
- // useFetch('handleReadMessage')
|
|
|
|
- // .fetch({ id: currentMessage.value.id })
|
|
|
|
- // .then(() => {
|
|
|
|
- // if (currentMessage.value?.unReadCount) {
|
|
|
|
- // // currentMessage.value.unReadCount--
|
|
|
|
- // currentMessage.value.unReadCount = 0
|
|
|
|
- // }
|
|
|
|
- // if (currentMessage.value?.sendUserId) {
|
|
|
|
- // getMessageHistory({
|
|
|
|
- // sendUserId:
|
|
|
|
- // currentMessage.value.sendUserId == mainStore?.myUserInfo?.id
|
|
|
|
- // ? currentMessage.value.receiveUserId
|
|
|
|
- // : currentMessage.value.sendUserId,
|
|
|
|
- // }).then(() => {
|
|
|
|
- // let newV = unref(newVal)
|
|
|
|
- // let oldV = unref(oldVal)
|
|
|
|
- // if (newV.id != oldV?.id) {
|
|
|
|
- // setTimeout(scrollToBottom, 1)
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
|
|
+ messageContent.value = ''
|
|
if (currentMessage.value?.unReadCount) {
|
|
if (currentMessage.value?.unReadCount) {
|
|
// currentMessage.value.unReadCount--
|
|
// currentMessage.value.unReadCount--
|
|
currentMessage.value.unReadCount = 0
|
|
currentMessage.value.unReadCount = 0
|
|
}
|
|
}
|
|
if (currentMessage.value?.sendUserId) {
|
|
if (currentMessage.value?.sendUserId) {
|
|
|
|
+ const targetId =
|
|
|
|
+ currentMessage.value.sendUserId == mainStore?.myUserInfo?.id
|
|
|
|
+ ? currentMessage.value.receiveUserId
|
|
|
|
+ : currentMessage.value.sendUserId
|
|
getMessageHistory({
|
|
getMessageHistory({
|
|
- sendUserId:
|
|
|
|
- currentMessage.value.sendUserId == mainStore?.myUserInfo?.id
|
|
|
|
- ? currentMessage.value.receiveUserId
|
|
|
|
- : currentMessage.value.sendUserId,
|
|
|
|
|
|
+ sendUserId: targetId,
|
|
}).then(() => {
|
|
}).then(() => {
|
|
let newV = unref(newVal)
|
|
let newV = unref(newVal)
|
|
let oldV = unref(oldVal)
|
|
let oldV = unref(oldVal)
|
|
@@ -262,6 +253,9 @@ watch(currentMessage, (newVal: any, oldVal: any) => {
|
|
setTimeout(scrollToBottom, 1)
|
|
setTimeout(scrollToBottom, 1)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+ const targetIdDraft = getUserConfigByType('draft')?.[targetId]
|
|
|
|
+ targetIdDraft && (messageContent.value = targetIdDraft)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -330,25 +324,6 @@ const onContentClick = (e: Event) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// getMessageList().then((result) => {
|
|
|
|
-// currentMessage.value = result?.[0]
|
|
|
|
-// if (result[0]) {
|
|
|
|
-// bus.emit('getCurMsg', result[0])
|
|
|
|
-// }
|
|
|
|
-// })
|
|
|
|
-// watch(
|
|
|
|
-// () => mainStore.newMsgs,
|
|
|
|
-// () => {
|
|
|
|
-// getMessageList().then((res) => {
|
|
|
|
-// if (res && Array.isArray(res)) {
|
|
|
|
-// let find = res.find((item) => item.sendUserId == currentMessage.value?.sendUserId)
|
|
|
|
-// if (!!find) {
|
|
|
|
-// currentMessage.value = find
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// })
|
|
|
|
-// }
|
|
|
|
-// )
|
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
useFetch('getUnReadMessage')
|
|
useFetch('getUnReadMessage')
|
|
.fetch()
|
|
.fetch()
|