alroyso 4 months ago
parent
commit
acd396a8c0
1 changed files with 9 additions and 4 deletions
  1. 9 4
      lib/app/service/connection_service.dart

+ 9 - 4
lib/app/service/connection_service.dart

@@ -7,6 +7,7 @@ import 'package:naiyouwl/app/component/connection_status.dart';
 import 'package:naiyouwl/app/clash/service/clash_service.dart';
 import 'package:naiyouwl/app/controller/service.dart';
 import 'package:naiyouwl/app/utils/shell.dart';
+import 'package:wl_base_help/wl_base_help.dart';
 
 import '../controller/GlobalController.dart';
 import '../modules/home/controllers/home_controller.dart';
@@ -101,7 +102,7 @@ class ConnectionService {
         }
       }
 
-      final proxyManager = WindowsProxyManager();
+      final proxyManager = WlBaseHelp();
 
       if(Platform.isWindows){
         int? port = controllers.config.mixedPort.value;
@@ -116,7 +117,11 @@ class ConnectionService {
         if (mixedPort == 0) {
           mixedPort = null;
         }
-        proxyManager.setSystemProxy("http=127.0.0.1:{$port};https=127.0.0.1:${port}", bypassList: "<local>");
+
+        if(port !=null){
+         await proxyManager.startProxy(port);
+        }
+
       }
       updateStatus(ConnectionStatus.connected);
       globalController.updateMsg("连接成功");
@@ -167,8 +172,8 @@ class ConnectionService {
       } else{
         if (controllers.service.clashServiceIsRuning){
           await controllers.service.stopClash();
-          final proxyManager = WindowsProxyManager();
-          proxyManager.disableSystemProxy();
+          final proxyManager = WlBaseHelp();
+          proxyManager.stopProxy();
           await globalController.closeProxy();
           globalController.updateMsg("内核已重新加载");
         } else {