fix: reply jump url

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-10 11:00:21 +08:00
parent a951d42623
commit 6817eb6e56
6 changed files with 35 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'dart:io'; import 'dart:io';
import 'dart:math' show Random; import 'dart:math' show Random;
import 'package:PiliPlus/build_config.dart';
import 'package:cookie_jar/cookie_jar.dart'; import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:dio/io.dart'; import 'package:dio/io.dart';
@@ -175,11 +176,13 @@ class Request {
} }
// 日志拦截器 输出请求、响应内容 // 日志拦截器 输出请求、响应内容
// dio.interceptors.add(LogInterceptor( if (BuildConfig.isDebug) {
// request: false, dio.interceptors.add(LogInterceptor(
// requestHeader: false, request: false,
// responseHeader: false, requestHeader: false,
// )); responseHeader: false,
));
}
dio.transformer = BackgroundTransformer(); dio.transformer = BackgroundTransformer();
dio.options.validateStatus = (int? status) { dio.options.validateStatus = (int? status) {

View File

@@ -26,6 +26,7 @@ class SearchPanelController extends CommonController {
String tag; String tag;
int? pubBegin; int? pubBegin;
int? pubEnd; int? pubEnd;
bool? hasPushDetail;
@override @override
void onInit() { void onInit() {
@@ -46,7 +47,10 @@ class SearchPanelController extends CommonController {
?.insertAll(0, (loadingState.value as Success).response); ?.insertAll(0, (loadingState.value as Success).response);
} }
loadingState.value = LoadingState.success(response.response.list); loadingState.value = LoadingState.success(response.response.list);
if (currentPage == 1) { if (hasPushDetail != true &&
currentPage == 1 &&
searchType == SearchType.video) {
hasPushDetail = true;
onPushDetail(response.response.list); onPushDetail(response.response.list);
} }
} else { } else {

View File

@@ -836,13 +836,11 @@ class ReplyItem extends StatelessWidget {
), ),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
final String title = content.jumpUrl[matchStr]['title']; late final String title = content.url[matchStr]!.title;
if (appUrlSchema == '') { if (appUrlSchema == '') {
if (matchStr.startsWith('BV')) { if (RegExp(r'^(av|bv)', caseSensitive: false)
UrlUtils.matchUrlPush( .hasMatch(matchStr)) {
matchStr, UrlUtils.matchUrlPush(matchStr, '');
'',
);
} else if (RegExp(r'^[Cc][Vv][0-9]+$') } else if (RegExp(r'^[Cc][Vv][0-9]+$')
.hasMatch(matchStr)) { .hasMatch(matchStr)) {
Get.toNamed('/htmlRender', parameters: { Get.toNamed('/htmlRender', parameters: {

View File

@@ -876,13 +876,11 @@ class ReplyItemGrpc extends StatelessWidget {
), ),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
final String title = content.url[matchStr]!.title; late final String title = content.url[matchStr]!.title;
if (appUrlSchema == '') { if (appUrlSchema == '') {
if (matchStr.startsWith('BV')) { if (RegExp(r'^(av|bv)', caseSensitive: false)
UrlUtils.matchUrlPush( .hasMatch(matchStr)) {
matchStr, UrlUtils.matchUrlPush(matchStr, '');
'',
);
} else if (RegExp(r'^[Cc][Vv][0-9]+$') } else if (RegExp(r'^[Cc][Vv][0-9]+$')
.hasMatch(matchStr)) { .hasMatch(matchStr)) {
Get.toNamed('/htmlRender', parameters: { Get.toNamed('/htmlRender', parameters: {

View File

@@ -10,6 +10,7 @@ commit_hash=$(git rev-parse HEAD)
cat <<EOL > lib/build_config.dart cat <<EOL > lib/build_config.dart
class BuildConfig { class BuildConfig {
static const bool isDebug = false;
static const String buildTime = '$build_time'; static const String buildTime = '$build_time';
static const String commitHash = '$commit_hash'; static const String commitHash = '$commit_hash';
} }

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../http/init.dart'; import '../http/init.dart';
@@ -53,19 +54,25 @@ class UrlUtils {
String redirectUrl, String redirectUrl,
) async { ) async {
final Map matchRes = IdUtils.matchAvorBv(input: pathSegment); final Map matchRes = IdUtils.matchAvorBv(input: pathSegment);
if (matchRes.containsKey('BV')) { if (matchRes.isNotEmpty) {
final String bv = matchRes['BV']; int? aid = matchRes['AV'];
final int cid = await SearchHttp.ab2c(bvid: bv); String? bvid = matchRes['BV'];
bvid ??= IdUtils.av2bv(aid!);
final int cid = await SearchHttp.ab2c(aid: aid, bvid: bvid);
await Get.toNamed( await Get.toNamed(
'/video?bvid=$bv&cid=$cid', '/video?bvid=$bvid&cid=$cid',
arguments: <String, String?>{ arguments: <String, String?>{
'pic': '', 'pic': '',
'heroTag': Utils.makeHeroTag(bv), 'heroTag': Utils.makeHeroTag(bvid),
}, },
preventDuplicates: false, preventDuplicates: false,
); );
} else { } else {
Utils.handleWebview(redirectUrl); if (redirectUrl.isNotEmpty) {
Utils.handleWebview(redirectUrl);
} else {
SmartDialog.showToast('matchUrlPush: $pathSegment');
}
} }
} }
} }