修复图片都是缩略图的问题

This commit is contained in:
SiYuan 2024-02-03 15:11:56 +08:00
parent 7099ce35cd
commit b793a4424a
4 changed files with 5 additions and 15 deletions

View File

@ -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}'}},'''

View File

@ -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

View File

@ -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))

View File

@ -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,