更新编辑器功能,新增编辑消息事件处理,优化撤回消息组件,调整相关事件总线
This commit is contained in:
parent
fca127b42b
commit
419bde4db2
2
components.d.ts
vendored
2
components.d.ts
vendored
@ -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']
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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 }}" 撤回了一条消息 |
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -4,5 +4,6 @@ export const enum ContactConst {
|
||||
|
||||
export const enum EditorConst {
|
||||
Mention = 'editor:mention',
|
||||
Quote = 'editor:quote'
|
||||
Quote = 'editor:quote',
|
||||
Edit = 'editor:edit'
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user