Fix multi instance on windows
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:hiddify/core/app_info/app_info_provider.dart';
|
import 'package:hiddify/core/app_info/app_info_provider.dart';
|
||||||
@@ -7,6 +8,7 @@ import 'package:hiddify/utils/utils.dart';
|
|||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:tray_manager/tray_manager.dart';
|
import 'package:tray_manager/tray_manager.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
import 'package:windows_single_instance/windows_single_instance.dart';
|
||||||
|
|
||||||
part 'window_notifier.g.dart';
|
part 'window_notifier.g.dart';
|
||||||
|
|
||||||
@@ -19,6 +21,11 @@ class WindowNotifier extends _$WindowNotifier with AppLogger {
|
|||||||
Future<void> build() async {
|
Future<void> build() async {
|
||||||
if (!PlatformUtils.isDesktop) return;
|
if (!PlatformUtils.isDesktop) return;
|
||||||
|
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
loggy.debug("ensuring single instance");
|
||||||
|
await WindowsSingleInstance.ensureSingleInstance([], "app.hiddify.com");
|
||||||
|
}
|
||||||
|
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
await windowManager.setMinimumSize(minimumWindowSize);
|
await windowManager.setMinimumSize(minimumWindowSize);
|
||||||
await windowManager.setSize(defaultWindowSize);
|
await windowManager.setSize(defaultWindowSize);
|
||||||
|
|||||||
@@ -1682,6 +1682,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.7"
|
version: "0.3.7"
|
||||||
|
windows_single_instance:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: windows_single_instance
|
||||||
|
sha256: "50d5dcd6bec90b4a5ed588b1822b1aad21b39fc96da843e61c734b3caccfd2fc"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
xdg_directories:
|
xdg_directories:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ dependencies:
|
|||||||
qr_flutter: ^4.1.0
|
qr_flutter: ^4.1.0
|
||||||
native_dio_adapter: ^1.2.0
|
native_dio_adapter: ^1.2.0
|
||||||
flutter_displaymode: ^0.6.0
|
flutter_displaymode: ^0.6.0
|
||||||
|
windows_single_instance: ^1.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
#include <vclibs/vclibs_plugin.h>
|
#include <vclibs/vclibs_plugin.h>
|
||||||
#include <window_manager/window_manager_plugin.h>
|
#include <window_manager/window_manager_plugin.h>
|
||||||
|
#include <windows_single_instance/windows_single_instance_plugin.h>
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
ProtocolHandlerPluginRegisterWithRegistrar(
|
ProtocolHandlerPluginRegisterWithRegistrar(
|
||||||
@@ -35,4 +36,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("VclibsPlugin"));
|
registry->GetRegistrarForPlugin("VclibsPlugin"));
|
||||||
WindowManagerPluginRegisterWithRegistrar(
|
WindowManagerPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
||||||
|
WindowsSingleInstancePluginRegisterWithRegistrar(
|
||||||
|
registry->GetRegistrarForPlugin("WindowsSingleInstancePlugin"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
vclibs
|
vclibs
|
||||||
window_manager
|
window_manager
|
||||||
|
windows_single_instance
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|||||||
Reference in New Issue
Block a user