新增:发送消息

This commit is contained in:
安浩浩
2024-05-08 23:09:33 +08:00
parent 93ba6c579a
commit ac66084650
5 changed files with 172 additions and 124 deletions

View File

@ -2,43 +2,21 @@
import { formatDate } from '@/utils/formatTime'
/* 默认头像 */
import defaultAvatar from '@/assets/imgs/avatar.gif'
/* emits */
const emit = defineEmits(['scroll-message-list', 're-edit-message', 'message-quote'])
const messageData = ref([
{
id: 1,
type: 'text',
isRecall: false,
time: '2024-04-01 12:00:00',
from: '1',
msg: 'Hello, world!',
modifiedInfo: {
operationCount: 1
}
/* props */
const props = defineProps({
messageData: {
type: [Array, Object],
default: () => []
},
{
id: 2,
type: 'text',
isRecall: false,
time: '2024-04-01 12:00:01',
from: '2',
msg: 'Hi, there!',
modifiedInfo: {
operationCount: 0
}
},
{
id: 3,
type: 'text',
isRecall: true,
time: '2024-04-01 12:00:02',
from: '1',
msg: 'Hello, world!',
modifiedInfo: {
operationCount: 0
}
nowPickInfo: {
type: Object,
default: () => ({}),
required: true
}
])
})
const { nowPickInfo } = toRefs(props)
const { messageData } = toRefs(props)
//消息类型
const ALL_MESSAGE_TYPE = {
TEXT: 'txt',
IMAGE: 'img',
@ -52,6 +30,7 @@ const ALL_MESSAGE_TYPE = {
}
/* 处理时间显示间隔 */
const handleMsgTimeShow = (time, index) => {
console.log('>>>>>时间显示', time, index)
const msgList = Array.from(messageData.value)
if (index !== 0) {
const lastTime = msgList[index - 1].time
@ -108,10 +87,6 @@ const startplayAudio = (msgBody) => {
audioPlayStatus.playMsgId = ''
})
}
//父组件重新编辑方法
const reEdit = (msg) => emit('reEditMessage', msg)
//调用父组件引用消息
const onMsgQuote = (msg) => emit('messageQuote', msg)
</script>
<template>
<div>