From 56442ab47d3bb31c3acbea35cc5bc781d3f65be1 Mon Sep 17 00:00:00 2001 From: cansnow Date: Sun, 8 Jun 2025 21:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E5=9C=B0=E5=9D=80,=E4=BF=AE=E6=AD=A3=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=B7=9F=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E8=81=94=E5=8A=A8,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 服务器有个设置 不会通过ws发送当前发送的信息,目前是关掉的,找不到设置在上面地方了 --- pages/im/chat.vue | 10 +++++++--- pages/im/index.vue | 2 +- static/im/mattermost.js | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pages/im/chat.vue b/pages/im/chat.vue index 465663b..dfd6473 100644 --- a/pages/im/chat.vue +++ b/pages/im/chat.vue @@ -165,7 +165,7 @@ export default { data() { return { init: { - cdnurl: 'http://q.sjqqzc.top' + cdnurl: "http://www.dxmt.io" }, channel:{}, // 滚动容器 @@ -407,7 +407,9 @@ export default { if (result && result.id) { this.content = ''; - //console.log('发送成功:', result); + result['from_user'] = await mattermost.getUserById(result.user_id); + this.talkList.push(result); + console.log('发送成功:', result,this.talkList); // 更新消息状态 //result.from_user = this.im_user; //this.talkList[result.id] = result; @@ -432,6 +434,8 @@ export default { if (!result || !result.id) { throw new Error('发送失败'); } + result['from_user'] = await mattermost.getUserById(result.user_id); + this.talkList.push(result); //this.content = ''; //console.log('发送图片消息成功:', result); @@ -829,7 +833,7 @@ export default { .body { margin-left: 20rpx; - max-width: 60%; + max-width: 80%; display: flex; flex-direction: column; diff --git a/pages/im/index.vue b/pages/im/index.vue index 4e56ec7..f0f5a52 100644 --- a/pages/im/index.vue +++ b/pages/im/index.vue @@ -163,7 +163,7 @@ const initRes = await this.$http.get('/api/common/init?lang=' + this.$i18n.locale); if (initRes.code === 0) { this.config = initRes.data; - this.config.cdnurl = initRes.data.cdnurl || "http://q.sjqqzc.top"; + this.config.cdnurl = initRes.data.cdnurl || "http://www.dxmt.io"; } // 检查 Mattermost 连接状态 diff --git a/static/im/mattermost.js b/static/im/mattermost.js index fd8a129..1426ea2 100644 --- a/static/im/mattermost.js +++ b/static/im/mattermost.js @@ -1014,6 +1014,13 @@ class MattermostClient { }); } } + async getUserById(user_id){ + if(this.kown_users[user_id]){ + return this.kown_users[user_id]; + } + var result = await this.getUsersByIds([user_id]); + return result[0]; + } async getUsersByIds(user_ids){ return await this.request({ to_server:'admin',