feat(添加favicon)
@ -1,6 +1,23 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from PyInstaller.utils.hooks import collect_data_files
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
# 获取spec文件所在目录(项目根目录)
|
||||||
|
spec_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||||
|
|
||||||
|
# 定义需要打包的资源文件
|
||||||
|
resource_files = [
|
||||||
|
# 将resource文件夹下的所有文件打包到程序内的resource目录
|
||||||
|
(os.path.join(spec_dir, 'resource'), 'resource')
|
||||||
|
]
|
||||||
|
|
||||||
|
# 收集PyQt相关的数据文件
|
||||||
|
qt_data = collect_data_files('PyQt5')
|
||||||
|
|
||||||
|
# 合并所有资源文件
|
||||||
|
all_resources = resource_files + qt_data
|
||||||
|
|
||||||
# 定义所有需要打包的文件和依赖
|
# 定义所有需要打包的文件和依赖
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
@ -43,5 +60,7 @@ exe = EXE(
|
|||||||
target_arch=None,
|
target_arch=None,
|
||||||
codesign_identity=None,
|
codesign_identity=None,
|
||||||
entitlements_file=None,
|
entitlements_file=None,
|
||||||
|
# 指定程序图标(使用resources文件夹中的ico文件)
|
||||||
|
icon=os.path.join(spec_dir, 'resource','favicon.ico'),
|
||||||
)
|
)
|
||||||
|
|
||||||
BIN
resource/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
resource/favicon/android-chrome-192x192.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
resource/favicon/android-chrome-512x512.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
resource/favicon/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
resource/favicon/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 451 B |
BIN
resource/favicon/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 965 B |
BIN
resource/favicon/favicon-48x48.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
19
resource/favicon/site.webmanifest
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"short_name": "",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-192x192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/android-chrome-512x512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#ffffff",
|
||||||
|
"background_color": "#ffffff",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
17
src/main.py
@ -1,13 +1,30 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import service
|
import service
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
from PyQt5.QtGui import QIcon
|
||||||
from main_window import MainWindow # 导入重构后的主窗口类
|
from main_window import MainWindow # 导入重构后的主窗口类
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Windows系统特定设置,确保任务栏图标正确显示
|
||||||
|
try:
|
||||||
|
from ctypes import windll
|
||||||
|
myappid = 'marcin.ZiJin.onekeydiag.1.0' # 自定义唯一ID
|
||||||
|
windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
||||||
|
except ImportError:
|
||||||
|
pass # 非Windows系统忽略
|
||||||
|
|
||||||
# 初始化服务缓存
|
# 初始化服务缓存
|
||||||
service.app_cache_init()
|
service.app_cache_init()
|
||||||
# 创建PyQt应用实例
|
# 创建PyQt应用实例
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
# 获取文件系统中存放的icon
|
||||||
|
icon_path = service.get_icon_path()
|
||||||
|
if os.path.exists(icon_path):
|
||||||
|
app.setWindowIcon(QIcon(icon_path))
|
||||||
|
else:
|
||||||
|
print("not found favicon")
|
||||||
|
|
||||||
# 初始化并显示主窗口
|
# 初始化并显示主窗口
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
window.show()
|
window.show()
|
||||||
|
|||||||
@ -43,7 +43,17 @@ def app_cache_init():
|
|||||||
utils.clean_log_data(cache_dir)
|
utils.clean_log_data(cache_dir)
|
||||||
|
|
||||||
os.mkdir(cache_dir)
|
os.mkdir(cache_dir)
|
||||||
pass
|
|
||||||
|
def get_icon_path():
|
||||||
|
"""获取资源文件的绝对路径"""
|
||||||
|
try:
|
||||||
|
# 打包后的环境
|
||||||
|
base_path = sys._MEIPASS
|
||||||
|
except AttributeError:
|
||||||
|
# 开发环境:
|
||||||
|
base_path = utils.get_project_root()
|
||||||
|
resource_dir = os.path.join(base_path, "resource")
|
||||||
|
return os.path.join(resource_dir, "favicon.ico")
|
||||||
|
|
||||||
def send_log_to_cache(filepath):
|
def send_log_to_cache(filepath):
|
||||||
project_root = utils.get_project_root()
|
project_root = utils.get_project_root()
|
||||||
|
|||||||
@ -5,7 +5,8 @@ from PyQt5.QtWidgets import (QApplication, QWidget, QGraphicsView, QGraphicsScen
|
|||||||
QGraphicsTextItem, QToolTip, QVBoxLayout,
|
QGraphicsTextItem, QToolTip, QVBoxLayout,
|
||||||
QTabWidget, QLabel)
|
QTabWidget, QLabel)
|
||||||
from PyQt5.QtCore import Qt, QEvent, QTimer, QPoint
|
from PyQt5.QtCore import Qt, QEvent, QTimer, QPoint
|
||||||
from PyQt5.QtGui import QPen, QBrush, QColor, QFont, QPainter
|
from PyQt5.QtGui import QPen, QBrush, QColor, QFont, QPainter, QIcon
|
||||||
|
import service
|
||||||
|
|
||||||
class TimelineEvent:
|
class TimelineEvent:
|
||||||
"""事件数据封装类"""
|
"""事件数据封装类"""
|
||||||
@ -312,6 +313,10 @@ class TimelineTabContent(QWidget):
|
|||||||
self.init_ui()
|
self.init_ui()
|
||||||
|
|
||||||
def init_ui(self):
|
def init_ui(self):
|
||||||
|
# 设置窗口图标
|
||||||
|
icon_path = service.get_icon_path()
|
||||||
|
self.setWindowIcon(QIcon(icon_path))
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
|
|
||||||
title_label = QLabel("事件时间线")
|
title_label = QLabel("事件时间线")
|
||||||
|
|||||||