From 1a5afc8ad030ae5577f1c37e2f0c0448c7eb6442 Mon Sep 17 00:00:00 2001 From: MoonLeeeaf <150461955+MoonLeeeaf@users.noreply.github.com> Date: Fri, 14 Jun 2024 19:31:42 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20rename=20symbols,=20add=20"=E5=8E=9F?= =?UTF-8?q?=E6=96=87"=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ling_chair_http/chat-message.css | 1 + ling_chair_http/handler.js | 61 +++++++++++++++++--------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/ling_chair_http/chat-message.css b/ling_chair_http/chat-message.css index dd59cab..33b435b 100644 --- a/ling_chair_http/chat-message.css +++ b/ling_chair_http/chat-message.css @@ -87,4 +87,5 @@ .message-image { max-width: 40%; max-height: 40%; + border-radius: 15px; } diff --git a/ling_chair_http/handler.js b/ling_chair_http/handler.js index adc197c..d283c49 100644 --- a/ling_chair_http/handler.js +++ b/ling_chair_http/handler.js @@ -268,7 +268,7 @@ class ChatMsgAdapter { static target static minMsgId static time - static bbn + static minutesCache static resizeDick /** * 切换到某一个聊天对象 @@ -395,60 +395,62 @@ class ChatMsgAdapter { * @param {String || int} 消息id * @returns {jQuery} 消息元素 */ - static async addMsg(name, m, t, re, msgid) { + static async addMsg(name, preMsg, time, addToTop, msgid) { let nick = await NickCache.getNick(name) // re.data == null ? name : re.data.nick let msg try { - msg = await marked.parse(m) - } catch(e) { - console.log("解析消息失败: " + e) - msg = escapeHTML(m) + msg = await marked.parse(preMsg) + } catch(error) { + console.log("解析消息失败: " + error) + msg = escapeHTML(preMsg) } let temp if (name === localStorage.userName) temp = `
- ` + nick + ` -
- ` + msg + ` + ${ nick } +
+ ${ msg } +
${ preMsg }
- +
` else temp = `
- +
- ` + nick + ` -
- ` + msg + ` + ${ nick } +
+ ${ msg } +
${ preMsg }
` - let bn = new Date(t).getMinutes() - let e - if (re) { - this.addSystemMsg(temp, re) - if (this.bbn != bn) { - e = this.addSystemMsg(`
` + new Date().format(t == null ? Date.parse("1000-1-1 00:00:00") : t, "yyyy年MM月dd日 hh:mm:ss") + `
`, re) - this.time = bn + let nowMinutes = new Date(time).getMinutes() + let msgElement + if (addToTop) { + this.addSystemMsg(temp, addToTop) + if (this.minutesCache != nowMinutes) { + msgElement = this.addSystemMsg(`
` + new Date().format(time == null ? Date.parse("1000-1-1 00:00:00") : time, "yyyy年MM月dd日 hh:mm:ss") + `
`, addToTop) + this.time = nowMinutes } } else { - if (this.bbn != bn) { - e = this.addSystemMsg(`
` + new Date().format(t == null ? Date.parse("1000-1-1 00:00:00") : t, "yyyy年MM月dd日 hh:mm:ss") + `
`, re) - this.time = bn + if (this.minutesCache != nowMinutes) { + msgElement = this.addSystemMsg(`
` + new Date().format(time == null ? Date.parse("1000-1-1 00:00:00") : time, "yyyy年MM月dd日 hh:mm:ss") + `
`, addToTop) + this.time = nowMinutes } - this.addSystemMsg(temp, re) + this.addSystemMsg(temp, addToTop) } - this.bbn = new Date(t).getMinutes() + this.minutesCache = new Date(time).getMinutes() - return e + return msgElement } /** * 从服务器加载一些聊天记录 @@ -507,7 +509,10 @@ class ChatMsgAdapter { e = $(ele) let menuHtml = $.parseHTML(`