From 3ceb9e23401792f19fc1110c39a493286bb2818a Mon Sep 17 00:00:00 2001
From: shuaikangzhou <863909694@qq.com>
Date: Wed, 15 Nov 2023 23:53:39 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddb=E6=96=87=E4=BB=B6=E7=A9=BA?=
=?UTF-8?q?=E6=A0=BC=E8=B7=AF=E5=BE=84=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 76 ++++++++++++++++----------------
app/DataBase/msg.py | 11 +++++
app/DataBase/output_pc.py | 52 ++++++++++++++++++++++
app/Ui/decrypt/decrypt.py | 6 ++-
app/Ui/mainview.py | 4 +-
app/person.py | 2 +-
app/ui_pc/contact/contactInfo.py | 17 +++++--
7 files changed, 125 insertions(+), 43 deletions(-)
create mode 100644 app/DataBase/msg.py
create mode 100644 app/DataBase/output_pc.py
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c1725e9..d2bda6c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,14 @@
-
+
+
+
+
+
-
-
-
+
@@ -105,7 +107,7 @@
-
+
@@ -169,6 +171,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -211,34 +234,13 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
@@ -254,13 +256,6 @@
1672848140146
-
- 1680232548867
-
-
-
- 1680232548867
-
1680441801589
@@ -597,7 +592,14 @@
1700058733119
-
+
+ 1700060367255
+
+
+
+ 1700060367255
+
+
@@ -633,7 +635,6 @@
-
@@ -658,7 +659,8 @@
-
+
+
diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py
new file mode 100644
index 0000000..ea8ed4a
--- /dev/null
+++ b/app/DataBase/msg.py
@@ -0,0 +1,11 @@
+import os.path
+import sqlite3
+
+DB = None
+cursor = None
+misc_path = "./app/Database/Msg/MSG0.db"
+# misc_path = './Msg/Misc.db'
+if os.path.exists(misc_path):
+ DB = sqlite3.connect(misc_path, check_same_thread=False)
+ # '''创建游标'''
+ cursor = DB.cursor()
diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py
new file mode 100644
index 0000000..b1bffb2
--- /dev/null
+++ b/app/DataBase/output_pc.py
@@ -0,0 +1,52 @@
+import os
+
+import numpy as np
+import pandas as pd
+from PyQt5.QtCore import pyqtSignal
+
+
+class Output(QThread):
+ """
+ 发送信息线程
+ """
+ progressSignal = pyqtSignal(int)
+ rangeSignal = pyqtSignal(int)
+ okSignal = pyqtSignal(int)
+ i = 1
+ CSV = 0
+ DOCX = 1
+ HTML = 2
+
+ def __init__(self, ta_u, parent=None, type_=DOCX):
+ super().__init__(parent)
+ self.sec = 2 # 默认1000秒
+ self.ta_username = ta_u
+ self.msg_id = 0
+ self.output_type = type_
+ self.total_num = 0
+
+ @log
+ def to_csv(self, conRemark, path):
+ origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}"
+ filename = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}/{conRemark}.csv"
+ last_timestamp = 1601968667000
+ columns = ["用户名", "消息内容", "发送时间", "发送状态", "消息类型", "isSend", "msgId"]
+ df = pd.DataFrame()
+ df["用户名"] = np.array(list(map(lambda x: x[7], messages)))
+ df["消息内容"] = np.array(list(map(lambda x: x[8], messages)))
+ df["发送时间"] = np.array(list(map(lambda x: time_format(x[6]), messages)))
+ df["发送状态"] = np.array(list(map(lambda x: x[3], messages)))
+ df["消息类型"] = np.array(list(map(lambda x: x[2], messages)))
+ df["isSend"] = np.array(list(map(lambda x: x[4], messages)))
+ df["msgId"] = np.array(list(map(lambda x: x[0], messages)))
+ df.to_csv(filename)
+ # df.to_csv('data.csv')
+ print(df)
+ self.progressSignal.emit(self.num)
+
+ def run(self):
+ if self.output_type == self.DOCX:
+ return
+ elif self.output_type == self.CSV:
+ # print("线程导出csv")
+ self.to_csv(self.ta_username, "path")
diff --git a/app/Ui/decrypt/decrypt.py b/app/Ui/decrypt/decrypt.py
index 981879b..7204a7c 100644
--- a/app/Ui/decrypt/decrypt.py
+++ b/app/Ui/decrypt/decrypt.py
@@ -51,7 +51,11 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
def get_db(self):
self.db_path, _ = QFileDialog.getOpenFileName(self, 'Open file', r'..', "Database files (*.db)")
if self.db_path:
- if self.db_path.isascii():
+ if ' ' in self.db_path:
+ self.label_db.setText('数据库未就绪')
+ QMessageBox.critical(self, "错误", "db文件路径请不要带有空格\n可以放在D:\\\\data 目录下")
+ self.db_path = ''
+ elif self.db_path.isascii():
self.label_db.setText('数据库已就绪')
return self.db_path
else:
diff --git a/app/Ui/mainview.py b/app/Ui/mainview.py
index 16ddfff..74b6129 100644
--- a/app/Ui/mainview.py
+++ b/app/Ui/mainview.py
@@ -12,11 +12,13 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from app import config
+from app.DataBase import data
from app.Ui import mainwindow
from app.Ui.Icon import Icon
from app.Ui.chat import chat
from app.Ui.contact import contact
from app.components.prompt_bar import PromptBar
+from app.person import Me
class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
@@ -29,7 +31,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.setWindowIcon(Icon.MainWindow_Icon)
self.setAttribute(Qt.WA_AttributeCount)
-
+ self.Me = Me(data.get_myinfo())
self.chatView = chat.ChatController(self.Me, parent=None)
self.lay = QHBoxLayout()
self.page_chat.setLayout(self.lay)
diff --git a/app/person.py b/app/person.py
index c03548e..09f22a4 100644
--- a/app/person.py
+++ b/app/person.py
@@ -5,7 +5,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from app.DataBase import data
-from app.ui_pc.Icon import Icon
+from app.Ui.Icon import Icon
# from app.Ui.Icon import Icon
diff --git a/app/ui_pc/contact/contactInfo.py b/app/ui_pc/contact/contactInfo.py
index 20b2d8e..9f70d27 100644
--- a/app/ui_pc/contact/contactInfo.py
+++ b/app/ui_pc/contact/contactInfo.py
@@ -2,7 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from app import person
-from app.DataBase import output
+from app.DataBase.output import Output
from app.Ui.Icon import Icon
from .contactInfoUi import Ui_Form
from .userinfo import userinfo
@@ -97,10 +97,21 @@ class ContactInfo(QWidget, Ui_Form):
"""
self.stackedWidget.setCurrentWidget(self.view_userinfo)
if self.sender() == self.toDocxAct:
- self.outputThread = output.Output(self.Me, self.contact.wxid)
+ print('功能暂未实现')
+ QMessageBox.warning(self,
+ "别急别急",
+ "马上就实现该功能"
+ )
+ return
+ self.outputThread = Output(self.Me, self.contact.wxid)
elif self.sender() == self.toCSVAct:
+ QMessageBox.warning(self,
+ "别急别急",
+ "马上就实现该功能"
+ )
print('开始导出csv')
- self.outputThread = output.Output(self.Me, self.contact.wxid, type_=output.Output.CSV)
+ return
+ self.outputThread = Output(self.Me, self.contact.wxid, type_=Output.CSV)
print('导出csv')
elif self.sender() == self.toHtmlAct:
print('功能暂未实现')