HTML支持导出图片

This commit is contained in:
shuaikangzhou 2023-11-28 21:51:49 +08:00
parent 652ffd7548
commit b1da9730b1
5 changed files with 25 additions and 30 deletions

View File

@ -4,11 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修复str_content转义问题">
<change afterPath="$PROJECT_DIR$/app/web_ui/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/app/web_ui/web.py" afterDir="false" />
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="add web">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/resources/resource.qrc" beforeDir="false" afterPath="$PROJECT_DIR$/app/resources/resource.qrc" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/DataBase/hard_link.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/hard_link.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/DataBase/output_pc.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/DataBase/output_pc.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/util/dat2pic.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/util/dat2pic.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/util/path.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/util/path.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -269,13 +270,6 @@
<option name="presentableId" value="Default" />
<updated>1672848140146</updated>
</task>
<task id="LOCAL-00045" summary="加快打开速度">
<created>1699367814847</created>
<option name="number" value="00045" />
<option name="presentableId" value="LOCAL-00045" />
<option name="project" value="LOCAL" />
<updated>1699367814847</updated>
</task>
<task id="LOCAL-00046" summary="修改导入路径方便打包成exe">
<created>1699373594568</created>
<option name="number" value="00046" />
@ -612,7 +606,14 @@
<option name="project" value="LOCAL" />
<updated>1701178257665</updated>
</task>
<option name="localTasksCounter" value="94" />
<task id="LOCAL-00094" summary="add web">
<created>1701178346464</created>
<option name="number" value="00094" />
<option name="presentableId" value="LOCAL-00094" />
<option name="project" value="LOCAL" />
<updated>1701178346464</updated>
</task>
<option name="localTasksCounter" value="95" />
<servers />
</component>
<component name="UnknownFeatures">
@ -648,7 +649,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="新增聊天记录导出csv格式" />
<MESSAGE value="导出所有数据库的聊天记录" />
<MESSAGE value="数据库加锁避免多线程访问报错" />
<MESSAGE value="修复聊天气泡不能更改大小的bug" />
@ -673,7 +673,8 @@
<MESSAGE value="更新帮助链接" />
<MESSAGE value="新增导出所有聊天记录到CSV" />
<MESSAGE value="修复str_content转义问题" />
<option name="LAST_COMMIT_MESSAGE" value="修复str_content转义问题" />
<MESSAGE value="add web" />
<option name="LAST_COMMIT_MESSAGE" value="add web" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component>

View File

@ -4,6 +4,8 @@ import sqlite3
import threading
import xml.etree.ElementTree as ET
from app.log import log
lock = threading.Lock()
DB = None
cursor = None
@ -56,10 +58,9 @@ def get_md5_from_xml(content):
return md5_value
@log
def get_image(content, thumb=False):
md5 = get_md5_from_xml(content)
# md5 = 'bc37a58c32cb203ee9ac587b068e5853'
# md5 = '41895664fc5a77878e2155fc96209a19'
result = get_image_by_md5(binascii.unhexlify(md5))
if result:
# print(result)

View File

@ -5,10 +5,10 @@ import os
from PyQt5.QtCore import pyqtSignal, QThread
from . import msg
from ..person_pc import MePC
from ..DataBase import hard_link
from ..person_pc import MePC
from ..util import get_abs_path
if not os.path.exists('./data/聊天记录'):
os.mkdir('./data/聊天记录')
@ -718,13 +718,8 @@ const chatMessages = [
avatar = 'myhead.png' if is_send else 'tahead.png'
timestamp = message[5]
self.progressSignal.emit(index)
if type_ == 1:
str_content = str_content.replace('"', '\\"').replace('{', '\\{').replace('}', '\\}').replace('\n',
'\\n').replace(
"'", "\\'")
str_content = escape_js_and_html(str_content)
if type_ == 1:
str_content = escape_js_and_html(str_content)
if self.is_5_min(timestamp):
f.write(
f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:''}},'''

View File

@ -44,6 +44,8 @@ def decode_dat(file_path, out_path):
:param file_path: dat文件路径
:return:
"""
if not os.path.exists(file_path):
return None
file_type, decode_code = get_code(file_path)
if decode_code == -1:

View File

@ -12,12 +12,8 @@ if not os.path.exists('./data/image'):
def get_abs_path(path):
# return os.path.join(os.getcwd(), 'app/data/icons/404.png')
if path:
# if os.path.exists(os.path.join())
# print(path, os.path.join(MePC().wx_dir, path), MePC().wx_dir)
output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), './data/image')
base_path = os.getcwd() + "/data/image"
output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), base_path) #'./data/image')
return output_path
output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), base_path) # './data/image')
return output_path if output_path else ':/icons/icons/404.png'
else:
return ':/icons/icons/404.png'