优化启动过程

This commit is contained in:
shuaikangzhou 2023-11-22 21:12:14 +08:00
parent af652a5adf
commit 4bd0e1aac5
6 changed files with 70 additions and 53 deletions

View File

@ -4,8 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="修复HTML卡顿的问题"> <list default="true" id="84e65474-7da9-466d-baf3-cc88dde3ffdd" name="变更" comment="update readme">
<change beforePath="$PROJECT_DIR$/readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/readme.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/decrypt/dat2pic.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/decrypt/dat2pic.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/chat/chat_info.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/ui_pc/mainview.py" beforeDir="false" afterPath="$PROJECT_DIR$/app/ui_pc/mainview.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main_pc.py" beforeDir="false" afterPath="$PROJECT_DIR$/main_pc.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -276,13 +280,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1672848140146</updated> <updated>1672848140146</updated>
</task> </task>
<task id="LOCAL-00040" summary="增加中文路径提示">
<created>1699025065814</created>
<option name="number" value="00040" />
<option name="presentableId" value="LOCAL-00040" />
<option name="project" value="LOCAL" />
<updated>1699025065814</updated>
</task>
<task id="LOCAL-00041" summary="update readme"> <task id="LOCAL-00041" summary="update readme">
<created>1699026207401</created> <created>1699026207401</created>
<option name="number" value="00041" /> <option name="number" value="00041" />
@ -619,7 +616,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1700583772986</updated> <updated>1700583772986</updated>
</task> </task>
<option name="localTasksCounter" value="89" /> <task id="LOCAL-00089" summary="update readme">
<created>1700583952342</created>
<option name="number" value="00089" />
<option name="presentableId" value="LOCAL-00089" />
<option name="project" value="LOCAL" />
<updated>1700583952342</updated>
</task>
<option name="localTasksCounter" value="90" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -669,7 +673,6 @@
<MESSAGE value="聊天记录从后往前显示" /> <MESSAGE value="聊天记录从后往前显示" />
<MESSAGE value="聊天消息自适应" /> <MESSAGE value="聊天消息自适应" />
<MESSAGE value="新版本更新" /> <MESSAGE value="新版本更新" />
<MESSAGE value="update readme" />
<MESSAGE value="修复时间插入位置" /> <MESSAGE value="修复时间插入位置" />
<MESSAGE value="修复第一次启动的显示问题" /> <MESSAGE value="修复第一次启动的显示问题" />
<MESSAGE value="支持查找功能" /> <MESSAGE value="支持查找功能" />
@ -680,7 +683,8 @@
<MESSAGE value="支持显示聊天图片" /> <MESSAGE value="支持显示聊天图片" />
<MESSAGE value="支持导出HTML" /> <MESSAGE value="支持导出HTML" />
<MESSAGE value="修复HTML卡顿的问题" /> <MESSAGE value="修复HTML卡顿的问题" />
<option name="LAST_COMMIT_MESSAGE" value="修复HTML卡顿的问题" /> <MESSAGE value="update readme" />
<option name="LAST_COMMIT_MESSAGE" value="update readme" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" /> <option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component> </component>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -57,6 +57,8 @@ def decode_dat(file_path, out_path):
else: else:
pic_name = file_path[:-4] + ".jpg" pic_name = file_path[:-4] + ".jpg"
file_outpath = os.path.join(out_path, pic_name) file_outpath = os.path.join(out_path, pic_name)
if os.path.exists(file_outpath):
return file_outpath
with open(file_path, 'rb') as file_in: with open(file_path, 'rb') as file_in:
data = file_in.read() data = file_in.read()
# 对数据进行异或加密/解密 # 对数据进行异或加密/解密

View File

@ -74,7 +74,6 @@ class ChatInfo(QWidget):
def is_5_min(self, timestamp): def is_5_min(self, timestamp):
if abs(timestamp - self.last_timestamp) > 300: if abs(timestamp - self.last_timestamp) > 300:
self.last_timestamp = timestamp self.last_timestamp = timestamp
return True return True
return False return False

View File

@ -63,7 +63,8 @@ HistoryPanel::item:hover {
class MainWinController(QMainWindow, mainwindow.Ui_MainWindow): class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
exitSignal = pyqtSignal() exitSignal = pyqtSignal(bool)
okSignal = pyqtSignal(bool)
# username = '' # username = ''
def __init__(self, username, parent=None): def __init__(self, username, parent=None):
@ -75,8 +76,10 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.resize(QSize(800, 600)) self.resize(QSize(800, 600))
self.action_desc.triggered.connect(self.about) self.action_desc.triggered.connect(self.about)
self.load_data() self.load_data()
self.init_ui()
self.load_num = 0 self.load_num = 0
self.label = QLabel(self)
self.label.setGeometry((self.width() - 300) // 2, (self.height() - 100) // 2, 300, 100)
self.label.setPixmap(QPixmap('./app/data/icons/loading.svg'))
def load_data(self): def load_data(self):
if os.path.exists('./app/data/info.json'): if os.path.exists('./app/data/info.json'):
@ -98,12 +101,8 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
) )
def init_ui(self): def init_ui(self):
# self.movie = QMovie("./app/data/loading.gif") self.listWidget.setVisible(False)
self.label = QLabel(self) self.stackedWidget.setVisible(False)
self.label.setGeometry(0, 0, self.width(), self.height())
self.label.setVisible(False)
# self.label.setMovie(self.movie)
# self.movie.start()
self.listWidget.currentRowChanged.connect(self.setCurrentIndex) self.listWidget.currentRowChanged.connect(self.setCurrentIndex)
tool_item = QListWidgetItem(Icon.MyInfo_Icon, '工具', self.listWidget) tool_item = QListWidgetItem(Icon.MyInfo_Icon, '工具', self.listWidget)
chat_item = QListWidgetItem(Icon.Chat_Icon, '聊天', self.listWidget) chat_item = QListWidgetItem(Icon.Chat_Icon, '聊天', self.listWidget)
@ -116,11 +115,11 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
self.stackedWidget.addWidget(tool_window) self.stackedWidget.addWidget(tool_window)
self.listWidget.setCurrentRow(0) self.listWidget.setCurrentRow(0)
self.stackedWidget.setCurrentIndex(0) self.stackedWidget.setCurrentIndex(0)
chat_window = ChatWindow() self.chat_window = ChatWindow()
# chat_window = QWidget() # chat_window = QWidget()
self.stackedWidget.addWidget(chat_window) self.stackedWidget.addWidget(self.chat_window)
contact_window = ContactWindow() self.contact_window = ContactWindow()
self.stackedWidget.addWidget(contact_window) self.stackedWidget.addWidget(self.contact_window)
label = QLabel('我是页面') label = QLabel('我是页面')
label.setAlignment(Qt.AlignCenter) label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机) # 设置label的背景颜色(这里随机)
@ -129,11 +128,11 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
randint(0, 255), randint(0, 255), randint(0, 255))) randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label) self.stackedWidget.addWidget(label)
tool_window.load_finish_signal.connect(self.loading) tool_window.load_finish_signal.connect(self.loading)
contact_window.load_finish_signal.connect(self.loading) self.contact_window.load_finish_signal.connect(self.loading)
# chat_window.load_finish_signal.connect(self.loading) self.chat_window.load_finish_signal.connect(self.loading)
# self.load_window_thread = LoadWindowThread(self.stackedWidget) # self.load_thread = LoadWindowThread()
# self.load_window_thread.okSignal.connect(self.stop_loading) # self.load_thread.okSignal.connect(self.load_window)
# self.load_window_thread.start() # self.load_thread.start()
def setCurrentIndex(self, row): def setCurrentIndex(self, row):
self.stackedWidget.setCurrentIndex(row) self.stackedWidget.setCurrentIndex(row)
@ -170,11 +169,15 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
def loading(self, a0): def loading(self, a0):
self.load_num += 1 self.load_num += 1
self.label.setVisible(False) # self.label.setVisible(False)
# print('加载一个了') print('加载一个了')
if self.load_num == 2: if self.load_num == 2:
# print('ok了') print('ok了')
self.label.setVisible(False) self.label.clear()
self.label.hide()
self.okSignal.emit(True)
self.listWidget.setVisible(True)
self.stackedWidget.setVisible(True)
def about(self): def about(self):
""" """
@ -198,20 +201,20 @@ class LoadWindowThread(QThread):
windowSignal = pyqtSignal(QWidget) windowSignal = pyqtSignal(QWidget)
okSignal = pyqtSignal(bool) okSignal = pyqtSignal(bool)
def __init__(self, stackedWidget): def __init__(self):
super().__init__() super().__init__()
self.stackedWidget = stackedWidget self.num = 0
def loading(self):
self.num += 1
print('加载一个了')
if self.num == 2:
self.okSignal.emit(True)
def run(self): def run(self):
chat_window = ChatWindow() self.chat_window = ChatWindow()
self.stackedWidget.addWidget(chat_window) self.contact_window = ContactWindow()
contact_window = ContactWindow() self.contact_window.load_finish_signal.connect(self.loading)
self.stackedWidget.addWidget(contact_window) self.chat_window.load_finish_signal.connect(self.loading)
label = QLabel('我是页面') print('加载完成')
label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机)
# 这里加了一个margin边距(方便区分QStackedWidget和QLabel的颜色)
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label)
self.okSignal.emit(True) self.okSignal.emit(True)

View File

@ -2,7 +2,7 @@ import ctypes
import sys import sys
import time import time
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon, QMovie
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from app.ui_pc import mainview from app.ui_pc import mainview
@ -16,8 +16,13 @@ class ViewController(QWidget):
super().__init__() super().__init__()
self.setWindowTitle('解密') self.setWindowTitle('解密')
self.setWindowIcon(QIcon('./app/data/icons/logo.svg')) self.setWindowIcon(QIcon('./app/data/icons/logo.svg'))
self.viewMainWIn = None self.viewMainWIndow = None
self.viewDecrypt = None self.viewDecrypt = None
# 创建加载动画
loading_label = QLabel()
movie = QMovie("./app/data/loading.gif") # 替换为你的加载动画文件路径
loading_label.setMovie(movie)
movie.start()
def loadPCDecryptView(self): def loadPCDecryptView(self):
""" """
@ -36,14 +41,16 @@ class ViewController(QWidget):
""" """
username = '' username = ''
start = time.time() start = time.time()
self.viewMainWIn = mainview.MainWinController(username=username) self.viewMainWIndow = mainview.MainWinController(username=username)
self.viewMainWIn.setWindowTitle("Chat") self.viewMainWIndow.setWindowTitle("Chat")
# print(username) # print(username)
self.viewMainWIn.username = username self.viewMainWIndow.username = username
# self.viewMainWIn.exitSignal.connect(self.loadDecryptView) # 不需要回到登录界面可以省略 # self.viewMainWIn.exitSignal.connect(self.loadDecryptView) # 不需要回到登录界面可以省略
self.viewMainWIn.show()
self.viewMainWIndow.show()
end = time.time() end = time.time()
print('ok', end - start) print('ok', end - start)
self.viewMainWIndow.init_ui()
def show_success(self): def show_success(self):
QMessageBox.about(self, "解密成功", "数据库文件存储在\napp/DataBase/Msg\n文件夹下") QMessageBox.about(self, "解密成功", "数据库文件存储在\napp/DataBase/Msg\n文件夹下")
@ -54,5 +61,6 @@ if __name__ == '__main__':
view = ViewController() view = ViewController()
# view.loadPCDecryptView() # view.loadPCDecryptView()
view.loadMainWinView() view.loadMainWinView()
# view.show()
# view.show_success() # view.show_success()
sys.exit(app.exec_()) sys.exit(app.exec_())