Skip to content

Commit

Permalink
修复图片都是缩略图的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Feb 3, 2024
1 parent 7099ce3 commit b793a44
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
7 changes: 1 addition & 6 deletions app/DataBase/exporter_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ def image(self, doc, message):
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}'}},'''
Expand Down
4 changes: 2 additions & 2 deletions app/DataBase/hard_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ def get_image_thumb(self, content, bytesExtra) -> str:
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

Expand Down
7 changes: 1 addition & 6 deletions app/DataBase/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,7 @@ def run(self):
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))
Expand Down
2 changes: 1 addition & 1 deletion app/ui/chat/chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def add_message(self, message):
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,
Expand Down

0 comments on commit b793a44

Please sign in to comment.