File tree Expand file tree Collapse file tree 3 files changed +48
-7
lines changed Expand file tree Collapse file tree 3 files changed +48
-7
lines changed Original file line number Diff line number Diff line change 3434
3535## 💻 快速安装
3636
37- [ 下载链接 ] ( https://github.com/mikumifa/biliTickerBuy/releases )
37+ 从github上 [ 下载 ] ( https://github.com/mikumifa/biliTickerBuy/releases )
3838
39- 如果您是MacOS M系列芯片/Linux用户 ,请前往[ 指南] ( https://github.com/mikumifa/biliTickerBuy/wiki/linux%E5%92%8CMacOS%E7%9A%84% E8%BF%90%E8%A1%8C%E6%96%B9%E5%BC%8F-(%E4%BD%BF%E7%94%A8Docker) )
39+ 如果没有您使用系统的已构建版本 ,请前往[ 指南] ( https://github.com/mikumifa/biliTickerBuy/wiki/Docker% E8%BF%90%E8%A1%8C%E6%96%B9%E6%B3%95 )
4040
4141## 👀 使用说明书
4242前往飞书: https://n1x87b5cqay.feishu.cn/wiki/Eg4xwt3Dbiah02k1WqOcVk2YnMd
Original file line number Diff line number Diff line change 1+ import os
2+ import loguru
3+ import gradio as gr
4+ import threading
15from argparse import Namespace
26
7+ def exit_app_ui ():
8+ loguru .logger .info ("程序退出" )
9+ threading .Timer (2.0 , lambda : os ._exit (0 )).start ()
10+ gr .Info ("⚠️ 程序将在弹出Error提示后退出 ⚠️" )
11+ return
312
413def ticker_cmd (args : Namespace ):
5- import gradio as gr
614 from tab .go import go_tab
715 from tab .problems import problems_tab
816 from tab .settings import setting_tab
@@ -12,6 +20,7 @@ def ticker_cmd(args: Namespace):
1220 from util import LOG_DIR
1321
1422 loguru_config (LOG_DIR , "app.log" , enable_console = True , file_colorize = False )
23+
1524 header = """
1625 # B 站会员购抢票🌈
1726
@@ -23,6 +32,11 @@ def ticker_cmd(args: Namespace):
2332 head = """<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>""" ,
2433 ) as demo :
2534 gr .Markdown (header )
35+ gr .Button ("退出应用" ).click (
36+ fn = exit_app_ui ,
37+ inputs = [],
38+ outputs = [],
39+ )
2640 with gr .Tab ("生成配置" ):
2741 setting_tab ()
2842 with gr .Tab ("操作抢票" ):
@@ -31,11 +45,10 @@ def ticker_cmd(args: Namespace):
3145 problems_tab ()
3246 with gr .Tab ("日志查看" ):
3347 log_tab ()
34- # 运行应用
3548
3649 demo .launch (
3750 share = args .share ,
3851 inbrowser = True ,
39- server_name = args .server_name , # 必须监听所有 IP
40- server_port = args .port , # 使用 Cloud Run 提供的端口
52+ server_name = args .server_name ,
53+ server_port = args .port ,
4154 )
Original file line number Diff line number Diff line change 11# -*- mode: python ; coding: utf-8 -*-
2+
3+ import os
4+ import sys
25from PyInstaller .utils .hooks import collect_data_files
36
47datas = []
@@ -7,6 +10,20 @@ datas += collect_data_files("gradio")
710datas += collect_data_files ("gradio_calendar" )
811datas += collect_data_files ("gradio_log" )
912
13+ # 自动选择图标
14+ if sys .platform == "darwin" :
15+ icon_file = os .path .abspath ("assets/icon.icns" )
16+ is_windowed = True # 不会跳出命令行,直接进入webui,需要确保运行稳定
17+ is_console = False # 一般命令行应用
18+ elif sys .platform == "win32" :
19+ icon_file = os .path .abspath ("assets/icon.ico" )
20+ is_windowed = False # 需要在windows环境下测试以决定怎样启用
21+ is_console = True # 一般命令行应用
22+ else :
23+ icon_file = None #Linux/*BSD等其他系统默认设置为标准命令行程序
24+ is_windowed = False
25+ is_console = True
26+
1027a = Analysis (
1128 ["main.py" ],
1229 pathex = [],
@@ -44,5 +61,16 @@ exe = EXE(
4461 target_arch = None ,
4562 codesign_identity = None ,
4663 entitlements_file = None ,
47- icon = [ "assets/icon.ico" ] ,
64+ icon = icon_file if icon_file else None ,
4865)
66+
67+ # macOS构建`.app`应用
68+ # 运行后会构建两个应用,一个是不会跳出命令行的带icon的程序,另一个则是命令行应用,没有icon
69+ app = None
70+ if sys .platform == "darwin" :
71+ app = BUNDLE (
72+ exe ,
73+ name = "biliTickerBuy.app" ,
74+ icon = icon_file ,
75+ bundle_identifier = "com.mikumifa.bilitickerbuy" , # 标识符瞎编的,用的github地址,可以随便改
76+ )
You can’t perform that action at this time.
0 commit comments