diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a0bdbc6..4405dbd 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,19 +4,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
+
-
-
+
-
-
+
@@ -83,6 +90,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -146,27 +174,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -191,10 +198,10 @@
+
-
@@ -532,7 +539,14 @@
1699373594568
-
+
+ 1699531863395
+
+
+
+ 1699531863395
+
+
@@ -590,10 +604,10 @@
-
-
+
+
diff --git a/app/DataBase/data.py b/app/DataBase/data.py
index ef72cde..df77120 100644
--- a/app/DataBase/data.py
+++ b/app/DataBase/data.py
@@ -68,6 +68,7 @@ def mkdir(path):
return True
+root_path = os.path.abspath('.')
mkdir(os.path.abspath('.') + '/app/DataBase')
mkdir(os.path.abspath('.') + '/app/data/emoji')
if os.path.exists('./app/DataBase/Msg.db'):
@@ -219,17 +220,18 @@ def avatar_md5(wxid):
def get_avator(wxid):
if wxid == None:
- return './app/data/icons/default_avatar.svg'
+ return os.path.join(root_path, '/app/data/icons/default_avatar.svg')
wxid = str(wxid)
avatar = avatar_md5(wxid)
- avatar_path = r"./app/data/avatar/"
- path = avatar_path + avatar[:2] + '/' + avatar[2:4]
+ path = os.path.join(root_path, 'app', 'data', 'avatar', avatar[:2], avatar[2:4])
+ # avatar_path + avatar[:2] + '/' + avatar[2:4]
for root, dirs, files in os.walk(path):
for file in files:
if avatar in file:
avatar = file
break
- return f'''{path}/{avatar}'''
+ return os.path.join(path, avatar)
+ # return f'''{path}/{avatar}'''
# return f'''{path}/user_{avatar}.png'''
diff --git a/app/Ui/MyComponents/Button_Contact.py b/app/Ui/MyComponents/Button_Contact.py
index 7c9bc45..14d5b0b 100644
--- a/app/Ui/MyComponents/Button_Contact.py
+++ b/app/Ui/MyComponents/Button_Contact.py
@@ -57,9 +57,9 @@ class ContactUi(QtWidgets.QPushButton):
self.gridLayout1.addWidget(self.label_time, 0, 2, 1, 1)
self.label_remark = QtWidgets.QLabel(self.layoutWidget)
font = QtGui.QFont()
- font.setFamily("微软雅黑")
+ font.setFamily("黑体")
font.setPointSize(10)
- font.setBold(True)
+ # font.setBold(True)
self.label_remark.setFont(font)
self.label_remark.setObjectName("label_remark")
self.gridLayout1.addWidget(self.label_remark, 0, 1, 1, 1)
diff --git a/app/Ui/contact/analysis/analysis.py b/app/Ui/contact/analysis/analysis.py
index 1c1d5c4..d24839b 100644
--- a/app/Ui/contact/analysis/analysis.py
+++ b/app/Ui/contact/analysis/analysis.py
@@ -72,9 +72,6 @@ class AnalysisController(QWidget):
self.browser4.resize(800, 600)
self.browser5 = QWebEngineView()
self.browser5.load(QUrl('file:///data/聊天统计/chat_session.html'))
- # self.browser5.adjustSize()
-
- # self.browser5.resize(800, 600)
self.browser6 = QWebEngineView()
self.browser6.load(QUrl('file:///data/聊天统计/sports.html'))
self.browser7 = QWebEngineView()
@@ -95,23 +92,18 @@ class AnalysisController(QWidget):
scrollAreaContent = QWidget(self.scrollArea)
scrollAreaContent.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
-
Vlayout2 = QVBoxLayout()
Vlayout2.setContentsMargins(0, 0, 0, 0)
Vlayout2.setSpacing(0)
-
Vlayout2.addWidget(self.browser3)
Vlayout2.addWidget(self.browser2)
-
Vlayout2.addWidget(self.browser8)
Vlayout2.addWidget(self.browser6)
Vlayout2.addWidget(self.browser5)
Vlayout2.addWidget(self.browser7)
-
Vlayout2.addWidget(self.browser9)
Vlayout2.addWidget(self.browser10)
scrollAreaContent.setLayout(Vlayout2)
-
self.scrollArea.setWidget(scrollAreaContent)
main_box.addWidget(self.scrollArea)
main_box.setStretch(0, 1)
diff --git a/app/Ui/contact/contactInfo.py b/app/Ui/contact/contactInfo.py
index f2b421e..903ebaa 100644
--- a/app/Ui/contact/contactInfo.py
+++ b/app/Ui/contact/contactInfo.py
@@ -73,8 +73,8 @@ class ContactInfo(QWidget, Ui_Form):
"敬请期待"
)
return
- self.report = report.ReportController(123)
- self.report.show()
+ # self.report = report.ReportController(self.contact)
+ # self.report.show()
def emotionale_Analysis(self):
self.stackedWidget.setCurrentWidget(self.view_emotion)
diff --git a/app/Ui/contact/report/annual_report.py b/app/Ui/contact/report/annual_report.py
new file mode 100644
index 0000000..3829e96
--- /dev/null
+++ b/app/Ui/contact/report/annual_report.py
@@ -0,0 +1,28 @@
+from bs4 import BeautifulSoup
+
+
+def create_title_page(nickname, time, avatar_path):
+ with open('D:\\Project\\Python\\WeChatMsg\\app\\data\\html\\0.html', 'r+', encoding='utf-8') as f:
+ html_document = f.read()
+ # 创建Beautiful Soup对象
+ soup = BeautifulSoup(html_document, 'html.parser')
+ # 找到需要替换的图片元素
+ target_image = soup.find(id='avatar')
+ # 替换图片元素的src属性
+ if target_image:
+ target_image['src'] = avatar_path
+ # 找到需要替换的元素
+ target_element = soup.find(id='nickname')
+ # 替换元素的文本内容
+ if target_element:
+ target_element.string = nickname
+ target_element = soup.find(id='first_time')
+ # 替换元素的文本内容
+ if target_element:
+ target_element.string = time
+ with open('./data/AnnualReport/0.html', 'w', encoding='utf-8') as f1:
+ f1.write(soup.prettify())
+
+
+if __name__ == '__main__':
+ create_title_page('小学生', '2023-09-18 20:39:08', 'D:\Project\Python\WeChatMsg\\app\data\icons\default_avatar.svg')
diff --git a/app/Ui/contact/report/report.py b/app/Ui/contact/report/report.py
index 6634345..c882900 100644
--- a/app/Ui/contact/report/report.py
+++ b/app/Ui/contact/report/report.py
@@ -5,12 +5,17 @@ from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import *
+from app import person
+from app.DataBase import data
+from . import annual_report
+
class ReportController(QWidget):
- def __init__(self, username, parent=None):
+ def __init__(self, contact: person.Contact, me: person.Me = None, parent=None):
super().__init__(parent)
- self.ta_username = username
-
+ self.ta_username = contact.wxid
+ self.contact = contact
+ self.Me = me
# self.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
# 加载动画
self.center()
@@ -40,15 +45,15 @@ class ReportController(QWidget):
movie.start()
def initUI(self):
+ start_time = data.get_msg_start_time(self.contact.wxid)
+ annual_report.create_title_page(self.contact.nickname, start_time, self.contact.avatar_path)
self.label.setVisible(False)
# self.setStyleSheet('''QWidget{background-color:rgb(244, 244, 244);}''')
main_box = QHBoxLayout(self)
self.browser1 = QWebEngineView()
self.browser1.load(QUrl('file:///data/AnnualReport/index.html'))
- # self.browser1.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
splitter1 = QSplitter(Qt.Vertical)
-
splitter1.addWidget(self.browser1)
main_box.addWidget(splitter1)
self.setLayout(main_box)
diff --git a/app/Ui/mainview.py b/app/Ui/mainview.py
index 4d2dea6..1480be4 100644
--- a/app/Ui/mainview.py
+++ b/app/Ui/mainview.py
@@ -46,12 +46,15 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
# self.btn_myinfo.clicked.connect(self.myInfo)
self.btn_about.clicked.connect(self.about)
self.now_btn = self.btn_chat
+ self.btn_about.setIcon(Icon.MainWindow_Icon)
self.btn_about.setContextMenuPolicy(Qt.CustomContextMenu)
self.btn_about.customContextMenuRequested.connect(self.create_rightmenu) # 连接到菜单显示函数
self.last_btn = None
self.lastView = None
self.show_avatar()
self.init_ui()
+ self.menubar.setVisible(False)
+ self.statusbar.setVisible(False)
# self.state_lable = QLabel(self)
# self.state_lable.raise_()
# pixmap = QPixmap('./app/data/icons/default_avatar.svg').scaled(32, 32) # 按指定路径找到图片
diff --git a/app/data/html/0.html b/app/data/html/0.html
new file mode 100644
index 0000000..d377192
--- /dev/null
+++ b/app/data/html/0.html
@@ -0,0 +1,290 @@
+
+
+
+
+
+
+
+
+
+
+ 年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 未眠人
+
+
+ 二零二二年度报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 我们第一次聊天发生在
+
+
+ 2023-09-18 20:39:08
+
+
+
+ 距今已有
+
+
+ 626 天
+
+
+ 6 时
+
+
+ 26 分
+
+
+ 26 秒
+
+
+
+
+
+
+
+
+
+ 进入
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/1.html b/app/data/html/1.html
new file mode 100644
index 0000000..646027f
--- /dev/null
+++ b/app/data/html/1.html
@@ -0,0 +1,706 @@
+
+
+
+
+
+
+
+
+
+
+ 年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Norcy
+
+
+
+
进入
+
+
+
+
+
+
+
+
+
+
过去的日子里
+
我们一共发送了
+ 91835 条消息
+
总计
+ 388161 字
+
+
+ 我们的聊天似乎没有规律
+
+ 八月份 我们一共发送了11629 条信息
+
+ 对你的话说不完
+
+
但
+ 六月份 只有2139 条信息
+
大概,我们有时候也想静静
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/2.html b/app/data/html/2.html
new file mode 100644
index 0000000..302d923
--- /dev/null
+++ b/app/data/html/2.html
@@ -0,0 +1,1243 @@
+
+
+
+
+
+
+
+
+
+
+
年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
这一年里
+
TA一共在云村听了
+ 1357 首歌
+
+
TA热衷的风格成谜
+
喜欢在
+ 午后 听歌
+
+
+
TA
+ 热爱分享
+
评论区里藏着TA的许多回忆
+
+
+
+
+
+
+
二零二二
+ 你说的最多的是
+
+
+
+
+ 喜
+
+ 欢
+
+
+ 5
+ 9
+ 5
+
+
+
+
+
+
+
+
我
+ 喜欢 这个衣服
+
+
+
- 它就是好看啊
+
+
+
+
+
我还是
+ 喜欢 大城市
+
+
+
- 很繁华
+
+
+
+
+
也不知道你为啥不
+ 喜欢
+
+
+
- 也没有吧
+
+
+
+
+
但是我
+ 喜欢 火锅
+
+
+
- 吃,使劲吃
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/3.html b/app/data/html/3.html
new file mode 100644
index 0000000..1d17efd
--- /dev/null
+++ b/app/data/html/3.html
@@ -0,0 +1,652 @@
+
+
+
+
+
+
+
+
+
+
+
年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
在TA的音乐品味中
+
也藏着高冷的一面
+
这首有些小众的
+
+ 《夏天的味道(Cover 石头剪刀布)》
+
在今年TA一共听了
+ 15次
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
2022-03-12
+ 04:36:10
+
+ 这么晚了你们还在聊天
+
+
这天一定有你们
+ 难忘的回忆 吧
+
+
+
+
你们都是
+ 夜猫子
+
+ 凌晨01:00
+
+
你们共发送了
+ 8517 条信息
+
+
+
+
+
+
+
+
2022-03-12 04:36:10
+
+
+
+
+
+
+
:
+
+
+
+
+
+ : 无语了也不知道我这大晚上干嘛不睡觉,生生接住了这波狗粮
+
+
+
+
+
+
+
+
+
+
+
+
:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/4.html b/app/data/html/4.html
new file mode 100644
index 0000000..472bb91
--- /dev/null
+++ b/app/data/html/4.html
@@ -0,0 +1,1232 @@
+
+
+
+
+
+
+
+
+
+
+
年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
2018
+ TA在网易云音乐听到的最多的歌词是
+
+
+
+
+
+
+
+
+
+
+
+ 7
+ 6
+ 5
+
+
+
+
+
+
+
+
+ 天使 在人间是该藏好翅膀
+
+
+
- Tank《专属天使》
+
+
+
+
+
你是魔鬼中的
+ 天使 , 所以送我心碎的方式
+
+
+
- 田馥甄《魔鬼中的天使》
+
+
+
+
+
请
+ 天使 来唱歌, 当我很不快乐
+
+
+
- S.H.E《天使在唱歌》
+
+
+
+
+
谁人又为
+ 天使 忧愁
+
+
+
- 梁汉文《七友》
+
+
+
+
+
+
+
+
+
+
+ 5月1日
+
大概是很特别的一天
+
这一天里
+
你们的对话充满了
+ 积极情感
+
从早上9点 到晚上12点
+
你们共发送了
+ 2294
+ 条信息
+
+
信息数量
+ 全年最高
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/5.html b/app/data/html/5.html
new file mode 100644
index 0000000..e3a95ff
--- /dev/null
+++ b/app/data/html/5.html
@@ -0,0 +1,7567 @@
+
+
+
+
+
+
+
+
+
+
+
年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
1月29日
+
这一天Ta走了
+
+ 17498 步
+
在你好友排名
+ 第一
+
+
你知道
+
+ 这一天Ta去哪了吗?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/6.html b/app/data/html/6.html
new file mode 100644
index 0000000..1e42b5f
--- /dev/null
+++ b/app/data/html/6.html
@@ -0,0 +1,1344 @@
+
+
+
+
+
+
+
+
+
+
+
年度聊天报告
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
这一年
+
我们有
+ 230天 在聊天
+
有你在的日子里
+
都很有
+ 意义 !
+
+
这一年
+
一共发送了
+ 3454 个表情包
+
Ta最常用的表情包是
+
+
+
一共
+ 184次
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/html/index.html b/app/data/html/index.html
new file mode 100644
index 0000000..dfb2b00
--- /dev/null
+++ b/app/data/html/index.html
@@ -0,0 +1,252 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/data/icons/back.svg b/app/data/icons/back.svg
new file mode 100644
index 0000000..97983e7
--- /dev/null
+++ b/app/data/icons/back.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/app/data/icons/output.svg b/app/data/icons/output.svg
new file mode 100644
index 0000000..2134295
--- /dev/null
+++ b/app/data/icons/output.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 6a21788..acd23d2 100644
Binary files a/requirements.txt and b/requirements.txt differ