feat(client): 系统托盘常驻 + 关闭窗口隐藏到托盘(桌面端)
ci-pangolin / Lint — shellcheck (push) Has been cancelled
ci-pangolin / OpenAPI Sync Check (push) Has been cancelled
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Has been cancelled
ci-pangolin / Flutter — analyze + test (push) Has been cancelled

- system_tray.dart:TrayService 用 tray_manager + window_manager。setPreventClose
  拦截关闭 → 隐藏到托盘(常驻保持隧道);托盘图标点击/「显示主界面」重新显示,
  「退出」真正退出。
- main() 改 async:桌面端 runApp 前 init 托盘;移动端/web 跳过(isDesktop 守卫)。
- 托盘图标复用 app_icon_32.png → assets/tray_icon.png。
- 新依赖:tray_manager / window_manager。

flutter analyze 0 error;114 tests passed。托盘为运行时/原生功能,需 release .app 验证。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-19 06:31:40 +08:00
parent aee9ba7b72
commit e10f214dee
4 changed files with 78 additions and 1 deletions
+9 -1
View File
@@ -8,11 +8,19 @@ import 'services/token_store.dart';
import 'shell/home_shell.dart';
import 'state/app_providers.dart';
import 'state/auth_provider.dart';
import 'system_tray.dart';
import 'widgets/auth_screen.dart';
import 'widgets/onboarding_screen.dart';
import 'widgets/pangolin_logo.dart';
void main() => runApp(const ProviderScope(child: PangolinApp()));
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// 桌面端:常驻系统托盘,关闭窗口隐藏到托盘而非退出。
if (isDesktop) {
await TrayService.instance.init();
}
runApp(const ProviderScope(child: PangolinApp()));
}
class PangolinApp extends ConsumerWidget {
const PangolinApp({super.key});