feat(im): 增加群消息的回执开关,通过向下箭头

im
YunaiV 2026-04-27 23:54:41 +08:00
parent 8847cdb79f
commit 29695b649a
2 changed files with 32 additions and 5 deletions

View File

@ -18,7 +18,7 @@ import { useUserStore } from '@/store/modules/user'
/** 非文本消息的扩展选项(通用) */
interface SendExtOptions {
atUserIds?: number[] // 群聊 @ 的用户编号列表
needReceipt?: boolean // 是否需要群回执(默认 false
receipt?: boolean // 是否需要群回执(默认 false
targetId?: number // 覆盖默认的 targetId
}
@ -110,7 +110,7 @@ export const useMessageSender = () => {
type,
content,
atUserIds: options?.atUserIds,
receipt: options?.needReceipt
receipt: options?.receipt
})
conversationStore.ackMessage(conversation.type, realTarget, clientMessageId, {
id: data.id,

View File

@ -68,7 +68,24 @@
</el-tooltip>
</div>
<el-button type="primary" :disabled="!canSend" @click="handleSend"> </el-button>
<!-- 群聊发送按钮 + 下拉菜单点主按钮普通发送 / 发送回执消息对齐微信 PC -->
<el-dropdown
v-if="isGroup"
split-button
type="primary"
:disabled="!canSend"
@click="handleSend()"
@command="handleSendCommand"
>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="receipt">发送回执消息</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<!-- 私聊普通发送按钮私聊没有群回执概念 -->
<el-button v-else type="primary" :disabled="!canSend" @click="handleSend()"> </el-button>
<!-- 表情面板bottom-full picker 下沿贴工具栏顶部向上弹出对齐工具栏左侧首图标 -->
<EmojiPicker
@ -220,7 +237,7 @@ function collectFromEditor(root: HTMLElement): { text: string; atUserIds: number
* 顺序很重要先清后 sync否则 sync 看到旧内容会误判
* 5. 上送atUserIds 非空才传避免发空数组
*/
async function handleSend() {
async function handleSend(options?: { receipt?: boolean }) {
const editor = editorRef.value
if (!canSend.value || !editor) {
return
@ -233,7 +250,17 @@ async function handleSend() {
editor.innerHTML = ''
syncEditorState()
// 2.
await send(text, atUserIds.length > 0 ? { atUserIds } : undefined)
await send(text, {
atUserIds: atUserIds.length > 0 ? atUserIds : undefined,
receipt: options?.receipt
})
}
/** 发送按钮 dropdown 菜单回调:选"发送回执消息"时这一次带 receipt=true每次独立决定 */
function handleSendCommand(command: string) {
if (command === 'receipt') {
handleSend({ receipt: true })
}
}
// ==================== / ====================