From efe314d5e62c0ea46875bfeef06b9cde14db70c8 Mon Sep 17 00:00:00 2001
From: shuaikangzhou <863909694@qq.com>
Date: Thu, 2 Feb 2023 00:26:44 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
TEST.py | 288 +--------
app/DB/__init__.py | 9 -
app/DB/data.py | 404 ------------
app/DataBase/data.py | 14 +-
app/DataBase/output.py | 176 +++--
app/DataBase/to_docx.py | 561 ----------------
app/Ui/chat/addContact/__init__.py | 9 -
app/Ui/chat/addContact/addContact.py | 89 ---
app/Ui/chat/addContact/addContactUi.py | 98 ---
app/Ui/chat/addContact/addContactUi.ui | 207 ------
app/Ui/chat/backup/chatUi - 副本.py | 143 -----
app/Ui/chat/backup/chatUi - 副本.ui | 845 -------------------------
app/Ui/chat/backup/chatUi.py | 184 ------
app/Ui/chat/backup/chatUi.ui | 422 ------------
app/Ui/chat/chat.py | 41 +-
app/Ui/chat/group/CreateGroup.py | 107 ----
app/Ui/chat/group/Group.py | 442 -------------
app/Ui/chat/group/GroupUi.py | 100 ---
app/Ui/chat/group/GroupUi.ui | 217 -------
app/Ui/chat/group/__init__.py | 9 -
app/Ui/chat/group/addGroup.py | 101 ---
app/Ui/chat/group/addGroup.ui | 226 -------
app/Ui/chat/group/create_groupUi.py | 113 ----
app/Ui/chat/group/create_groupUi.ui | 217 -------
app/Ui/chat/myinfo/__init__.py | 9 -
app/Ui/chat/myinfo/myinfo.py | 67 --
app/Ui/chat/myinfo/myinfoUi.py | 128 ----
app/Ui/chat/myinfo/myinfoUi.ui | 211 ------
app/Ui/chat/userinfo/__init__.py | 9 -
app/Ui/chat/userinfo/userinfoUi.py | 100 ---
app/Ui/chat/userinfo/userinfoUi.ui | 208 ------
app/Ui/contact/analysis/analysis.py | 83 ++-
app/Ui/contact/analysis/charts.py | 5 -
app/Ui/contact/contact.py | 34 +-
app/Ui/contact/userinfo/userinfoUi.py | 4 +
app/Ui/contact/userinfo/userinfoUi.ui | 13 +
app/Ui/decrypt/decrypt.py | 4 +-
app/Ui/mainview.py | 17 +-
38 files changed, 254 insertions(+), 5660 deletions(-)
delete mode 100644 app/DB/__init__.py
delete mode 100644 app/DB/data.py
delete mode 100644 app/DataBase/to_docx.py
delete mode 100644 app/Ui/chat/addContact/__init__.py
delete mode 100644 app/Ui/chat/addContact/addContact.py
delete mode 100644 app/Ui/chat/addContact/addContactUi.py
delete mode 100644 app/Ui/chat/addContact/addContactUi.ui
delete mode 100644 app/Ui/chat/backup/chatUi - 副本.py
delete mode 100644 app/Ui/chat/backup/chatUi - 副本.ui
delete mode 100644 app/Ui/chat/backup/chatUi.py
delete mode 100644 app/Ui/chat/backup/chatUi.ui
delete mode 100644 app/Ui/chat/group/CreateGroup.py
delete mode 100644 app/Ui/chat/group/Group.py
delete mode 100644 app/Ui/chat/group/GroupUi.py
delete mode 100644 app/Ui/chat/group/GroupUi.ui
delete mode 100644 app/Ui/chat/group/__init__.py
delete mode 100644 app/Ui/chat/group/addGroup.py
delete mode 100644 app/Ui/chat/group/addGroup.ui
delete mode 100644 app/Ui/chat/group/create_groupUi.py
delete mode 100644 app/Ui/chat/group/create_groupUi.ui
delete mode 100644 app/Ui/chat/myinfo/__init__.py
delete mode 100644 app/Ui/chat/myinfo/myinfo.py
delete mode 100644 app/Ui/chat/myinfo/myinfoUi.py
delete mode 100644 app/Ui/chat/myinfo/myinfoUi.ui
delete mode 100644 app/Ui/chat/userinfo/__init__.py
delete mode 100644 app/Ui/chat/userinfo/userinfoUi.py
delete mode 100644 app/Ui/chat/userinfo/userinfoUi.ui
diff --git a/TEST.py b/TEST.py
index 93c1e5f..517bf1f 100644
--- a/TEST.py
+++ b/TEST.py
@@ -1,263 +1,29 @@
-from pyecharts import options as opts
-from pyecharts.charts import WordCloud
+from PyQt5 import QtCore, QtGui, QtWidgets
+import time
-words = [
- ("花鸟市场", 1446),
- ("汽车", 928),
- ("视频", 906),
- ("电视", 825),
- ("Lover Boy 88", 514),
- ("动漫", 486),
- ("音乐", 53),
- ("直播", 163),
- ("广播电台", 86),
- ("戏曲曲艺", 17),
- ("演出票务", 6),
- ("给陌生的你听", 1),
- ("资讯", 1437),
- ("商业财经", 422),
- ("娱乐八卦", 353),
- ("军事", 331),
- ("科技资讯", 313),
- ("社会时政", 307),
- ("时尚", 43),
- ("网络奇闻", 15),
- ("旅游出行", 438),
- ("景点类型", 957),
- ("国内游", 927),
- ("远途出行方式", 908),
- ("酒店", 693),
- ("关注景点", 611),
- ("旅游网站偏好", 512),
- ("出国游", 382),
- ("交通票务", 312),
- ("旅游方式", 187),
- ("旅游主题", 163),
- ("港澳台", 104),
- ("本地周边游", 3),
- ("小卖家", 1331),
- ("全日制学校", 941),
- ("基础教育科目", 585),
- ("考试培训", 473),
- ("语言学习", 358),
- ("留学", 246),
- ("K12课程培训", 207),
- ("艺术培训", 194),
- ("技能培训", 104),
- ("IT培训", 87),
- ("高等教育专业", 63),
- ("家教", 48),
- ("体育培训", 23),
- ("职场培训", 5),
- ("金融财经", 1328),
- ("银行", 765),
- ("股票", 452),
- ("保险", 415),
- ("贷款", 253),
- ("基金", 211),
- ("信用卡", 180),
- ("外汇", 138),
- ("P2P", 116),
- ("贵金属", 98),
- ("债券", 93),
- ("网络理财", 92),
- ("信托", 90),
- ("征信", 76),
- ("期货", 76),
- ("公积金", 40),
- ("银行理财", 36),
- ("银行业务", 30),
- ("典当", 7),
- ("海外置业", 1),
- ("汽车", 1309),
- ("汽车档次", 965),
- ("汽车品牌", 900),
- ("汽车车型", 727),
- ("购车阶段", 461),
- ("二手车", 309),
- ("汽车美容", 260),
- ("新能源汽车", 173),
- ("汽车维修", 155),
- ("租车服务", 136),
- ("车展", 121),
- ("违章查询", 76),
- ("汽车改装", 62),
- ("汽车用品", 37),
- ("路况查询", 32),
- ("汽车保险", 28),
- ("陪驾代驾", 4),
- ("网络购物", 1275),
- ("做我的猫", 1088),
- ("只想要你知道", 907),
- ("团购", 837),
- ("比价", 201),
- ("海淘", 195),
- ("移动APP购物", 179),
- ("支付方式", 119),
- ("代购", 43),
- ("体育健身", 1234),
- ("体育赛事项目", 802),
- ("运动项目", 405),
- ("体育类赛事", 337),
- ("健身项目", 199),
- ("健身房健身", 78),
- ("运动健身", 77),
- ("家庭健身", 36),
- ("健身器械", 29),
- ("办公室健身", 3),
- ("商务服务", 1201),
- ("法律咨询", 508),
- ("化工材料", 147),
- ("广告服务", 125),
- ("会计审计", 115),
- ("人员招聘", 101),
- ("印刷打印", 66),
- ("知识产权", 32),
- ("翻译", 22),
- ("安全安保", 9),
- ("公关服务", 8),
- ("商旅服务", 2),
- ("展会服务", 2),
- ("特许经营", 1),
- ("休闲爱好", 1169),
- ("收藏", 412),
- ("摄影", 393),
- ("温泉", 230),
- ("博彩彩票", 211),
- ("美术", 207),
- ("书法", 139),
- ("DIY手工", 75),
- ("舞蹈", 23),
- ("钓鱼", 21),
- ("棋牌桌游", 17),
- ("KTV", 6),
- ("密室", 5),
- ("采摘", 4),
- ("电玩", 1),
- ("真人CS", 1),
- ("轰趴", 1),
- ("家电数码", 1111),
- ("手机", 885),
- ("电脑", 543),
- ("大家电", 321),
- ("家电关注品牌", 253),
- ("网络设备", 162),
- ("摄影器材", 149),
- ("影音设备", 133),
- ("办公数码设备", 113),
- ("生活电器", 67),
- ("厨房电器", 54),
- ("智能设备", 45),
- ("个人护理电器", 22),
- ("服饰鞋包", 1047),
- ("服装", 566),
- ("饰品", 289),
- ("鞋", 184),
- ("箱包", 168),
- ("奢侈品", 137),
- ("母婴亲子", 1041),
- ("孕婴保健", 505),
- ("母婴社区", 299),
- ("早教", 103),
- ("奶粉辅食", 66),
- ("童车童床", 41),
- ("关注品牌", 271),
- ("宝宝玩乐", 30),
- ("母婴护理服务", 25),
- ("纸尿裤湿巾", 16),
- ("妈妈用品", 15),
- ("宝宝起名", 12),
- ("童装童鞋", 9),
- ("胎教", 8),
- ("宝宝安全", 1),
- ("宝宝洗护用品", 1),
- ("软件应用", 1018),
- ("系统工具", 896),
- ("理财购物", 440),
- ("生活实用", 365),
- ("影音图像", 256),
- ("社交通讯", 214),
- ("手机美化", 39),
- ("办公学习", 28),
- ("应用市场", 23),
- ("母婴育儿", 14),
- ("游戏", 946),
- ("手机游戏", 565),
- ("PC游戏", 353),
- ("网页游戏", 254),
- ("游戏机", 188),
- ("模拟辅助", 166),
- ("个护美容", 942),
- ("护肤品", 177),
- ("彩妆", 133),
- ("美发", 80),
- ("香水", 50),
- ("个人护理", 46),
- ("美甲", 26),
- ("SPA美体", 21),
- ("花鸟萌宠", 914),
- ("绿植花卉", 311),
- ("狗", 257),
- ("其他宠物", 131),
- ("水族", 125),
- ("猫", 122),
- ("动物", 81),
- ("鸟", 67),
- ("宠物用品", 41),
- ("宠物服务", 26),
- ("书籍阅读", 913),
- ("网络小说", 483),
- ("关注书籍", 128),
- ("文学", 105),
- ("报刊杂志", 77),
- ("人文社科", 22),
- ("建材家居", 907),
- ("装修建材", 644),
- ("家具", 273),
- ("家居风格", 187),
- ("家居家装关注品牌", 140),
- ("家纺", 107),
- ("厨具", 47),
- ("灯具", 43),
- ("家居饰品", 29),
- ("家居日常用品", 10),
- ("生活服务", 883),
- ("物流配送", 536),
- ("家政服务", 108),
- ("摄影服务", 49),
- ("搬家服务", 38),
- ("物业维修", 37),
- ("婚庆服务", 24),
- ("二手回收", 24),
- ("鲜花配送", 3),
- ("维修服务", 3),
- ("殡葬服务", 1),
- ("求职创业", 874),
- ("创业", 363),
- ("目标职位", 162),
- ("目标行业", 50),
- ("兼职", 21),
- ("期望年薪", 20),
- ("实习", 16),
- ("雇主类型", 10),
- ("星座运势", 789),
- ("星座", 316),
- ("算命", 303),
- ("解梦", 196),
- ("风水", 93),
- ("面相分析", 47),
- ("手相", 32),
- ("公益", 90),
-]
+class MyWindow(QtWidgets.QPushButton):
-c = (
- WordCloud()
- .add(
- "",
- words,
- word_size_range=[20, 100],
- textstyle_opts=opts.TextStyleOpts(font_family="cursive"),
- )
- .set_global_opts(title_opts=opts.TitleOpts(title="WordCloud-自定义文字样式"))
- .render("wordcloud_custom_font_style.html")
-)
+ def __init__(self):
+ QtWidgets.QPushButton.__init__(self)
+ self.setText("关闭窗口")
+ self.clicked.connect(QtWidgets.qApp.quit)
+
+ def load_data(self, sp):
+ for i in range(1, 11): #模拟主程序加载过程
+ time.sleep(2) # 加载数据
+ sp.showMessage("加载... {0}%".format(i * 10), QtCore.Qt.AlignHCenter |QtCore.Qt.AlignBottom, QtCore.Qt.black)
+ QtWidgets.qApp.processEvents() # 允许主进程处理事件
+
+if __name__ == "__main__":
+ import sys
+ app = QtWidgets.QApplication(sys.argv)
+ splash = QtWidgets.QSplashScreen(QtGui.QPixmap("img.jpg"))
+ splash.showMessage("加载... 0%", QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.black)
+ splash.show() # 显示启动界面
+ QtWidgets.qApp.processEvents() # 处理主进程事件
+ window = MyWindow()
+ window.setWindowTitle("QSplashScreen类使用")
+ window.resize(300, 30)
+ window.load_data(splash) # 加载数据
+ window.show()
+ splash.finish(window) # 隐藏启动界面
\ No newline at end of file
diff --git a/app/DB/__init__.py b/app/DB/__init__.py
deleted file mode 100644
index b32c754..0000000
--- a/app/DB/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-@File : __init__.py
-@Author : Shuaikang Zhou
-@Time : 2022/12/25 19:53
-@IDE : Pycharm
-@Version : Python3.10
-@comment : ···
-"""
diff --git a/app/DB/data.py b/app/DB/data.py
deleted file mode 100644
index e8ec0fd..0000000
--- a/app/DB/data.py
+++ /dev/null
@@ -1,404 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-@File : data.py
-@Author : Shuaikang Zhou
-@Time : 2022/12/13 20:59
-@IDE : Pycharm
-@Version : Python3.10
-@comment : ···
-"""
-import json
-import pymysql
-import random
-import time
-import hashlib
-import datetime
-import os
-import shutil
-f = open('./app/data/config.json','r')
-config = json.loads(f.read())
-username = config['username']
-password = config['password']
-database = config['database']
-# 打开数据库连接t
-db = pymysql.connect(
- host='localhost',
- user=username,
- password=password,
- database=database,
- autocommit=True
-)
-cursor = db.cursor()
-
-
-def register(username, password, nickname):
- """
- 注册账号
- :param username: 用户名
- :param password: 密码
- :param nickname: 昵称
- :return:
- """
- try:
- create = 'insert into users (username,password,createTime) values (%s,%s,%s)'
- timestamp = float(time.time())
- dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- cursor.execute(create, [username, password, dt])
- create = 'insert into userinfo (username,nickname) values (%s,%s)'
- cursor.execute(create, [username, nickname])
- db.commit()
- try:
- sql = f'''
- create view msg_view_{username}
- as
- select msgId,type,IsSend,createTime,content,talkerId from message
- where username = %s
- order by msgId;
- '''
- cursor.execute(sql, [username])
- sql = f'''
- create view contact_view_{username}
- as
- select contactId,conRemark,type,addTime from contact
- where username = %s;
- '''
- cursor.execute(sql, [username])
- sql = f'''
- create view group_view_{username}
- as
- select g_id,g_name,gu_nickname,gu_type,gu_time from group_users,`group`
- where gu_uid=%s and group_users.gu_gid=`group`.g_id;
- '''
- cursor.execute(sql, [username])
- db.commit()
- except pymysql.err.OperationalError:
- print('视图已经存在')
- except pymysql.err.IntegrityError:
- print('用户已存在')
- return False
- return True
-
-
-def login(username, password):
- select = 'select * from users where username = %s and password = %s'
- cursor.execute(select, [username, password])
- result = cursor.fetchall()
- if result:
- return True
- return False
-
-
-def del_user(username):
- sql = 'delete from users where username = %s'
- cursor.execute(sql, [username])
- db.commit()
- return True
-
-
-def searchUser(username):
- select = 'select * from users where username = %s'
- cursor.execute(select, [username])
- result = cursor.fetchall()
- if result:
- return True
- return False
-
-
-def add_contact(username, contactId, conRemark, _type=3):
- send = 'insert into contact (username,conRemark,type,addTime,contactId) values(%s,%s,%s,%s,%s)'
- dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- select = 'select * from userinfo where username = %s '
- cursor.execute(select, [username])
- result = cursor.fetchall()
- if not result:
- return False
- if not conRemark:
- conRemark = None
- try:
- if _type == 3:
- cursor.execute(send, [username, conRemark, 3, dt, contactId])
- db.commit()
- return (contactId, conRemark, 3, dt)
- except:
- return False
-
-
-def get_userinfo(username):
- sql = 'select * from userinfo where username = %s'
- cursor.execute(sql, [username])
- result = cursor.fetchone()
- return result[0]
-
-
-def online(username, socket=None):
- status = random.randint(32010, 52090)
- sql = 'update userinfo set status = %s where username=%s'
- cursor.execute(sql, [status, username])
- db.commit()
-
- return status
-
-
-def tell_online(username, socket):
- if socket:
- contacts = get_contacts(username)
- for contact in contacts:
- contactID = contact[0]
- status = check_online(contactID)
- if status != -1:
- ta_addr = ('localhost', status)
- send_data = {
- 'type': 'T',
- 'username': username,
- 'content': '在线0000_1'
- }
- socket.sendto(json.dumps(send_data).encode('utf-8'), ta_addr)
-
-
-def offline(username):
- status = -1
- sql = 'update userinfo set status = %s where username=%s'
- cursor.execute(sql, [status, username])
- db.commit()
- return status
-
-
-def check_online(username):
- db.commit()
- sql = 'select status from userinfo where username=%s'
- cursor.execute(sql, [username])
- db.commit()
- result = cursor.fetchone()
- # print(username, '端口号:', result)
- if result:
- return result[0]
- else:
- return -1
-
-
-def send_msg(IsSend, msg, ta, me, status=-1, _type=3):
- if status == -1:
- return False
- send = 'insert into message (type,isSend,createTime,content,talkerId,username) values(%s,%s,%s,%s,%s,%s)'
- dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- if _type == 3:
- cursor.execute(send, [_type, IsSend, dt, msg, ta, me])
- db.commit()
- return 1, _type, IsSend, datetime.datetime.now(), msg, ta
-
-
-def send_group_msg(gid, msg, talker, IsSend=0, _type=3):
- send = 'insert into group_message (g_id,gm_type,gm_content,gm_time,gm_talker,gm_isSend) values(%s,%s,%s,%s,%s,%s)'
- dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- if _type == 3:
- cursor.execute(send, [gid, _type, msg, dt, talker, IsSend])
- db.commit()
- return 1, gid, _type, msg, datetime.datetime.now(), talker, IsSend
-
-
-def get_group_message(g_id):
- sql = f'select * from group_message where g_id = %s order by gm_id'
- cursor.execute(sql, [g_id])
- result = cursor.fetchall()
- return result
-
-
-def avatar_md5(wxid):
- m = hashlib.md5()
- # 参数必须是byte类型,否则报Unicode-objects must be encoded before hashing错误
- m.update(bytes(wxid.encode('utf-8')))
- return m.hexdigest()
-
-
-def get_avator(wxid):
- if wxid == None:
- return
- wxid = str(wxid)
- avatar = avatar_md5(wxid)
- avatar_path = r"./data/avatar/"
- path = 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 path + '/' + avatar
-
-
-def get_contacts(username):
- sql = f'select * from contact_view_{username} '
- cursor.execute(sql)
- result = cursor.fetchall()
- return result
-
-
-def get_myinfo(username):
- sql = 'select * from userinfo where username = %s'
- cursor.execute(sql, [username])
- result = cursor.fetchone()
- return result
-
-
-def update_userinfo(userinfo):
- sql = '''
- update userinfo
- set
- nickname=%s,
- gender=%s,
- city=%s,
- province=%s,
- tel=%s,
- email=%s,
- signsture=%s
- where username=%s
- '''
- cursor.execute(sql, userinfo)
-
-
-def get_nickname(username):
- sql = 'select nickname from userinfo where username=%s'
- cursor.execute(sql, [username])
- result = cursor.fetchone()
- return result[0]
-
-
-def update_conRemark(username, contactId, new_conRemark):
- sql = 'update contact set conRemark=%s where username=%s and contactId=%s'
- cursor.execute(sql, [new_conRemark, username, contactId])
- db.commit()
- return True
-
-
-def delete_contact(username, contactId):
- sql = 'delete from contact where username=%s and contactId=%s'
- cursor.execute(sql, [username, contactId])
- db.commit()
- return True
-
-
-def delete_group(uid, gid):
- sql = 'delete from group_users where gu_uid=%s and gu_gid=%s'
- cursor.execute(sql, [uid, gid])
- db.commit()
- return True
-
-
-def get_remark(username, talkerId):
- sql = f'select conRemark from contact_view_{username} where contactId = %s'
- cursor.execute(sql, [talkerId])
- result = cursor.fetchone()
- return result[0]
-
-
-def mycopyfile(srcfile, dstpath):
- # 复制函数
- """
- 复制文件
- :param srcfile: 原路径
- :param dstpath: 新路径
- :return:
- """
- # if 1:
- try:
- if not os.path.isfile(srcfile):
- print("%s not exist!" % (srcfile))
- return
- else:
- print(dstpath)
- if os.path.isfile(dstpath):
- os.remove(dstpath)
- fpath, fname = os.path.split(srcfile) # 分离文件名和路径
- dpath, dname = os.path.split(dstpath)
- if not os.path.exists(dpath):
- os.makedirs(dpath) # 创建路径
- # dstpath = '/'.join(dstpath.split('/')[:-1])+'/'
-
- # print(dpath,dname)
- shutil.copy(srcfile, dpath) # 复制文件
- os.rename(dpath + '/' + fname, dstpath)
- # print ("copy %s -> %s"%(srcfile, dstpath + fname))
- except:
- print('文件已存在')
-
-
-def get_message(username, talkerId):
- sql = f'select * from msg_view_{username} where talkerId = %s order by msgId'
- cursor.execute(sql, [talkerId])
- result = cursor.fetchall()
- return result
-
-
-def create_group(g_name, g_admin, g_notice=None, g_intro=None):
- g_id = random.randint(10000, 99999)
- sql = '''insert into `group` (g_id,g_name,g_admin,g_notice,g_intro,g_time) values (%s, %s, %s, %s, %s, %s);'''
- dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- param = [g_id, g_name, g_admin, g_notice, g_intro, dt]
- print(param)
- cursor.execute(sql, param)
- sql = '''insert into `group_users` (gu_uid,gu_gid,gu_time,gu_nickname,gu_type) values (%s, %s, %s, %s, %s);'''
- param = [g_admin, g_id, dt, None, 1]
- cursor.execute(sql, param)
- db.commit()
- return g_id
-
-
-def add_group(username, g_id, nickname):
- group = search_group(g_id)
- if not group:
- return False
- if not nickname:
- nickname = None
- sql = 'insert into group_users (gu_uid,gu_gid,gu_time,gu_nickname,gu_type) values (%s,%s,%s,%s,%s)'
- dt = dt = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- cursor.execute(sql, [username, g_id, dt, nickname, 2])
- db.commit()
- return [g_id, dt, nickname, 2]
-
-
-def search_group(gid):
- sql = 'select * from `group` where g_id=%s'
- cursor.execute(sql, [gid])
- result = cursor.fetchone()
- return result
-
-
-def get_groups(username):
- sql = f'select * from group_view_{username}'
- cursor.execute(sql)
- result = cursor.fetchall()
- return result
-
-
-def get_group_users(g_id):
- db.commit()
- sql = '''
- select gu_uid,gu_gid,gu_time,gu_nickname,status
- from group_users,userinfo
- where gu_gid=%s and
- gu_uid=userinfo.username
- '''
- cursor.execute(sql, [g_id])
- db.commit()
- result = cursor.fetchall()
- return result
-
-
-# send_msg(3, '你好', '123456')
-if __name__ == '__main__':
- # add_contact('2020303457', '周帅康')
- # contacts = get_contacts('')
- # print(contacts)
- # messages = get_message('2020303457', '')
- # print(messages)
- # online('2020303457')
- # status = check_online('2020303457')
- # print('status:', status)
- # offline('2020303457')
- # status = check_online('2020303457')
- # print('status:', status)
- # print(get_remark('', 2020303457))
- # print(get_groups('2020303457'))
- # # print(create_group("DB实验", '2020303457', g_notice=str(12), g_intro="test"))
- # print(get_groups(''))
- # print(get_group_users(61067))
- print(get_myinfo(''))
diff --git a/app/DataBase/data.py b/app/DataBase/data.py
index 396c8e1..1dcf093 100644
--- a/app/DataBase/data.py
+++ b/app/DataBase/data.py
@@ -72,7 +72,7 @@ if os.path.exists('./app/DataBase/Msg.db'):
# '''创建游标'''
cursor = DB.cursor()
if os.path.exists('./Msg.db'):
- DB = sqlite3.connect("./Msg.db")
+ DB = sqlite3.connect("./Msg.db", check_same_thread=False)
# '''创建游标'''
cursor = DB.cursor()
@@ -110,7 +110,7 @@ def decrypt(db, key):
p = os.system(f"{os.path.abspath('.')}{cmd} {db} < ./app/DataBase/config.txt")
global DB
global cursor
- DB = sqlite3.connect("./app/DataBase/Msg.db")
+ DB = sqlite3.connect("./app/DataBase/Msg.db", check_same_thread=False)
# '''创建游标'''
cursor = DB.cursor()
@@ -249,9 +249,13 @@ def get_emoji(imgPath):
from EmojiInfo
where md5=?
'''
- cursor.execute(sql, [imgPath])
- result = cursor.fetchone()
- download_emoji(newPath, result[0])
+ try:
+ cursor.execute(sql, [imgPath])
+ result = cursor.fetchone()
+ download_emoji(newPath, result[0])
+ except sqlite3.ProgrammingError as e:
+ print(e, imgPath)
+ return False
return newPath
diff --git a/app/DataBase/output.py b/app/DataBase/output.py
index 31bce2b..e268bc7 100644
--- a/app/DataBase/output.py
+++ b/app/DataBase/output.py
@@ -33,35 +33,14 @@ def time_format(timestamp):
return time.strftime("%Y-%m-%d %H:%M:%S", time_tuple)
-def merge_docx(conRemark, n):
- origin_docx_path = f"{path}/{conRemark}"
- all_word = os.listdir(origin_docx_path)
- all_file_path = []
- for i in range(n):
- file_name = f"{conRemark}{i}.docx"
- all_file_path.append(origin_docx_path + '/' + file_name)
- filename = f"{conRemark}.docx"
- # print(all_file_path)
- doc = docx.Document()
- doc.save(origin_docx_path + '/' + filename)
- master = docx.Document(origin_docx_path + '/' + filename)
- middle_new_docx = Composer(master)
- num = 0
- for word in all_file_path:
- word_document = docx.Document(word)
- word_document.add_page_break()
- if num != 0:
- middle_new_docx.append(word_document)
- num = num + 1
- middle_new_docx.save(origin_docx_path + '/' + filename)
-
-
class Output(QThread):
"""
发送信息线程
"""
progressSignal = pyqtSignal(int)
- successSignal = pyqtSignal(int)
+ rangeSignal = pyqtSignal(int)
+ okSignal = pyqtSignal(int)
+ i = 1
def __init__(self, Me, ta_u, parent=None):
super().__init__(parent)
@@ -72,6 +51,83 @@ class Output(QThread):
self.ta_avatar = data.get_avator(ta_u)
self.msg_id = 0
+ def merge_docx(self, conRemark, n):
+ origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}"
+ all_word = os.listdir(origin_docx_path)
+ all_file_path = []
+ for i in range(n):
+ file_name = f"{conRemark}{i}.docx"
+ all_file_path.append(origin_docx_path + '/' + file_name)
+ filename = f"{conRemark}.docx"
+ # print(all_file_path)
+ doc = docx.Document()
+ doc.save(origin_docx_path + '/' + filename)
+ master = docx.Document(origin_docx_path + '/' + filename)
+ middle_new_docx = Composer(master)
+ num = 0
+ for word in all_file_path:
+ word_document = docx.Document(word)
+ word_document.add_page_break()
+ if num != 0:
+ middle_new_docx.append(word_document)
+ num = num + 1
+ middle_new_docx.save(origin_docx_path + '/' + filename)
+
+ def progress(self, value):
+ self.i += 1
+ # 处理完成之后将多个文件合并
+ if self.i == self.total_num:
+ QThread.sleep(1)
+ conRemark = data.get_conRemark(self.ta_username)
+ self.progressSignal.emit(self.total_num-1)
+ self.merge_docx(conRemark, self.n)
+ print('ok')
+ self.progressSignal.emit(self.total_num)
+ self.okSignal.emit(1)
+ self.progressSignal.emit(self.i)
+
+ def run(self):
+ self.Child = {}
+ if 1:
+ conRemark = data.get_conRemark(self.ta_username)
+ data.mkdir(f"{os.path.abspath('.')}/data/聊天记录/{conRemark}")
+ messages = data.get_all_message(self.ta_username)
+ self.total_num = len(messages)
+ self.rangeSignal.emit(self.total_num)
+ l = len(messages)
+ self.n = 10
+ for i in range(self.n):
+ q = i * (l // self.n)
+ p = (i + 1) * (l // self.n)
+ if i == self.n - 1:
+ p = l
+ len_data = messages[q:p]
+ # self.to_docx(len_data, i, conRemark)
+ self.Child[i] = ChildThread(self.Me, self.ta_username, len_data, conRemark,i)
+ self.Child[i].progressSignal.connect(self.progress)
+ self.Child[i].start()
+
+
+class ChildThread(QThread):
+ """
+ 子线程,用于导出部分聊天记录
+ """
+ progressSignal = pyqtSignal(int)
+ rangeSignal = pyqtSignal(int)
+ i = 1
+
+ def __init__(self, Me, ta_u, message, conRemark,num, parent=None):
+ super().__init__(parent)
+ self.Me = Me
+ self.sec = 2 # 默认1000秒
+ self.ta_username = ta_u
+ self.num = num
+ self.my_avatar = self.Me.my_avatar
+ self.ta_avatar = data.get_avator(ta_u)
+ self.conRemark = conRemark
+ self.message = message
+ self.msg_id = 0
+
def create_table(self, doc, isSend):
'''
#! 创建一个1*2表格
@@ -268,11 +324,14 @@ class Output(QThread):
def to_docx(self, messages, i, conRemark):
'''创建联系人目录'''
- data.mkdir(f"{os.path.abspath('.')}/data/聊天记录/{conRemark}")
+
filename = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}/{conRemark}{i}.docx"
doc = docx.Document()
last_timestamp = 1601968667000
+
for message in messages:
+ self.progressSignal.emit(self.i)
+ self.i += 1
msgId = message[0]
ta_username = message[7]
Type = int(message[2])
@@ -311,76 +370,11 @@ class Output(QThread):
doc.save(filename)
def run(self):
- if 1:
- conRemark = data.get_conRemark(self.ta_username)
- messages = data.get_all_message(self.ta_username)
- # self.self_text.emit(conRemark)
- # self.self_text.emit(path)
- self.to_docx(messages, 0, conRemark)
- # l = len(user_data)
- # n = 50
- # for i in range(n):
- # q = i * (l // n)
- # p = (i + 1) * (l // n)
- # if i == n - 1:
- # p = l
- # len_data = user_data[q:p]
- # self.to_docx(len_data, i, conRemark)
- # self.self_text.emit('\n\n\n导出进度还差一点点!!!')
- # self.bar.emit(99)
- # merge_docx(conRemark, n)
- # self.self_text.emit(f'{conRemark}聊天记录导出成功!!!')
- # self.bar.emit(100)
-
- # def run(self):
- # self.ta_avatar = data.get_avator(self.ta_u)
- # messages = data.get_all_message(self.ta_u)
- # total_num = len(messages)
- # for message in messages:
- # msgId = message[0]
- # ta_username = message[7]
- # msgType = str(message[2])
- # isSend = message[4]
- # content = message[8]
- # imgPath = message[9]
- # msg_time = message[6]
- # self.check_time(msg_time)
- #
- # if msgType == '1':
- # # return
- # self.show_text(isSend, content)
- # elif msgType == '3':
- # # return
- # self.show_img(isSend, imgPath, content)
- # elif msgType == '47':
- # # return
- # self.show_emoji(isSend, imgPath, content)
- # elif msgType == '268445456':
- # self.show_recall_information(content)
- # elif msgType == '922746929':
- # self.pat_a_pat(content)
+ self.to_docx(self.message, self.num, self.conRemark)
if __name__ == '__main__':
- # # conRemark = '张三' #! 微信备注名
- # n = 100 # ! 分割的文件个数
- # main(conRemark, n)
- # img_self.close()
- # img_ta.close()
me = data.Me('wxid_27hqbq7vx5hf22')
t = Output(Me=me, ta_u='wxid_q3ozn70pweud22')
- # t.ta_info = {
- # 'wxid': 'wxid_q3ozn70pweud22',
- # 'conRemark': '小钱'
- # }
- # t.ta_info = {
- # 'wxid': 'wxid_8piw6sb4hvfm22',
- # 'conRemark': '曹雨萱'
- # }
- # # wxid_8piw6sb4hvfm22
- # t.self_info = {
- # 'wxid': 'wxid_27hqbq7vx5hf22',
- # 'conRemark': 'Shuaikang Zhou'
- # }
t.run()
diff --git a/app/DataBase/to_docx.py b/app/DataBase/to_docx.py
deleted file mode 100644
index b282b59..0000000
--- a/app/DataBase/to_docx.py
+++ /dev/null
@@ -1,561 +0,0 @@
-import hashlib
-import os
-import re
-import threading
-import time
-import docx
-import pandas as pd
-import requests
-from docx import shared
-from docx.enum.table import WD_ALIGN_VERTICAL
-from docx.enum.text import WD_COLOR_INDEX, WD_PARAGRAPH_ALIGNMENT
-from docxcompose.composer import Composer
-import rcontact
-
-import sys
-from PyQt5.QtGui import QIcon
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
-from PyQt5.QtGui import QPixmap
-
-path = 'D:\Project\PythonProject\WeChat'
-# conRemark = '曹雨萱'
-# self_wxid = rcontact.get_self_wxid()
-# ta_wxid = rcontact.get_one_wxid(conRemark)
-
-'''
-#! 创建emoji目录,存放emoji文件
-'''
-
-
-def mkdir(path):
- path = path.strip()
- path = path.rstrip("\\")
- if os.path.exists(path):
- return False
- os.makedirs(path)
- return True
-
-
-mkdir(path + '/emoji')
-# mkdir('..//db_tables')
-'''
-#! 将wxid使用MD5编码加密
-#! 加密结果是用户头像路径
-'''
-
-
-def avatar_md5(wxid):
- m = hashlib.md5()
- # 参数必须是byte类型,否则报Unicode-objects must be encoded before hashing错误
- m.update(bytes(wxid.encode('utf-8')))
- return m.hexdigest()
-
-
-'''
-#! 获取头像文件完整路径
-'''
-
-
-def get_avator(wxid):
- avatar = avatar_md5(wxid)
- avatar_path = path + "/avatar/"
- Path = 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 Path + '/' + avatar
-
-
-def read_csv(conRemark):
- '''
- :param conRemark: (str) 要导出的联系人备注名
- :return: pandas数据
- '''
- user_data = pd.read_csv(f'{path}/db_tables/{conRemark}.csv')
- '''将浮点数转化成字符串类型,否则会舍入影响时间结果'''
- user_data['createTime'] = user_data['createTime'].astype(str)
- # print(user_data)
- return user_data
-
-
-def download_emoji(content, img_path):
- '''
- #! 下载emoji文件
- #!
- #!
- '''
- # if 1:
- try:
- # print(img_path)
- url = content.split('cdnurl = "')[1].split('"')[0]
- print(url)
- url = ':'.join(url.split('*#*'))
- if 'amp;' in url:
- url = ''.join(url.split('amp;'))
- print('emoji downloading!!!')
- resp = requests.get(url)
- with open(f'{path}/emoji/{img_path}', 'wb') as f:
- f.write(resp.content)
- except Exception:
- print("emoji download error")
-
-
-def time_format(timestamp):
- '''
- #! 将字符串类型的时间戳转换成日期
- #! 返回格式化的时间字符串
- #! %Y-%m-%d %H:%M:%S
- '''
- # print(timestamp)
- # timestamp = timestamp[:-5]
- timestamp = float(timestamp[:-3] + '.' + timestamp[-3:])
- # print(timestamp)
- time_tuple = time.localtime(timestamp)
- # print(time.strftime("%Y-%m-%d %H:%M:%S", time_tuple))
- # quit()
- return time.strftime("%Y-%m-%d %H:%M:%S", time_tuple)
-
-
-def IS_5_min(last_m, now_m):
- '''
- #! 判断两次聊天时间是不是大于五分钟
- #! 若大于五分钟则显示时间
- #! 否则不显示
- '''
- last_m = last_m[:-5]
- last_m = float(last_m + '.' + last_m[-5:2])
- now_m = now_m[:-5]
- now_m = float(now_m + '.' + now_m[-5:2])
- '''两次聊天记录时间差,单位是秒'''
- time_sub = now_m - last_m
- return time_sub >= 300
-
-
-def judge_type(Type):
- pass
-
-
-'''合并word文档到一个文件里'''
-
-
-def merge_docx(conRemark, n):
- origin_docx_path = f"{path}/{conRemark}"
- all_word = os.listdir(origin_docx_path)
- all_file_path = []
- for i in range(n):
- file_name = f"{conRemark}{i}.docx"
- all_file_path.append(origin_docx_path + '/' + file_name)
- filename = f"{conRemark}.docx"
- # print(all_file_path)
- doc = docx.Document()
- doc.save(origin_docx_path + '/' + filename)
- master = docx.Document(origin_docx_path + '/' + filename)
- middle_new_docx = Composer(master)
- num = 0
- for word in all_file_path:
- word_document = docx.Document(word)
- word_document.add_page_break()
- if num != 0:
- middle_new_docx.append(word_document)
- num = num + 1
- middle_new_docx.save(origin_docx_path + '/' + filename)
-
-
-class MyThread(QThread):
- signal = pyqtSignal(str)
- self_text = pyqtSignal(str)
- ta_text = pyqtSignal(str)
- bar = pyqtSignal(int)
-
- def __init__(self):
- super(MyThread, self).__init__()
- self.ta_info = {}
- self.self_info = {}
- self.textBrowser = None
- self.num = 0
- self.total_num = 1
-
- def get_avator(self):
- self.wxid = self.self_info['wxid']
- self.ta_wxid = self.ta_info['wxid']
- self.avator = get_avator(self.wxid)
- print(self.avator)
- self.ta_avator = get_avator(self.ta_wxid)
- print(self.ta_avator)
- # quit()
- self.img_self = open(self.avator, 'rb')
- self.img_ta = open(self.ta_avator, 'rb')
-
- def read_csv(self, conRemark):
- '''
- :param conRemark: (str) 要导出的联系人备注名
- :return: pandas数据
- '''
- user_data = pd.read_csv(f'{path}/db_tables/{conRemark}.csv')
- '''将浮点数转化成字符串类型,否则会舍入影响时间结果'''
- user_data['createTime'] = user_data['createTime'].astype(str)
- # print(user_data)
- self.total_num = len(user_data)
- return user_data
-
- def create_table(self, doc, isSend):
- '''
- #! 创建一个1*2表格
- #! isSend = 1 (0,0)存聊天内容,(0,1)存头像
- #! isSend = 0 (0,0)存头像,(0,1)存聊天内容
- #! 返回聊天内容的坐标
- '''
- table = doc.add_table(rows=1, cols=2, style='Normal Table')
- table.cell(0, 1).height = shared.Inches(0.5)
- table.cell(0, 0).height = shared.Inches(0.5)
- text_size = 1
- if isSend:
- '''表格右对齐'''
- table.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
- avatar = table.cell(0, 1).paragraphs[0].add_run()
- '''插入头像,设置头像宽度'''
- avatar.add_picture(self.img_self, width=shared.Inches(0.5))
- '''设置单元格宽度跟头像一致'''
- table.cell(0, 1).width = shared.Inches(0.5)
- content_cell = table.cell(0, 0)
- '''聊天内容右对齐'''
- content_cell.paragraphs[0].paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
- else:
- avatar = table.cell(0, 0).paragraphs[0].add_run()
- avatar.add_picture(self.img_ta, width=shared.Inches(0.5))
- '''设置单元格宽度'''
- table.cell(0, 0).width = shared.Inches(0.5)
- content_cell = table.cell(0, 1)
- '''聊天内容垂直居中对齐'''
- content_cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER
- return content_cell
-
- def text(self, doc, isSend, message, status):
- if status == 5:
- message += '(未发出) '
- content_cell = self.create_table(doc, isSend)
- content_cell.paragraphs[0].add_run(message)
- content_cell.paragraphs[0].font_size = shared.Inches(0.5)
- self.self_text.emit(message)
- if isSend:
- p = content_cell.paragraphs[0]
- p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
- doc.add_paragraph()
-
- def image(self, doc, isSend, Type, content, imgPath):
- '''
- #! 插入聊天图片
- #! isSend = 1 只有缩略图
- #! isSend = 0 有原图
- :param doc:
- :param isSend:
- :param Type:
- :param content:
- :param imgPath:
- :return:
- '''
- content = self.create_table(doc, isSend)
- run = content.paragraphs[0].add_run()
- imgPath = imgPath.split('//th_')[-1]
- Path = None
- if Type == 3:
- Path = f'{path}/image2//{imgPath[:2]}//{imgPath[2:4]}'
- elif Type == 47:
- Path = '{path}/emoji'
- for root, dirs, files in os.walk(Path):
- for file in files:
- if isSend:
- if imgPath + 'hd' in file:
- imgPath = file
- try:
- run.add_picture(f'{Path}/{imgPath}', height=shared.Inches(2))
- doc.add_paragraph()
- except Exception:
- print("Error!image")
- return
- elif imgPath in file:
- imgPath = file
- break
- try:
- run.add_picture(f'{Path}/{imgPath}', height=shared.Inches(2))
- doc.add_paragraph()
- except Exception:
- print("Error!image")
-
- # run.add_picture(f'{Path}/{imgPath}', height=shared.Inches(2))
-
- def emoji(self, doc, isSend, content, imgPath):
- '''
- #! 添加表情包
- :param isSend:
- :param content:
- :param imgPath:
- :return:
- '''
- if 1:
- # try:
- Path = f'{path}/emoji/{imgPath}'
- is_Exist = os.path.exists(Path)
- if not is_Exist:
- '''表情包不存在,则下载表情包到emoji文件夹中'''
- download_emoji(content, imgPath)
- self.image(doc, isSend, Type=47, content=content, imgPath=imgPath)
- # except Exception:
- # print("can't find emoji!")
-
- def wx_file(self, doc, isSend, content, status):
- '''
- #! 添加微信文件
- :param isSend:
- :param content:
- :param status:
- :return:
- '''
- pattern = re.compile(r"
(.*?)<")
- r = pattern.search(content).group()
- filename = r.lstrip('').rstrip('<')
- self.text(doc, isSend, filename, status)
-
- def retract_message(self, doc, isSend, content, status):
- '''
- #! 显示撤回消息
- :param isSend:
- :param content:
- :param status:
- :return:
- '''
- paragraph = doc.add_paragraph(content)
- paragraph.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
- def reply(self, doc, isSend, content, status):
- '''
- #! 添加回复信息
- :param isSend:
- :param content:
- :param status:
- :return:
- '''
- pattern1 = re.compile(r"(?P(.*?))")
- title = pattern1.search(content).groupdict()['title']
- pattern2 = re.compile(r"(?P(.*?))")
- displayname = pattern2.search(content).groupdict()['displayname']
- '''匹配回复的回复'''
- pattern3 = re.compile(r"\n?title>(?P(.*?))\n?</title>")
- if not pattern3.search(content):
- if isSend == 0:
- '''匹配对方的回复'''
- pattern3 = re.compile(r"(?P(.*?))")
- else:
- '''匹配自己的回复'''
- pattern3 = re.compile(r"\n?(?P(.*?))\n?")
-
- '''这部分代码完全可以用if代替'''
-
- try:
- '''试错'''
- text = pattern3.search(content).groupdict()['content']
- except Exception:
- try:
- '''试错'''
- text = pattern3.search(content).groupdict()['content']
- except Exception:
- '''试错'''
- pattern3 = re.compile(r"\n?(?P(.*?))\n?")
- '''试错'''
- if pattern3.search(content):
- text = pattern3.search(content).groupdict()['content']
- else:
- text = '图片'
- if status == 5:
- message = '(未发出) ' + ''
- content_cell = self.create_table(doc, isSend)
- content_cell.paragraphs[0].add_run(title)
- content_cell.paragraphs[0].font_size = shared.Inches(0.5)
- reply_p = content_cell.add_paragraph()
- run = content_cell.paragraphs[1].add_run(displayname + ':' + text)
- '''设置被回复内容格式'''
- run.font.color.rgb = shared.RGBColor(121, 121, 121)
- run.font_size = shared.Inches(0.3)
- run.font.highlight_color = WD_COLOR_INDEX.GRAY_25
-
- if isSend:
- p = content_cell.paragraphs[0]
- p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
- reply_p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
- doc.add_paragraph()
-
- def pat_a_pat(self, doc, isSend, content, status):
- '''
- #! 添加拍一拍信息
- todo 把wxid转化成昵称
- :param isSend:
- :param content:
- :param status:
- :return:
- '''
- ''''''
- pattern = re.compile(r"(.*?))]]>")
- result = pattern.search(content).groupdict()['it']
- fromusername = '${fromusername@textstatusicon}'
- pattedusername = '${pattedusername@textstatusicon}'
- '''我拍别人'''
- if result[0] == u'我':
- result = ''.join(result.split(fromusername))
- result = ''.join(result.split(pattedusername))
- pat = result
- else:
- '''处理多余的引号'''
- result = result.split('""') if '""' in result else result.split('"')
- for i in range(len(result)):
- if fromusername in result[i]:
- result[i] = result[i].rstrip(fromusername)
- elif pattedusername in result[i]:
- result[i] = result[i].rstrip(pattedusername)
-
- if len(result) >= 4:
- '''别人拍别人
- #! ""${s407575157}${fromusername@textstatusicon}"" \
- #! 拍了拍 \
- #! ""${wxid_7rs401fwlaje22}${pattedusername@textstatusicon}"" \
- #! 的豪宅不小心塌了??
- #! [' ', wxid0, '拍了拍', wxid1, '内容']
- '''
- wxid0 = result[1].lstrip('${').rstrip('}') # ! 第一个人的wxid
- wxid1 = result[3].lstrip('${').rstrip('}') # ! 第二个人的wxid
- nickname0 = rcontact.wxid_to_conRemark(wxid0) # ! 将wxid转换成昵称
- nickname1 = rcontact.wxid_to_conRemark(wxid1) # ! 将wxid转换成昵称
- pat = nickname0 + result[2] + nickname1 # todo 留着把wxid转换成昵称
- if len(result) == 5:
- pat += result[4]
- else:
- '''#! ""${wxid_8piw6sb4hvfm22}"" 拍了拍我 '''
- '''
- #! 别人拍我
- #! [' ', wxid0, '拍了拍我']
- '''
- wxid0 = result[1].lstrip('${').rstrip('}')
- pat = wxid0 + result[2]
- print(pat)
- p = doc.add_paragraph()
- run = p.add_run(pat)
- p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
- '''设置拍一拍文字格式'''
- run.font.color.rgb = shared.RGBColor(121, 121, 121)
- run.font_size = shared.Inches(0.3)
- # run.font.highlight_color=WD_COLOR_INDEX.GRAY_25
-
- def video(self, doc, isSend, content, status, img_path):
- print(content, img_path)
-
- def to_docx(self, user_data, i, conRemark):
- '''
-
- :param user_data:
- :param i:
- :param conRemark:
- :return:
- '''
- '''创建联系人目录'''
- mkdir(f"{path}/{conRemark}")
- filename = f"{path}/{conRemark}/{conRemark}{i}.docx"
- doc = docx.Document()
- now_timestamp = '1600008700000.0'
- for row_index, row in user_data.iterrows():
- self.num += 1
- self.bar.emit(int((self.num) / self.total_num * 100))
- Type = row['type']
- content = row['content']
- isSend = row['isSend']
- last_timestamp = now_timestamp
- now_timestamp = row['createTime']
- createTime = time_format(now_timestamp)
- imgPath = row['imgPath']
- status = row['status']
- if IS_5_min(last_timestamp, now_timestamp):
- doc.add_paragraph(createTime).alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
- if Type == 1:
- # print('文本信息')
- # print(createTime, content)
- # continue
- self.text(doc, isSend, content, status)
- elif Type == 3:
- # print('图片信息')
- # continue
- self.image(doc, isSend, 3, content, imgPath)
- elif Type == 47:
- # print(content)
- print(imgPath, content)
- self.emoji(doc, isSend, content, imgPath)
- elif Type == 1090519089:
- self.wx_file(doc, isSend, content, status)
- elif Type == 268445456:
- self.retract_message(doc, isSend, content, status)
- elif Type == 822083633:
- self.reply(doc, isSend, content, status)
- elif Type == 922746929:
- self.pat_a_pat(doc, isSend, content, status)
- elif Type == 43:
- # print(createTime)
- self.video(doc, isSend, content, status, imgPath)
- # doc.add_paragraph(str(i))
- # print(filename)
- doc.save(filename)
-
- def run(self):
- if 1:
- # try:
- self.get_avator()
- conRemark = self.ta_info['conRemark']
- self.self_text.emit(conRemark)
- self.self_text.emit(path)
- user_data = self.read_csv(conRemark)
- l = len(user_data)
- n = 50
- threads = []
- for i in range(n):
- q = i * (l // n)
- p = (i + 1) * (l // n)
- if i == n - 1:
- p = l
- data = user_data[q:p]
- self.to_docx(data, i, conRemark)
- # # t = threading.Thread(target=self.to_docx, args=(data, i, conRemark))
- # # threads.append(t)
- # # for thr in threads:
- # # thr.start()
- # # thr.join()
- self.self_text.emit('\n\n\n导出进度还差一点点!!!')
- self.bar.emit(99)
- merge_docx(conRemark, n)
- self.self_text.emit(f'{conRemark}聊天记录导出成功!!!')
- self.bar.emit(100)
- # except Exception as e:
- # self.self_text.emit('发生异常')
- # print(e)
- # self.self_text.emit(e)
-
-
-if __name__ == '__main__':
- # # conRemark = '张三' #! 微信备注名
- # n = 100 # ! 分割的文件个数
- # main(conRemark, n)
- # img_self.close()
- # img_ta.close()
- t = MyThread()
- # t.ta_info = {
- # 'wxid': 'wxid_q3ozn70pweud22',
- # 'conRemark': '小钱'
- # }
- t.ta_info = {
- 'wxid': 'wxid_8piw6sb4hvfm22',
- 'conRemark': '曹雨萱'
- }
- # wxid_8piw6sb4hvfm22
- t.self_info = {
- 'wxid': 'wxid_27hqbq7vx5hf22',
- 'conRemark': 'Shuaikang Zhou'
- }
- t.run()
diff --git a/app/Ui/chat/addContact/__init__.py b/app/Ui/chat/addContact/__init__.py
deleted file mode 100644
index 6d32454..0000000
--- a/app/Ui/chat/addContact/__init__.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-@File : __init__.py.py
-@Author : Shuaikang Zhou
-@Time : 2022/12/24 10:34
-@IDE : Pycharm
-@Version : Python3.10
-@comment : ···
-"""
diff --git a/app/Ui/chat/addContact/addContact.py b/app/Ui/chat/addContact/addContact.py
deleted file mode 100644
index 9f975e7..0000000
--- a/app/Ui/chat/addContact/addContact.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-@File : addContact.py
-@Author : Shuaikang Zhou
-@Time : 2022/12/17 14:26
-@IDE : Pycharm
-@Version : Python3.10
-@comment : ···
-"""
-from .addContactUi import *
-from PyQt5.QtGui import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtCore import *
-from ....DB import data
-import time
-
-
-class addControl(QWidget, Ui_Dialog):
- backSignal = pyqtSignal(str)
- contactSignal = pyqtSignal(tuple)
- def __init__(self, username,parent=None):
- super(addControl, self).__init__(parent)
- self.setupUi(self)
- self.tips.setVisible(False)
- self.time.setVisible(False)
- self.setWindowTitle('添加联系人')
- self.setWindowIcon(QIcon('./data/icon.png'))
- self.Username = username
- # self.register_2.clicked.connect(self.login_)
- self.back.clicked.connect(self.btnEnterClicked)
- self.search.clicked.connect(self.search_user)
- self.add_contact.clicked.connect(self.add_contact_)
- self.avatar = None
-
- def search_user(self):
- username = self.username.text()
- nickname = self.nickname.text()
- print(username,nickname)
- if data.searchUser(username):
- imgpath = data.get_avator(username)
- print(imgpath)
- pixmap = QPixmap(imgpath).scaled(60, 60) # 按指定路径找到图片
- self.avatar_img.setPixmap(pixmap) # 在label上显示图片
- else:
- self.error.setText('用户不存在')
-
- def add_contact_(self):
- username = self.username.text()
- nickname = self.nickname.text()
- flag = data.add_contact(self.Username,username, nickname)
- if flag:
- self.error.setText('添加成功')
- self.contactSignal.emit(flag)
- self.thread = MyThread() # 创建一个线程
- self.thread.sec_changed_signal.connect(self._update) # 线程发过来的信号挂接到槽:update
- self.thread.start()
- else:
- QMessageBox.critical(self, "错误", "用户不存在")
-
-
- def _update(self, sec):
- self.time.setProperty("value", float(sec))
- # self.time.setDigitCount(sec)
- # self.time.s
- if sec == 0:
- self.btnEnterClicked()
-
- def btnEnterClicked(self):
- print("退出添加联系人界面")
- # 中间可以添加处理逻辑
- self.backSignal.emit("back")
- self.close()
-
- def btnExitClicked(self):
- print("Exit clicked")
- self.close()
-
-
-class MyThread(QThread):
- sec_changed_signal = pyqtSignal(int) # 信号类型:int
-
- def __init__(self, sec=1000, parent=None):
- super().__init__(parent)
- self.sec = 2 # 默认1000秒
-
- def run(self):
- for i in range(self.sec, -1, -1):
- self.sec_changed_signal.emit(i) # 发射信号
- time.sleep(1)
diff --git a/app/Ui/chat/addContact/addContactUi.py b/app/Ui/chat/addContact/addContactUi.py
deleted file mode 100644
index 31149ce..0000000
--- a/app/Ui/chat/addContact/addContactUi.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'addContactUi.ui'
-#
-# Created by: PyQt5 UI code generator 5.15.7
-#
-# WARNING: Any manual changes made to this file will be lost when pyuic5 is
-# run again. Do not edit this file unless you know what you are doing.
-
-
-from PyQt5 import QtCore, QtGui, QtWidgets
-
-
-class Ui_Dialog(object):
- def setupUi(self, Dialog):
- Dialog.setObjectName("Dialog")
- Dialog.resize(400, 300)
- self.label_3 = QtWidgets.QLabel(Dialog)
- self.label_3.setGeometry(QtCore.QRect(120, 0, 221, 51))
- font = QtGui.QFont()
- font.setFamily("一纸情书")
- font.setPointSize(20)
- self.label_3.setFont(font)
- self.label_3.setObjectName("label_3")
- self.error = QtWidgets.QLabel(Dialog)
- self.error.setGeometry(QtCore.QRect(300, 70, 101, 16))
- self.error.setAutoFillBackground(False)
- self.error.setStyleSheet("color:red")
- self.error.setText("")
- self.error.setObjectName("error")
- self.time = QtWidgets.QLCDNumber(Dialog)
- self.time.setGeometry(QtCore.QRect(230, 230, 51, 61))
- self.time.setLineWidth(5)
- self.time.setDigitCount(1)
- self.time.setProperty("value", 8.0)
- self.time.setObjectName("time")
- self.tips = QtWidgets.QLabel(Dialog)
- self.tips.setGeometry(QtCore.QRect(140, 250, 61, 16))
- self.tips.setObjectName("tips")
- self.toolButton = QtWidgets.QToolButton(Dialog)
- self.toolButton.setGeometry(QtCore.QRect(360, 0, 47, 21))
- self.toolButton.setObjectName("toolButton")
- self.back = QtWidgets.QPushButton(Dialog)
- self.back.setGeometry(QtCore.QRect(10, 10, 41, 28))
- self.back.setObjectName("back")
- self.avatar_img = QtWidgets.QLabel(Dialog)
- self.avatar_img.setGeometry(QtCore.QRect(310, 130, 80, 80))
- self.avatar_img.setObjectName("avatar_img")
- self.layoutWidget = QtWidgets.QWidget(Dialog)
- self.layoutWidget.setGeometry(QtCore.QRect(71, 63, 227, 155))
- self.layoutWidget.setObjectName("layoutWidget")
- self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
- self.verticalLayout.setContentsMargins(0, 0, 0, 0)
- self.verticalLayout.setObjectName("verticalLayout")
- self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
- self.horizontalLayout_2.setObjectName("horizontalLayout_2")
- self.label_2 = QtWidgets.QLabel(self.layoutWidget)
- self.label_2.setObjectName("label_2")
- self.horizontalLayout_2.addWidget(self.label_2)
- self.username = QtWidgets.QLineEdit(self.layoutWidget)
- self.username.setObjectName("username")
- self.horizontalLayout_2.addWidget(self.username)
- self.verticalLayout.addLayout(self.horizontalLayout_2)
- self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
- self.horizontalLayout_4.setObjectName("horizontalLayout_4")
- self.label_4 = QtWidgets.QLabel(self.layoutWidget)
- self.label_4.setMinimumSize(QtCore.QSize(38, 21))
- self.label_4.setMaximumSize(QtCore.QSize(38, 21))
- self.label_4.setObjectName("label_4")
- self.horizontalLayout_4.addWidget(self.label_4)
- self.nickname = QtWidgets.QLineEdit(self.layoutWidget)
- self.nickname.setMinimumSize(QtCore.QSize(0, 0))
- self.nickname.setMaximumSize(QtCore.QSize(100000, 10000))
- self.nickname.setObjectName("nickname")
- self.horizontalLayout_4.addWidget(self.nickname)
- self.verticalLayout.addLayout(self.horizontalLayout_4)
- self.search = QtWidgets.QPushButton(self.layoutWidget)
- self.search.setObjectName("search")
- self.verticalLayout.addWidget(self.search)
- self.add_contact = QtWidgets.QPushButton(self.layoutWidget)
- self.add_contact.setObjectName("add_contact")
- self.verticalLayout.addWidget(self.add_contact)
-
- self.retranslateUi(Dialog)
- QtCore.QMetaObject.connectSlotsByName(Dialog)
-
- def retranslateUi(self, Dialog):
- _translate = QtCore.QCoreApplication.translate
- Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
- self.label_3.setText(_translate("Dialog", "添加好友"))
- self.tips.setText(_translate("Dialog", "即将返回"))
- self.toolButton.setText(_translate("Dialog", "..."))
- self.back.setText(_translate("Dialog", "返回"))
- self.avatar_img.setText(_translate("Dialog", "+"))
- self.label_2.setText(_translate("Dialog", "账号:"))
- self.label_4.setText(_translate("Dialog", "备注:"))
- self.search.setText(_translate("Dialog", "查找"))
- self.add_contact.setText(_translate("Dialog", "添加联系人"))
diff --git a/app/Ui/chat/addContact/addContactUi.ui b/app/Ui/chat/addContact/addContactUi.ui
deleted file mode 100644
index 207082d..0000000
--- a/app/Ui/chat/addContact/addContactUi.ui
+++ /dev/null
@@ -1,207 +0,0 @@
-
-
- Dialog
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- Dialog
-
-
-
-
- 120
- 0
- 221
- 51
-
-
-
-
- 一纸情书
- 20
-
-
-
- 添加好友
-
-
-
-
-
- 300
- 70
- 101
- 16
-
-
-
- false
-
-
- color:red
-
-
-
-
-
-
-
-
- 230
- 230
- 51
- 61
-
-
-
- 5
-
-
- 1
-
-
- 8.000000000000000
-
-
-
-
-
- 140
- 250
- 61
- 16
-
-
-
- 即将返回
-
-
-
-
-
- 360
- 0
- 47
- 21
-
-
-
- ...
-
-
-
-
-
- 10
- 10
- 41
- 28
-
-
-
- 返回
-
-
-
-
-
- 310
- 130
- 80
- 80
-
-
-
- +
-
-
-
-
-
- 71
- 63
- 227
- 155
-
-
-
- -
-
-
-
-
-
- 账号:
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
- 38
- 21
-
-
-
-
- 38
- 21
-
-
-
- 备注:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 100000
- 10000
-
-
-
-
-
-
- -
-
-
- 查找
-
-
-
- -
-
-
- 添加联系人
-
-
-
-
-
-
-
-
-
diff --git a/app/Ui/chat/backup/chatUi - 副本.py b/app/Ui/chat/backup/chatUi - 副本.py
deleted file mode 100644
index ee581fb..0000000
--- a/app/Ui/chat/backup/chatUi - 副本.py
+++ /dev/null
@@ -1,143 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'mainviewUi.ui'
-#
-# Created by: PyQt5 UI code generator 5.15.7
-#
-# WARNING: Any manual changes made to this file will be lost when pyuic5 is
-# run again. Do not edit this file unless you know what you are doing.
-
-
-from PyQt5 import QtCore, QtGui, QtWidgets
-
-
-class Ui_Dialog(object):
- def setupUi(self, Dialog):
- Dialog.setObjectName("Dialog")
- Dialog.resize(1280, 720)
- Dialog.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
- Dialog.setAutoFillBackground(False)
- self.sign_up = QtWidgets.QPushButton(Dialog)
- self.sign_up.setGeometry(QtCore.QRect(680, 10, 93, 28))
- self.sign_up.setObjectName("sign_up")
- self.message = QtWidgets.QTextBrowser(Dialog)
- self.message.setGeometry(QtCore.QRect(480, 50, 780, 520))
- self.message.setObjectName("message")
- self.textEdit = QtWidgets.QTextEdit(Dialog)
- self.textEdit.setGeometry(QtCore.QRect(480, 600, 800, 120))
- self.textEdit.setObjectName("textEdit")
- self.toolButton = QtWidgets.QToolButton(Dialog)
- self.toolButton.setGeometry(QtCore.QRect(1240, 0, 47, 51))
- self.toolButton.setObjectName("toolButton")
- self.btn_sendMsg = QtWidgets.QPushButton(Dialog)
- self.btn_sendMsg.setGeometry(QtCore.QRect(1162, 670, 121, 51))
- font = QtGui.QFont()
- font.setFamily("黑体")
- font.setPointSize(15)
- font.setBold(False)
- font.setWeight(50)
- self.btn_sendMsg.setFont(font)
- self.btn_sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
- self.btn_sendMsg.setMouseTracking(False)
- self.btn_sendMsg.setAutoFillBackground(False)
- self.btn_sendMsg.setStyleSheet("QPushButton {\n"
-" background-color: #f0f0f0;\n"
-" \n"
-" padding: 10px;\n"
-" color:rgb(5,180,104);\n"
-"}")
- self.btn_sendMsg.setIconSize(QtCore.QSize(40, 40))
- self.btn_sendMsg.setCheckable(False)
- self.btn_sendMsg.setAutoDefault(True)
- self.btn_sendMsg.setObjectName("btn_sendMsg")
- self.line = QtWidgets.QFrame(Dialog)
- self.line.setGeometry(QtCore.QRect(480, 570, 800, 3))
- self.line.setFrameShape(QtWidgets.QFrame.HLine)
- self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line.setObjectName("line")
- self.line_2 = QtWidgets.QFrame(Dialog)
- self.line_2.setGeometry(QtCore.QRect(480, 50, 800, 3))
- self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
- self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line_2.setObjectName("line_2")
- self.line_3 = QtWidgets.QFrame(Dialog)
- self.line_3.setGeometry(QtCore.QRect(480, 0, 3, 720))
- self.line_3.setFrameShape(QtWidgets.QFrame.VLine)
- self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line_3.setObjectName("line_3")
- self.verticalScrollBar = QtWidgets.QScrollBar(Dialog)
- self.verticalScrollBar.setGeometry(QtCore.QRect(460, 50, 16, 671))
- self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical)
- self.verticalScrollBar.setObjectName("verticalScrollBar")
- self.verticalScrollBar_2 = QtWidgets.QScrollBar(Dialog)
- self.verticalScrollBar_2.setGeometry(QtCore.QRect(1260, 50, 16, 520))
- self.verticalScrollBar_2.setStyleSheet("background-color: #f0f0f0;")
- self.verticalScrollBar_2.setOrientation(QtCore.Qt.Vertical)
- self.verticalScrollBar_2.setObjectName("verticalScrollBar_2")
- self.pushButton_2 = QtWidgets.QPushButton(Dialog)
- self.pushButton_2.setGeometry(QtCore.QRect(160, 50, 300, 80))
- self.pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
- self.pushButton_2.setAutoFillBackground(False)
- self.pushButton_2.setText("")
- self.pushButton_2.setIconSize(QtCore.QSize(80, 80))
- self.pushButton_2.setObjectName("pushButton_2")
- self.verticalLayoutWidget = QtWidgets.QWidget(Dialog)
- self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 160, 111, 562))
- self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
- self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
- self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
- self.verticalLayout_2.setSpacing(0)
- self.verticalLayout_2.setObjectName("verticalLayout_2")
- self.btn_chat = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_chat.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_chat.setObjectName("btn_chat")
- self.verticalLayout_2.addWidget(self.btn_chat)
- self.btn_contact = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_contact.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_contact.setObjectName("btn_contact")
- self.verticalLayout_2.addWidget(self.btn_contact)
- self.btn_addC = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_addC.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_addC.setObjectName("btn_addC")
- self.verticalLayout_2.addWidget(self.btn_addC)
- self.btn_delC = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_delC.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_delC.setObjectName("btn_delC")
- self.verticalLayout_2.addWidget(self.btn_delC)
- self.btn_create_group = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_create_group.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_create_group.setObjectName("btn_create_group")
- self.verticalLayout_2.addWidget(self.btn_create_group)
- self.btn_add_group = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_add_group.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_add_group.setObjectName("btn_add_group")
- self.verticalLayout_2.addWidget(self.btn_add_group)
- self.pushButton_6 = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.pushButton_6.setMinimumSize(QtCore.QSize(100, 80))
- self.pushButton_6.setObjectName("pushButton_6")
- self.verticalLayout_2.addWidget(self.pushButton_6)
- self.verticalLayout_2.setStretch(0, 1)
- self.verticalLayout_2.setStretch(2, 1)
- self.verticalLayout_2.setStretch(3, 1)
- self.verticalLayout_2.setStretch(6, 1)
- self.myavatar = QtWidgets.QLabel(Dialog)
- self.myavatar.setGeometry(QtCore.QRect(10, 30, 100, 100))
- self.myavatar.setObjectName("myavatar")
-
- self.retranslateUi(Dialog)
- QtCore.QMetaObject.connectSlotsByName(Dialog)
-
- def retranslateUi(self, Dialog):
- _translate = QtCore.QCoreApplication.translate
- Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
- self.sign_up.setText(_translate("Dialog", "退出登录"))
- self.toolButton.setText(_translate("Dialog", "..."))
- self.btn_sendMsg.setText(_translate("Dialog", "发送"))
- self.btn_chat.setText(_translate("Dialog", "聊天"))
- self.btn_contact.setText(_translate("Dialog", "联系人"))
- self.btn_addC.setText(_translate("Dialog", "添加联系人"))
- self.btn_delC.setText(_translate("Dialog", "删除联系人"))
- self.btn_create_group.setText(_translate("Dialog", "建群"))
- self.btn_add_group.setText(_translate("Dialog", "加群"))
- self.pushButton_6.setText(_translate("Dialog", "设置"))
- self.myavatar.setText(_translate("Dialog", "avatar"))
diff --git a/app/Ui/chat/backup/chatUi - 副本.ui b/app/Ui/chat/backup/chatUi - 副本.ui
deleted file mode 100644
index 705a441..0000000
--- a/app/Ui/chat/backup/chatUi - 副本.ui
+++ /dev/null
@@ -1,845 +0,0 @@
-
-
- Dialog
-
-
-
- 0
- 0
- 1280
- 720
-
-
-
- ArrowCursor
-
-
- Dialog
-
-
- false
-
-
-
-
- 580
- 570
- 93
- 28
-
-
-
- PushButton
-
-
-
-
-
- 480
- 50
- 800
- 520
-
-
-
-
-
-
- 480
- 600
- 800
- 120
-
-
-
-
-
-
- 1240
- 0
- 47
- 51
-
-
-
- ...
-
-
-
-
-
- 1162
- 670
- 121
- 51
-
-
-
-
- 黑体
- 15
- 50
- false
-
-
-
- ArrowCursor
-
-
- false
-
-
- false
-
-
- QPushButton {
- background-color: #f0f0f0;
- border: 1px solid #dcdfe6;
- padding: 10px;
- color:rgb(5,180,104);
-}
-
-
- 发送
-
-
-
- 40
- 40
-
-
-
- false
-
-
- true
-
-
-
-
-
- 480
- 570
- 800
- 3
-
-
-
- Qt::Horizontal
-
-
-
-
-
- 480
- 50
- 800
- 3
-
-
-
- Qt::Horizontal
-
-
-
-
-
- 480
- 0
- 3
- 720
-
-
-
- Qt::Vertical
-
-
-
-
-
- 40
- 370
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 290
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 210
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 130
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 450
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 530
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 40
- 610
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
- 460
- 50
- 16
- 671
-
-
-
- Qt::Vertical
-
-
-
-
-
- 1260
- 50
- 16
- 520
-
-
-
- background-color: #f0f0f0;
-
-
- Qt::Vertical
-
-
-
-
-
- 40
- 50
- 411
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 0
-
-
- 4
-
-
- 0
-
- -
-
-
-
- 10
-
-
-
- Qt::RightToLeft
-
-
- 昨天
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- 15
-
-
-
- 司小远
-
-
-
- -
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- TextLabel
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
-
-
-
-
-
-
diff --git a/app/Ui/chat/backup/chatUi.py b/app/Ui/chat/backup/chatUi.py
deleted file mode 100644
index 164372b..0000000
--- a/app/Ui/chat/backup/chatUi.py
+++ /dev/null
@@ -1,184 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file 'chatUi.ui'
-#
-# Created by: PyQt5 UI code generator 5.15.7
-#
-# WARNING: Any manual changes made to this file will be lost when pyuic5 is
-# run again. Do not edit this file unless you know what you are doing.
-
-
-from PyQt5 import QtCore, QtGui, QtWidgets
-
-
-class Ui_Dialog(object):
- def setupUi(self, Dialog):
- Dialog.setObjectName("Dialog")
- Dialog.resize(1280, 720)
- Dialog.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
- Dialog.setAutoFillBackground(False)
- self.pushButton = QtWidgets.QPushButton(Dialog)
- self.pushButton.setGeometry(QtCore.QRect(580, 570, 93, 28))
- self.pushButton.setObjectName("pushButton")
- self.textBrowser = QtWidgets.QTextBrowser(Dialog)
- self.textBrowser.setGeometry(QtCore.QRect(480, 50, 800, 520))
- self.textBrowser.setObjectName("textBrowser")
- self.textEdit = QtWidgets.QTextEdit(Dialog)
- self.textEdit.setGeometry(QtCore.QRect(480, 600, 800, 120))
- self.textEdit.setObjectName("textEdit")
- self.toolButton = QtWidgets.QToolButton(Dialog)
- self.toolButton.setGeometry(QtCore.QRect(1240, 0, 47, 51))
- self.toolButton.setObjectName("toolButton")
- self.sendMsg = QtWidgets.QPushButton(Dialog)
- self.sendMsg.setGeometry(QtCore.QRect(1162, 670, 121, 51))
- font = QtGui.QFont()
- font.setFamily("黑体")
- font.setPointSize(15)
- font.setBold(False)
- font.setWeight(50)
- self.sendMsg.setFont(font)
- self.sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
- self.sendMsg.setMouseTracking(False)
- self.sendMsg.setAutoFillBackground(False)
- self.sendMsg.setStyleSheet("QPushButton {\n"
-" background-color: #f0f0f0;\n"
-" \n"
-" padding: 10px;\n"
-" color:rgb(5,180,104);\n"
-"}")
- self.sendMsg.setIconSize(QtCore.QSize(40, 40))
- self.sendMsg.setCheckable(False)
- self.sendMsg.setAutoDefault(True)
- self.sendMsg.setObjectName("sendMsg")
- self.line = QtWidgets.QFrame(Dialog)
- self.line.setGeometry(QtCore.QRect(480, 570, 800, 3))
- self.line.setFrameShape(QtWidgets.QFrame.HLine)
- self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line.setObjectName("line")
- self.line_2 = QtWidgets.QFrame(Dialog)
- self.line_2.setGeometry(QtCore.QRect(480, 50, 800, 3))
- self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
- self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line_2.setObjectName("line_2")
- self.line_3 = QtWidgets.QFrame(Dialog)
- self.line_3.setGeometry(QtCore.QRect(480, 0, 3, 720))
- self.line_3.setFrameShape(QtWidgets.QFrame.VLine)
- self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
- self.line_3.setObjectName("line_3")
- self.verticalScrollBar = QtWidgets.QScrollBar(Dialog)
- self.verticalScrollBar.setGeometry(QtCore.QRect(460, 50, 16, 671))
- self.verticalScrollBar.setOrientation(QtCore.Qt.Vertical)
- self.verticalScrollBar.setObjectName("verticalScrollBar")
- self.verticalScrollBar_2 = QtWidgets.QScrollBar(Dialog)
- self.verticalScrollBar_2.setGeometry(QtCore.QRect(1260, 50, 16, 520))
- self.verticalScrollBar_2.setStyleSheet("background-color: #f0f0f0;")
- self.verticalScrollBar_2.setOrientation(QtCore.Qt.Vertical)
- self.verticalScrollBar_2.setObjectName("verticalScrollBar_2")
- self.pushButton_2 = QtWidgets.QPushButton(Dialog)
- self.pushButton_2.setGeometry(QtCore.QRect(160, 50, 300, 80))
- self.pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight)
- self.pushButton_2.setAutoFillBackground(False)
- self.pushButton_2.setText("")
- self.pushButton_2.setIconSize(QtCore.QSize(80, 80))
- self.pushButton_2.setObjectName("pushButton_2")
- self.layoutWidget = QtWidgets.QWidget(Dialog)
- self.layoutWidget.setGeometry(QtCore.QRect(150, 200, 318, 81))
- self.layoutWidget.setObjectName("layoutWidget")
- self.gridLayout1 = QtWidgets.QGridLayout(self.layoutWidget)
- self.gridLayout1.setSizeConstraint(QtWidgets.QLayout.SetMaximumSize)
- self.gridLayout1.setContentsMargins(10, 10, 10, 10)
- self.gridLayout1.setSpacing(10)
- self.gridLayout1.setObjectName("gridLayout1")
- self.label_time = QtWidgets.QLabel(self.layoutWidget)
- font = QtGui.QFont()
- font.setPointSize(8)
- self.label_time.setFont(font)
- self.label_time.setLayoutDirection(QtCore.Qt.RightToLeft)
- self.label_time.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
- self.label_time.setObjectName("label_time")
- self.gridLayout1.addWidget(self.label_time, 0, 2, 1, 1)
- self.label_remark = QtWidgets.QLabel(self.layoutWidget)
- font = QtGui.QFont()
- font.setFamily("Adobe 黑体 Std R")
- font.setPointSize(10)
- font.setBold(False)
- font.setWeight(50)
- self.label_remark.setFont(font)
- self.label_remark.setObjectName("label_remark")
- self.gridLayout1.addWidget(self.label_remark, 0, 1, 1, 1)
- self.label_msg = QtWidgets.QLabel(self.layoutWidget)
- font = QtGui.QFont()
- font.setPointSize(8)
- self.label_msg.setFont(font)
- self.label_msg.setObjectName("label_msg")
- self.gridLayout1.addWidget(self.label_msg, 1, 1, 1, 2)
- self.label_avatar = QtWidgets.QLabel(self.layoutWidget)
- self.label_avatar.setMinimumSize(QtCore.QSize(60, 60))
- self.label_avatar.setMaximumSize(QtCore.QSize(60, 60))
- self.label_avatar.setLayoutDirection(QtCore.Qt.RightToLeft)
- self.label_avatar.setAutoFillBackground(False)
- self.label_avatar.setStyleSheet("background-color: #ffffff;")
- self.label_avatar.setInputMethodHints(QtCore.Qt.ImhNone)
- self.label_avatar.setFrameShape(QtWidgets.QFrame.NoFrame)
- self.label_avatar.setFrameShadow(QtWidgets.QFrame.Plain)
- self.label_avatar.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
- self.label_avatar.setObjectName("label_avatar")
- self.gridLayout1.addWidget(self.label_avatar, 0, 0, 2, 1)
- self.gridLayout1.setColumnStretch(0, 1)
- self.gridLayout1.setColumnStretch(1, 6)
- self.gridLayout1.setRowStretch(0, 5)
- self.gridLayout1.setRowStretch(1, 3)
- self.verticalLayoutWidget = QtWidgets.QWidget(Dialog)
- self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 160, 111, 402))
- self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
- self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
- self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
- self.verticalLayout_2.setSpacing(0)
- self.verticalLayout_2.setObjectName("verticalLayout_2")
- self.btn_msg = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_msg.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_msg.setObjectName("btn_msg")
- self.verticalLayout_2.addWidget(self.btn_msg)
- self.btn_contact = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_contact.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_contact.setObjectName("btn_contact")
- self.verticalLayout_2.addWidget(self.btn_contact)
- self.btn_addC = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_addC.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_addC.setObjectName("btn_addC")
- self.verticalLayout_2.addWidget(self.btn_addC)
- self.btn_delC = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.btn_delC.setMinimumSize(QtCore.QSize(0, 80))
- self.btn_delC.setObjectName("btn_delC")
- self.verticalLayout_2.addWidget(self.btn_delC)
- self.pushButton_6 = QtWidgets.QPushButton(self.verticalLayoutWidget)
- self.pushButton_6.setMinimumSize(QtCore.QSize(100, 80))
- self.pushButton_6.setObjectName("pushButton_6")
- self.verticalLayout_2.addWidget(self.pushButton_6)
- self.verticalLayout_2.setStretch(0, 1)
- self.verticalLayout_2.setStretch(2, 1)
- self.verticalLayout_2.setStretch(3, 1)
- self.verticalLayout_2.setStretch(4, 1)
- self.myavatar = QtWidgets.QLabel(Dialog)
- self.myavatar.setGeometry(QtCore.QRect(10, 30, 100, 100))
- self.myavatar.setObjectName("myavatar")
-
- self.retranslateUi(Dialog)
- QtCore.QMetaObject.connectSlotsByName(Dialog)
-
- def retranslateUi(self, Dialog):
- _translate = QtCore.QCoreApplication.translate
- Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
- self.pushButton.setText(_translate("Dialog", "PushButton"))
- self.toolButton.setText(_translate("Dialog", "..."))
- self.sendMsg.setText(_translate("Dialog", "发送"))
- self.label_time.setText(_translate("Dialog", "22/12/17"))
- self.label_remark.setText(_translate("Dialog", "西北工业大学财务处"))
- self.label_msg.setText(_translate("Dialog", "我没去"))
- self.label_avatar.setText(_translate("Dialog", "TextLabel"))
- self.btn_msg.setText(_translate("Dialog", "聊天"))
- self.btn_contact.setText(_translate("Dialog", "联系人"))
- self.btn_addC.setText(_translate("Dialog", "添加联系人"))
- self.btn_delC.setText(_translate("Dialog", "删除联系人"))
- self.pushButton_6.setText(_translate("Dialog", "设置"))
- self.myavatar.setText(_translate("Dialog", "avatar"))
diff --git a/app/Ui/chat/backup/chatUi.ui b/app/Ui/chat/backup/chatUi.ui
deleted file mode 100644
index 227ff01..0000000
--- a/app/Ui/chat/backup/chatUi.ui
+++ /dev/null
@@ -1,422 +0,0 @@
-
-
- Dialog
-
-
-
- 0
- 0
- 1280
- 720
-
-
-
- ArrowCursor
-
-
- Dialog
-
-
- false
-
-
-
-
- 580
- 570
- 93
- 28
-
-
-
- PushButton
-
-
-
-
-
- 480
- 50
- 800
- 520
-
-
-
-
-
-
- 480
- 600
- 800
- 120
-
-
-
-
-
-
- 1240
- 0
- 47
- 51
-
-
-
- ...
-
-
-
-
-
- 1162
- 670
- 121
- 51
-
-
-
-
- 黑体
- 15
- 50
- false
-
-
-
- ArrowCursor
-
-
- false
-
-
- false
-
-
- QPushButton {
- background-color: #f0f0f0;
-
- padding: 10px;
- color:rgb(5,180,104);
-}
-
-
- 发送
-
-
-
- 40
- 40
-
-
-
- false
-
-
- true
-
-
-
-
-
- 480
- 570
- 800
- 3
-
-
-
- Qt::Horizontal
-
-
-
-
-
- 480
- 50
- 800
- 3
-
-
-
- Qt::Horizontal
-
-
-
-
-
- 480
- 0
- 3
- 720
-
-
-
- Qt::Vertical
-
-
-
-
-
- 460
- 50
- 16
- 671
-
-
-
- Qt::Vertical
-
-
-
-
-
- 1260
- 50
- 16
- 520
-
-
-
- background-color: #f0f0f0;
-
-
- Qt::Vertical
-
-
-
-
-
- 160
- 50
- 300
- 80
-
-
-
- Qt::LeftToRight
-
-
- false
-
-
-
-
-
-
- 80
- 80
-
-
-
-
-
-
- 150
- 200
- 318
- 81
-
-
-
-
- QLayout::SetMaximumSize
-
-
- 10
-
-
- 10
-
-
- 10
-
-
- 10
-
-
- 10
-
- -
-
-
-
- 8
-
-
-
- Qt::RightToLeft
-
-
- 22/12/17
-
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
-
-
- -
-
-
-
- Adobe 黑体 Std R
- 10
- 50
- false
-
-
-
- 西北工业大学财务处
-
-
-
- -
-
-
-
- 8
-
-
-
- 我没去
-
-
-
- -
-
-
-
- 60
- 60
-
-
-
-
- 60
- 60
-
-
-
- Qt::RightToLeft
-
-
- false
-
-
- background-color: #ffffff;
-
-
- Qt::ImhNone
-
-
- QFrame::NoFrame
-
-
- QFrame::Plain
-
-
- TextLabel
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
-
-
-
- 0
- 160
- 111
- 402
-
-
-
-
- 0
-
- -
-
-
-
- 0
- 80
-
-
-
- 聊天
-
-
-
- -
-
-
-
- 0
- 80
-
-
-
- 联系人
-
-
-
- -
-
-
-
- 0
- 80
-
-
-
- 添加联系人
-
-
-
- -
-
-
-
- 0
- 80
-
-
-
- 删除联系人
-
-
-
- -
-
-
-
- 100
- 80
-
-
-
- 设置
-
-
-
-
-
-
-
-
- 10
- 30
- 100
- 100
-
-
-
- avatar
-
-
-
-
-
-
diff --git a/app/Ui/chat/chat.py b/app/Ui/chat/chat.py
index 8a6fe93..7312ce8 100644
--- a/app/Ui/chat/chat.py
+++ b/app/Ui/chat/chat.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
"""
-@File : mainview.py
+@File : chat.py
@Author : Shuaikang Zhou
-@Time : 2022/12/13 15:07
+@Time : 2022/12/13 17:07
@IDE : Pycharm
@Version : Python3.10
-@comment : ···
+@comment : 聊天窗口
"""
import datetime
import time
@@ -58,15 +58,6 @@ class ChatController(QWidget, Ui_Dialog):
self.message.setOpenExternalLinks(False)
# self.message.anchorClicked(self.hyperlink())
self.message.anchorClicked.connect(self.hyperlink)
- self.textEdit = myTextEdit(self.frame)
- self.textEdit.setGeometry(QtCore.QRect(9, 580, 821, 141))
- font = QtGui.QFont()
- font.setPointSize(15)
- self.textEdit.setFont(font)
- self.textEdit.setTabStopWidth(80)
- self.textEdit.setCursorWidth(1)
- self.textEdit.setObjectName("textEdit")
- self.textEdit.sendSignal.connect(self.sendMsg)
self.btn_sendMsg = QtWidgets.QPushButton(self.frame)
self.btn_sendMsg.setGeometry(QtCore.QRect(680, 670, 121, 51))
font = QtGui.QFont()
@@ -177,9 +168,6 @@ class ChatController(QWidget, Ui_Dialog):
print(pos)
self.message.verticalScrollBar().setValue(pos)
- def sendMsg(self, msg):
- pass
-
def check_time(self, msg_time):
"""
判断两次聊天时间是否大于五分钟
@@ -338,9 +326,12 @@ class ChatController(QWidget, Ui_Dialog):
''' % (content)
self.left(html)
-
-
def hyperlink(self, url: QUrl):
+ """
+ 超链接,点击之后放大显示图片
+ :param url:
+ :return:
+ """
path = data.clearImagePath(url.path())
print(url.path(), path)
self.imagebox = MainDemo()
@@ -540,7 +531,7 @@ class Contact(QtWidgets.QPushButton):
class ChatMsg(QThread):
"""
- 发送信息线程
+ 多线程显示信息
"""
isSend_signal = pyqtSignal(tuple)
okSignal = pyqtSignal(int)
@@ -571,11 +562,15 @@ class myTextEdit(QtWidgets.QTextEdit): # 继承 原本组件
self.parent = parent
_translate = QtCore.QCoreApplication.translate
self.setHtml(_translate("Dialog",
- "\n"
+ "\n"
"\n"
- "
"))
+ "\n"
+ "