From 83b238ba011f718f6c78f42d139c174655eac57d Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Wed, 13 Dec 2023 13:19:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8refertype?= =?UTF-8?q?=E7=9A=84bug=EF=BC=8C=E7=BE=8E=E5=8C=96=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=85=83=E7=B4=A0=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=B7=A8=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 36 ++++++++++++++++++++++++++---------- app/util/compress_content.py | 8 ++++---- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index ed1db8c..2a78a96 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -293,13 +293,14 @@ class ChildThread(QThread): content = parser_reply(message[11]) refer_msg = content.get('refer') if self.output_type == Output.HTML: - doc.write( - f'''{{ type:1, text: '{content.get('title')}',is_send:{is_send},avatar_path:'{avatar}'}},''' - ) - - doc.write( - f'''{{ type:{49},sub_type:{content.get('type')}, text: '{refer_msg.get('displayname')}:{refer_msg.get('content')}',is_send:{is_send},avatar_path:''}},''' - ) + if refer_msg: + doc.write( + f'''{{ type:49, text: '{content.get('title')}',is_send:{is_send},sub_type:{content.get('type')},refer_text: '{refer_msg.get('displayname')}:{refer_msg.get('content')}',avatar_path:'{avatar}'}},''' + ) + else: + doc.write( + f'''{{ type:49, text: '{content.get('title')}',is_send:{is_send},sub_type:{content.get('type')},avatar_path:'{avatar}'}},''' + ) elif self.output_type==Output.TXT: name = '你' if is_send else self.contact.remark doc.write( @@ -641,7 +642,7 @@ body{ } .chat-refer{ max-width: 400px; - padding: 3px; + padding: 6px; border-radius: 5px; position: relative; color: #000; @@ -690,6 +691,9 @@ body{ display: flex; width: 100%; } +.item-refer{ + margin-top: 4px; +} .item.item-right{ justify-content: flex-end; } @@ -908,6 +912,7 @@ html_end = ''' for (let i = startIndex; i < endIndex && i < chatMessages.length; i++) { const message = chatMessages[i]; const messageElement = document.createElement('div'); + const messageElementRefer = document.createElement('div'); if (message.type == 1) { if (message.is_send == 1) { messageElement.className = "item item-right"; @@ -946,11 +951,19 @@ html_end = ''' if (message.sub_type == 57){ if (message.is_send == 1) { messageElement.className = "item item-right"; - messageElement.innerHTML = `
${message.text}
` + messageElement.innerHTML = `
${message.text}
` + if (message.refer_text) { + messageElementRefer.className = "item item-right item-refer"; + messageElementRefer.innerHTML = `
${message.refer_text}
` + } } else if (message.is_send == 0) { messageElement.className = "item item-left"; - messageElement.innerHTML = `
${message.text}
` + messageElement.innerHTML = `
${message.text}
` + if (message.refer_text) { + messageElementRefer.className = "item item-left item-refer"; + messageElementRefer.innerHTML = `
${message.refer_text}
` + } } } } @@ -965,6 +978,9 @@ html_end = ''' } } chatContainer.appendChild(messageElement); + if (message.type == 49 && message.sub_type == 57 && message.refer_text) { + chatContainer.appendChild(messageElementRefer); + } } document.querySelector("#chat-container").scrollTop = 0; updatePaginationInfo(); diff --git a/app/util/compress_content.py b/app/util/compress_content.py index 42ae7b7..4d6511e 100644 --- a/app/util/compress_content.py +++ b/app/util/compress_content.py @@ -50,15 +50,15 @@ def parser_reply(data: bytes): } root = ET.XML(xml_content) appmsg = root.find('appmsg') - msg_type = appmsg.find('type').text + msg_type = int(appmsg.find('type').text) title = appmsg.find('title').text refermsg_content = appmsg.find('refermsg').find('content').text - refermsg_type = appmsg.find('refermsg').find('type').text + refermsg_type = int(appmsg.find('refermsg').find('type').text) refermsg_displayname = appmsg.find('refermsg').find('displayname').text return { 'type': msg_type, - 'title': title, - 'refer': { + 'title': escape_js_and_html(title), + 'refer': None if refermsg_type != 1 else { 'type': refermsg_type, 'content': escape_js_and_html(refermsg_content), 'displayname': escape_js_and_html(refermsg_displayname),