alroyso 1 year ago
parent
commit
da769dcdc1

+ 9 - 0
lib/app/modules/home/controllers/home_controller.dart

@@ -155,6 +155,15 @@ class HomeController extends GetxController {
 
   Future<void> fetchAuthUser() async {
     try {
+      if (connectStatus.value == ConnectionStatus.stopped) {
+        controllers.global.allowStatusUpdate = false;
+        await controllers.config.setBreakConnections(true);
+        // // 停止服务
+        await controllers.service.stopClash();
+        await controllers.global.systemProxySwitch(false);
+        updateStatus(ConnectionStatus.disconnected);
+        return;
+      }
       final ret  = await ApiService().fetchAuthUser(KAuthUser);
       controllers.global.selectedNode.value = ret;
       controllers.global.selectNode(ret);

+ 2 - 0
macos/Flutter/GeneratedPluginRegistrant.swift

@@ -9,6 +9,7 @@ import connectivity_plus_macos
 import file_selector_macos
 import flutter_secure_storage_macos
 import path_provider_foundation
+import protocol_handler
 import proxy_manager
 import screen_retriever
 import shared_preferences_foundation
@@ -22,6 +23,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
   FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
   FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin"))
   PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
+  ProtocolHandlerPlugin.register(with: registry.registrar(forPlugin: "ProtocolHandlerPlugin"))
   ProxyManagerPlugin.register(with: registry.registrar(forPlugin: "ProxyManagerPlugin"))
   ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
   SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))

+ 3 - 0
windows/flutter/generated_plugin_registrant.cc

@@ -10,6 +10,7 @@
 #include <file_selector_windows/file_selector_windows.h>
 #include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
 #include <permission_handler_windows/permission_handler_windows_plugin.h>
+#include <protocol_handler/protocol_handler_plugin.h>
 #include <proxy_manager/proxy_manager_plugin.h>
 #include <screen_retriever/screen_retriever_plugin.h>
 #include <tray_manager/tray_manager_plugin.h>
@@ -25,6 +26,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
       registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
   PermissionHandlerWindowsPluginRegisterWithRegistrar(
       registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
+  ProtocolHandlerPluginRegisterWithRegistrar(
+      registry->GetRegistrarForPlugin("ProtocolHandlerPlugin"));
   ProxyManagerPluginRegisterWithRegistrar(
       registry->GetRegistrarForPlugin("ProxyManagerPlugin"));
   ScreenRetrieverPluginRegisterWithRegistrar(

+ 1 - 0
windows/flutter/generated_plugins.cmake

@@ -7,6 +7,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
   file_selector_windows
   flutter_secure_storage_windows
   permission_handler_windows
+  protocol_handler
   proxy_manager
   screen_retriever
   tray_manager