更新编辑器功能,新增编辑消息事件处理,优化撤回消息组件,调整相关事件总线

This commit is contained in:
Phoenix 2025-05-16 11:32:07 +08:00
parent fca127b42b
commit 419bde4db2
6 changed files with 48 additions and 24 deletions

2
components.d.ts vendored
View File

@ -59,9 +59,7 @@ declare module 'vue' {
NoticeEditor: typeof import('./src/components/group/manage/NoticeEditor.vue')['default']
NoticeTab: typeof import('./src/components/group/manage/NoticeTab.vue')['default']
NotificationApi: typeof import('./src/components/common/NotificationApi.vue')['default']
NProgress: typeof import('naive-ui')['NProgress']
NRadio: typeof import('naive-ui')['NRadio']
NTag: typeof import('naive-ui')['NTag']
NVirtualList: typeof import('naive-ui')['NVirtualList']
RevokeMessage: typeof import('./src/components/talk/message/RevokeMessage.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -572,6 +572,26 @@ function hideMentionDom() {
}
}
/**
* 处理编辑消息事件
* @param data 消息数据
*/
function onSubscribeEdit(data: any) {
console.log('data', data)
const quill = getQuill()
if (!quill) return
//
quill.setContents([])
//
quill.setText(data.content)
//
const index = quill.getLength() - 1
quill.setSelection(index > 0 ? index : 0, 0, 'user')
}
// 稿
watch(indexName, loadEditorDraftText, { immediate: true })
@ -588,7 +608,8 @@ onUnmounted(() => {
// 线
useEventBus([
{ name: EditorConst.Mention, event: onSubscribeMention }, // @
{ name: EditorConst.Quote, event: onSubscribeQuote } //
{ name: EditorConst.Quote, event: onSubscribeQuote }, //
{ name: EditorConst.Edit, event: onSubscribeEdit } //
])
</script>

View File

@ -1,7 +1,9 @@
<script setup>
import { formatTime } from '@/utils/datetime'
import { bus } from '@/utils/event-bus'
import { EditorConst } from '@/constant/event-bus'
defineProps({
const props = defineProps({
login_uid: {
type: Number,
default: 0
@ -21,13 +23,30 @@ defineProps({
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">
<span v-if="login_uid == user_id"> 你撤回了一条消息 | {{ formatTime(datetime) }} </span>
<div v-if="login_uid === user_id">
<span> 你撤回了一条消息 | {{ formatTime(datetime) }} </span>
<n-button @click="onRevoke" v-if="data.msg_type === 1&&data.extra?.content" text class="text-#46299D text-11px">重新编辑</n-button>
</div>
<span v-else-if="talk_type == 1"> 对方撤回了一条消息 | {{ formatTime(datetime) }} </span>
<span v-else>
"{{ nickname }}" 撤回了一条消息 |

View File

@ -171,23 +171,6 @@ function retryUpload(e) {
/> -->
</div>
</div>
<!-- 上传失败显示 -->
<div v-if="uploadFailed" class="upload-failed" @click.stop>
<n-popconfirm
placement="right"
@positive-click="retryUpload"
positive-text="重新发送"
negative-text="取消"
>
<template #trigger>
<div class="failed-icon">
<n-icon :component="Attention" size="22" color="#ff4d4f" />
</div>
</template>
确认重新发送该视频消息吗
</n-popconfirm>
</div>
<!-- 播放按钮仅在视频不是上传状态且未失败时显示 -->
<div v-if="!extra.is_uploading && !uploadFailed" class="btn-video">
<n-icon :component="Play" size="40" />
@ -218,6 +201,7 @@ function retryUpload(e) {
display: inline-flex;
position: relative;
height:149px;
width: 225px;
&.left {
background: var(--im-message-right-bg-color);
}

View File

@ -4,5 +4,6 @@ export const enum ContactConst {
export const enum EditorConst {
Mention = 'editor:mention',
Quote = 'editor:quote'
Quote = 'editor:quote',
Edit = 'editor:edit'
}

View File

@ -15,6 +15,7 @@ import { EditorConst } from '@/constant/event-bus'
import { useInject, useTalkRecord, useUtil } from '@/hooks'
import { ExclamationCircleFilled } from '@ant-design/icons-vue';
import { useUserStore } from '@/store'
import RevokeMessage from '@/components/talk/message/RevokeMessage.vue'
const props = defineProps({
uid: {
type: Number,
@ -296,7 +297,7 @@ onMounted(() => {
<!-- 撤回消息 -->
<div v-else-if="item.is_revoke == 1" class="message-box">
<revoke-message :login_uid="uid" :user_id="item.user_id" :nickname="item.nickname" :talk_type="item.talk_type"
<revoke-message :login_uid="uid" :data="item" :user_id="item.user_id" :nickname="item.nickname" :talk_type="item.talk_type"
:datetime="item.created_at" />
</div>