✨ feat(im): 增加群消息的回执开关,通过向下箭头
parent
8847cdb79f
commit
29695b649a
|
|
@ -18,7 +18,7 @@ import { useUserStore } from '@/store/modules/user'
|
||||||
/** 非文本消息的扩展选项(通用) */
|
/** 非文本消息的扩展选项(通用) */
|
||||||
interface SendExtOptions {
|
interface SendExtOptions {
|
||||||
atUserIds?: number[] // 群聊 @ 的用户编号列表
|
atUserIds?: number[] // 群聊 @ 的用户编号列表
|
||||||
needReceipt?: boolean // 是否需要群回执(默认 false)
|
receipt?: boolean // 是否需要群回执(默认 false)
|
||||||
targetId?: number // 覆盖默认的 targetId
|
targetId?: number // 覆盖默认的 targetId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ export const useMessageSender = () => {
|
||||||
type,
|
type,
|
||||||
content,
|
content,
|
||||||
atUserIds: options?.atUserIds,
|
atUserIds: options?.atUserIds,
|
||||||
receipt: options?.needReceipt
|
receipt: options?.receipt
|
||||||
})
|
})
|
||||||
conversationStore.ackMessage(conversation.type, realTarget, clientMessageId, {
|
conversationStore.ackMessage(conversation.type, realTarget, clientMessageId, {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,24 @@
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</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 下沿贴工具栏顶部,向上弹出(对齐工具栏左侧首图标) -->
|
<!-- 表情面板:bottom-full 让 picker 下沿贴工具栏顶部,向上弹出(对齐工具栏左侧首图标) -->
|
||||||
<EmojiPicker
|
<EmojiPicker
|
||||||
|
|
@ -220,7 +237,7 @@ function collectFromEditor(root: HTMLElement): { text: string; atUserIds: number
|
||||||
* (顺序很重要:先清后 sync,否则 sync 看到旧内容会误判)
|
* (顺序很重要:先清后 sync,否则 sync 看到旧内容会误判)
|
||||||
* 5. 上送:atUserIds 非空才传,避免发空数组
|
* 5. 上送:atUserIds 非空才传,避免发空数组
|
||||||
*/
|
*/
|
||||||
async function handleSend() {
|
async function handleSend(options?: { receipt?: boolean }) {
|
||||||
const editor = editorRef.value
|
const editor = editorRef.value
|
||||||
if (!canSend.value || !editor) {
|
if (!canSend.value || !editor) {
|
||||||
return
|
return
|
||||||
|
|
@ -233,7 +250,17 @@ async function handleSend() {
|
||||||
editor.innerHTML = ''
|
editor.innerHTML = ''
|
||||||
syncEditorState()
|
syncEditorState()
|
||||||
// 2. 发送
|
// 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 })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 选区 / 插入 ====================
|
// ==================== 选区 / 插入 ====================
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue