mirror of
https://gitee.com/lijingbo-2021/open-anylink-web.git
synced 2025-12-30 02:52:26 +00:00
实现消息删除功能
This commit is contained in:
@@ -16,6 +16,10 @@ export const msgChatRevokeMsgService = (obj) => {
|
|||||||
return request.post('/chat/revokeMsg', obj)
|
return request.post('/chat/revokeMsg', obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const msgChatDeleteMsgService = (obj) => {
|
||||||
|
return request.post('/chat/deleteMsg', obj)
|
||||||
|
}
|
||||||
|
|
||||||
export const msgAtService = () => {
|
export const msgAtService = () => {
|
||||||
return request.get('/chat/queryAt')
|
return request.get('/chat/queryAt')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export const useMessageStore = defineStore('anylink-message', () => {
|
|||||||
*/
|
*/
|
||||||
const removeMsgRecord = (sessionId, msgKey) => {
|
const removeMsgRecord = (sessionId, msgKey) => {
|
||||||
if (msgRecordsList.value[sessionId] && msgKey in msgRecordsList.value[sessionId]) {
|
if (msgRecordsList.value[sessionId] && msgKey in msgRecordsList.value[sessionId]) {
|
||||||
delete msgRecordsList.value[sessionId][msgKey]
|
msgRecordsList.value[sessionId][msgKey].delete = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import MsgBoxVideo from '@/views/message/components/MsgBoxVideo.vue'
|
|||||||
import MsgBoxDocument from '@/views/message/components/MsgBoxDocument.vue'
|
import MsgBoxDocument from '@/views/message/components/MsgBoxDocument.vue'
|
||||||
import MenuMsgItem from '@/views/message/components/MenuMsgItem.vue'
|
import MenuMsgItem from '@/views/message/components/MenuMsgItem.vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { msgChatRevokeMsgService } from '@/api/message'
|
import { msgChatDeleteMsgService, msgChatRevokeMsgService } from '@/api/message'
|
||||||
|
|
||||||
const props = defineProps([
|
const props = defineProps([
|
||||||
'sessionId',
|
'sessionId',
|
||||||
@@ -631,6 +631,10 @@ const isRevoke = computed(() => {
|
|||||||
return msg.value.revoke
|
return msg.value.revoke
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isDelete = computed(() => {
|
||||||
|
return msg.value.delete
|
||||||
|
})
|
||||||
|
|
||||||
const isReedit = computed(() => {
|
const isReedit = computed(() => {
|
||||||
const contentJson = jsonParseSafe(msg.value.content)
|
const contentJson = jsonParseSafe(msg.value.content)
|
||||||
if (!contentJson) {
|
if (!contentJson) {
|
||||||
@@ -712,13 +716,13 @@ const onSelectMenuMsgItem = async (label) => {
|
|||||||
case 'revoke':
|
case 'revoke':
|
||||||
msgChatRevokeMsgService({
|
msgChatRevokeMsgService({
|
||||||
sessionId: props.sessionId,
|
sessionId: props.sessionId,
|
||||||
revokeMsgId: msg.value.msgId, // 服务器上删除用msg.value.msgId
|
revokeMsgId: msg.value.msgId, // 服务器上撤销用msg.value.msgId
|
||||||
isGroupChat: isGroupChatMsgType.value,
|
isGroupChat: isGroupChatMsgType.value,
|
||||||
remoteId: messageData.sessionList[props.sessionId].remoteId
|
remoteId: messageData.sessionList[props.sessionId].remoteId
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.code === 0) {
|
if (res.data.code === 0) {
|
||||||
// 本地删除用props.msgKey,因为key有可能是发送消息时产生的本地UUID
|
// 本地撤销用props.msgKey,因为key有可能是发送消息时产生的本地UUID
|
||||||
messageData.revokeMsgRcord(props.sessionId, props.msgKey)
|
messageData.revokeMsgRcord(props.sessionId, props.msgKey)
|
||||||
isReeditTimeOut.value = false
|
isReeditTimeOut.value = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -731,6 +735,22 @@ const onSelectMenuMsgItem = async (label) => {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
case 'delete':
|
||||||
|
msgChatDeleteMsgService({
|
||||||
|
sessionId: props.sessionId,
|
||||||
|
deleteMsgId: msg.value.msgId // 服务器上删除用msg.value.msgId
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
// 本地删除用props.msgKey,因为key有可能是发送消息时产生的本地UUID
|
||||||
|
messageData.removeMsgRecord(props.sessionId, props.msgKey)
|
||||||
|
ElMessage.success('消息已删除')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -778,7 +798,7 @@ watch(
|
|||||||
v-html="systemMsgContent"
|
v-html="systemMsgContent"
|
||||||
@click="onClickSystemMsg"
|
@click="onClickSystemMsg"
|
||||||
></div>
|
></div>
|
||||||
<div v-else-if="!isSystemMsg && isRevoke" class="revoke-wrapper">
|
<div v-else-if="!isSystemMsg && isRevoke" class="revoke-delete">
|
||||||
<div v-if="isSelf">
|
<div v-if="isSelf">
|
||||||
<span>你撤回了一条消息</span>
|
<span>你撤回了一条消息</span>
|
||||||
<span
|
<span
|
||||||
@@ -794,6 +814,9 @@ watch(
|
|||||||
<div v-else>{{ `“${objectInfo.nickName}”撤回了一条消息` }}</div>
|
<div v-else>{{ `“${objectInfo.nickName}”撤回了一条消息` }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="!isSystemMsg && isDelete" class="revoke-delete">
|
||||||
|
<span>消息已删除</span>
|
||||||
|
</div>
|
||||||
<div v-else class="message-container-wrapper">
|
<div v-else class="message-container-wrapper">
|
||||||
<el-container class="el-container-right" v-if="isSelf">
|
<el-container class="el-container-right" v-if="isSelf">
|
||||||
<el-main class="el-main-right">
|
<el-main class="el-main-right">
|
||||||
@@ -949,7 +972,7 @@ watch(
|
|||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.revoke-wrapper {
|
.revoke-delete {
|
||||||
padding: 2px 4px 2px 4px;
|
padding: 2px 4px 2px 4px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user