From 755bf1bb08f5bf6dcf74513bd5ee1d755b3ae5c4 Mon Sep 17 00:00:00 2001 From: dylanmay <670374839@qq.com> Date: Mon, 28 Oct 2024 16:30:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89conversatNo=E7=9A=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chat/api/messageApi.ts | 8 +++++--- src/views/chat/components/InputSection/Index.vue | 2 +- src/views/chat/model/BaseMessage.ts | 6 +++--- src/views/chat/model/ImageMessage.ts | 4 ++-- src/views/chat/model/TextMessage.ts | 4 ++-- src/views/chat/store/chatstore.ts | 7 +++++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/views/chat/api/messageApi.ts b/src/views/chat/api/messageApi.ts index c882f9ca..d086b639 100644 --- a/src/views/chat/api/messageApi.ts +++ b/src/views/chat/api/messageApi.ts @@ -17,8 +17,10 @@ export interface SendMsg { } export interface SessionMsgReq { - conversationNo: string - sendTime: Date + sendTime: string + receiverId: number + userId: number + conversationType: number } /** @@ -40,7 +42,7 @@ export default class MessageApi { * @returns Promise> */ static getSessionMsg(params: SessionMsgReq): Promise> { - return request.get({ url: '/im/message/listByNo', params }) + return request.get({ url: '/im/message/list', params }) } /** diff --git a/src/views/chat/components/InputSection/Index.vue b/src/views/chat/components/InputSection/Index.vue index 62f282c5..fe26348e 100644 --- a/src/views/chat/components/InputSection/Index.vue +++ b/src/views/chat/components/InputSection/Index.vue @@ -55,7 +55,7 @@ const createTextMessage = (content: string): TextMessage => { chatStore.currentSession?.id || '', chatStore.currentSession ? chatStore.currentSession.targetId : 0, chatStore.currentSession?.type || CONVERSATION_TYPE.SINGLE, - chatStore.currentSession?.conversationNo || '' + chatStore.currentSession?.senderId || '' ) return msg diff --git a/src/views/chat/model/BaseMessage.ts b/src/views/chat/model/BaseMessage.ts index 4a3a86b7..c65834f8 100644 --- a/src/views/chat/model/BaseMessage.ts +++ b/src/views/chat/model/BaseMessage.ts @@ -13,7 +13,7 @@ export default class BaseMessage { clientMessageId: string receiverId: number conversationType: number - conversationNo: string + conversationUserId: number constructor( id: string, avatar: string, @@ -26,7 +26,7 @@ export default class BaseMessage { conversationId: string, receiverId: number, conversationType: number, - conversationNo: string + conversationUserId: number ) { this.id = id this.avatar = avatar @@ -40,7 +40,7 @@ export default class BaseMessage { this.receiverId = receiverId this.clientMessageId = this.generateClientMessageId() this.conversationType = conversationType - this.conversationNo = conversationNo + this.conversationUserId = conversationUserId } private generateClientMessageId() { diff --git a/src/views/chat/model/ImageMessage.ts b/src/views/chat/model/ImageMessage.ts index e7030c2f..35717431 100644 --- a/src/views/chat/model/ImageMessage.ts +++ b/src/views/chat/model/ImageMessage.ts @@ -16,7 +16,7 @@ export default class ImageMessage extends BaseMessage { conversationId: string, receiverId: number, conversationType: number, - conversationNo: string + conversationUserId: number ) { super( id, @@ -30,7 +30,7 @@ export default class ImageMessage extends BaseMessage { conversationId, receiverId, conversationType, - conversationNo + conversationUserId ) this.content = content } diff --git a/src/views/chat/model/TextMessage.ts b/src/views/chat/model/TextMessage.ts index 57be8a5b..75fb416f 100644 --- a/src/views/chat/model/TextMessage.ts +++ b/src/views/chat/model/TextMessage.ts @@ -16,7 +16,7 @@ export default class TextMessage extends BaseMessage { conversationId: string, receiverId: number, conversationType: number, - conversationNo: string + conversationUserId: number ) { super( id, @@ -30,7 +30,7 @@ export default class TextMessage extends BaseMessage { conversationId, receiverId, conversationType, - conversationNo + conversationUserId ) this.content = content } diff --git a/src/views/chat/store/chatstore.ts b/src/views/chat/store/chatstore.ts index c7f7f17b..c2d1b91f 100644 --- a/src/views/chat/store/chatstore.ts +++ b/src/views/chat/store/chatstore.ts @@ -6,6 +6,7 @@ import { ConversationModelType, MessageRole, ContentType, SendStatus } from '../ import SessionApi from '../api/sessionApi' import MessageApi, { SendMsg } from '../api/messageApi' import { useUserStoreWithOut } from '@/store/modules/user' +import { formatDate } from '@/utils/formatTime' // TODO @dylan:是不是 chat => im;session => conversation;这样统一一点哈。 interface ChatStoreModel { @@ -142,8 +143,10 @@ export const useChatStore = defineStore('chatStore', { try { const res = await MessageApi.getSessionMsg({ - conversationNo: this.currentSession.conversationNo - // sendTime: new Date().toISOString().slice(0, -1) + receiverId: this.currentSession.targetId, + userId: this.currentSession.senderId, + // sendTime: formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss') + conversationType: this.currentSession.type }) this.currentSession.msgList = res.map((item) => {