add
This commit is contained in:
Vendored
+1
@@ -11,6 +11,7 @@
|
||||
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd"
|
||||
},
|
||||
"runtimeArgs": ["--sourcemap"],
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
"REMOTE_DEBUGGING_PORT": "9222"
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
"editor.defaultFormatter": "vscode.typescript-language-features"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
|
||||
@@ -7,6 +7,9 @@ export default defineConfig({
|
||||
main: {},
|
||||
preload: {},
|
||||
renderer: {
|
||||
server: {
|
||||
host: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src/renderer/src')
|
||||
|
||||
@@ -3,10 +3,23 @@ import { MESSAGE_TYPE } from "../constants/MessageType";
|
||||
|
||||
export const messageHandler = (msg) => {
|
||||
const conversationStore = useConversationStore();
|
||||
const conversation = conversationStore.conversations.find(x =>
|
||||
((x.targetId == msg.senderId || x.targetId == msg.receiverId) && msg.chatType == MESSAGE_TYPE.PRIVATE) ||
|
||||
(x.targetId == msg.receiverId && msg.chatType == MESSAGE_TYPE.GROUP)
|
||||
);
|
||||
const conversation = conversationStore.conversations.find(x => {
|
||||
// 1. 如果是私聊:目标 ID 必须是对方(可能是发送者,也可能是接收者)
|
||||
if (msg.chatType === MESSAGE_TYPE.PRIVATE) {
|
||||
return x.chatType === MESSAGE_TYPE.PRIVATE &&
|
||||
(x.targetId === msg.senderId || x.targetId === msg.receiverId);
|
||||
}
|
||||
|
||||
// 2. 如果是群聊:目标 ID 必须是群 ID(即消息的 receiverId)
|
||||
if (msg.chatType === MESSAGE_TYPE.GROUP) {
|
||||
return x.chatType === MESSAGE_TYPE.GROUP &&
|
||||
x.targetId === msg.receiverId;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!conversation) return; // 容错处理:如果没找到会话,不执行后续逻辑
|
||||
conversation.lastMessage = msg.content;
|
||||
if (conversation.targetId == msg.receiverId) {
|
||||
conversation.unreadCount = 0;
|
||||
|
||||
@@ -10,5 +10,5 @@ export const generateSessionId = (id1, id2, isGroup = false) => {
|
||||
if (isGroup) {
|
||||
return `g:${id2}`;
|
||||
}
|
||||
return [String(id1), String(id2)].sort().join('_');
|
||||
return 'p:' + [String(id1), String(id2)].sort().join('_');
|
||||
};
|
||||
@@ -18,6 +18,7 @@ onMounted(async () => {
|
||||
if(authStore.token){
|
||||
signalRStore.initSignalR();
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user