91 lines
1.9 KiB
Vue
91 lines
1.9 KiB
Vue
<script setup>
|
|
import { formatTime } from '@/utils/datetime'
|
|
import { bus } from '@/utils/event-bus'
|
|
import { EditorConst } from '@/constant/event-bus'
|
|
|
|
const props = defineProps({
|
|
login_uid: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
user_id: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
talk_type: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
nickname: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
datetime: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
data: {
|
|
type: Object,
|
|
default: () => {}
|
|
}
|
|
})
|
|
|
|
const onRevoke = () => {
|
|
// 只处理文本消息
|
|
if (props.data.msg_type === 1 && props.data.extra?.content) {
|
|
// 通过事件总线发送编辑消息事件
|
|
bus.emit(EditorConst.Edit, {
|
|
content: props.data.extra.content
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
<template>
|
|
<div class="im-message-revoke">
|
|
<div class="content">
|
|
<div v-if="login_uid === user_id">
|
|
<span> 你撤回了一条消息 | {{ formatTime(datetime) }} </span>
|
|
<n-button @click="onRevoke" v-if="data.msg_type === 1&&data.extra?.content&&data.is_self_action" text class="text-#46299D text-11px">重新编辑</n-button>
|
|
</div>
|
|
<span v-else-if="talk_type == 1"> 对方撤回了一条消息 | {{ formatTime(datetime) }} </span>
|
|
<span v-else>
|
|
"{{ nickname }}" 撤回了一条消息 |
|
|
{{ formatTime(datetime) }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<style lang="less" scoped>
|
|
.im-message-revoke {
|
|
display: flex;
|
|
justify-content: center;
|
|
|
|
.content {
|
|
margin: 10px auto;
|
|
background-color: #f5f5f5;
|
|
font-size: 11px;
|
|
line-height: 30px;
|
|
padding: 0 8px;
|
|
word-break: break-all;
|
|
word-wrap: break-word;
|
|
color: #979191;
|
|
user-select: none;
|
|
font-weight: 300;
|
|
display: inline-block;
|
|
border-radius: 3px;
|
|
|
|
span {
|
|
margin: 0 5px;
|
|
}
|
|
}
|
|
}
|
|
|
|
html[theme-mode='dark'] {
|
|
.im-message-revoke {
|
|
.content {
|
|
background: unset;
|
|
}
|
|
}
|
|
}
|
|
</style>
|