From 9feddf33ab42ab5d952203384ab426b8753315df Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Tue, 8 Nov 2022 11:02:55 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=B0=86=E7=A7=81=E8=81=8A=E5=92=8C?= =?UTF-8?q?=E7=BE=A4=E8=81=8A=E6=95=B4=E5=90=88=E6=88=90=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/api/emotion.js | 1 - .../chat/{ChatGroup.vue => ChatBox.vue} | 218 ++++++++++++--- im-ui/src/components/chat/ChatPrivate.vue | 251 ------------------ im-ui/src/store/chatStore.js | 8 +- im-ui/src/view/Chat.vue | 147 +--------- im-ui/src/view/Friend.vue | 2 +- 6 files changed, 182 insertions(+), 445 deletions(-) rename im-ui/src/components/chat/{ChatGroup.vue => ChatBox.vue} (63%) delete mode 100644 im-ui/src/components/chat/ChatPrivate.vue diff --git a/im-ui/src/api/emotion.js b/im-ui/src/api/emotion.js index 3e571f2..fb4d0d1 100644 --- a/im-ui/src/api/emotion.js +++ b/im-ui/src/api/emotion.js @@ -2,7 +2,6 @@ const emoTextList = ['微笑', '撇嘴', '色', '发呆', '得意', '流泪', ' let transform = (content) => { - console.log(content) return content.replace(/\#[\u4E00-\u9FA5]{1,3}\;/gi, textToImg); } diff --git a/im-ui/src/components/chat/ChatGroup.vue b/im-ui/src/components/chat/ChatBox.vue similarity index 63% rename from im-ui/src/components/chat/ChatGroup.vue rename to im-ui/src/components/chat/ChatBox.vue index ae91911..91949b3 100644 --- a/im-ui/src/components/chat/ChatGroup.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -2,7 +2,7 @@ {{title}} - + @@ -54,7 +54,7 @@ import MessageItem from "./MessageItem.vue"; import FileUpload from "../common/FileUpload.vue"; import Emotion from "../common/Emotion.vue"; - + export default { name: "chatPrivate", components: { @@ -70,12 +70,13 @@ }, data() { return { - sendText: "", - showSide: false, + friend: {}, group: {}, groupMembers: [], - showEmotion: false, - emoBoxPos: { + sendText: "", + showSide: false, // 是否显示群聊信息栏 + showEmotion: false, // 是否显示emoji表情 + emoBoxPos: { // emoji表情弹出位置 x: 0, y: 0 } @@ -84,17 +85,19 @@ methods: { handleImageSuccess(res, file) { let msgInfo = { - groupId: file.raw.targetId, + recvId: file.raw.targetId, content: JSON.stringify(res.data), type: 1 } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); this.$http({ - url: '/message/group/send', + url: this.messageAction, method: 'post', data: msgInfo }).then((data) => { let info = { - type: 'GROUP', + type: this.chat.type, targetId: file.raw.targetId, fileId: file.raw.uid, content: JSON.stringify(res.data), @@ -105,7 +108,7 @@ }, handleImageFail(res, file) { let info = { - type: 'GROUP', + type: this.chat.type, targetId: file.raw.targetId, fileId: file.raw.uid, loadStatus: "fail" @@ -121,13 +124,14 @@ let msgInfo = { fileId: file.uid, sendId: this.mine.id, - groupId: this.chat.targetId, content: JSON.stringify(data), sendTime: new Date().getTime(), selfSend: true, type: 1, loadStatus: "loading" } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); // 插入消息 this.$store.commit("insertMessage", msgInfo); // 滚动到底部 @@ -142,17 +146,18 @@ url: res.data } let msgInfo = { - groupId: file.raw.targetId, content: JSON.stringify(data), type: 2 } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); this.$http({ - url: '/message/group/send', + url: this.messageAction, method: 'post', data: msgInfo }).then(() => { let info = { - type: 'GROUP', + type: this.chat.type, targetId: file.raw.targetId, fileId: file.raw.uid, content: JSON.stringify(data), @@ -163,7 +168,7 @@ }, handleFileFail(res, file) { let info = { - type: 'GROUP', + type: this.chat.type, targetId: file.raw.targetId, fileId: file.raw.uid, loadStatus: "fail" @@ -180,13 +185,14 @@ let msgInfo = { fileId: file.uid, sendId: this.mine.id, - groupId: this.chat.targetId, content: JSON.stringify(data), sendTime: new Date().getTime(), selfSend: true, type: 2, loadStatus: "loading" } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); // 插入消息 this.$store.commit("insertMessage", msgInfo); // 滚动到底部 @@ -207,6 +213,15 @@ }, handleEmotion(emoText) { this.sendText += emoText; + // 保持输入框焦点 + this.$refs.sendBox.focus(); + }, + setTargetId(msgInfo, targetId) { + if (this.chat.type == "GROUP") { + msgInfo.groupId = targetId; + } else { + msgInfo.recvId = targetId; + } }, sendTextMessage() { @@ -215,12 +230,13 @@ return } let msgInfo = { - groupId: this.chat.targetId, content: this.sendText, type: 0 } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); this.$http({ - url: '/message/group/send', + url: this.messageAction, method: 'post', data: msgInfo }).then((data) => { @@ -235,7 +251,7 @@ // 滚动到底部 this.scrollToBottom(); }) - const e = window.event || arguments[0] + const e = window.event || arguments[0]; if (e.key === 'Enter' || e.code === 'Enter' || e.keyCode === 13) { e.returnValue = false; e.preventDefault(); @@ -249,6 +265,8 @@ }).then((group) => { this.group = group; this.$store.commit("updateChatFromGroup", group); + this.$store.commit("updateGroup", group); + }); this.$http({ @@ -257,15 +275,34 @@ }).then((groupMembers) => { this.groupMembers = groupMembers; }); - + }, + loadFriend(friendId) { + // 获取对方最新信息 + this.$http({ + url: `/user/find/${friendId}`, + method: 'get' + }).then((friend) => { + this.friend = friend; + this.$store.commit("updateChatFromFriend", friend); + this.$store.commit("updateFriend", friend); + }) }, showName(msgInfo) { - let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); - return member ? member.aliasName : ""; + if (this.chat.type == 'Group') { + let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); + return member ? member.aliasName : ""; + } else { + return msgInfo.sendId == this.mine.id ? this.mine.nickName : this.chat.showName + } + }, headImage(msgInfo) { - let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); - return member ? member.headImage : ""; + if (this.chat.type == 'Group') { + let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); + return member ? member.headImage : ""; + } else { + return msgInfo.sendId == this.mine.id ? this.mine.headImageThumb : this.chat.headImage + } }, scrollToBottom() { this.$nextTick(() => { @@ -279,41 +316,134 @@ return this.$store.state.userStore.userInfo; }, title() { - let size = this.groupMembers.filter(m => !m.quit).length; - return `${this.chat.showName}(${size})`; + let title = this.chat.showName; + if (this.chat.type == "GROUP") { + let size = this.groupMembers.filter(m => !m.quit).length; + title += `(${size})`; + } + return title; }, imageAction() { return `${process.env.VUE_APP_BASE_API}/image/upload`; }, fileAction() { return `${process.env.VUE_APP_BASE_API}/file/upload`; + }, + messageAction() { + return `/message/${this.chat.type.toLowerCase()}/send`; } - }, - mounted() { - console.log("group mount...") - this.loadGroup(this.chat.targetId); - this.scrollToBottom(); + watch: { + chat: { + handler(newChat, oldChat) { + if(newChat.type != oldChat.type || newChat.targetId != oldChat.targetId){ + if (this.chat.type == "GROUP") { + this.loadGroup(this.chat.targetId); + } else { + this.loadFriend(this.chat.targetId); + } + this.scrollToBottom(); + this.sendText = ""; + // 保持输入框焦点 + this.$refs.sendBox.focus(); + } + }, + deep: true // 深度监听 + } } } - diff --git a/im-ui/src/components/chat/ChatPrivate.vue b/im-ui/src/components/chat/ChatPrivate.vue deleted file mode 100644 index 8ece220..0000000 --- a/im-ui/src/components/chat/ChatPrivate.vue +++ /dev/null @@ -1,251 +0,0 @@ - - - - - diff --git a/im-ui/src/store/chatStore.js b/im-ui/src/store/chatStore.js index 38ff629..9328c18 100644 --- a/im-ui/src/store/chatStore.js +++ b/im-ui/src/store/chatStore.js @@ -102,12 +102,12 @@ export default { msg.content = info.content; } }, - updateChatFromUser(state, user) { + updateChatFromFriend(state, friend) { for (let i in state.chats) { let chat = state.chats[i]; - if (chat.type=='PRIVATE' && chat.targetId == user.id) { - chat.headImage = user.headImageThumb; - chat.showName = user.nickName; + if (chat.type=='PRIVATE' && chat.targetId == friend.id) { + chat.headImage = friend.headImageThumb; + chat.showName = friend.nickName; break; } } diff --git a/im-ui/src/view/Chat.vue b/im-ui/src/view/Chat.vue index 4b181f4..fd9903c 100644 --- a/im-ui/src/view/Chat.vue +++ b/im-ui/src/view/Chat.vue @@ -14,31 +14,20 @@ - - + diff --git a/im-ui/src/view/Home.vue b/im-ui/src/view/Home.vue index f654c7d..85f6d84 100644 --- a/im-ui/src/view/Home.vue +++ b/im-ui/src/view/Home.vue @@ -23,7 +23,7 @@ - + @@ -34,7 +34,7 @@ - + Date: Tue, 8 Nov 2022 17:27:05 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E8=AF=AD=E8=A8=80=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/im-ui/package.json b/im-ui/package.json index 950f505..b95209b 100644 --- a/im-ui/package.json +++ b/im-ui/package.json @@ -11,6 +11,7 @@ "axios": "^1.1.3", "core-js": "^3.6.5", "element-ui": "^2.15.10", + "recorderx": "^2.0.2", "sass": "^1.47.0", "sass-loader": "^7.3.1", "vue": "^2.6.11", @@ -50,7 +51,7 @@ "vue/no-unused-components": "off", "no-irregular-whitespace": "off", "no-debugger": "off", - "no-useless-escape": "off" + "no-useless-escape": "off" } }, "browserslist": [ From 2ad211cefe1ab49980b0c934f0bf814272613ef1 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Tue, 8 Nov 2022 20:39:24 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E5=8F=91=E9=80=81=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bx/common/enums/FileTypeEnum.java | 4 +- im-ui/package.json | 2 +- im-ui/src/components/chat/ChatBox.vue | 27 ++++- im-ui/src/components/chat/ChatVoice.vue | 109 ++++++++++++------ im-ui/src/components/chat/MessageItem.vue | 24 +++- 5 files changed, 127 insertions(+), 39 deletions(-) diff --git a/commom/src/main/java/com/bx/common/enums/FileTypeEnum.java b/commom/src/main/java/com/bx/common/enums/FileTypeEnum.java index 35091b1..a41ac1f 100644 --- a/commom/src/main/java/com/bx/common/enums/FileTypeEnum.java +++ b/commom/src/main/java/com/bx/common/enums/FileTypeEnum.java @@ -4,7 +4,9 @@ public enum FileTypeEnum { FILE(0,"文件"), IMAGE(1,"图片"), - VIDEO(2,"视频"); + VIDEO(2,"视频"), + AUDIO(3,"声音"); + private Integer code; diff --git a/im-ui/package.json b/im-ui/package.json index b95209b..0413271 100644 --- a/im-ui/package.json +++ b/im-ui/package.json @@ -11,7 +11,7 @@ "axios": "^1.1.3", "core-js": "^3.6.5", "element-ui": "^2.15.10", - "recorderx": "^2.0.2", + "js-audio-recorder": "^1.0.7", "sass": "^1.47.0", "sass-loader": "^7.3.1", "vue": "^2.6.11", diff --git a/im-ui/src/components/chat/ChatBox.vue b/im-ui/src/components/chat/ChatBox.vue index 14bf987..477c900 100644 --- a/im-ui/src/components/chat/ChatBox.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -48,7 +48,7 @@ - + @@ -231,6 +231,31 @@ closeVoiceBox(){ this.showVoice = false; }, + handleSendVoice(data){ + let msgInfo = { + content: JSON.stringify(data), + type: 3 + } + // 填充对方id + this.setTargetId(msgInfo, this.chat.targetId); + this.$http({ + url: this.messageAction, + method: 'post', + data: msgInfo + }).then(() => { + this.$message.success("发送成功"); + msgInfo.sendTime = new Date().getTime(); + msgInfo.sendId = this.$store.state.userStore.userInfo.id; + msgInfo.selfSend = true; + this.$store.commit("insertMessage", msgInfo); + // 保持输入框焦点 + this.$refs.sendBox.focus(); + // 滚动到底部 + this.scrollToBottom(); + // 关闭录音窗口 + this.showVoice = false; + }) + }, setTargetId(msgInfo, targetId) { if (this.chat.type == "GROUP") { msgInfo.groupId = targetId; diff --git a/im-ui/src/components/chat/ChatVoice.vue b/im-ui/src/components/chat/ChatVoice.vue index a18250e..80b335a 100644 --- a/im-ui/src/components/chat/ChatVoice.vue +++ b/im-ui/src/components/chat/ChatVoice.vue @@ -1,15 +1,21 @@ - diff --git a/im-ui/src/components/chat/MessageItem.vue b/im-ui/src/components/chat/MessageItem.vue index cd05691..9e89f7c 100644 --- a/im-ui/src/components/chat/MessageItem.vue +++ b/im-ui/src/components/chat/MessageItem.vue @@ -32,6 +32,9 @@ +
+ +
@@ -65,6 +68,12 @@ required: true } }, + data(){ + return { + audioPlayState: 'STOP', + } + + }, methods:{ handleSendFail(){ this.$message.error("该文件已发送失败,目前不支持自动重新发送,建议手动重新发送") @@ -74,7 +83,15 @@ if(imageUrl){ this.$store.commit('showFullImageBox',imageUrl); } - } + }, + handlePlayVoice(){ + if(!this.audio){ + this.audio = new Audio(); + } + this.audio.src = JSON.parse(this.msgInfo.content).url; + this.audio.play(); + this.handlePlayVoice = 'RUNNING'; + } }, computed:{ loading(){ @@ -229,6 +246,11 @@ } } + + .im-msg-voice { + font-size: 14px; + cursor: pointer; + } } } From 35905a277996948cbe6581b42b9108ed85d1bdc1 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Tue, 8 Nov 2022 22:45:01 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/components/chat/ChatVoice.vue | 4 +++- im-ui/src/view/Login.vue | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/im-ui/src/components/chat/ChatVoice.vue b/im-ui/src/components/chat/ChatVoice.vue index 80b335a..cf3ff97 100644 --- a/im-ui/src/components/chat/ChatVoice.vue +++ b/im-ui/src/components/chat/ChatVoice.vue @@ -48,7 +48,8 @@ methods: { handleClose() { // 关闭前清除数据 - this.rc.stop(); + this.rc.destroy(); + this.rc = new Recorder(); this.audio.pause(); this.mode = 'RECORD'; this.state = 'STOP'; @@ -118,6 +119,7 @@ url: url } this.$emit("send", data); + this.handleClose(); }) } } diff --git a/im-ui/src/view/Login.vue b/im-ui/src/view/Login.vue index 2583a8c..7a43dfc 100644 --- a/im-ui/src/view/Login.vue +++ b/im-ui/src/view/Login.vue @@ -85,7 +85,7 @@ let reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); let arr = document.cookie.match(reg) if (arr){ - return (arr[2]); + return unescape(arr[2]); } return ''; }, From d3743db6ca2e7bcf730cde3587850d8fef5f7001 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Tue, 8 Nov 2022 23:23:12 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BF=83=E8=B7=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bx/common/contant/Constant.java | 2 ++ .../websocket/processor/HeartbeatProcessor.java | 17 +++++++++++++++++ .../websocket/processor/LoginProcessor.java | 9 +++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/commom/src/main/java/com/bx/common/contant/Constant.java b/commom/src/main/java/com/bx/common/contant/Constant.java index 40d3cf7..8e6b2dd 100644 --- a/commom/src/main/java/com/bx/common/contant/Constant.java +++ b/commom/src/main/java/com/bx/common/contant/Constant.java @@ -10,4 +10,6 @@ public class Constant { public static final long MAX_FILE_SIZE = 10*1024*1024; // 群聊最大人数 public static final long MAX_GROUP_MEMBER = 500; + // 在线状态过期时间 600s + public static final long ONLINE_TIMEOUT_SECOND = 600; } diff --git a/im-server/src/main/java/com/bx/imserver/websocket/processor/HeartbeatProcessor.java b/im-server/src/main/java/com/bx/imserver/websocket/processor/HeartbeatProcessor.java index 69cb8f2..9ae18de 100644 --- a/im-server/src/main/java/com/bx/imserver/websocket/processor/HeartbeatProcessor.java +++ b/im-server/src/main/java/com/bx/imserver/websocket/processor/HeartbeatProcessor.java @@ -1,17 +1,22 @@ package com.bx.imserver.websocket.processor; import cn.hutool.core.bean.BeanUtil; +import com.bx.common.contant.Constant; +import com.bx.common.contant.RedisKey; import com.bx.common.enums.WSCmdEnum; import com.bx.common.model.im.HeartbeatInfo; import com.bx.common.model.im.SendInfo; import com.bx.imserver.websocket.WebsocketServer; import io.netty.channel.ChannelHandlerContext; +import io.netty.util.Attribute; +import io.netty.util.AttributeKey; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import java.util.HashMap; +import java.util.concurrent.TimeUnit; @Slf4j @Component @@ -30,6 +35,18 @@ public class HeartbeatProcessor extends MessageProcessor { SendInfo sendInfo = new SendInfo(); sendInfo.setCmd(WSCmdEnum.HEART_BEAT.getCode()); ctx.channel().writeAndFlush(sendInfo); + + // 设置属性 + AttributeKey attr = AttributeKey.valueOf("HEARTBEAt_TIMES"); + Long heartbeatTimes = ctx.channel().attr(attr).get(); + ctx.channel().attr(attr).set(++heartbeatTimes); + if(heartbeatTimes%10 == 0){ + // 每心跳10次,用户在线状态续一次命 + attr = AttributeKey.valueOf("USER_ID"); + Long userId = ctx.channel().attr(attr).get(); + String key = RedisKey.IM_USER_SERVER_ID+userId; + redisTemplate.expire(key, Constant.ONLINE_TIMEOUT_SECOND, TimeUnit.SECONDS); + } } diff --git a/im-server/src/main/java/com/bx/imserver/websocket/processor/LoginProcessor.java b/im-server/src/main/java/com/bx/imserver/websocket/processor/LoginProcessor.java index a5225f8..64bd23a 100644 --- a/im-server/src/main/java/com/bx/imserver/websocket/processor/LoginProcessor.java +++ b/im-server/src/main/java/com/bx/imserver/websocket/processor/LoginProcessor.java @@ -1,6 +1,7 @@ package com.bx.imserver.websocket.processor; import cn.hutool.core.bean.BeanUtil; +import com.bx.common.contant.Constant; import com.bx.common.contant.RedisKey; import com.bx.common.enums.WSCmdEnum; import com.bx.common.model.im.LoginInfo; @@ -15,6 +16,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; import java.util.HashMap; +import java.util.concurrent.TimeUnit; @Slf4j @Component @@ -39,12 +41,15 @@ public class LoginProcessor extends MessageProcessor { } // 绑定用户和channel WebsocketChannelCtxHolder.addChannelCtx(loginInfo.getUserId(),ctx); - // 设置属性 + // 设置用户id属性 AttributeKey attr = AttributeKey.valueOf("USER_ID"); ctx.channel().attr(attr).set(loginInfo.getUserId()); + // 心跳次数 + attr = AttributeKey.valueOf("HEARTBEAt_TIMES"); + ctx.channel().attr(attr).set(0L); // 在redis上记录每个user的channelId,15秒没有心跳,则自动过期 String key = RedisKey.IM_USER_SERVER_ID+loginInfo.getUserId(); - redisTemplate.opsForValue().set(key, WSServer.getServerId()); + redisTemplate.opsForValue().set(key, WSServer.getServerId(), Constant.ONLINE_TIMEOUT_SECOND, TimeUnit.SECONDS); // 响应ws SendInfo sendInfo = new SendInfo(); sendInfo.setCmd(WSCmdEnum.LOGIN.getCode()); From 14574891b949937fcd5ecce71217806bc7c65296 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Wed, 9 Nov 2022 14:20:36 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E6=94=AF=E6=8C=81ssl=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/.env.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/im-ui/.env.production b/im-ui/.env.production index 49fc05a..8353ff1 100644 --- a/im-ui/.env.production +++ b/im-ui/.env.production @@ -1,6 +1,6 @@ ENV = 'production' # 接口地址 -VUE_APP_BASE_API = 'http://8.134.92.70/api' +VUE_APP_BASE_API = 'https://8.134.92.70:443/api' VUE_APP_WS_URL = 'ws://8.134.92.70:81/im' \ No newline at end of file From 314bb8c071d9a35c608a99e05a41704a9b189c73 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Wed, 9 Nov 2022 14:43:16 +0800 Subject: [PATCH 12/17] =?UTF-8?q?ssl=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/.env.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/im-ui/.env.production b/im-ui/.env.production index 8353ff1..94bf790 100644 --- a/im-ui/.env.production +++ b/im-ui/.env.production @@ -3,4 +3,4 @@ ENV = 'production' # 接口地址 VUE_APP_BASE_API = 'https://8.134.92.70:443/api' -VUE_APP_WS_URL = 'ws://8.134.92.70:81/im' \ No newline at end of file +VUE_APP_WS_URL = 'wss://8.134.92.70:443/im' \ No newline at end of file From 39c6de135e0a6f3e6fbd068ce83252cb207ac31e Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Wed, 9 Nov 2022 14:46:20 +0800 Subject: [PATCH 13/17] =?UTF-8?q?ssl=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/.env.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/im-ui/.env.production b/im-ui/.env.production index 94bf790..acca7e2 100644 --- a/im-ui/.env.production +++ b/im-ui/.env.production @@ -3,4 +3,4 @@ ENV = 'production' # 接口地址 VUE_APP_BASE_API = 'https://8.134.92.70:443/api' -VUE_APP_WS_URL = 'wss://8.134.92.70:443/im' \ No newline at end of file +VUE_APP_WS_URL = 'wss://8.134.92.70:81/im' \ No newline at end of file From 57ad2a622222fef56b5cc7d34156c8bf4a111d0b Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Wed, 9 Nov 2022 17:46:09 +0800 Subject: [PATCH 14/17] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/store/chatStore.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/im-ui/src/store/chatStore.js b/im-ui/src/store/chatStore.js index 9328c18..ca1debf 100644 --- a/im-ui/src/store/chatStore.js +++ b/im-ui/src/store/chatStore.js @@ -84,7 +84,16 @@ export default { break; } } - chat.lastContent = msgInfo.type == 1 ? "[图片]" : msgInfo.type == 2 ? "[文件]" : msgInfo.content; + console.log(msgInfo.type) + if(msgInfo.type == 1){ + chat.lastContent = "[图片]"; + }else if(msgInfo.type == 2){ + chat.lastContent = "[文件]"; + }else if(msgInfo.type == 3){ + chat.lastContent = "[语音]"; + }else{ + chat.lastContent = msgInfo.content; + } chat.lastSendTime = msgInfo.sendTime; chat.messages.push(msgInfo); // 如果不是当前会话,未读加1 From 3932c9f04b2c7e45b28112725cbc214d57e9e089 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Sat, 12 Nov 2022 21:36:19 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BE=A4=E6=98=B5?= =?UTF-8?q?=E7=A7=B0=E5=A4=B4=E5=83=8F=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-platform/src/main/resources/application.yml | 2 +- im-ui/src/components/chat/ChatBox.vue | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/im-platform/src/main/resources/application.yml b/im-platform/src/main/resources/application.yml index 7237f51..bb22378 100644 --- a/im-platform/src/main/resources/application.yml +++ b/im-platform/src/main/resources/application.yml @@ -5,7 +5,7 @@ server: spring: datasource: driver-class-name: com.mysql.jdbc.Driver - url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8 + url: jdbc:mysql://localhost:3306/box-im?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true username: root password: root diff --git a/im-ui/src/components/chat/ChatBox.vue b/im-ui/src/components/chat/ChatBox.vue index 477c900..bc5ffde 100644 --- a/im-ui/src/components/chat/ChatBox.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -328,8 +328,9 @@ }) }, showName(msgInfo) { - if (this.chat.type == 'Group') { + if (this.chat.type == 'GROUP') { let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); + console.log(member.aliasName) return member ? member.aliasName : ""; } else { return msgInfo.sendId == this.mine.id ? this.mine.nickName : this.chat.showName @@ -337,7 +338,7 @@ }, headImage(msgInfo) { - if (this.chat.type == 'Group') { + if (this.chat.type == 'GROUP') { let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); return member ? member.headImage : ""; } else { From 888435c7f80e4fc58c207bbcf0d5121d1f3a9fdd Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Sat, 12 Nov 2022 21:42:50 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bx/implatform/service/impl/GroupMessageServiceImpl.java | 4 +++- .../bx/implatform/service/impl/PrivateMessageServiceImpl.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java index 75deeda..3c62332 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/GroupMessageServiceImpl.java @@ -16,6 +16,7 @@ import com.bx.implatform.service.IGroupMessageService; import com.bx.implatform.service.IGroupService; import com.bx.implatform.session.SessionContext; import com.bx.implatform.vo.GroupMessageVO; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -24,7 +25,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; - +@Slf4j @Service public class GroupMessageServiceImpl extends ServiceImpl implements IGroupMessageService { @@ -86,6 +87,7 @@ public class GroupMessageServiceImpl extends ServiceImpl implements IPrivateMessageService { @@ -59,6 +60,7 @@ public class PrivateMessageServiceImpl extends ServiceImpl Date: Sat, 12 Nov 2022 22:45:45 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E6=8E=92?= =?UTF-8?q?=E7=89=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/components/chat/ChatBox.vue | 91 ++++++++++--------- im-ui/src/components/group/AddGroupMember.vue | 4 +- im-ui/src/components/setting/Setting.vue | 2 +- im-ui/src/view/Group.vue | 8 +- im-ui/src/view/Register.vue | 3 +- 5 files changed, 57 insertions(+), 51 deletions(-) diff --git a/im-ui/src/components/chat/ChatBox.vue b/im-ui/src/components/chat/ChatBox.vue index bc5ffde..3ba8913 100644 --- a/im-ui/src/components/chat/ChatBox.vue +++ b/im-ui/src/components/chat/ChatBox.vue @@ -2,51 +2,57 @@ {{title}} - + - - - -
-
    -
  • - - -
  • -
-
-
- -
-
+ + + + +
+
    +
  • + + +
  • +
-
- - - + + +
+
+
+
+ + + +
+
+ + + +
+
+
+
-
- - - + +
+ 发送
-
-
-
-
- -
- 发送 -
-
+ + + + + + - - - - + @@ -228,10 +234,10 @@ this.showVoice = true; }, - closeVoiceBox(){ + closeVoiceBox() { this.showVoice = false; }, - handleSendVoice(data){ + handleSendVoice(data) { let msgInfo = { content: JSON.stringify(data), type: 3 @@ -330,7 +336,6 @@ showName(msgInfo) { if (this.chat.type == 'GROUP') { let member = this.groupMembers.find((m) => m.userId == msgInfo.sendId); - console.log(member.aliasName) return member ? member.aliasName : ""; } else { return msgInfo.sendId == this.mine.id ? this.mine.nickName : this.chat.showName diff --git a/im-ui/src/components/group/AddGroupMember.vue b/im-ui/src/components/group/AddGroupMember.vue index 9ace9ce..8692c31 100644 --- a/im-ui/src/components/group/AddGroupMember.vue +++ b/im-ui/src/components/group/AddGroupMember.vue @@ -5,7 +5,7 @@ - +
@@ -17,7 +17,7 @@
已勾选{{checkCount}}位好友
- +
diff --git a/im-ui/src/components/setting/Setting.vue b/im-ui/src/components/setting/Setting.vue index 4e5fe61..e3e57aa 100644 --- a/im-ui/src/components/setting/Setting.vue +++ b/im-ui/src/components/setting/Setting.vue @@ -1,5 +1,5 @@ @@ -306,7 +306,7 @@ .r-group-info { display: flex; - padding: 20px; + padding: 5px 20px; .r-group-form { flex: 1; @@ -351,7 +351,7 @@ } .r-group-member-list { - padding: 20px; + padding: 5px 20px; display: flex; align-items: center; flex-wrap: wrap; diff --git a/im-ui/src/view/Register.vue b/im-ui/src/view/Register.vue index 00d942f..d1c4907 100644 --- a/im-ui/src/view/Register.vue +++ b/im-ui/src/view/Register.vue @@ -3,7 +3,7 @@
-
欢迎注册成为FLY CHAT用户
+
欢迎注册
@@ -142,6 +142,7 @@ font-size: 22px; font-weight: 600; letter-spacing: 2px; + text-align: center; text-transform: uppercase; }