mirror of
https://github.com/LingChair/LingChair-V0.git
synced 2025-12-08 18:15:50 +08:00
chore: rename symbols, add "原文" menu
This commit is contained in:
@@ -87,4 +87,5 @@
|
|||||||
.message-image {
|
.message-image {
|
||||||
max-width: 40%;
|
max-width: 40%;
|
||||||
max-height: 40%;
|
max-height: 40%;
|
||||||
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ class ChatMsgAdapter {
|
|||||||
static target
|
static target
|
||||||
static minMsgId
|
static minMsgId
|
||||||
static time
|
static time
|
||||||
static bbn
|
static minutesCache
|
||||||
static resizeDick
|
static resizeDick
|
||||||
/**
|
/**
|
||||||
* 切换到某一个聊天对象
|
* 切换到某一个聊天对象
|
||||||
@@ -395,60 +395,62 @@ class ChatMsgAdapter {
|
|||||||
* @param {String || int} 消息id
|
* @param {String || int} 消息id
|
||||||
* @returns {jQuery} 消息元素
|
* @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 nick = await NickCache.getNick(name) // re.data == null ? name : re.data.nick
|
||||||
|
|
||||||
let msg
|
let msg
|
||||||
|
|
||||||
try {
|
try {
|
||||||
msg = await marked.parse(m)
|
msg = await marked.parse(preMsg)
|
||||||
} catch(e) {
|
} catch(error) {
|
||||||
console.log("解析消息失败: " + e)
|
console.log("解析消息失败: " + error)
|
||||||
msg = escapeHTML(m)
|
msg = escapeHTML(preMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp
|
let temp
|
||||||
if (name === localStorage.userName)
|
if (name === localStorage.userName)
|
||||||
temp = `<div class="chat-message-right">
|
temp = `<div class="chat-message-right">
|
||||||
<div class="message-content-with-nickname-right">
|
<div class="message-content-with-nickname-right">
|
||||||
<span class="nickname">` + nick + `</span>
|
<span class="nickname">${ nick }</span>
|
||||||
<div class="message-content mdui-card" tag="msg-card" id="msgid_` + msgid + `">
|
<div class="message-content mdui-card" tag="msg-card" id="msgid_${ msgid }">
|
||||||
<span id="msg-content">` + msg + `</span>
|
<span id="msg-content">${ msg }</span>
|
||||||
|
<pre class="mdui-hidden" id="raw-msg-content">${ preMsg }</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<img class="avatar" src="` + CurrentUser.getUserHeadUrl(name) + `" onerror="this.src='res/default_head.png'" />
|
<img class="avatar" src="${ CurrentUser.getUserHeadUrl(name) }" onerror="this.src='res/default_head.png'" />
|
||||||
</div>`
|
</div>`
|
||||||
else
|
else
|
||||||
temp = `<div class="chat-message-left">
|
temp = `<div class="chat-message-left">
|
||||||
<img class="avatar" src="` + CurrentUser.getUserHeadUrl(name) + `" onerror="this.src='res/default_head.png'" />
|
<img class="avatar" src="${ CurrentUser.getUserHeadUrl(name) }" onerror="this.src='res/default_head.png'" />
|
||||||
<div class="message-content-with-nickname-left">
|
<div class="message-content-with-nickname-left">
|
||||||
<span class="nickname">` + nick + `</span>
|
<span class="nickname">${ nick }</span>
|
||||||
<div class="message-content mdui-card" tag="msg-card" id="msgid_` + msgid + `">
|
<div class="message-content mdui-card" tag="msg-card" id="msgid_${ msgid }">
|
||||||
<span id="msg-content">` + msg + `</span>
|
<span id="msg-content">${ msg }</span>
|
||||||
|
<pre class="mdui-hidden" id="raw-msg-content">${ preMsg }</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
|
|
||||||
let bn = new Date(t).getMinutes()
|
let nowMinutes = new Date(time).getMinutes()
|
||||||
let e
|
let msgElement
|
||||||
if (re) {
|
if (addToTop) {
|
||||||
this.addSystemMsg(temp, re)
|
this.addSystemMsg(temp, addToTop)
|
||||||
if (this.bbn != bn) {
|
if (this.minutesCache != nowMinutes) {
|
||||||
e = this.addSystemMsg(`<div class="mdui-center">` + new Date().format(t == null ? Date.parse("1000-1-1 00:00:00") : t, "yyyy年MM月dd日 hh:mm:ss") + `</div>`, re)
|
msgElement = this.addSystemMsg(`<div class="mdui-center">` + new Date().format(time == null ? Date.parse("1000-1-1 00:00:00") : time, "yyyy年MM月dd日 hh:mm:ss") + `</div>`, addToTop)
|
||||||
this.time = bn
|
this.time = nowMinutes
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.bbn != bn) {
|
if (this.minutesCache != nowMinutes) {
|
||||||
e = this.addSystemMsg(`<div class="mdui-center">` + new Date().format(t == null ? Date.parse("1000-1-1 00:00:00") : t, "yyyy年MM月dd日 hh:mm:ss") + `</div>`, re)
|
msgElement = this.addSystemMsg(`<div class="mdui-center">` + new Date().format(time == null ? Date.parse("1000-1-1 00:00:00") : time, "yyyy年MM月dd日 hh:mm:ss") + `</div>`, addToTop)
|
||||||
this.time = bn
|
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)
|
e = $(ele)
|
||||||
let menuHtml = $.parseHTML(`<ul class="mdui-menu menu-on-message">
|
let menuHtml = $.parseHTML(`<ul class="mdui-menu menu-on-message">
|
||||||
<li class="mdui-menu-item">
|
<li class="mdui-menu-item">
|
||||||
<a onclick="copyText(\`` + e.find("#msg-content").text() + `\`)" class="mdui-ripple">复制</a>
|
<a onclick="copyText(\`${ e.find("#msg-content").text() }\`)" class="mdui-ripple">复制</a>
|
||||||
|
</li>
|
||||||
|
<li class="mdui-menu-item">
|
||||||
|
<a onclick="mdui.alert(\`${ e.find("#raw-msg-content").text() }\`, '消息原文', () => { }, { confirmText: '关闭' })" class="mdui-ripple">原文</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="mdui-menu-item">
|
<li class="mdui-menu-item">
|
||||||
<a onclick="mdui.alert('未制作功能', '提示', () => { }, { confirmText: '关闭' })" class="mdui-ripple">转发</a>
|
<a onclick="mdui.alert('未制作功能', '提示', () => { }, { confirmText: '关闭' })" class="mdui-ripple">转发</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user