From bbfb3175fea0855e0fee80b3356be3a5b621a5fc Mon Sep 17 00:00:00 2001 From: guozhigq Date: Tue, 14 Nov 2023 00:06:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=A3=E7=90=86=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E7=BD=91=E7=BB=9C=E5=BC=82=E5=B8=B8=20issues=20#242?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/init.dart | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/http/init.dart b/lib/http/init.dart index 6a60dca0..1e55be38 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -115,30 +115,24 @@ class Request { idleTimeout: const Duration(milliseconds: 10000), onClientCreate: (_, config) => config.onBadCertificate = (_) => true, ), - ) + ); - /// 设置代理 - ..httpClientAdapter = IOHttpClientAdapter( + /// 设置代理 + if (enableSystemProxy) { + dio.httpClientAdapter = IOHttpClientAdapter( createHttpClient: () { final client = HttpClient(); // Config the client. client.findProxy = (uri) { - if (enableSystemProxy) { - print('🌹:$systemProxyHost'); - print('🌹:$systemProxyPort'); - - // return 'PROXY host:port'; - return 'PROXY $systemProxyHost:$systemProxyPort'; - } else { - // 不设置代理 - return 'DIRECT'; - } + // return 'PROXY host:port'; + return 'PROXY $systemProxyHost:$systemProxyPort'; }; client.badCertificateCallback = (X509Certificate cert, String host, int port) => true; return client; }, ); + } //添加拦截器 dio.interceptors.add(ApiInterceptor());