From 5c1bb2523732e01fab5bd99dd36624069307d629 Mon Sep 17 00:00:00 2001 From: dylanmay <670374839@qq.com> Date: Thu, 12 Dec 2024 22:19:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=81=94=E7=B3=BB=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/dept/index.ts | 3 +- src/api/system/user/index.ts | 9 ++ src/store/indexedDB.ts | 5 +- src/views/chat/ChatPage/Index.vue | 28 ++++- src/views/chat/api/sessionApi.ts | 20 +++- .../chat/components/ChatHeader/Index.vue | 2 +- .../chat/components/Conversation/index.vue | 2 +- .../components/ConversationItem/index.vue | 4 +- .../Department/components/TreeNode.vue | 53 +++++++++ .../Department/components/TreeView.vue | 28 +++++ .../chat/components/Department/index.vue | 63 ++++++++++ .../chat/components/FriendDetail/Index.vue | 20 +++- .../chat/components/FriendItem/Index.vue | 6 +- src/views/chat/components/Friends/Index.vue | 5 +- .../chat/components/ToolSection/Index.vue | 42 ++++--- src/views/chat/model/Friend.ts | 6 +- src/views/chat/store/chatstore.ts | 71 +++++++++++- src/views/chat/store/friendstore.ts | 108 ++++++++++++++---- src/views/chat/store/websocketStore.ts | 8 ++ src/views/chat/types/types.ts | 3 +- 20 files changed, 421 insertions(+), 65 deletions(-) create mode 100644 src/views/chat/components/Department/components/TreeNode.vue create mode 100644 src/views/chat/components/Department/components/TreeView.vue create mode 100644 src/views/chat/components/Department/index.vue diff --git a/src/api/system/dept/index.ts b/src/api/system/dept/index.ts index 04d5c8807..f212b4079 100644 --- a/src/api/system/dept/index.ts +++ b/src/api/system/dept/index.ts @@ -1,7 +1,7 @@ import request from '@/config/axios' export interface DeptVO { - id?: number + id: number name: string parentId: number status: number @@ -10,6 +10,7 @@ export interface DeptVO { phone: string email: string createTime: Date + children?: DeptVO[] } // 查询部门(精简)列表 diff --git a/src/api/system/user/index.ts b/src/api/system/user/index.ts index beb6e5154..1618b2e55 100644 --- a/src/api/system/user/index.ts +++ b/src/api/system/user/index.ts @@ -27,6 +27,15 @@ export const getAllUser = () => { return request.get({ url: '/system/user/all' }) } +/** + * 获取部门成员 + * @param id + * @returns + */ +export const getDeptUser = (id: number) => { + return request.get({ url: '/system/user/listByDept?id='+ id }) +} + // 查询用户详情 export const getUser = (id: number) => { return request.get({ url: '/system/user/get?id=' + id }) diff --git a/src/store/indexedDB.ts b/src/store/indexedDB.ts index d14278996..93f1ef3d8 100644 --- a/src/store/indexedDB.ts +++ b/src/store/indexedDB.ts @@ -1,3 +1,4 @@ +import { CACHE_KEY, useCache } from '@/hooks/web/useCache' import { ConversationModelType } from '@/views/chat/types/types' import { openDB, DBSchema, IDBPDatabase } from 'idb' @@ -14,7 +15,9 @@ let dbPromise: Promise> export const initDB = () => { if (!dbPromise) { try { - dbPromise = openDB('yudao-im-indexeddb', 1, { + const { wsCache } = useCache() + const user = wsCache.get(CACHE_KEY.USER).user + dbPromise = openDB('yudao-im-indexeddb-' + user.id, 1, { upgrade(db) { db.createObjectStore('Conversations', { keyPath: 'conversationNo' }) } diff --git a/src/views/chat/ChatPage/Index.vue b/src/views/chat/ChatPage/Index.vue index dae352481..98ac2b4f0 100644 --- a/src/views/chat/ChatPage/Index.vue +++ b/src/views/chat/ChatPage/Index.vue @@ -1,14 +1,17 @@ @@ -20,22 +23,35 @@ import ToolSection from '../components/ToolSection/Index.vue' import Session from '../components/Conversation/index.vue' import Friends from '../components/Friends/Index.vue' +import Department from '../components/Department/index.vue' import ChatHeader from '../components/ChatHeader/index.vue' import ChatMessage from '../components/ChatMessage/index.vue' import InputSection from '../components/InputSection/index.vue' import FriendDetail from '../components/FriendDetail/Index.vue' import { MENU_LIST_ENUM } from '../types/types' import { useWebSocketStore } from '../store/websocketStore' +import { useFriendStoreWithOut } from '../store/friendstore' +import { useChatStore } from '../store/chatstore' defineOptions({ name: 'ChatPage' }) -const bussinessType = ref(1) const webSocketStore = useWebSocketStore(); +const useFriendStore = useFriendStoreWithOut() +const { resetFriendList } = useFriendStore +const chatStore = useChatStore() +const { setBussinessType } = useChatStore() + onMounted(() => { webSocketStore.connect() }) +watch(() => chatStore.bussinessType, (newVal) => { + if (newVal !== MENU_LIST_ENUM.FRIENDS) { + resetFriendList() + } +}) + const toolMenuSelectChange = (value) => { - bussinessType.value = value + setBussinessType(value) } diff --git a/src/views/chat/api/sessionApi.ts b/src/views/chat/api/sessionApi.ts index a11f9ca44..8f5fd02e7 100644 --- a/src/views/chat/api/sessionApi.ts +++ b/src/views/chat/api/sessionApi.ts @@ -2,12 +2,17 @@ * @Author: dylan.may@qq.com * @Date: 2024-10-16 11:30:31 * @Last Modified by: dylan.may@qq.com - * @Last Modified time: 2024-10-16 16:01:25 + * @Last Modified time: 2024-11-28 17:32:26 */ import request from '@/config/axios' import { ChatConversation } from '../model/ChatConversation' +interface createConversationParam { + targetId: string, + type: number +} + /** * 会话接口 */ @@ -19,4 +24,17 @@ export default class SessionApi { static getSessionList(): Promise> { return request.get({ url: '/im/conversation/list' }) } + + + /** + * 创建会话 + * @param data createConversationParam + * @returns Promise + */ + static createConversation(data: createConversationParam):Promise { + return request.post({ + url: '/im/conversation/create', + data + }) + } } diff --git a/src/views/chat/components/ChatHeader/Index.vue b/src/views/chat/components/ChatHeader/Index.vue index 6b33c3efc..a1593c1f2 100644 --- a/src/views/chat/components/ChatHeader/Index.vue +++ b/src/views/chat/components/ChatHeader/Index.vue @@ -4,7 +4,7 @@ style="height: 60px; min-height: 60px" > diff --git a/src/views/chat/components/Conversation/index.vue b/src/views/chat/components/Conversation/index.vue index 6aa3e1945..9bb7a2b16 100644 --- a/src/views/chat/components/Conversation/index.vue +++ b/src/views/chat/components/Conversation/index.vue @@ -1,5 +1,5 @@