Phase 4 剩余三项: - 首次引导向导(setup/first_run + ui/setup_wizard):服务自检(含 C# 助手共存 提示)→ 打印机检测与 HiTi 驱动安装指引(官网链接/重新检测,mac 与 win 文案 分支,允许无打印机完成)→ 开机自启开关 + scheme 注册;侧栏底部常驻设置区 (自启开关 + 重新运行引导) - 开机自启(setup/autostart):mac 写 LaunchAgent(RunAtLoad 一次性,不用 KeepAlive——托盘退出不能被拉回);Windows 走 HKCU Run(reg 命令免 win32 依赖) - URL scheme 闭环:单实例唤醒端口 38210(setup/single_instance)——zaxprint:// 唤起或重复双击启动第二进程时通知常驻实例弹窗后自退,跨平台一致(弃用 app_links 的 mac 事件转发不确定性);Windows 启动时幂等注册 HKCU scheme; 前端 cardPrinter.ts 加 launchAgent()(zaxprint://open),开卡抽屉离线时显示 "启动打印助手"按钮,点击唤起后 1s×6 轮询自动上线(biz 前端改动待用户提交) Phase 5: - tool/package_macos.sh:构建 → ad-hoc 就地签名(--deep,勿加 --options=runtime: hardened runtime 库校验会因 ad-hoc 无 Team ID 拒载 framework,实测踩坑)→ hdiutil dmg;实测产出 22MB dmg + 签名后冒烟通过 - windows/installer.iss:Inno Setup 安装包脚本(快捷方式/桌面图标/开机自启 Tasks/zaxprint scheme 注册与卸载清理/HiTi SDK DLL 随 Release 目录打包) 依赖 +url_launcher +shared_preferences;13 测试全过、analyze 零问题。
92 lines
3.1 KiB
Dart
92 lines
3.1 KiB
Dart
import 'dart:io';
|
||
|
||
import 'package:flutter/material.dart';
|
||
import 'package:window_manager/window_manager.dart';
|
||
|
||
import 'agent.dart';
|
||
import 'setup/single_instance.dart';
|
||
import 'setup/url_scheme.dart';
|
||
import 'ui/app_shell.dart';
|
||
import 'ui/app_tray.dart';
|
||
|
||
/// 资安信插件助手(desktop-plugin):桌面插件集成软件。
|
||
/// 当前内置插件:饭卡打印机(card-printer);左侧菜单与插件页均由 lib/ui/routes.dart 驱动。
|
||
/// 关闭窗口 = 最小化到后台托盘,服务持续运行;退出入口在托盘菜单。
|
||
Future<void> main(List<String> args) async {
|
||
WidgetsFlutterBinding.ensureInitialized();
|
||
await windowManager.ensureInitialized();
|
||
|
||
// 单实例:zaxprint:// 唤起或重复双击会启动第二进程——通知常驻实例弹窗后自己退出
|
||
final isPrimary = await SingleInstance.acquire(
|
||
onWake: () async {
|
||
await windowManager.show();
|
||
await windowManager.focus();
|
||
},
|
||
);
|
||
if (!isPrimary) {
|
||
exit(0);
|
||
}
|
||
|
||
final agent = Agent(AgentOptions.parse(args));
|
||
String? startError;
|
||
try {
|
||
await agent.start();
|
||
} catch (e) {
|
||
startError = '$e';
|
||
}
|
||
|
||
await UrlScheme.ensureRegistered(); // Windows 运行时注册 zaxprint://;mac 由 Info.plist 声明
|
||
|
||
final appTray = AppTray(agent: agent);
|
||
await appTray.start();
|
||
|
||
runApp(DesktopPluginApp(agent: agent, startError: startError));
|
||
}
|
||
|
||
class DesktopPluginApp extends StatelessWidget {
|
||
const DesktopPluginApp({super.key, required this.agent, this.startError});
|
||
|
||
final Agent agent;
|
||
final String? startError;
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return MaterialApp(
|
||
title: '资安信插件助手',
|
||
debugShowCheckedModeBanner: false,
|
||
theme: _darkTheme(),
|
||
home: AppShell(agent: agent, startError: startError),
|
||
);
|
||
}
|
||
|
||
/// 深色运维风格(ui-ux-pro-max 设计系统:OLED 深底 + 运维三色语义)。
|
||
ThemeData _darkTheme() {
|
||
final base = ThemeData(brightness: Brightness.dark, useMaterial3: true);
|
||
final scheme = base.colorScheme.copyWith(
|
||
// 正常/主操作:operational green
|
||
primary: const Color(0xFF4ADE80),
|
||
onPrimary: const Color(0xFF052E16),
|
||
primaryContainer: const Color(0xFF14532D),
|
||
onPrimaryContainer: const Color(0xFFDCFCE7),
|
||
// 故障红
|
||
error: const Color(0xFFF87171),
|
||
errorContainer: const Color(0xFF7F1D1D),
|
||
onErrorContainer: const Color(0xFFFEE2E2),
|
||
// 表面层级:#0F172A 底 / #111827 卡 / #1E293B 强调
|
||
surface: const Color(0xFF0F172A),
|
||
onSurface: const Color(0xFFF8FAFC),
|
||
onSurfaceVariant: const Color(0xFFCBD5E1),
|
||
surfaceContainerLow: const Color(0xFF111827),
|
||
surfaceContainerHighest: const Color(0xFF1E293B),
|
||
outlineVariant: const Color(0xFF334155),
|
||
);
|
||
return base.copyWith(
|
||
colorScheme: scheme,
|
||
scaffoldBackgroundColor: const Color(0xFF0F172A),
|
||
cardTheme: const CardTheme(color: Color(0xFF111827)),
|
||
snackBarTheme: const SnackBarThemeData(behavior: SnackBarBehavior.floating),
|
||
dividerTheme: const DividerThemeData(color: Color(0xFF334155), thickness: 1),
|
||
);
|
||
}
|
||
}
|