fix trayicon
This commit is contained in:
parent
375e16e0dc
commit
4c9a66f586
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -92,7 +92,9 @@ jobs:
|
||||
Remove-Item -Path "dist" -Recurse -Force
|
||||
Move-Item -Path "nginx/html/nginx.conf" -Destination "nginx/conf/nginx.conf" -Force
|
||||
New-Item -Path "nginx/temp" -ItemType Directory -Force
|
||||
New-Item -Path "nginx/temp/__keep__.txt" -ItemType File -Force
|
||||
New-Item -Path "nginx/logs" -ItemType Directory -Force
|
||||
New-Item -Path "nginx/logs/__keep__.txt" -ItemType File -Force
|
||||
shell: pwsh
|
||||
|
||||
- name: Pyinstaller
|
||||
|
16
app/main.py
16
app/main.py
@ -32,7 +32,6 @@ App.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
|
||||
# uvicorn服务
|
||||
Server = uvicorn.Server(Config(App, host=settings.HOST, port=settings.PORT,
|
||||
reload=settings.DEV, workers=multiprocessing.cpu_count()))
|
||||
@ -120,6 +119,14 @@ def start_module():
|
||||
start_frontend()
|
||||
|
||||
|
||||
def start_tray():
|
||||
"""
|
||||
启动托盘图标
|
||||
"""
|
||||
|
||||
if not SystemUtils.is_frozen():
|
||||
return
|
||||
|
||||
def open_web():
|
||||
"""
|
||||
调用浏览器打开前端页面
|
||||
@ -127,7 +134,6 @@ def open_web():
|
||||
import webbrowser
|
||||
webbrowser.open(f"http://localhost:{settings.NGINX_PORT}")
|
||||
|
||||
|
||||
def quit_app():
|
||||
"""
|
||||
退出程序
|
||||
@ -135,7 +141,6 @@ def quit_app():
|
||||
TrayIcon.stop()
|
||||
Server.should_exit = True
|
||||
|
||||
|
||||
# 托盘图标
|
||||
TrayIcon = pystray.Icon(
|
||||
settings.PROJECT_NAME,
|
||||
@ -151,6 +156,9 @@ TrayIcon = pystray.Icon(
|
||||
)
|
||||
)
|
||||
)
|
||||
# 启动托盘图标
|
||||
threading.Thread(target=TrayIcon.run, daemon=True).start()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 初始化数据库
|
||||
@ -158,6 +166,6 @@ if __name__ == '__main__':
|
||||
# 更新数据库
|
||||
update_db()
|
||||
# 启动托盘
|
||||
threading.Thread(target=TrayIcon.run, daemon=True).start()
|
||||
start_tray()
|
||||
# 启动API服务
|
||||
Server.run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user