From 33413cdb512427ef7bf070caae0713b589f208e5 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 14 Sep 2023 23:35:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E7=AC=AC=E4=B8=89=E6=96=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=87=8D=E5=AE=9A=E5=90=91=E3=80=81=E6=9C=89=E6=95=88?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 6 ------ lib/http/constants.dart | 33 +++++++++++++++++++++++++++++++++ lib/http/init.dart | 3 ++- lib/http/search.dart | 4 +++- pubspec.lock | 16 ++++++++++++++++ pubspec.yaml | 1 + 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 27d4531c..b00a1fff 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1,8 +1,6 @@ PODS: - appscheme (1.0.4): - Flutter - - auto_orientation (0.0.1): - - Flutter - connectivity_plus (0.0.1): - Flutter - ReachabilitySwift @@ -54,7 +52,6 @@ PODS: DEPENDENCIES: - appscheme (from `.symlinks/plugins/appscheme/ios`) - - auto_orientation (from `.symlinks/plugins/auto_orientation/ios`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - Flutter (from `Flutter`) @@ -85,8 +82,6 @@ SPEC REPOS: EXTERNAL SOURCES: appscheme: :path: ".symlinks/plugins/appscheme/ios" - auto_orientation: - :path: ".symlinks/plugins/auto_orientation/ios" connectivity_plus: :path: ".symlinks/plugins/connectivity_plus/ios" device_info_plus: @@ -132,7 +127,6 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: appscheme: b1c3f8862331cb20430cf9e0e4af85dbc1572ad8 - auto_orientation: 102ed811a5938d52c86520ddd7ecd3a126b5d39d connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 diff --git a/lib/http/constants.dart b/lib/http/constants.dart index 1f5319fb..cf10a606 100644 --- a/lib/http/constants.dart +++ b/lib/http/constants.dart @@ -2,4 +2,37 @@ class HttpString { static const String baseUrl = 'https://www.bilibili.com'; static const String baseApiUrl = 'https://api.bilibili.com'; static const String tUrl = 'https://api.vc.bilibili.com'; + static const List validateStatusCodes = [ + 302, + 304, + 307, + 400, + 401, + 403, + 404, + 405, + 409, + 412, + 500, + 503, + 504, + 509, + 616, + 617, + 625, + 626, + 628, + 629, + 632, + 643, + 650, + 652, + 658, + 662, + 688, + 689, + 701, + 799, + 8888 + ]; } diff --git a/lib/http/init.dart b/lib/http/init.dart index 52bd085f..f927e2e5 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -118,7 +118,8 @@ class Request { dio.transformer = BackgroundTransformer(); dio.options.validateStatus = (status) { - return status! >= 200 && status < 300 || status == 304 || status == 302; + return status! >= 200 && status < 300 || + HttpString.validateStatusCodes.contains(status); }; } diff --git a/lib/http/search.dart b/lib/http/search.dart index 5d99e3e0..ed00c2c6 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -83,7 +83,9 @@ class SearchHttp { return { 'status': false, 'data': [], - 'msg': res.data['data']['numPages'] == 0 ? '没有相关数据' : '请求错误 🙅', + 'msg': res.data['data'] != null && res.data['data']['numPages'] == 0 + ? '没有相关数据' + : res.data['message'], }; } } diff --git a/pubspec.lock b/pubspec.lock index 834bb054..ee904a63 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -337,6 +337,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + dio_http2_adapter: + dependency: "direct main" + description: + name: dio_http2_adapter + sha256: "3d81128cf389649ae6ac5cce23bcf5f9b254882b7f27185ca3b0d443ee9b825c" + url: "https://pub.dev" + source: hosted + version: "2.3.1+1" dismissible_page: dependency: "direct main" description: @@ -621,6 +629,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + http2: + dependency: transitive + description: + name: http2 + sha256: "38db0c4aa9f1cd238a5d2e86aa0cc7cc91c77e0c6c94ba64bbe85e4ff732a952" + url: "https://pub.dev" + source: hosted + version: "2.2.0" http_client_helper: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 2672cf63..2add035f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,6 +45,7 @@ dependencies: cookie_jar: ^4.0.8 dio_cookie_manager: ^3.1.0 connectivity_plus: ^4.0.1 + dio_http2_adapter: ^2.3.1+1 # 图片 cached_network_image: ^3.2.3 From 481d5e77d7b49f945df30b0fcd3cb23f61033739 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 15 Sep 2023 00:08:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=90=9C=E7=B4=A2=E5=BB=BA=E8=AE=AE?= =?UTF-8?q?=E8=AF=8D=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/search.dart | 8 ++++++-- lib/pages/search/controller.dart | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/http/search.dart b/lib/http/search.dart index ed00c2c6..d1f1770c 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -27,10 +27,14 @@ class SearchHttp { var res = await Request().get(Api.serachSuggest, data: {'term': term, 'main_ver': 'v1', 'highlight': term}); if (res.data['code'] == 0) { - res.data['result']['term'] = term; + if (res.data['result'] is Map) { + res.data['result']['term'] = term; + } return { 'status': true, - 'data': SearchSuggestModel.fromJson(res.data['result']), + 'data': res.data['result'] is Map + ? SearchSuggestModel.fromJson(res.data['result']) + : [], }; } else { return { diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 9a93dabe..05303a9b 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -103,7 +103,9 @@ class SSearchController extends GetxController { Future querySearchSuggest(String value) async { var result = await SearchHttp.searchSuggest(term: value); if (result['status']) { - searchSuggestList.value = result['data'].tag; + if (result['data'].isNotEmpty) { + searchSuggestList.value = result['data'].tag; + } } } From 54c66d54da11b369a775b830ee6b630e59f6209c Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 16 Sep 2023 01:18:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E7=83=AD=E6=90=9C=E8=AF=8D=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/search.dart | 24 +++++++++++++++++------- lib/pages/search/controller.dart | 6 ++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/http/search.dart b/lib/http/search.dart index d1f1770c..965f91cf 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:pilipala/http/index.dart'; import 'package:pilipala/models/bangumi/info.dart'; import 'package:pilipala/models/common/search_type.dart'; @@ -8,18 +10,26 @@ import 'package:pilipala/models/search/suggest.dart'; class SearchHttp { static Future hotSearchList() async { var res = await Request().get(Api.hotSearchList); - if (res.data['code'] == 0) { + if (res.data is String) { + Map resultMap = json.decode(res.data); + if (resultMap['code'] == 0) { + return { + 'status': true, + 'data': HotSearchModel.fromJson(resultMap), + }; + } + } else if (res.data is Map && res.data['code'] == 0) { return { 'status': true, 'data': HotSearchModel.fromJson(res.data), }; - } else { - return { - 'status': false, - 'data': [], - 'msg': '请求错误 🙅', - }; } + + return { + 'status': false, + 'data': [], + 'msg': '请求错误 🙅', + }; } // 获取搜索建议 diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 05303a9b..36d6a189 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -12,7 +12,7 @@ class SSearchController extends GetxController { final FocusNode searchFocusNode = FocusNode(); RxString searchKeyWord = ''.obs; Rx controller = TextEditingController().obs; - RxList hotSearchList = [HotSearchItem()].obs; + RxList hotSearchList = [].obs; Box histiryWord = GStrorage.historyword; List historyCacheList = []; RxList historyList = [].obs; @@ -85,7 +85,9 @@ class SSearchController extends GetxController { // 获取热搜关键词 Future queryHotSearchList() async { var result = await SearchHttp.hotSearchList(); - hotSearchList.value = result['data'].list; + if (result['status']) { + hotSearchList.value = result['data'].list; + } return result; }