Merge branch 'fix'

This commit is contained in:
guozhigq
2024-05-25 16:16:58 +08:00
2 changed files with 33 additions and 32 deletions

View File

@ -1,3 +1,4 @@
import 'package:appscheme/appscheme.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -11,6 +12,7 @@ import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/preview/index.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/reply_new/index.dart';
import 'package:pilipala/utils/app_scheme.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
@ -643,34 +645,17 @@ InlineSpan buildContent(
'',
);
} else {
final String pathSegment = Uri.parse(matchStr).path;
Map matchRes = IdUtils.matchAvorBv(input: pathSegment);
List matchKeys = matchRes.keys.toList();
if (matchKeys.isNotEmpty) {
UrlUtils.matchUrlPush(
matchRes.containsKey('AV')
? matchRes['AV']! as int
: matchRes['BV'],
title,
matchStr,
);
} else {
final String redirectUrl =
await UrlUtils.parseRedirectUrl(matchStr);
// if (redirectUrl == matchStr) {
// Clipboard.setData(ClipboardData(text: matchStr));
// SmartDialog.showToast('地址可能有误');
// return;
// }
Get.toNamed(
'/webview',
parameters: {
'url': redirectUrl,
'type': 'url',
'pageTitle': title
},
);
}
Uri uri = Uri.parse(matchStr);
SchemeEntity scheme = SchemeEntity(
scheme: uri.scheme,
host: uri.host,
port: uri.port,
path: uri.path,
query: uri.queryParameters,
source: '',
dataString: matchStr,
);
PiliSchame.fullPathPush(scheme);
}
} else {
if (appUrlSchema.startsWith('bilibili://search')) {

View File

@ -95,7 +95,7 @@ class PiliSchame {
}
}
if (scheme == 'https') {
_fullPathPush(value);
fullPathPush(value);
}
}
@ -126,7 +126,7 @@ class PiliSchame {
}
}
static Future<void> _fullPathPush(SchemeEntity value) async {
static Future<void> fullPathPush(SchemeEntity value) async {
// https://m.bilibili.com/bangumi/play/ss39708
// https | m.bilibili.com | /bangumi/play/ss39708
// final String scheme = value.scheme!;
@ -135,8 +135,6 @@ class PiliSchame {
Map<String, String>? query = value.query;
RegExp regExp = RegExp(r'^((www\.)|(m\.))?bilibili\.com$');
if (regExp.hasMatch(host)) {
print('bilibili.com host: $host');
print('bilibili.com path: $path');
final String lastPathSegment = path!.split('/').last;
if (path.startsWith('/video')) {
Map matchRes = IdUtils.matchAvorBv(input: path);
@ -236,6 +234,24 @@ class PiliSchame {
print('个人空间');
Get.toNamed('/member?mid=$area', arguments: {'face': ''});
break;
default:
final Map<String, dynamic> map =
IdUtils.matchAvorBv(input: area.split('?').first);
if (map.containsKey('AV')) {
_videoPush(map['AV']! as int, null);
} else if (map.containsKey('BV')) {
_videoPush(null, map['BV'] as String);
} else {
Get.toNamed(
'/webview',
parameters: {
'url': value.dataString ?? "",
'type': 'url',
'pageTitle': ''
},
);
}
break;
}
}
}