mirror of
https://github.com/LC044/WeChatMsg
synced 2025-05-23 08:38:02 +08:00
Merge pull request #114 from STDquantum/master
html页面输入页码可以回车跳转,跳转后自动滚动到页面顶部。统一了缩进
This commit is contained in:
commit
9d22c17ebd
@ -1,6 +1,42 @@
|
|||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
|
def merge_MediaMSG_databases(source_paths, target_path):
|
||||||
|
# 创建目标数据库连接
|
||||||
|
target_conn = sqlite3.connect(target_path)
|
||||||
|
target_cursor = target_conn.cursor()
|
||||||
|
try:
|
||||||
|
# 开始事务
|
||||||
|
target_conn.execute("BEGIN;")
|
||||||
|
for i, source_path in enumerate(source_paths):
|
||||||
|
if not os.path.exists(source_path):
|
||||||
|
break
|
||||||
|
db = sqlite3.connect(source_path)
|
||||||
|
db.text_factory = str
|
||||||
|
cursor = db.cursor()
|
||||||
|
sql = '''
|
||||||
|
SELECT Key,Reserved0,Buf,Reserved1,Reserved2 FROM Media;
|
||||||
|
'''
|
||||||
|
cursor.execute(sql)
|
||||||
|
result = cursor.fetchall()
|
||||||
|
# 附加源数据库
|
||||||
|
target_cursor.executemany(
|
||||||
|
"INSERT INTO Media (Key,Reserved0,Buf,Reserved1,Reserved2)"
|
||||||
|
"VALUES(?,?,?,?,?)",
|
||||||
|
result)
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
# 提交事务
|
||||||
|
target_conn.execute("COMMIT;")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
# 发生异常时回滚事务
|
||||||
|
target_conn.execute("ROLLBACK;")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# 关闭目标数据库连接
|
||||||
|
target_conn.close()
|
||||||
|
|
||||||
def merge_databases(source_paths, target_path):
|
def merge_databases(source_paths, target_path):
|
||||||
# 创建目标数据库连接
|
# 创建目标数据库连接
|
||||||
|
@ -518,7 +518,6 @@ html_head = '''
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Chat Records</title>
|
<title>Chat Records</title>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
*{
|
*{
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@ -779,9 +778,7 @@ input {
|
|||||||
<div class="item item-center">
|
<div class="item item-center">
|
||||||
<span>昨天 13:15</span>
|
<span>昨天 13:15</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div></div>
|
<div></div>
|
||||||
<div id="modal" class="modal" onclick="hideModal()">
|
<div id="modal" class="modal" onclick="hideModal()">
|
||||||
@ -793,7 +790,7 @@ input {
|
|||||||
<button onclick="nextPage()">下一页</button>
|
<button onclick="nextPage()">下一页</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="jump-row">
|
<div class="jump-row">
|
||||||
<input type="number" id="gotoPageInput" placeholder="跳转到第几页">
|
<input type="number" id="gotoPageInput" onkeydown="checkEnter(event)" placeholder="跳转到第几页">
|
||||||
<button onclick="gotoPage()">跳转</button>
|
<button onclick="gotoPage()">跳转</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="paginationInfo"></div>
|
<div id="paginationInfo"></div>
|
||||||
@ -846,6 +843,11 @@ html_end = '''
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkEnter(event) {
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
gotoPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const itemsPerPage = 100; // 每页显示的元素个数
|
const itemsPerPage = 100; // 每页显示的元素个数
|
||||||
let currentPage = 1; // 当前页
|
let currentPage = 1; // 当前页
|
||||||
@ -898,6 +900,7 @@ html_end = '''
|
|||||||
}
|
}
|
||||||
chatContainer.appendChild(messageElement);
|
chatContainer.appendChild(messageElement);
|
||||||
}
|
}
|
||||||
|
document.querySelector("#chat-container").scrollTop = 0;
|
||||||
updatePaginationInfo();
|
updatePaginationInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from PyQt5.QtGui import QDesktopServices
|
|||||||
from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog
|
from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog
|
||||||
|
|
||||||
from app.DataBase import msg_db, misc_db
|
from app.DataBase import msg_db, misc_db
|
||||||
from app.DataBase.merge import merge_databases
|
from app.DataBase.merge import merge_databases, merge_MediaMSG_databases
|
||||||
from app.decrypt import get_wx_info, decrypt
|
from app.decrypt import get_wx_info, decrypt
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.util import path
|
from app.util import path
|
||||||
@ -184,6 +184,19 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
|||||||
merge_databases(source_databases, target_database)
|
merge_databases(source_databases, target_database)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
|
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
|
||||||
|
|
||||||
|
# 音频数据库文件
|
||||||
|
target_database = "app/DataBase/Msg/MediaMSG.db"
|
||||||
|
# 源数据库文件列表
|
||||||
|
source_databases = [f"app/DataBase/Msg/MediaMSG{i}.db" for i in range(1, 20)]
|
||||||
|
import shutil
|
||||||
|
shutil.copy("app/DataBase/Msg/MediaMSG0.db", target_database) # 使用一个数据库文件作为模板
|
||||||
|
# 合并数据库
|
||||||
|
try:
|
||||||
|
merge_MediaMSG_databases(source_databases, target_database)
|
||||||
|
except FileNotFoundError:
|
||||||
|
QMessageBox.critical(self, "错误", "数据库不存在\n请检查微信版本是否为最新")
|
||||||
|
|
||||||
self.DecryptSignal.emit(True)
|
self.DecryptSignal.emit(True)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user