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' })