mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-23 19:52:18 +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,234 +518,233 @@ 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;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
*{
|
.modal {
|
||||||
padding: 0;
|
display: none;
|
||||||
margin: 0;
|
position: fixed;
|
||||||
}
|
z-index: 9999;
|
||||||
body{
|
top: 0;
|
||||||
height: 100vh;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
height: 100%;
|
||||||
align-items: center;
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
justify-content: center;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.modal {
|
.modal-image {
|
||||||
display: none;
|
display: block;
|
||||||
position: fixed;
|
max-width: 90%;
|
||||||
z-index: 9999;
|
max-height: 90%;
|
||||||
top: 0;
|
margin: auto;
|
||||||
left: 0;
|
margin-top: 5%;
|
||||||
width: 100%;
|
}
|
||||||
height: 100%;
|
.container{
|
||||||
background-color: rgba(0, 0, 0, 0.8);
|
height: 760px;
|
||||||
}
|
width: 900px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 0.5px solid #e0e0e0;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
padding: 20px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.content:hover::-webkit-scrollbar-thumb{
|
||||||
|
background:rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.bubble{
|
||||||
|
max-width: 400px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px;
|
||||||
|
position: relative;
|
||||||
|
color: #000;
|
||||||
|
word-wrap:break-word;
|
||||||
|
word-break:normal;
|
||||||
|
}
|
||||||
|
.item-left .bubble{
|
||||||
|
margin-left: 15px;
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.item-left .bubble:before{
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 10px solid transparent;
|
||||||
|
border-top: 10px solid transparent;
|
||||||
|
border-right: 10px solid #fff;
|
||||||
|
border-bottom: 10px solid transparent;
|
||||||
|
left: -20px;
|
||||||
|
}
|
||||||
|
.item-right .bubble{
|
||||||
|
margin-right: 15px;
|
||||||
|
background-color: #9eea6a;
|
||||||
|
}
|
||||||
|
.item-right .bubble:before{
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 10px solid #9eea6a;
|
||||||
|
border-top: 10px solid transparent;
|
||||||
|
border-right: 10px solid transparent;
|
||||||
|
border-bottom: 10px solid transparent;
|
||||||
|
right: -20px;
|
||||||
|
}
|
||||||
|
.item{
|
||||||
|
margin-top: 15px;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.item.item-right{
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
.item.item-center{
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.item.item-center span{
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 2px 4px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #dadada;
|
||||||
|
border-radius: 3px;
|
||||||
|
-moz-user-select:none; /*火狐*/
|
||||||
|
-webkit-user-select:none; /*webkit浏览器*/
|
||||||
|
-ms-user-select:none; /*IE10*/
|
||||||
|
-khtml-user-select:none; /*早期浏览器*/
|
||||||
|
user-select:none;
|
||||||
|
}
|
||||||
|
|
||||||
.modal-image {
|
.chat-image img{
|
||||||
display: block;
|
|
||||||
max-width: 90%;
|
|
||||||
max-height: 90%;
|
|
||||||
margin: auto;
|
|
||||||
margin-top: 5%;
|
|
||||||
}
|
|
||||||
.container{
|
|
||||||
height: 760px;
|
|
||||||
width: 900px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border: 0.5px solid #e0e0e0;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
display: flex;
|
|
||||||
flex-flow: column;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.content{
|
|
||||||
width: calc(100% - 40px);
|
|
||||||
padding: 20px;
|
|
||||||
overflow-y: scroll;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
.content:hover::-webkit-scrollbar-thumb{
|
|
||||||
background:rgba(0,0,0,0.1);
|
|
||||||
}
|
|
||||||
.bubble{
|
|
||||||
max-width: 400px;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
position: relative;
|
|
||||||
color: #000;
|
|
||||||
word-wrap:break-word;
|
|
||||||
word-break:normal;
|
|
||||||
}
|
|
||||||
.item-left .bubble{
|
|
||||||
margin-left: 15px;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
.item-left .bubble:before{
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-left: 10px solid transparent;
|
|
||||||
border-top: 10px solid transparent;
|
|
||||||
border-right: 10px solid #fff;
|
|
||||||
border-bottom: 10px solid transparent;
|
|
||||||
left: -20px;
|
|
||||||
}
|
|
||||||
.item-right .bubble{
|
|
||||||
margin-right: 15px;
|
|
||||||
background-color: #9eea6a;
|
|
||||||
}
|
|
||||||
.item-right .bubble:before{
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border-left: 10px solid #9eea6a;
|
|
||||||
border-top: 10px solid transparent;
|
|
||||||
border-right: 10px solid transparent;
|
|
||||||
border-bottom: 10px solid transparent;
|
|
||||||
right: -20px;
|
|
||||||
}
|
|
||||||
.item{
|
|
||||||
margin-top: 15px;
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.item.item-right{
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
.item.item-center{
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
.item.item-center span{
|
|
||||||
font-size: 12px;
|
|
||||||
padding: 2px 4px;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #dadada;
|
|
||||||
border-radius: 3px;
|
|
||||||
-moz-user-select:none; /*火狐*/
|
|
||||||
-webkit-user-select:none; /*webkit浏览器*/
|
|
||||||
-ms-user-select:none; /*IE10*/
|
|
||||||
-khtml-user-select:none; /*早期浏览器*/
|
|
||||||
user-select:none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-image img{
|
|
||||||
margin-right: 18px;
|
margin-right: 18px;
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
max-height: auto;
|
max-height: auto;
|
||||||
}
|
}
|
||||||
.avatar img{
|
.avatar img{
|
||||||
width: 42px;
|
width: 42px;
|
||||||
height: 42px;
|
height: 42px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
.chat-video video{
|
.chat-video video{
|
||||||
margin-right: 18px;
|
margin-right: 18px;
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
max-width: 350px;
|
max-width: 350px;
|
||||||
}
|
}
|
||||||
.input-area{
|
.input-area{
|
||||||
border-top:0.5px solid #e0e0e0;
|
border-top:0.5px solid #e0e0e0;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
textarea{
|
textarea{
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
outline:none;
|
outline:none;
|
||||||
resize:none;
|
resize:none;
|
||||||
}
|
}
|
||||||
.button-area{
|
.button-area{
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
.button-area button{
|
.button-area button{
|
||||||
width: 80px;
|
width: 80px;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
float: right;
|
float: right;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 设置滚动条的样式 */
|
/* 设置滚动条的样式 */
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width:10px;
|
width:10px;
|
||||||
}
|
}
|
||||||
/* 滚动槽 */
|
/* 滚动槽 */
|
||||||
::-webkit-scrollbar-track {
|
::-webkit-scrollbar-track {
|
||||||
-webkit-box-shadow:inset006pxrgba(0,0,0,0.3);
|
-webkit-box-shadow:inset006pxrgba(0,0,0,0.3);
|
||||||
border-radius:8px;
|
border-radius:8px;
|
||||||
}
|
}
|
||||||
/* 滚动条滑块 */
|
/* 滚动条滑块 */
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
border-radius:10px;
|
border-radius:10px;
|
||||||
background:rgba(0,0,0,0);
|
background:rgba(0,0,0,0);
|
||||||
-webkit-box-shadow:inset006pxrgba(0,0,0,0.5);
|
-webkit-box-shadow:inset006pxrgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination-container {
|
.pagination-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-left: 20px; /* 新增的左边距 */
|
margin-left: 20px; /* 新增的左边距 */
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-row,
|
.button-row,
|
||||||
.jump-row,
|
.jump-row,
|
||||||
#paginationInfo {
|
#paginationInfo {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 10px 25px;
|
padding: 10px 25px;
|
||||||
background-color: #3498db;
|
background-color: #3498db;
|
||||||
color: white;
|
color: white;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin: 0 14px;
|
margin: 0 14px;
|
||||||
transition: background-color 0.3s;
|
transition: background-color 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
background-color: #2980b9;
|
background-color: #2980b9;
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
input {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin-right: 0px;
|
margin-right: 0px;
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button,
|
button,
|
||||||
input {
|
input {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#paginationInfo {
|
#paginationInfo {
|
||||||
color: #555;
|
color: #555;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji_img {
|
.emoji_img {
|
||||||
@ -758,7 +757,7 @@ input {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="content" id="chat-container">
|
<div class="content" id="chat-container">
|
||||||
<div class="item item-center"><span>昨天 12:35</span></div>
|
<div class="item item-center"><span>昨天 12:35</span></div>
|
||||||
<div class="item item-center"><span>你已添加了凡繁烦,现在可以开始聊天了。</span></div>
|
<div class="item item-center"><span>你已添加了凡繁烦,现在可以开始聊天了。</span></div>
|
||||||
@ -779,65 +778,63 @@ 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()">
|
||||||
<img id="modal-image" class="modal-image">
|
<img id="modal-image" class="modal-image">
|
||||||
</div>
|
</div>
|
||||||
<div class="pagination-container">
|
<div class="pagination-container">
|
||||||
<div class="button-row">
|
<div class="button-row">
|
||||||
<button onclick="prevPage()">上一页</button>
|
<button onclick="prevPage()">上一页</button>
|
||||||
<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>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
const chatContainer = document.getElementById('chat-container');
|
const chatContainer = document.getElementById('chat-container');
|
||||||
// Sample chat messages (replace this with your actual data)
|
// Sample chat messages (replace this with your actual data)
|
||||||
const chatMessages = [
|
const chatMessages = [
|
||||||
'''
|
'''
|
||||||
html_end = '''
|
html_end = '''
|
||||||
];
|
];
|
||||||
function renderMessages(messages) {
|
function renderMessages(messages) {
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
const messageElement = document.createElement('div');
|
const messageElement = document.createElement('div');
|
||||||
if (message.type == 1){
|
if (message.type == 1) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='bubble bubble-right'>${message.text}</div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='bubble bubble-right'>${message.text}</div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='bubble bubble-right'>${message.text}</div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='bubble bubble-right'>${message.text}</div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(message.type == 0){
|
else if (message.type == 0) {
|
||||||
messageElement.className = "item item-center";
|
messageElement.className = "item item-center";
|
||||||
messageElement.innerHTML = `<span>${message.text}</span>`
|
messageElement.innerHTML = `<span>${message.text}</span>`
|
||||||
}
|
}
|
||||||
else if (message.type == 3){
|
else if (message.type == 3) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='chat-image'><img src="${message.text}" /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='chat-image'><img src="${message.text}" /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-image'><img src="${message.text}" /></div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-image'><img src="${message.text}" /></div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (message.type == 43) {
|
else if (message.type == 43) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='chat-video'><video src="${message.text}" controls /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='chat-video'><video src="${message.text}" controls /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-video'><video src="${message.text}" controls /></div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-video'><video src="${message.text}" controls /></div>`
|
||||||
}
|
}
|
||||||
@ -846,110 +843,116 @@ html_end = '''
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkEnter(event) {
|
||||||
|
if (event.keyCode === 13) {
|
||||||
|
gotoPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const itemsPerPage = 100; // 每页显示的元素个数
|
const itemsPerPage = 100; // 每页显示的元素个数
|
||||||
let currentPage = 1; // 当前页
|
let currentPage = 1; // 当前页
|
||||||
|
|
||||||
function renderPage(page) {
|
function renderPage(page) {
|
||||||
const container = document.getElementById('chat-container');
|
const container = document.getElementById('chat-container');
|
||||||
container.innerHTML = ''; // 清空容器
|
container.innerHTML = ''; // 清空容器
|
||||||
|
|
||||||
// 计算当前页应该显示的元素范围
|
// 计算当前页应该显示的元素范围
|
||||||
const startIndex = (page - 1) * itemsPerPage;
|
const startIndex = (page - 1) * itemsPerPage;
|
||||||
const endIndex = startIndex + itemsPerPage;
|
const endIndex = startIndex + itemsPerPage;
|
||||||
console.log(page);
|
console.log(page);
|
||||||
// 从数据列表中取出对应范围的元素并添加到容器中
|
// 从数据列表中取出对应范围的元素并添加到容器中
|
||||||
for (let i = startIndex; i < endIndex && i < chatMessages.length; i++) {
|
for (let i = startIndex; i < endIndex && i < chatMessages.length; i++) {
|
||||||
const message = chatMessages[i];
|
const message = chatMessages[i];
|
||||||
const messageElement = document.createElement('div');
|
const messageElement = document.createElement('div');
|
||||||
if (message.type == 1){
|
if (message.type == 1) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='bubble bubble-right'>${message.text}</div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='bubble bubble-right'>${message.text}</div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='bubble bubble-right'>${message.text}</div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='bubble bubble-right'>${message.text}</div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(message.type == 0){
|
else if (message.type == 0) {
|
||||||
messageElement.className = "item item-center";
|
messageElement.className = "item item-center";
|
||||||
messageElement.innerHTML = `<span>${message.text}</span>`
|
messageElement.innerHTML = `<span>${message.text}</span>`
|
||||||
}
|
}
|
||||||
else if (message.type == 3){
|
else if (message.type == 3) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='chat-image' ><img src="${message.text}" onclick="showModal(this)"/></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='chat-image' ><img src="${message.text}" onclick="showModal(this)"/></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}"/></div><div class='chat-image'><img src="${message.text}" onclick="showModal(this)"/></div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}"/></div><div class='chat-image'><img src="${message.text}" onclick="showModal(this)"/></div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (message.type == 43) {
|
else if (message.type == 43) {
|
||||||
if (message.is_send == 1){
|
if (message.is_send == 1) {
|
||||||
messageElement.className = "item item-right";
|
messageElement.className = "item item-right";
|
||||||
messageElement.innerHTML = `<div class='chat-video'><video src="${message.text}" controls /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
messageElement.innerHTML = `<div class='chat-video'><video src="${message.text}" controls /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
|
||||||
}
|
}
|
||||||
else if(message.is_send==0){
|
else if (message.is_send == 0) {
|
||||||
messageElement.className = "item item-left";
|
messageElement.className = "item item-left";
|
||||||
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-video'><video src="${message.text}" controls "/></div>`
|
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-video'><video src="${message.text}" controls "/></div>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chatContainer.appendChild(messageElement);
|
chatContainer.appendChild(messageElement);
|
||||||
|
}
|
||||||
|
document.querySelector("#chat-container").scrollTop = 0;
|
||||||
|
updatePaginationInfo();
|
||||||
}
|
}
|
||||||
updatePaginationInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
function prevPage() {
|
function prevPage() {
|
||||||
if (currentPage > 1) {
|
if (currentPage > 1) {
|
||||||
currentPage--;
|
currentPage--;
|
||||||
renderPage(currentPage);
|
renderPage(currentPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function nextPage() {
|
function nextPage() {
|
||||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||||
if (currentPage < totalPages) {
|
if (currentPage < totalPages) {
|
||||||
currentPage++;
|
currentPage++;
|
||||||
renderPage(currentPage);
|
renderPage(currentPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
function updatePaginationInfo() {
|
||||||
function updatePaginationInfo() {
|
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
const paginationInfo = document.getElementById('paginationInfo');
|
||||||
const paginationInfo = document.getElementById('paginationInfo');
|
paginationInfo.textContent = `共 ${totalPages} 页,当前第 ${currentPage} 页`;
|
||||||
paginationInfo.textContent = `共 ${totalPages} 页,当前第 ${currentPage} 页`;
|
|
||||||
}
|
|
||||||
function gotoPage() {
|
|
||||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
|
||||||
const inputElement = document.getElementById('gotoPageInput');
|
|
||||||
const targetPage = parseInt(inputElement.value);
|
|
||||||
|
|
||||||
if (targetPage >= 1 && targetPage <= totalPages) {
|
|
||||||
currentPage = targetPage;
|
|
||||||
renderPage(currentPage);
|
|
||||||
} else {
|
|
||||||
alert('请输入有效的页码');
|
|
||||||
}
|
}
|
||||||
}
|
function gotoPage() {
|
||||||
|
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||||
|
const inputElement = document.getElementById('gotoPageInput');
|
||||||
|
const targetPage = parseInt(inputElement.value);
|
||||||
|
|
||||||
// 初始化页面
|
if (targetPage >= 1 && targetPage <= totalPages) {
|
||||||
renderPage(currentPage);
|
currentPage = targetPage;
|
||||||
|
renderPage(currentPage);
|
||||||
|
} else {
|
||||||
|
alert('请输入有效的页码');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化页面
|
||||||
|
renderPage(currentPage);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function showModal(image) {
|
function showModal(image) {
|
||||||
var modal = document.getElementById("modal");
|
var modal = document.getElementById("modal");
|
||||||
var modalImage = document.getElementById("modal-image");
|
var modalImage = document.getElementById("modal-image");
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
modalImage.src = image.src;
|
modalImage.src = image.src;
|
||||||
console.log(image.src);
|
console.log(image.src);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideModal() {
|
function hideModal() {
|
||||||
var modal = document.getElementById("modal");
|
var modal = document.getElementById("modal");
|
||||||
modal.style.display = "none";
|
modal.style.display = "none";
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -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
|
||||||
@ -173,7 +173,7 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
|||||||
except:
|
except:
|
||||||
with open('./info.json', 'w', encoding='utf-8') as f:
|
with open('./info.json', 'w', encoding='utf-8') as f:
|
||||||
f.write(json.dumps(dic))
|
f.write(json.dumps(dic))
|
||||||
# 目标数据库文件
|
# 目标数据库文件
|
||||||
target_database = "app/DataBase/Msg/MSG.db"
|
target_database = "app/DataBase/Msg/MSG.db"
|
||||||
# 源数据库文件列表
|
# 源数据库文件列表
|
||||||
source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1, 20)]
|
source_databases = [f"app/DataBase/Msg/MSG{i}.db" for i in range(1, 20)]
|
||||||
@ -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