diff --git a/src/api/im/manager/statistics/index.ts b/src/api/im/manager/statistics/index.ts index 10d10fe5e..360e96afd 100644 --- a/src/api/im/manager/statistics/index.ts +++ b/src/api/im/manager/statistics/index.ts @@ -20,7 +20,7 @@ export interface ImStatisticsTrendVO { } export interface ImStatisticsMessageTypeVO { - type: number // 参见 ImMessageTypeEnum 枚举类,由前端按 DICT_TYPE.IM_MESSAGE_TYPE 翻译 + type: number // 参见 ImContentTypeEnum 枚举类,由前端按 DICT_TYPE.IM_CONTENT_TYPE 翻译 value: number } @@ -50,7 +50,7 @@ export const getUserTrend = (days: number): Promise => { return request.get({ url: '/im/manager/statistics/user-trend', params: { days } }) } -// 获得消息类型分布(最近 30 天) +// 获得内容类型分布(最近 30 天) export const getMessageTypeDistribution = (): Promise => { return request.get({ url: '/im/manager/statistics/message-type-distribution' diff --git a/src/api/im/message/group/index.ts b/src/api/im/message/group/index.ts index e8988e588..7bb4523a2 100644 --- a/src/api/im/message/group/index.ts +++ b/src/api/im/message/group/index.ts @@ -6,7 +6,7 @@ export interface ImGroupMessageRespVO { clientMessageId: string // 客户端消息编号 senderId: number // 发送人编号 groupId: number // 群编号 - type: number // 消息类型 + type: number // 内容类型 content: string // 消息内容(JSON 格式) status: number // 消息状态 sendTime: string // 发送时间 @@ -20,7 +20,7 @@ export interface ImGroupMessageRespVO { export interface ImGroupMessageSendReqVO { clientMessageId: string // 客户端消息编号 groupId: number // 群编号 - type: number // 消息类型 + type: number // 内容类型 content: string // 消息内容(JSON 格式) atUserIds?: number[] // @ 目标用户编号列表 receipt?: boolean // 是否需要回执 diff --git a/src/api/im/message/private/index.ts b/src/api/im/message/private/index.ts index 376347e0b..3c5bf16aa 100644 --- a/src/api/im/message/private/index.ts +++ b/src/api/im/message/private/index.ts @@ -6,7 +6,7 @@ export interface ImPrivateMessageRespVO { clientMessageId: string // 客户端消息编号 senderId: number // 发送人编号 receiverId: number // 接收人编号 - type: number // 消息类型 + type: number // 内容类型 content: string // 消息内容(JSON 格式) status: number // 消息状态(正常 / 已撤回) receiptStatus?: number // 回执状态(不需要 / 待完成 / 已完成),对齐 ImMessageReceiptStatus @@ -17,7 +17,7 @@ export interface ImPrivateMessageRespVO { export interface ImPrivateMessageSendReqVO { clientMessageId: string // 客户端消息编号 receiverId: number // 接收人编号 - type: number // 消息类型 + type: number // 内容类型 content: string // 消息内容(JSON 格式) receipt?: boolean // 是否需要回执;不传后端默认 true(普通私聊用户消息) } diff --git a/src/utils/dict.ts b/src/utils/dict.ts index cd82beaa1..f8032db94 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -328,7 +328,7 @@ export enum DICT_TYPE { MES_WM_PACKAGE_STATUS = 'mes_wm_package_status', // MES 装箱单状态 // ========== IM - 即时通讯模块 ========== - IM_MESSAGE_TYPE = 'im_message_type', // IM 消息类型 + IM_CONTENT_TYPE = 'im_content_type', // IM 内容类型 IM_MESSAGE_STATUS = 'im_message_status', // IM 消息状态:0=正常 / 2=已撤回(私聊 / 群聊共用) IM_MESSAGE_RECEIPT_STATUS = 'im_message_receipt_status', // IM 消息回执状态:0=不需要 / 1=待完成 / 2=已完成 IM_FRIEND_STATUS = 'im_friend_status', // IM 好友状态 diff --git a/src/views/im/home/components/user/RecommendCardDialog.vue b/src/views/im/home/components/user/RecommendCardDialog.vue index abdc04fea..95a5ef24b 100644 --- a/src/views/im/home/components/user/RecommendCardDialog.vue +++ b/src/views/im/home/components/user/RecommendCardDialog.vue @@ -115,7 +115,7 @@ import { useConversationStore } from '../../store/conversationStore' import { useFriendStore } from '../../store/friendStore' import { useGroupStore } from '../../store/groupStore' import { useMessageSender } from '../../composables/useMessageSender' -import { ImConversationType, ImMessageType, isGroupConversation } from '../../../utils/constants' +import { ImConversationType, ImContentType, isGroupConversation } from '../../../utils/constants' import { getConversationKey } from '../../../utils/conversation' import { buildDefaultGroupName } from '../../../utils/group' import { serializeMessage, type CardTarget } from '../../../utils/message' @@ -221,7 +221,7 @@ async function handleSend() { sending.value = true try { const tasks = targets.map(async (conversation) => { - const cardOk = await sendRaw(ImMessageType.CARD, cardContent, { conversation }) + const cardOk = await sendRaw(ImContentType.CARD, cardContent, { conversation }) if (!cardOk) { return { conversation, ok: false } } @@ -289,7 +289,7 @@ async function handleCreateGroupAndSend() { lastContent: '', lastSendTime: 0 } - const cardOk = await sendRaw(ImMessageType.CARD, serializeMessage({ ...card }), { + const cardOk = await sendRaw(ImContentType.CARD, serializeMessage({ ...card }), { conversation: newConversation }) if (!cardOk) { diff --git a/src/views/im/home/composables/useMediaUploader.ts b/src/views/im/home/composables/useMediaUploader.ts index cac807995..7c55c3823 100644 --- a/src/views/im/home/composables/useMediaUploader.ts +++ b/src/views/im/home/composables/useMediaUploader.ts @@ -7,7 +7,7 @@ import { useConversationStore } from '../store/conversationStore' import { useMessageStore } from '../store/messageStore' import { useMessageSender } from './useMessageSender' import { useMuteOverlay } from './useMuteOverlay' -import { ImMessageStatus, ImMessageType } from '../../utils/constants' +import { ImMessageStatus, ImContentType } from '../../utils/constants' import { MESSAGE_FILE_MAX_MB, MESSAGE_IMAGE_MAX_MB, @@ -56,17 +56,17 @@ export interface MediaTypeHandler { /** 媒体类型注册表:image / file / voice / video 各自的 kind + 首发 / 重传共用的 build / extract */ export const mediaTypeHandlers: Partial> = { - [ImMessageType.IMAGE]: { + [ImContentType.IMAGE]: { kind: '图片', build: (_file, url) => ({ url }) as ImageMessage, extractResendContext: () => ({}) }, - [ImMessageType.FILE]: { + [ImContentType.FILE]: { kind: '文件', build: (file, url) => ({ url, name: file.name, size: file.size }) as FileMessage, extractResendContext: () => ({}) }, - [ImMessageType.VOICE]: { + [ImContentType.VOICE]: { kind: '语音', build: (_file, url, context) => ({ url, duration: context.voiceDuration ?? 0 }) as AudioMessage, extractResendContext: (oldContent) => { @@ -74,7 +74,7 @@ export const mediaTypeHandlers: Partial> = { return { voiceDuration: old?.duration ?? 0 } } }, - [ImMessageType.VIDEO]: { + [ImContentType.VIDEO]: { kind: '视频', build: (file, url, context) => ({ @@ -101,7 +101,7 @@ export const mediaTypeHandlers: Partial> = { /** 单次媒体上传的入参(image / file / voice 走 uploadAndSendMedia;video 走低层 helper 自行组装) */ export interface UploadAndSendMediaOptions { file: File - /** 对齐 ImMessageType;mediaTypeHandlers 必须有对应项 */ + /** 对齐 ImContentType;mediaTypeHandlers 必须有对应项 */ type: number /** 媒体特定的元数据(如语音时长 / 视频元信息);不传按空对象处理 */ context?: MediaTypeContext @@ -124,23 +124,23 @@ export interface UploadAndSendMediaOptions { * * 任意失败把消息状态置 FAILED;MessageItem 上点重试再走一次本函数(_localFile 还在内存就行) */ -/** 按消息类型映射体积上限(MB);未识别类型返回 0 表示不限 */ +/** 按内容类型映射体积上限(MB);未识别类型返回 0 表示不限 */ function resolveMediaMaxMb(type: number): number { switch (type) { - case ImMessageType.IMAGE: + case ImContentType.IMAGE: return MESSAGE_IMAGE_MAX_MB - case ImMessageType.VIDEO: + case ImContentType.VIDEO: return MESSAGE_VIDEO_MAX_MB - case ImMessageType.VOICE: + case ImContentType.VOICE: return MESSAGE_VOICE_MAX_MB - case ImMessageType.FILE: + case ImContentType.FILE: return MESSAGE_FILE_MAX_MB default: return 0 } } -/** 校验媒体文件大小是否超过消息类型上限;超限触发 warn 并返回 false,调用方不应进入占位 / 上传链路 */ +/** 校验媒体文件大小是否超过内容类型上限;超限触发 warn 并返回 false,调用方不应进入占位 / 上传链路 */ export function ensureMediaSizeWithinLimit( file: File, type: number, diff --git a/src/views/im/home/composables/useMessagePuller.ts b/src/views/im/home/composables/useMessagePuller.ts index 85b778c18..a3d148462 100644 --- a/src/views/im/home/composables/useMessagePuller.ts +++ b/src/views/im/home/composables/useMessagePuller.ts @@ -23,7 +23,7 @@ import { pullMyConversationReadList as apiPullMyConversationReadList } from '@/a import { ImConversationType, ImMessageStatus, - ImMessageType, + ImContentType, isFriendChatTip, isFriendNotification } from '../../utils/constants' @@ -208,7 +208,7 @@ export const useMessagePuller = () => { if (isPrivate) { const message = raw as ImPrivateMessageRespVO // 特殊:撤回消息的处理 - if (message.type === ImMessageType.RECALL) { + if (message.type === ImContentType.RECALL) { pulledMessages.push({ kind: 'recall', conversationType: ImConversationType.PRIVATE, @@ -235,7 +235,7 @@ export const useMessagePuller = () => { } else { const message = raw as ImGroupMessageRespVO // 特殊:撤回消息的处理 - if (message.type === ImMessageType.RECALL) { + if (message.type === ImContentType.RECALL) { pulledMessages.push({ kind: 'recall', conversationType: ImConversationType.GROUP, diff --git a/src/views/im/home/composables/useMessageSender.ts b/src/views/im/home/composables/useMessageSender.ts index 2d5251611..820f7889b 100644 --- a/src/views/im/home/composables/useMessageSender.ts +++ b/src/views/im/home/composables/useMessageSender.ts @@ -19,7 +19,7 @@ import { type QuoteMessage, type TextMessage } from '../../utils/message' -import { ImMessageType, ImMessageStatus, ImConversationType } from '../../utils/constants' +import { ImContentType, ImMessageStatus, ImConversationType } from '../../utils/constants' import { MESSAGE_PRIVATE_READ_ENABLED, MESSAGE_GROUP_READ_ENABLED } from '../../utils/config' import { getClientConversationId } from '../../utils/db' import type { Conversation, Message } from '../types' @@ -193,7 +193,7 @@ export const useMessageSender = () => { return false } const payload = withQuotePayload({ content: text }, options?.quote) - return sendRaw(ImMessageType.TEXT, serializeMessage(payload), options) + return sendRaw(ImContentType.TEXT, serializeMessage(payload), options) } /** diff --git a/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue b/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue index 2ae328d5b..a31f632d5 100644 --- a/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue +++ b/src/views/im/home/pages/conversation/components/conversation/ConversationItem.vue @@ -107,7 +107,7 @@ import { useFriendStore } from '../../../../store/friendStore' import { useGroupStore } from '../../../../store/groupStore' import { useGroupRequestStore } from '../../../../store/groupRequestStore' import { useImUiStore } from '../../../../store/uiStore' -import { ImConversationType, ImMessageType, isNormalMessage } from '../../../../../utils/constants' +import { ImConversationType, ImContentType, isNormalMessage } from '../../../../../utils/constants' import { getSenderDisplayName } from '@/views/im/utils/user' import { buildRecallTip } from '@/views/im/utils/conversation' import type { Conversation } from '../../../../types' @@ -183,7 +183,7 @@ const lastContentDisplay = computed(() => { return draft.value.plain } if ( - props.conversation.lastMessageType === ImMessageType.RECALL && + props.conversation.lastMessageType === ImContentType.RECALL && props.conversation.lastSenderId != null ) { return buildRecallTip( diff --git a/src/views/im/home/pages/conversation/components/input/FacePicker.vue b/src/views/im/home/pages/conversation/components/input/FacePicker.vue index 2cee51023..5b61ad7e9 100644 --- a/src/views/im/home/pages/conversation/components/input/FacePicker.vue +++ b/src/views/im/home/pages/conversation/components/input/FacePicker.vue @@ -2,7 +2,7 @@ diff --git a/src/views/im/home/pages/conversation/components/input/MessageInput.vue b/src/views/im/home/pages/conversation/components/input/MessageInput.vue index 25c6ae80c..1c1e07a03 100644 --- a/src/views/im/home/pages/conversation/components/input/MessageInput.vue +++ b/src/views/im/home/pages/conversation/components/input/MessageInput.vue @@ -178,7 +178,7 @@ import { import { useMuteOverlay } from '@/views/im/home/composables/useMuteOverlay' import { isOpenableUrl } from '@/utils/url' import { getConversationKey } from '@/views/im/utils/conversation' -import { ImConversationType, ImGroupMemberRole, ImMessageType } from '@/views/im/utils/constants' +import { ImConversationType, ImGroupMemberRole, ImContentType } from '@/views/im/utils/constants' import { DANGEROUS_FILE_EXTENSIONS, MESSAGE_GROUP_READ_ENABLED } from '@/views/im/utils/config' import { serializeMessage, @@ -616,7 +616,7 @@ async function onSelectFace(face: { url: string; width: number; height: number; { url: face.url, width: face.width, height: face.height, name: face.name }, replyQuote ) - await sendRaw(ImMessageType.FACE, serializeMessage(payload), { conversation }) + await sendRaw(ImContentType.FACE, serializeMessage(payload), { conversation }) } // ==================== @ 成员选择(群聊) ==================== @@ -862,7 +862,7 @@ async function uploadAndSendImage(file: File) { } await uploadAndSendMedia({ file, - type: ImMessageType.IMAGE, + type: ImContentType.IMAGE, quote: context.quote, conversation: context.conversation }) @@ -882,7 +882,7 @@ async function uploadAndSendFile(file: File) { } await uploadAndSendMedia({ file, - type: ImMessageType.FILE, + type: ImContentType.FILE, quote: context.quote, conversation: context.conversation }) @@ -924,7 +924,7 @@ async function onVoiceSend(payload: { blob: Blob; duration: number }) { const file = new File([payload.blob], `voice-${Date.now()}.webm`, { type: payload.blob.type }) await uploadAndSendMedia({ file, - type: ImMessageType.VOICE, + type: ImContentType.VOICE, quote: context.quote, conversation: context.conversation, context: { voiceDuration: payload.duration } @@ -1034,7 +1034,7 @@ async function probeVideoFile(file: File): Promise { * 4. 视频链路耗时长,上传期间用户切会话则放弃发送(避免落到错误会话里);切走再切回来不算变化(key 仍相等) */ async function uploadAndSendVideo(file: File) { - if (!ensureMediaSizeWithinLimit(file, ImMessageType.VIDEO, message.warning)) { + if (!ensureMediaSizeWithinLimit(file, ImContentType.VIDEO, message.warning)) { return } const context = prepareMediaUpload() @@ -1049,12 +1049,12 @@ async function uploadAndSendVideo(file: File) { // (