fix bug#3892 重新编辑已撤回的消息
This commit is contained in:
parent
659c2c3e12
commit
2d28872a12
@ -179,3 +179,11 @@ export const uploadImg = (data,onProgressFn) => {
|
|||||||
onUploadProgress:(progressEvent)=>onProgressFn(progressEvent,data.get('file'))
|
onUploadProgress:(progressEvent)=>onProgressFn(progressEvent,data.get('file'))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 根据msg_id获取消息
|
||||||
|
export const detailGetRecordsContext = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/api/v1/talk/record/detail',
|
||||||
|
method: 'GET',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -69,8 +69,8 @@
|
|||||||
:datetime="item.created_at"
|
:datetime="item.created_at"
|
||||||
:msg_id="item.msg_id"
|
:msg_id="item.msg_id"
|
||||||
>
|
>
|
||||||
<template v-if="canEditRevokedMessage(item.msg_id) && item.user_id === userStore.uid">
|
<template v-if="canEditRevokedMessage(item) && item.user_id === userStore.uid">
|
||||||
<span class="edit-revoked-message" @click="restoreRevokedMessage(item.msg_id)">重新编辑</span>
|
<span class="edit-revoked-message" @click="restoreRevokedMessage(item)">重新编辑</span>
|
||||||
</template>
|
</template>
|
||||||
</revoke-message>
|
</revoke-message>
|
||||||
</div>
|
</div>
|
||||||
@ -478,7 +478,7 @@ import useZPaging from '@/uni_modules/z-paging/components/z-paging/js/hooks/useZ
|
|||||||
import emojiPanel from './components/emojiPanel.vue'
|
import emojiPanel from './components/emojiPanel.vue'
|
||||||
import filePanel from './components/filePanel.vue'
|
import filePanel from './components/filePanel.vue'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import { ServePublishMessage } from '@/api/chat'
|
import { ServePublishMessage,detailGetRecordsContext } from '@/api/chat'
|
||||||
import copy07 from '@/static/image/chatList/copy07@2x.png'
|
import copy07 from '@/static/image/chatList/copy07@2x.png'
|
||||||
import multipleChoices from '@/static/image/chatList/multipleChoices@2x.png'
|
import multipleChoices from '@/static/image/chatList/multipleChoices@2x.png'
|
||||||
import cite from '@/static/image/chatList/cite@2x.png'
|
import cite from '@/static/image/chatList/cite@2x.png'
|
||||||
@ -917,43 +917,48 @@ const actionWithdraw = (item) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const withdrawerConfirm = () => {
|
const withdrawerConfirm = () => {
|
||||||
// 保存撤回的消息内容和时间
|
|
||||||
if (state.value.onfocusItem && state.value.onfocusItem.msg_type === 1) {
|
|
||||||
state.value.revokedMessages[state.value.onfocusItem.msg_id] = {
|
|
||||||
content: state.value.onfocusItem.extra.content,
|
|
||||||
revokeTime: new Date().getTime(),
|
|
||||||
msgType: state.value.onfocusItem.msg_type,
|
|
||||||
extra: state.value.onfocusItem.extra
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dialogueStore.ApiRevokeRecord(state.value.onfocusItem.msg_id)
|
dialogueStore.ApiRevokeRecord(state.value.onfocusItem.msg_id)
|
||||||
state.value.onfocusItem = null
|
state.value.onfocusItem = null
|
||||||
state.value.showWin = false
|
state.value.showWin = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加检查是否可以重新编辑撤回消息的函数
|
// 添加检查是否可以重新编辑撤回消息的函数
|
||||||
const canEditRevokedMessage = (msgId) => {
|
const canEditRevokedMessage = (item) => {
|
||||||
if (!state.value.revokedMessages[msgId]) return false
|
console.log( item)
|
||||||
|
if(item.is_revoke === 1 && item.msg_type === 1) {
|
||||||
const now = new Date().getTime()
|
const now = new Date().getTime();
|
||||||
const revokeTime = state.value.revokedMessages[msgId].revokeTime
|
const revokeTime = new Date(item.created_at).getTime();
|
||||||
|
console.log(now)
|
||||||
// 检查是否在5分钟内
|
// 检查是否在5分钟内
|
||||||
return (now - revokeTime) <= 5 * 60 * 1000
|
return (now - revokeTime) <= 5 * 60 * 1000
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加恢复撤回消息到输入框的函数
|
// 添加恢复撤回消息到输入框的函数
|
||||||
const restoreRevokedMessage = (msgId) => {
|
const restoreRevokedMessage = async (item) => {
|
||||||
if (!state.value.revokedMessages[msgId]) return
|
// 接口拿数据,之后把查询的内容给输入框
|
||||||
|
const res = await detailGetRecordsContext({
|
||||||
const revokedMsg = state.value.revokedMessages[msgId]
|
msgId: item.msg_id
|
||||||
|
})
|
||||||
|
console.log(res)
|
||||||
|
if(res.code == 200) {
|
||||||
|
const content = res.data.item?.extra?.content;
|
||||||
|
const quill = getQuill()
|
||||||
|
quill.setText(content)
|
||||||
|
// 将光标设置到文本末尾
|
||||||
|
quill.setSelection(content.length, 0)
|
||||||
|
quill.focus()
|
||||||
|
}
|
||||||
|
/* const revokedMsg = state.value.revokedMessages[msgId]
|
||||||
|
|
||||||
// 根据消息类型处理
|
// 根据消息类型处理
|
||||||
if (revokedMsg.msgType === 1) { // 文本消息
|
if (revokedMsg.msgType === 1) { // 文本消息
|
||||||
const quill = getQuill()
|
const quill = getQuill()
|
||||||
quill.setText(revokedMsg.content)
|
quill.setText(revokedMsg.content)
|
||||||
quill.focus()
|
quill.focus()
|
||||||
}
|
} */
|
||||||
// 可以根据需要添加其他类型消息的处理
|
// 可以根据需要添加其他类型消息的处理
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user