diff --git a/lib/http/init.dart b/lib/http/init.dart index 4af20cae..dbf189c6 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -89,11 +89,7 @@ class Request { //响应流上前后两次接受到数据的间隔,单位为毫秒。 receiveTimeout: const Duration(milliseconds: 12000), //Http请求头. - headers: { - 'keep-alive': 'true', - 'user-agent': headerUa(), - }, - persistentConnection: true, + headers: {}, ); dio = Dio(options) @@ -128,20 +124,15 @@ class Request { */ get(url, {data, options, cancelToken, extra}) async { Response response; - Options options; + Options options = Options(); ResponseType resType = ResponseType.json; - - options = Options(); - options.responseType = resType; - if (extra != null) { - options.responseType = extra!['resType'] ?? ResponseType.json; + resType = extra!['resType'] ?? ResponseType.json; if (extra['ua'] != null) { - print(options.headers); options.headers = {'user-agent': headerUa(type: extra['ua'])}; - // options.headers!['user-agent'] = headerUa(type: extra['ua']); } } + options.responseType = resType; try { response = await dio.get( diff --git a/lib/pages/about/index.dart b/lib/pages/about/index.dart index 76173fae..31808e1c 100644 --- a/lib/pages/about/index.dart +++ b/lib/pages/about/index.dart @@ -184,7 +184,7 @@ class AboutController extends GetxController { // 获取远程版本 Future getRemoteApp() async { - var result = await Request().get(Api.latestApp); + var result = await Request().get(Api.latestApp, extra: {'ua': 'pc'}); data = LatestDataModel.fromJson(result.data); remoteAppInfo = data; remoteVersion.value = data.tagName!;