diff --git a/app/DataBase/exporter_html.py b/app/DataBase/exporter_html.py index 086666b..65ff969 100644 --- a/app/DataBase/exporter_html.py +++ b/app/DataBase/exporter_html.py @@ -55,12 +55,7 @@ class HtmlExporter(ExporterBase): avatar = self.get_avatar_path(is_send, message) display_name = self.get_display_name(is_send, message) str_content = escape_js_and_html(str_content) - image_path = hard_link_db.get_image(str_content, BytesExtra, thumb=False) - if not os.path.exists(os.path.join(Me().wx_dir, image_path)): - image_thumb_path = hard_link_db.get_image(str_content, BytesExtra, thumb=True) - if not os.path.exists(os.path.join(Me().wx_dir, image_thumb_path)): - return - image_path = image_thumb_path + image_path = hard_link_db.get_image(str_content, BytesExtra, up_dir=Me().wx_dir, thumb=False) image_path = get_image_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image') doc.write( f'''{{ type:{type_}, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{display_name}'}},''' diff --git a/app/DataBase/hard_link.py b/app/DataBase/hard_link.py index 177c497..95cf643 100644 --- a/app/DataBase/hard_link.py +++ b/app/DataBase/hard_link.py @@ -226,14 +226,14 @@ class HardLink: result = dat_image return result - def get_image(self, content, bytesExtra, thumb=False) -> str: + def get_image(self, content, bytesExtra, up_dir="", thumb=False) -> str: msg_bytes = MessageBytesExtra() msg_bytes.ParseFromString(bytesExtra) if thumb: result = self.get_image_thumb(content, bytesExtra) else: result = self.get_image_original(content, bytesExtra) - if not (result and os.path.exists(result)): + if not (result and os.path.exists(os.path.join(up_dir, result))): result = self.get_image_thumb(content, bytesExtra) return result diff --git a/app/DataBase/output.py b/app/DataBase/output.py index 540e7c4..a8e2ab8 100644 --- a/app/DataBase/output.py +++ b/app/DataBase/output.py @@ -379,12 +379,7 @@ class OutputImage(QThread): BytesExtra = message[10] timestamp = message[5] try: - image_path = hard_link_db.get_image(str_content, BytesExtra, thumb=False) - if not os.path.exists(os.path.join(Me().wx_dir, image_path)): - image_thumb_path = hard_link_db.get_image(str_content, BytesExtra, thumb=True) - if not os.path.exists(os.path.join(Me().wx_dir, image_thumb_path)): - continue - image_path = image_thumb_path + image_path = hard_link_db.get_image(str_content, BytesExtra, up_dir=Me().wx_dir,thumb=False) image_path = get_image(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image') try: os.utime(origin_docx_path + image_path[1:], (timestamp, timestamp)) diff --git a/app/ui/chat/chat_info.py b/app/ui/chat/chat_info.py index 6473846..0fa8b42 100644 --- a/app/ui/chat/chat_info.py +++ b/app/ui/chat/chat_info.py @@ -134,7 +134,7 @@ class ChatInfo(QWidget): time_message = Notice(self.last_str_time) self.last_str_time = str_time self.chat_window.add_message_item(time_message, 0) - image_path = hard_link_db.get_image(content=str_content, bytesExtra=BytesExtra, thumb=False) + image_path = hard_link_db.get_image(content=str_content, bytesExtra=BytesExtra, up_dir=Me().wx_dir,thumb=False) image_path = get_abs_path(image_path) bubble_message = BubbleMessage( image_path,