mirror of
https://github.com/EasyTier/astral.git
synced 2025-05-19 10:30:24 +00:00
更换为官方服务器,提升稳定性。 移除模拟延迟 改为直接检测连接,优化体验。 修复延迟计算 从 peer 获取最小延迟(μs→ms),无效时用路由延迟。 修复管理员权限 解决管理员操作无权限问题。 配置存储位置调整 将配置信息改为运行目录,方便管理。 查看 NAT 类型 添加功能检测并显示 NAT 类型。 修复页面状态丢失 解决缩放导致导航栏移动时页面状态丢失问题。 优化延迟检测 始终检测延迟,移除暂停/开始功能,简化逻辑。 最小化通知 应用最小化时提供通知,提醒用户状态。 增加客户端搜索功能 添加客户端搜索功能,支持快速查找内容或设备。
59 lines
1.9 KiB
Dart
59 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:window_manager/window_manager.dart';
|
|
import '../config/app_config.dart';
|
|
import 'package:windows_notification/notification_message.dart';
|
|
import 'package:windows_notification/windows_notification.dart';
|
|
|
|
// Create an instance of Windows Notification with your application name
|
|
// application id must be null in packaged mode
|
|
final _winNotifyPlugin = WindowsNotification(applicationId: 'Astral');
|
|
// create new NotificationMessage instance with id, title, body, and images
|
|
NotificationMessage message = NotificationMessage.fromPluginTemplate(
|
|
"astral_minimized",
|
|
"Astral 已最小化到托盘",
|
|
"应用程序正在后台运行,点击托盘图标可以恢复窗口",
|
|
// largeImage: "assets/images/icon.ico",
|
|
// image: file_path
|
|
);
|
|
|
|
class WindowControls extends StatelessWidget {
|
|
const WindowControls({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.remove),
|
|
onPressed: () => windowManager.minimize(),
|
|
tooltip: '最小化',
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.crop_square),
|
|
onPressed: () async {
|
|
if (await windowManager.isMaximized()) {
|
|
windowManager.unmaximize();
|
|
} else {
|
|
windowManager.maximize();
|
|
}
|
|
},
|
|
tooltip: '最大化/还原',
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.close),
|
|
onPressed: () async {
|
|
if (AppConfig().closeToTray) {
|
|
await windowManager.hide(); // 隐藏主窗口
|
|
// 替换托盘提示为系统通知
|
|
_winNotifyPlugin.showNotificationPluginTemplate(message);
|
|
} else {
|
|
windowManager.close();
|
|
}
|
|
},
|
|
tooltip: '关闭',
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|