diff --git a/src/api/system/dept/index.ts b/src/api/system/dept/index.ts index 04d5c880..f212b407 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 beb6e515..1618b2e5 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 d1427899..93f1ef3d 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 dae35248..98ac2b4f 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 a11f9ca4..8f5fd02e 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 6b33c3ef..a1593c1f 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 6aa3e194..9bb7a2b1 100644 --- a/src/views/chat/components/Conversation/index.vue +++ b/src/views/chat/components/Conversation/index.vue @@ -1,5 +1,5 @@