diff --git a/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfo.cs b/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfo.cs index 8145089..568afa5 100644 --- a/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfo.cs +++ b/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfo.cs @@ -14,7 +14,11 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("IMTest")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +<<<<<<< HEAD [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+eb8455e141ea496a2134ad7c7d9b759b6029dd75")] +======= +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f7223dc5904286fdf8e117b56c37f58dc431d68b")] +>>>>>>> eb8455e141ea496a2134ad7c7d9b759b6029dd75 [assembly: System.Reflection.AssemblyProductAttribute("IMTest")] [assembly: System.Reflection.AssemblyTitleAttribute("IMTest")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfoInputs.cache b/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfoInputs.cache index 2827c86..c1ab4c0 100644 --- a/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfoInputs.cache +++ b/backend/IMTest/obj/Debug/net8.0/IMTest.AssemblyInfoInputs.cache @@ -1 +1,5 @@ +<<<<<<< HEAD 546570633bb9288fc2957cbb29a807a45f3e48ba127ec13bc3956d28f5e6ed5b +======= +3c0a5335719f892c65744a9df7eae9fd7b12de9067131f5c9f4cb65f2b27b8d4 +>>>>>>> eb8455e141ea496a2134ad7c7d9b759b6029dd75 diff --git a/backend/IM_API/Application/EventHandlers/FriendAddHandler/FriendAddSignalRHandler.cs b/backend/IM_API/Application/EventHandlers/FriendAddHandler/FriendAddSignalRHandler.cs index e692035..021f3c3 100644 --- a/backend/IM_API/Application/EventHandlers/FriendAddHandler/FriendAddSignalRHandler.cs +++ b/backend/IM_API/Application/EventHandlers/FriendAddHandler/FriendAddSignalRHandler.cs @@ -22,7 +22,7 @@ namespace IM_API.Application.EventHandlers.FriendAddHandler var usersList = new List { @event.RequestUserId.ToString(), @event.ResponseUserId.ToString() }; - var res = new HubResponse("Event", new MessageBaseDto() + var res = new HubResponse(HubResponseType.FriendAccepted, new MessageBaseDto() { ChatType = ChatType.PRIVATE, Content = "您有新的好友关系已添加", diff --git a/backend/IM_API/Dtos/HubResponse.cs b/backend/IM_API/Dtos/HubResponse.cs index 18c2c0e..c0dc9bb 100644 --- a/backend/IM_API/Dtos/HubResponse.cs +++ b/backend/IM_API/Dtos/HubResponse.cs @@ -39,11 +39,44 @@ namespace IM_API.Dtos Message = codeDefine.Message; Data = data; } + public HubResponse(HubResponseType type, T? data) + { + Code = CodeDefine.SUCCESS.Code; + Method = "Event"; + Type = type; + Data = data; + } } public enum HubResponseType { - ChatMsg = 1, // 聊天内容 - SystemNotice = 2, // 系统通知(如:申请好友成功) - ActionStatus = 3 // 状态变更(如:对方正在输入、已读回执) + // --- 基础聊天 (10-19) --- + ChatMsg = 1, // 普通消息 + + // --- 系统与通知 (20-29) --- + SystemNotice = 2, // 通用系统通知 + FriendRequest = 21, // 好友申请消息 + FriendAccepted = 22, // 好友通过通知 + UserInLine = 23, // 好友上线/下线通知 + + // --- 状态变更与交互 (30-39) --- + ActionStatus = 3, // 通用状态(正在输入等) + MsgReadReceipt = 31, // 已读回执 + MsgRevoke = 32, // 消息撤回 + MsgEdit = 33, // 消息二次编辑更新 + + // --- 群组管理 (40-49) --- + GroupInvited = 41, // 被邀请入群 + GroupMemberUpdate = 42, // 群成员变动(进群/退群) + GroupAnnouncement = 43, // 群公告更新 + GroupDismissed = 44, // 群组解散 + + // --- 实时通信控制 (50-59) --- + RTC_CallRequest = 51, // 音视频通话邀请 + RTC_CallHandled = 52, // 音视频接听/挂断/取消状态 + + // --- 异常与安全 (90-99) --- + ErrorInternal = 91, // 服务器内部错误 + TokenExpired = 92, // 登录过期,强制下线 + KickedOut = 93 // 被挤下线(异地登录) } } diff --git a/backend/IM_API/Services/ConversationService.cs b/backend/IM_API/Services/ConversationService.cs index 1cfbb43..36b1746 100644 --- a/backend/IM_API/Services/ConversationService.cs +++ b/backend/IM_API/Services/ConversationService.cs @@ -146,7 +146,8 @@ namespace IM_API.Services public async Task MakeConversationAsync(int userAId, int userBId, ChatType chatType) { - var userAcExist = await _context.Conversations.AnyAsync(x => x.UserId == userAId && x.TargetId == userBId); + var userAcExist = await _context.Conversations.AnyAsync( + x => x.UserId == userAId && x.TargetId == userBId && x.ChatType == chatType); if (userAcExist) return; var streamKey = chatType == ChatType.PRIVATE ? StreamKeyBuilder.Private(userAId, userBId) : StreamKeyBuilder.Group(userBId); diff --git a/frontend/pc/IM/.env b/frontend/pc/IM/.env index ea10082..12da4fe 100644 --- a/frontend/pc/IM/.env +++ b/frontend/pc/IM/.env @@ -1,8 +1,8 @@ -# VITE_API_BASE_URL = http://localhost:5202/api -# VITE_SIGNALR_BASE_URL = http://localhost:5202/chat/ +VITE_API_BASE_URL = http://localhost:5202/api +VITE_SIGNALR_BASE_URL = http://localhost:5202/chat/ # VITE_API_BASE_URL = https://im.test.nxsir.cn/api # VITE_SIGNALR_BASE_URL = https://im.test.nxsir.cn/chat/ -VITE_API_BASE_URL = http://192.168.5.116:7070/api -VITE_SIGNALR_BASE_URL = http://192.168.5.116:7070/chat/ +# VITE_API_BASE_URL = http://192.168.5.116:7070/api +# VITE_SIGNALR_BASE_URL = http://192.168.5.116:7070/chat/ diff --git a/frontend/pc/IM/src/main/index.js b/frontend/pc/IM/src/main/index.js index 8bb5f3f..d053649 100644 --- a/frontend/pc/IM/src/main/index.js +++ b/frontend/pc/IM/src/main/index.js @@ -26,7 +26,7 @@ function createWindow() { createTry(mainWindow); mainWindow.on('ready-to-show', () => { - mainWindow.show() + // mainWindow.show() }) diff --git a/frontend/pc/IM/src/main/ipcHandlers/window.js b/frontend/pc/IM/src/main/ipcHandlers/window.js index b462962..6c32000 100644 --- a/frontend/pc/IM/src/main/ipcHandlers/window.js +++ b/frontend/pc/IM/src/main/ipcHandlers/window.js @@ -25,7 +25,9 @@ export function registerWindowHandler() { changeSize: () => { win.setSize(data.width, data.height, true) win.setResizable(data.resizable) - } + win.center() + }, + show: () => win.show() } actions[action]?.() }) diff --git a/frontend/pc/IM/src/preload/index.js b/frontend/pc/IM/src/preload/index.js index 2f4d62e..5d7065c 100644 --- a/frontend/pc/IM/src/preload/index.js +++ b/frontend/pc/IM/src/preload/index.js @@ -8,6 +8,7 @@ const api = { maximize: () => ipcRenderer.send('window-action', 'maximize'), close: () => ipcRenderer.send('window-action', 'close'), closeThis: () => ipcRenderer.send('window-action', 'closeThis'), + show: () => ipcRenderer.send('window-action', 'show'), isMaximized: () => ipcRenderer.send('window-action', 'isMaximized'), newWindow: (route, data, width, height) => ipcRenderer.send('window-new', { route, data, width, height }), getWindowData: (winId) => ipcRenderer.invoke('get-window-data', winId), diff --git a/frontend/pc/IM/src/renderer/src/components/WindowControls.vue b/frontend/pc/IM/src/renderer/src/components/WindowControls.vue index 6b9a3dc..b0e0462 100644 --- a/frontend/pc/IM/src/renderer/src/components/WindowControls.vue +++ b/frontend/pc/IM/src/renderer/src/components/WindowControls.vue @@ -50,6 +50,7 @@ function toggleMaximize() { function close() { window.api.window.close() emits('close') + emits('close') } diff --git a/frontend/pc/IM/src/renderer/src/constants/notificationType.js b/frontend/pc/IM/src/renderer/src/constants/notificationType.js new file mode 100644 index 0000000..9e5131c --- /dev/null +++ b/frontend/pc/IM/src/renderer/src/constants/notificationType.js @@ -0,0 +1,34 @@ +export const NOTIFICATION_TYPE = Object.freeze({ + // --- 基础聊天 (10-19) --- + ChatMsg: 1, + FileMsg: 11, + EmojiSticker: 12, + ForwardMsg: 13, + + // --- 系统与通知 (20-29) --- + SystemNotice: 2, + FriendRequest: 21, + FriendAccepted: 22, + UserInLine: 23, + + // --- 状态变更与交互 (30-39) --- + ActionStatus: 3, + MsgReadReceipt: 31, + MsgRevoke: 32, + MsgEdit: 33, + + // --- 群组管理 (40-49) --- + GroupInvited: 41, + GroupMemberUpdate: 42, + GroupAnnouncement: 43, + GroupDismissed: 44, + + // --- 实时通信控制 (50-59) --- + RTC_CallRequest: 51, + RTC_CallHandled: 52, + + // --- 异常与安全 (90-99) --- + ErrorInternal: 91, + TokenExpired: 92, + KickedOut: 93 +}) diff --git a/frontend/pc/IM/src/renderer/src/utils/signalr/SignalMessageHandler.js b/frontend/pc/IM/src/renderer/src/utils/signalr/SignalMessageHandler.js index 3af6a9e..d143c7b 100644 --- a/frontend/pc/IM/src/renderer/src/utils/signalr/SignalMessageHandler.js +++ b/frontend/pc/IM/src/renderer/src/utils/signalr/SignalMessageHandler.js @@ -1,22 +1,28 @@ -import { useBrowserNotification } from "@/services/useBrowserNotification"; +import { useBrowserNotification } from '@/services/useBrowserNotification' -import { useChatStore } from "@/stores/chat"; +import { useChatStore } from '@/stores/chat' -import { messageHandler } from "@/handler/messageHandler"; -import { generateSessionId } from "../sessionIdTools"; -import { useConversationStore } from "@/stores/conversation"; -import { MESSAGE_TYPE } from "@/constants/MessageType"; +import { messageHandler } from '@/handler/messageHandler' +import { generateSessionId } from '../sessionIdTools' +import { useConversationStore } from '@/stores/conversation' +import { MESSAGE_TYPE } from '@/constants/MessageType' +import { NOTIFICATION_TYPE } from '../../constants/notificationType' export const SignalRMessageHandler = (data) => { - const msg = data.data; - const chatStore = useChatStore() - const browserNotification = useBrowserNotification(); - const sessionId = generateSessionId(msg.senderId, msg.receiverId, msg.chatType == MESSAGE_TYPE.GROUP); - messageHandler(msg); - chatStore.pushAndSortMessagesAsync([msg], sessionId); - const conversation = useConversationStore().conversations.find(x => x.targetId == msg.senderId); - browserNotification.send(`${conversation.targetName}发来一条消息`, { - body: msg.content, - icon: conversation.targetAvatar - }); -} \ No newline at end of file + const msg = data.data + const type = data.type + const chatStore = useChatStore() + const browserNotification = useBrowserNotification() + const sessionId = generateSessionId( + msg.senderId, + msg.receiverId, + msg.chatType == MESSAGE_TYPE.GROUP + ) + messageHandler(msg) + chatStore.pushAndSortMessagesAsync([msg], sessionId) + const conversation = useConversationStore().conversations.find((x) => x.targetId == msg.senderId) + browserNotification.send(`${conversation.targetName}发来一条消息`, { + body: msg.content, + icon: conversation.targetAvatar + }) +} diff --git a/frontend/pc/IM/src/renderer/src/views/Main.vue b/frontend/pc/IM/src/renderer/src/views/Main.vue index 4ea2703..5301266 100644 --- a/frontend/pc/IM/src/renderer/src/views/Main.vue +++ b/frontend/pc/IM/src/renderer/src/views/Main.vue @@ -2,7 +2,7 @@