From 63460e0caadcb9d6c15b112bf17c315b77aa0d86 Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Fri, 19 Jan 2024 18:40:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/exporter_html.py | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/app/DataBase/exporter_html.py b/app/DataBase/exporter_html.py index 2d799f7..c6c40c9 100644 --- a/app/DataBase/exporter_html.py +++ b/app/DataBase/exporter_html.py @@ -298,36 +298,25 @@ class HtmlExporter(ExporterBase): print(f"【开始导出 HTML {self.contact.remark}】") messages = msg_db.get_messages(self.contact.wxid, time_range=self.time_range) filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}.html" - file_path = "./app/resources/data/template.html" + file_path = './app/resources/data/template.html' if not os.path.exists(file_path): - resource_dir = getattr( - sys, "_MEIPASS", os.path.abspath(os.path.dirname(__file__)) - ) - file_path = os.path.join( - resource_dir, "app", "resources", "data", "template.html" - ) + resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__))) + file_path = os.path.join(resource_dir, 'app', 'resources', 'data', 'template.html') with open(file_path, "r", encoding="utf-8") as f: content = f.read() - html_head, html_end = content.split("/*注意看这是分割线*/") - f = open(filename, "w", encoding="utf-8") - html_head = html_head.replace( - "出错了", f"{self.contact.remark}" - ) - html_head = html_head.replace( - '

出错了

', f'

{self.contact.remark}

' - ) + html_head, html_end = content.split('/*注意看这是分割线*/') + f = open(filename, 'w', encoding='utf-8') + html_head = html_head.replace("出错了", f"{self.contact.remark}") + html_head = html_head.replace("

出错了

", f"

{self.contact.remark}

") f.write(html_head) self.rangeSignal.emit(len(messages)) for index, message in enumerate(messages): type_ = message[2] sub_type = message[3] timestamp = message[5] - if ( - (type_ == 3 and self.message_types.get(3)) - or (type_ == 34 and self.message_types.get(34)) - or (type_ == 47 and self.message_types.get(47)) - ): + if (type_ == 3 and self.message_types.get(3)) or (type_ == 34 and self.message_types.get(34)) or ( + type_ == 47 and self.message_types.get(47)): pass else: self.progressSignal.emit(1)