mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-14 20:16:28 +00:00
feat: add flutter tray and hide logic of main window
This commit is contained in:
@@ -4,11 +4,14 @@ import 'package:tray_manager/tray_manager.dart';
|
||||
|
||||
import '../common.dart';
|
||||
|
||||
const kTrayItemShowKey = "show";
|
||||
const kTrayItemQuitKey = "quit";
|
||||
|
||||
Future<void> initTray({List<MenuItem>? extra_item}) async {
|
||||
List<MenuItem> items = [
|
||||
MenuItem(key: "show", label: translate("show rustdesk")),
|
||||
MenuItem(key: kTrayItemShowKey, label: translate("Show RustDesk")),
|
||||
MenuItem.separator(),
|
||||
MenuItem(key: "quit", label: translate("quit rustdesk")),
|
||||
MenuItem(key: kTrayItemQuitKey, label: translate("Quit")),
|
||||
];
|
||||
if (extra_item != null) {
|
||||
items.insertAll(0, extra_item);
|
||||
@@ -17,7 +20,13 @@ Future<void> initTray({List<MenuItem>? extra_item}) async {
|
||||
trayManager
|
||||
.setIcon(Platform.isWindows ? "assets/logo.ico" : "assets/logo.png"),
|
||||
trayManager.setContextMenu(Menu(items: items)),
|
||||
trayManager.setToolTip("rustdesk"),
|
||||
trayManager.setTitle("rustdesk")
|
||||
]);
|
||||
if (Platform.isMacOS || Platform.isWindows) {
|
||||
await trayManager.setToolTip("rustdesk");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> destoryTray() async {
|
||||
return trayManager.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user