From 063a61644a30e192069d898fd2d2161b6701bd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Mon, 27 May 2024 23:41:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=20websocket=20=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/im/message/index.ts | 11 +- src/layout/components/ImChat/src/ImChat.vue | 12 ++ src/store/modules/imMessageStore.ts | 26 +++ src/store/modules/webSocketStore.ts | 81 ++++++++++ .../im/Contacts/components/contactInfo.vue | 150 ++++++++++++++++++ .../im/Contacts/components/friendItem.vue | 116 ++++++++++++++ src/views/im/Contacts/index.vue | 33 +++- .../im/Message/components/inputBox/index.vue | 4 +- .../Message/components/messageList/index.vue | 124 +++------------ src/views/im/Message/index.vue | 92 +++-------- src/views/im/index.vue | 26 ++- 11 files changed, 473 insertions(+), 202 deletions(-) create mode 100644 src/store/modules/imMessageStore.ts create mode 100644 src/store/modules/webSocketStore.ts create mode 100644 src/views/im/Contacts/components/contactInfo.vue create mode 100644 src/views/im/Contacts/components/friendItem.vue diff --git a/src/api/im/message/index.ts b/src/api/im/message/index.ts index d8a9a54d..a127aa43 100644 --- a/src/api/im/message/index.ts +++ b/src/api/im/message/index.ts @@ -26,17 +26,22 @@ export interface ImMessageRespVO { sequence: number // 序号 } +export interface pullParams { + sequence: number + size: number +} + // 发送消息 -export const sendMessage = async (data: ImMessageSendReqVO) => { +export const sendMessage = async (data: ImMessageSendReqVO): Promise => { return await request.post({ url: `/im/message/send`, data }) } // 消息列表-拉取大于 sequence 的消息列表 -export const pullMessageList = async (params: { sequence: number; size: number }) => { +export const pullMessageList = async (params: pullParams): Promise => { return await request.get({ url: `/im/message/pull`, params }) } // 消息列表-根据接收人和发送时间进行分页查询 -export const getMessageList = async (params: any) => { +export const getMessageList = async (params: any): Promise => { return await request.get({ url: `/im/message/list`, params }) } diff --git a/src/layout/components/ImChat/src/ImChat.vue b/src/layout/components/ImChat/src/ImChat.vue index e3b92d73..164cd8a1 100644 --- a/src/layout/components/ImChat/src/ImChat.vue +++ b/src/layout/components/ImChat/src/ImChat.vue @@ -1,6 +1,7 @@