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: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) {

View File

@@ -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 {

View File

@@ -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: {

View File

@@ -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: {

View File

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

View File

@@ -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: <String, String?>{
'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');
}
}
}
}