alroyso 3 周之前
父節點
當前提交
5626e80f81

+ 10 - 10
lib/app/controller/GlobalController.dart

@@ -278,17 +278,17 @@ class GlobalController extends GetxController {
       }
 
       await controllers.core.fetchSetProxieGroup(g, name);
-      final conn = await controllers.core.fetchConnection();
-      if(conn == null) {
-        LogHelper().d("没有连接数据");
-        return;
-      }
-
-      for (final it in conn.connections) {
-        if (it.chains.contains(name)) controllers.core.fetchCloseConnections(it.id);
-      }
+      // final conn = await controllers.core.fetchConnection();
+      // if(conn == null) {
+      //   LogHelper().d("没有连接数据");
+      //   return;
+      // }
+      //
+      // for (final it in conn.connections) {
+      //   if (it.chains.contains(name)) controllers.core.fetchCloseConnections(it.id);
+      // }
     } catch (e) {
-      LogHelper().d("fetchConnection ---- >$e");
+      LogHelper().d("fetchSetProxieGroup ---- >$e");
     }
   }
   // 创建代理配置文件

+ 1 - 1
lib/app/controller/core.dart

@@ -349,7 +349,7 @@ class CoreController extends GetxController {
       print("fetchSetProxieGroup ${ret.statusCode}");
 
       // 检查状态码,确保请求成功
-      if (ret.statusCode == 200) {
+      if (ret.statusCode == 204) {
         print('Proxy group updated successfully.');
       } else {
         print('Failed to update proxy group: ${ret.statusCode}');

+ 11 - 2
lib/app/modules/home/controllers/home_controller.dart

@@ -158,14 +158,23 @@ class HomeController extends GetxController {
      // await Future.delayed(Duration(seconds: 3)); // 等待核心状态更新
       if(globalController.selectedNode.value != null)
       {
-        await connectionService.startConnectionWin();
+        if(Platform.isMacOS){
+          await connectionService.startConnectionMac();
+        } else {
+          await connectionService.startConnectionWin();
+        }
+
       } else {
         // 继续后面的逻辑
         var error = await networkService.fetchAuthUser();
 
         // 根据 error 的结果继续处理
         if (error == "") {
-          await connectionService.startConnectionWin();
+          if(Platform.isMacOS){
+            await connectionService.startConnectionMac();
+          } else {
+            await connectionService.startConnectionWin();
+          }
         } else {
           connectionService.updateStatus(ConnectionStatus.disconnected);
           globalController.updateMsg("验证失败,{$error}");

+ 12 - 1
lib/app/service/connection_service.dart

@@ -21,7 +21,18 @@ class ConnectionService {
   final ServiceController serviceController = Get.find<ServiceController>();
 
   ConnectionService(this.globalController, this.updateStatus);
-
+  Future<void> startConnectionMac() async {
+    updateStatus(ConnectionStatus.connecting);
+    globalController.updateMsg("正在启动连接...");
+    await globalController.updateNode();
+    await globalController.swift(globalController.selectedNode.value?.name ?? "");
+    // 等待连接建立
+    await Future.delayed(Duration(seconds: 2));
+    updateStatus(ConnectionStatus.connected);
+    globalController.connectStatus.value = true;
+    globalController.updateMsg("连接成功");
+    await globalController.openProxy();
+  }
 
   Future<void> startConnectionWin() async {
     try {