feat(client): 开机自启拉起直接最小化到托盘(--autostart 标志)(1.0.28)
计划任务 /tr 命令带 --autostart;main() 检测到该参数在首帧前 windowManager.hide() 隐藏主窗口到托盘,自动连接逻辑照常跑。手动打开(无参数)仍正常显示窗口。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -25,8 +25,10 @@ import 'widgets/onboarding_screen.dart';
|
||||
import 'widgets/pangolin_logo.dart';
|
||||
import 'widgets/pangolin_toast.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
Future<void> main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
// 开机自启拉起(计划任务 /tr 带 --autostart)→ 直接最小化到托盘,不弹主窗口。
|
||||
final bootAutostart = args.contains('--autostart');
|
||||
// 桌面端:单实例 + 常驻系统托盘(关闭窗口隐藏到托盘而非退出)。
|
||||
if (isDesktop) {
|
||||
if (!await ensureSingleInstance()) {
|
||||
@@ -40,6 +42,11 @@ Future<void> main() async {
|
||||
await windowManager.center();
|
||||
// 窗口标题用中文品牌名(不带 "VPN" 字眼);英文环境下原生标题为 "Pangolin"。
|
||||
await windowManager.setTitle('穿山甲');
|
||||
// 自启:首帧前就隐藏窗口(避免闪现),托盘已就绪可随时唤回;自动连接逻辑照常跑。
|
||||
if (bootAutostart) {
|
||||
await windowManager.hide();
|
||||
logLine('AutoStart', 'launched by --autostart; hiding to tray');
|
||||
}
|
||||
}
|
||||
runApp(const ProviderScope(child: PangolinApp()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user