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()));
|
||||
}
|
||||
|
||||
@@ -130,12 +130,13 @@ class SettingsController extends StateNotifier<AppSettings> {
|
||||
|
||||
// 用 schtasks 建/删最高权限登录触发任务。app 已是管理员 → 可建 /rl highest 任务,
|
||||
// 开机由计划程序静默提权拉起、不弹 UAC。/tr 含空格路径须内嵌引号。
|
||||
// 带 --autostart 标志:让开机拉起的实例直接最小化到托盘(不弹主窗口),见 main.dart。
|
||||
Future<void> _applyWindowsAutostart(bool v) async {
|
||||
if (v) {
|
||||
final exe = Platform.resolvedExecutable;
|
||||
await Process.run('schtasks', [
|
||||
'/create', '/tn', _kWinTaskName,
|
||||
'/tr', '"$exe"',
|
||||
'/tr', '"$exe" --autostart',
|
||||
'/sc', 'onlogon',
|
||||
'/rl', 'highest',
|
||||
'/f',
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: pangolin_vpn
|
||||
description: 穿山甲 · Pangolin — 极简、稳定、跨平台网络加速客户端。
|
||||
publish_to: "none"
|
||||
version: 1.0.27+28
|
||||
version: 1.0.28+29
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
; 前置: 先在 client/ 跑 `flutter build windows`(Release),产物在
|
||||
; ..\..\build\windows\x64\runner\Release
|
||||
#define MyAppName "穿山甲 Pangolin"
|
||||
#define MyAppVersion "1.0.27"
|
||||
#define MyAppVersion "1.0.28"
|
||||
#define MyAppPublisher "Pangolin"
|
||||
#define MyAppExeName "pangolin_vpn.exe"
|
||||
#define BuildDir "..\..\build\windows\x64\runner\Release"
|
||||
|
||||
Reference in New Issue
Block a user