This commit is contained in:
xkeyC 2024-02-16 22:47:06 +08:00
parent 04e19a7311
commit 066bf11275
4 changed files with 7 additions and 10 deletions

View File

@ -1,5 +1,3 @@
import 'dart:convert';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:starcitizen_doctor/common/conf/url_conf.dart'; import 'package:starcitizen_doctor/common/conf/url_conf.dart';
import 'package:starcitizen_doctor/common/io/rs_http.dart'; import 'package:starcitizen_doctor/common/io/rs_http.dart';
@ -11,9 +9,9 @@ class AnalyticsApi {
if (kDebugMode) return; if (kDebugMode) return;
dPrint("AnalyticsApi.touch === $key start"); dPrint("AnalyticsApi.touch === $key start");
try { try {
await RSHttp.postData("${URLConf.xkeycApiHome}/analytics/$key", final r = await RSHttp.postData("${URLConf.xkeycApiHome}/analytics/$key",
data: utf8.encode(json.encode({"test": "a"})), contentType: "application/json"); data: null);
dPrint("AnalyticsApi.touch === $key over"); dPrint("AnalyticsApi.touch === $key over statusCode == ${r.statusCode}");
} catch (e) { } catch (e) {
dPrint("AnalyticsApi.touch === $key Error:$e"); dPrint("AnalyticsApi.touch === $key Error:$e");
} }

View File

@ -29,7 +29,7 @@ class RSHttp {
return str; return str;
} }
static Future postData(String url, static Future<RustHttpResponse> postData(String url,
{Map<String, String>? headers, {Map<String, String>? headers,
String? contentType, String? contentType,
Uint8List? data}) async { Uint8List? data}) async {
@ -39,7 +39,7 @@ class RSHttp {
} }
final r = await rust_http.fetch( final r = await rust_http.fetch(
method: MyMethod.post, url: url, headers: headers, inputData: data); method: MyMethod.post, url: url, headers: headers, inputData: data);
return r.statusCode == 200; return r;
} }
static Future<RustHttpResponse> head(String url, static Future<RustHttpResponse> head(String url,

View File

@ -35,7 +35,7 @@ class AppGlobalUIModel extends BaseUIModel {
await Future.delayed(const Duration(milliseconds: 100)); await Future.delayed(const Duration(milliseconds: 100));
if (AppConf.networkVersionData == null) { if (AppConf.networkVersionData == null) {
showToast(context, showToast(context,
"网络异常,这可能是服务器正在维护或遭受攻击... \n进入离线模式.. \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${AppConf.appVersionDate}\n QQ群940696487 \n错误信息:$checkUpdateError"); "网络异常\n这可能是您的网络环境存在DNS污染请尝试更换DNS。\n或服务器正在维护或遭受攻击,稍后再试。 \n进入离线模式... \n\n请谨慎在离线模式中使用。 \n当前版本构建日期:${AppConf.appVersionDate}\n QQ群940696487 \n错误信息:$checkUpdateError");
return false; return false;
} }
final lastVersion = AppConf.isMSE final lastVersion = AppConf.isMSE

View File

@ -25,9 +25,8 @@ lazy_static! {
static ref HTTP_CLIENT: reqwest::Client = { static ref HTTP_CLIENT: reqwest::Client = {
reqwest::Client::builder() reqwest::Client::builder()
.use_rustls_tls() .use_rustls_tls()
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(10))
.dns_resolver(DNS_CLIENT.clone()) .dns_resolver(DNS_CLIENT.clone())
.connect_timeout(Duration::from_secs(10))
.gzip(true) .gzip(true)
.brotli(true) .brotli(true)
.deflate(true) .deflate(true)