diff --git a/lib/http/init.dart b/lib/http/init.dart index 676bf7f19..89b31cf68 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:developer'; import 'dart:io'; import 'dart:math' show Random; +import 'package:PiliPlus/build_config.dart'; import 'package:cookie_jar/cookie_jar.dart'; import 'package:dio/dio.dart'; import 'package:dio/io.dart'; @@ -175,11 +176,13 @@ class Request { } // 日志拦截器 输出请求、响应内容 - // dio.interceptors.add(LogInterceptor( - // request: false, - // requestHeader: false, - // responseHeader: false, - // )); + if (BuildConfig.isDebug) { + dio.interceptors.add(LogInterceptor( + request: false, + requestHeader: false, + responseHeader: false, + )); + } dio.transformer = BackgroundTransformer(); dio.options.validateStatus = (int? status) { diff --git a/lib/pages/search_panel/controller.dart b/lib/pages/search_panel/controller.dart index b9e58b43e..3c20a3328 100644 --- a/lib/pages/search_panel/controller.dart +++ b/lib/pages/search_panel/controller.dart @@ -26,6 +26,7 @@ class SearchPanelController extends CommonController { String tag; int? pubBegin; int? pubEnd; + bool? hasPushDetail; @override void onInit() { @@ -46,7 +47,10 @@ class SearchPanelController extends CommonController { ?.insertAll(0, (loadingState.value as Success).response); } loadingState.value = LoadingState.success(response.response.list); - if (currentPage == 1) { + if (hasPushDetail != true && + currentPage == 1 && + searchType == SearchType.video) { + hasPushDetail = true; onPushDetail(response.response.list); } } else { diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 9f1424bcb..c40316405 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -836,13 +836,11 @@ class ReplyItem extends StatelessWidget { ), recognizer: TapGestureRecognizer() ..onTap = () async { - final String title = content.jumpUrl[matchStr]['title']; + late final String title = content.url[matchStr]!.title; if (appUrlSchema == '') { - if (matchStr.startsWith('BV')) { - UrlUtils.matchUrlPush( - matchStr, - '', - ); + if (RegExp(r'^(av|bv)', caseSensitive: false) + .hasMatch(matchStr)) { + UrlUtils.matchUrlPush(matchStr, ''); } else if (RegExp(r'^[Cc][Vv][0-9]+$') .hasMatch(matchStr)) { Get.toNamed('/htmlRender', parameters: { diff --git a/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart b/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart index c5ea1a9f2..544d6462f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item_grpc.dart @@ -876,13 +876,11 @@ class ReplyItemGrpc extends StatelessWidget { ), recognizer: TapGestureRecognizer() ..onTap = () async { - final String title = content.url[matchStr]!.title; + late final String title = content.url[matchStr]!.title; if (appUrlSchema == '') { - if (matchStr.startsWith('BV')) { - UrlUtils.matchUrlPush( - matchStr, - '', - ); + if (RegExp(r'^(av|bv)', caseSensitive: false) + .hasMatch(matchStr)) { + UrlUtils.matchUrlPush(matchStr, ''); } else if (RegExp(r'^[Cc][Vv][0-9]+$') .hasMatch(matchStr)) { Get.toNamed('/htmlRender', parameters: { diff --git a/lib/scripts/build.sh b/lib/scripts/build.sh index 515d0e123..fece0c353 100644 --- a/lib/scripts/build.sh +++ b/lib/scripts/build.sh @@ -10,6 +10,7 @@ commit_hash=$(git rev-parse HEAD) cat < lib/build_config.dart class BuildConfig { + static const bool isDebug = false; static const String buildTime = '$build_time'; static const String commitHash = '$commit_hash'; } diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index c2df05696..ac4b18bce 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -1,4 +1,5 @@ import 'package:dio/dio.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import '../http/init.dart'; @@ -53,19 +54,25 @@ class UrlUtils { String redirectUrl, ) async { final Map matchRes = IdUtils.matchAvorBv(input: pathSegment); - if (matchRes.containsKey('BV')) { - final String bv = matchRes['BV']; - final int cid = await SearchHttp.ab2c(bvid: bv); + if (matchRes.isNotEmpty) { + int? aid = matchRes['AV']; + String? bvid = matchRes['BV']; + bvid ??= IdUtils.av2bv(aid!); + final int cid = await SearchHttp.ab2c(aid: aid, bvid: bvid); await Get.toNamed( - '/video?bvid=$bv&cid=$cid', + '/video?bvid=$bvid&cid=$cid', arguments: { 'pic': '', - 'heroTag': Utils.makeHeroTag(bv), + 'heroTag': Utils.makeHeroTag(bvid), }, preventDuplicates: false, ); } else { - Utils.handleWebview(redirectUrl); + if (redirectUrl.isNotEmpty) { + Utils.handleWebview(redirectUrl); + } else { + SmartDialog.showToast('matchUrlPush: $pathSegment'); + } } } }