|
@@ -6,6 +6,7 @@ import 'package:naiyouwl/app/controller/controllers.dart';
|
|
|
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 '../controller/GlobalController.dart';
|
|
|
import '../modules/home/controllers/home_controller.dart';
|
|
@@ -80,7 +81,7 @@ class ConnectionService {
|
|
|
if (serviceController.serviceIsRuning) {
|
|
|
//await serviceController.fetchStartInit();
|
|
|
await serviceController.fetchSetProxy();
|
|
|
-
|
|
|
+ await globalController.openProxy();
|
|
|
} else {
|
|
|
if (controllers.service.clashServiceIsRuning) {
|
|
|
globalController.connectStatus.value = true;
|
|
@@ -99,18 +100,37 @@ class ConnectionService {
|
|
|
throw Exception("内核启动失败");
|
|
|
}
|
|
|
}
|
|
|
- //await globalController.openProxy();
|
|
|
+
|
|
|
+ final proxyManager = WindowsProxyManager();
|
|
|
+
|
|
|
+ if(Platform.isWindows){
|
|
|
+ int? port = controllers.config.mixedPort.value;
|
|
|
+ if (port == 0) {
|
|
|
+ port = null;
|
|
|
+ }
|
|
|
+ int? socksPort = controllers.config.mixedPort.value;
|
|
|
+ if (socksPort == 0) {
|
|
|
+ socksPort = null;
|
|
|
+ }
|
|
|
+ int? mixedPort = controllers.config.mixedPort.value;
|
|
|
+ if (mixedPort == 0) {
|
|
|
+ mixedPort = null;
|
|
|
+ }
|
|
|
+ proxyManager.setSystemProxy("http=127.0.0.1:{$port};https=127.0.0.1:${port}", bypassList: "<local>");
|
|
|
+ }
|
|
|
updateStatus(ConnectionStatus.connected);
|
|
|
globalController.updateMsg("连接成功");
|
|
|
controllers.global.connectStatus.value = true;
|
|
|
|
|
|
//检测系统代理并切换成网卡模式
|
|
|
if(Platform.isWindows){
|
|
|
- final proxyManager = WindowsProxyManager();
|
|
|
+
|
|
|
if(!await proxyManager.isProxyEnabled()){
|
|
|
+ globalController.updateMsg("当前没有设置系统代理,20秒后切换成网卡模式");
|
|
|
+ await Future.delayed(Duration(seconds: 20)); // 等待核心状态更新
|
|
|
await globalController.TunProxySwitch(true);
|
|
|
await globalController.makeProxy();
|
|
|
- await serviceController.reloadClashCore();
|
|
|
+ await reloadClashCore();
|
|
|
LogHelper().d("重置网卡模式");
|
|
|
}
|
|
|
|
|
@@ -221,7 +241,7 @@ class ConnectionService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
Future<void> UninstallService() async{
|
|
|
if(serviceController.serviceStatus.value == RunningState.running){
|