From 35b97b1ec01e5b03a935247fa9153143f92ee29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Sun, 19 May 2024 15:30:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=86=85=E5=AE=B9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/im/conversation/index.ts | 27 ++++++ src/layout/components/ImChat/src/ImChat.vue | 6 +- src/utils/fileSizeFormat.ts | 6 ++ src/utils/paseLink.ts | 20 ++++ .../components/ConversationList.vue | 66 ++++--------- src/views/im/Conversation/index.vue | 17 +--- src/views/im/InformDetails/index.vue | 7 -- .../Message/components/messageList/index.vue | 94 ++++--------------- src/views/im/Message/index.vue | 64 +++++++++---- src/views/im/index.vue | 4 +- 10 files changed, 146 insertions(+), 165 deletions(-) create mode 100644 src/api/im/conversation/index.ts create mode 100644 src/utils/fileSizeFormat.ts create mode 100644 src/utils/paseLink.ts delete mode 100644 src/views/im/InformDetails/index.vue diff --git a/src/api/im/conversation/index.ts b/src/api/im/conversation/index.ts new file mode 100644 index 00000000..a60956fb --- /dev/null +++ b/src/api/im/conversation/index.ts @@ -0,0 +1,27 @@ +import request from '@/config/axios' + +export interface ImConversationRespVO { + id: number // 编号 + userId: number // 所属用户 + conversationType: number // 会话类型 + targetId: number // 聊天对象编号 + no: string // 会话标志 + pinned: boolean // 是否置顶 + lastReadTime: string // 最后已读时间 + createTime: string // 创建时间 +} + +// 获得用户的会话列表 +export const getConversationList = async () => { + return await request.get({ url: `/im/conversation/list` }) +} + +// 置顶会话 +export const updatePinned = async (data: any) => { + return await request.post({ url: `/im/conversation/update-pinned`, data }) +} + +// 更新最后已读时间 +export const updateLastReadTime = async (data: any) => { + return await request.post({ url: `/im/conversation/update-last-read-time`, data }) +} diff --git a/src/layout/components/ImChat/src/ImChat.vue b/src/layout/components/ImChat/src/ImChat.vue index 1f087a14..e3b92d73 100644 --- a/src/layout/components/ImChat/src/ImChat.vue +++ b/src/layout/components/ImChat/src/ImChat.vue @@ -1,12 +1,12 @@ diff --git a/src/views/im/Message/index.vue b/src/views/im/Message/index.vue index 5f89bf32..3b70e5f8 100644 --- a/src/views/im/Message/index.vue +++ b/src/views/im/Message/index.vue @@ -4,6 +4,7 @@ import { messageType } from '@/constant/im' /* 组件 */ import MessageList from './components/messageList/index.vue' import InputBox from './components/inputBox/index.vue' +import * as MessageApi from '@/api/im/message' const { query } = useRoute() // 查询参数 @@ -47,34 +48,70 @@ const messageData = computed(() => [ id: 1, type: ALL_MESSAGE_TYPE.TEXT, isRecall: false, - time: '1711944000000', + time: '1711944110000', from: '1', - msg: 'Hello, world!', + msg: 'Hello, world!111', modifiedInfo: { operationCount: 1 - } + }, + customExts: { + nickname: '芋道源码', + avatar: 'https://avatars.githubusercontent.com/u/2?v=4' + }, + customEvent: { + type: '1', + data: { + type: '1', + data: 'https://avatars.githubusercontent.com/u/2?v=4' + } + }, + file_length: 0 }, { id: 2, type: ALL_MESSAGE_TYPE.TEXT, isRecall: false, - time: '1711944001000', + time: '1711944221000', from: '2', - msg: 'Hi, there!', + msg: 'Hi, there!222', modifiedInfo: { operationCount: 0 - } + }, + customExts: { + nickname: '芋道源码', + avatar: 'https://avatars.githubusercontent.com/u/2?v=4' + }, + customEvent: { + type: '1', + data: { + type: '1', + data: 'https://avatars.githubusercontent.com/u/2?v=4' + } + }, + file_length: 0 }, { id: 3, type: ALL_MESSAGE_TYPE.TEXT, - isRecall: true, - time: '1711944002000', + isRecall: false, + time: '1711944332000', from: '1', - msg: 'Hello, world!', + msg: 'Hello, world!333', modifiedInfo: { operationCount: 0 - } + }, + customExts: { + nickname: '芋道源码', + avatar: 'https://avatars.githubusercontent.com/u/2?v=4' + }, + customEvent: { + type: '1', + data: { + type: '1', + data: 'https://avatars.githubusercontent.com/u/2?v=4' + } + }, + file_length: 0 } ]) @@ -117,12 +154,7 @@ const messageQuote = (msg) => inputBox.value.handleQuoteMessage(msg)
-
+
-import { ref, defineAsyncComponent } from 'vue' +import { shallowRef, defineAsyncComponent, DefineComponent } from 'vue' import NavBar from './NavBar/index.vue' // 定义异步加载的组件 @@ -7,7 +7,7 @@ const ConversationComponent = defineAsyncComponent( () => import('@/views/im/Conversation/index.vue') ) -const currentComponent = ref(ConversationComponent) // 默认加载对话组件 +const currentComponent = shallowRef(ConversationComponent) // 默认加载对话组件 defineOptions({ name: 'IM' })