mod: minor tweaks

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-11 12:05:21 +08:00
parent 1417fcda6e
commit 51a12d7266
6 changed files with 72 additions and 83 deletions

View File

@@ -1,7 +1,6 @@
import 'package:PiliPlus/grpc/dm/v1/dm.pb.dart'; import 'package:PiliPlus/grpc/dm/v1/dm.pb.dart';
import 'package:PiliPlus/http/danmaku.dart'; import 'package:PiliPlus/http/danmaku.dart';
import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart';
import 'package:PiliPlus/utils/storage.dart';
class PlDanmakuController { class PlDanmakuController {
PlDanmakuController( PlDanmakuController(
@@ -19,8 +18,6 @@ class PlDanmakuController {
static int segmentLength = 60 * 6 * 1000; static int segmentLength = 60 * 6 * 1000;
late final mergeDanmaku = GStorage.mergeDanmaku;
void initiate(int videoDuration, int progress) { void initiate(int videoDuration, int progress) {
if (videoDuration <= 0) { if (videoDuration <= 0) {
return; return;
@@ -50,7 +47,7 @@ class PlDanmakuController {
final DmSegMobileReply result = await DanmakaHttp.queryDanmaku( final DmSegMobileReply result = await DanmakaHttp.queryDanmaku(
cid: cid, cid: cid,
segmentIndex: segmentIndex + 1, segmentIndex: segmentIndex + 1,
mergeDanmaku: mergeDanmaku, mergeDanmaku: plPlayerController.mergeDanmaku,
); );
if (result.elems.isNotEmpty) { if (result.elems.isNotEmpty) {
for (var element in result.elems) { for (var element in result.elems) {

View File

@@ -846,24 +846,19 @@ class ReplyItem extends StatelessWidget {
if (RegExp(r'^(av|bv)', caseSensitive: false) if (RegExp(r'^(av|bv)', caseSensitive: false)
.hasMatch(matchStr)) { .hasMatch(matchStr)) {
UrlUtils.matchUrlPush(matchStr, ''); UrlUtils.matchUrlPush(matchStr, '');
} else if (RegExp(r'^cv\d+$', caseSensitive: false)
.hasMatch(matchStr)) {
String cvid = 'cv${matchStr.substring(2)}';
Get.toNamed('/htmlRender', parameters: {
'url': 'https://www.bilibili.com/read/$cvid',
'title': title,
'id': cvid,
'dynamicType': 'read'
});
} else { } else {
String? cvId = RegExp(r'/read/(cv\d+)') RegExpMatch? firstMatch = RegExp(
.firstMatch(matchStr) r'^cv(\d+)$|/read/cv(\d+)|note-app/view\?cvid=(\d+)',
?.group(1); caseSensitive: false)
if (cvId != null) { .firstMatch(matchStr);
String? cvid = firstMatch?.group(1) ??
firstMatch?.group(2) ??
firstMatch?.group(3);
if (cvid != null) {
Get.toNamed('/htmlRender', parameters: { Get.toNamed('/htmlRender', parameters: {
'url': matchStr, 'url': 'https://www.bilibili.com/read/cv$cvid',
'title': title, 'title': title,
'id': cvId, 'id': 'cv$cvid',
'dynamicType': 'read' 'dynamicType': 'read'
}); });
return; return;

View File

@@ -884,24 +884,19 @@ class ReplyItemGrpc extends StatelessWidget {
if (RegExp(r'^(av|bv)', caseSensitive: false) if (RegExp(r'^(av|bv)', caseSensitive: false)
.hasMatch(matchStr)) { .hasMatch(matchStr)) {
UrlUtils.matchUrlPush(matchStr, ''); UrlUtils.matchUrlPush(matchStr, '');
} else if (RegExp(r'^cv\d+$', caseSensitive: false)
.hasMatch(matchStr)) {
String cvid = 'cv${matchStr.substring(2)}';
Get.toNamed('/htmlRender', parameters: {
'url': 'https://www.bilibili.com/read/$cvid',
'title': title,
'id': cvid,
'dynamicType': 'read'
});
} else { } else {
String? cvId = RegExp(r'/read/(cv\d+)') RegExpMatch? firstMatch = RegExp(
.firstMatch(matchStr) r'^cv(\d+)$|/read/cv(\d+)|note-app/view\?cvid=(\d+)',
?.group(1); caseSensitive: false,
if (cvId != null) { ).firstMatch(matchStr);
String? cvid = firstMatch?.group(1) ??
firstMatch?.group(2) ??
firstMatch?.group(3);
if (cvid != null) {
Get.toNamed('/htmlRender', parameters: { Get.toNamed('/htmlRender', parameters: {
'url': matchStr, 'url': 'https://www.bilibili.com/read/cv$cvid',
'title': title, 'title': title,
'id': cvId, 'id': 'cv$cvid',
'dynamicType': 'read' 'dynamicType': 'read'
}); });
return; return;

View File

@@ -165,7 +165,8 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
userAgent: Request().headerUa(type: uaType), userAgent: Request().headerUa(type: uaType),
mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW,
), ),
initialUrlRequest: URLRequest(url: WebUri.uri(Uri.parse(_url))), initialUrlRequest:
URLRequest(url: WebUri.uri(Uri.tryParse(_url) ?? Uri())),
onWebViewCreated: (InAppWebViewController controller) { onWebViewCreated: (InAppWebViewController controller) {
_webViewController = controller; _webViewController = controller;
}, },
@@ -272,7 +273,8 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
return NavigationActionPolicy.CANCEL; return NavigationActionPolicy.CANCEL;
} }
} catch (_) {} } catch (_) {}
} else if (url.startsWith('http').not) { } else if (RegExp(r'^(?!(https?://))\S+://', caseSensitive: false)
.hasMatch(url)) {
if (url.startsWith('bilibili://video/')) { if (url.startsWith('bilibili://video/')) {
String? str = String? str =
navigationAction.request.url!.pathSegments.getOrNull(0); navigationAction.request.url!.pathSegments.getOrNull(0);

View File

@@ -260,6 +260,7 @@ class PlPlayerController {
// 关联弹幕控制器 // 关联弹幕控制器
DanmakuController? danmakuController; DanmakuController? danmakuController;
bool showDanmaku = true; bool showDanmaku = true;
late final mergeDanmaku = GStorage.mergeDanmaku;
// 弹幕相关配置 // 弹幕相关配置
late List blockTypes; late List blockTypes;
late double showArea; late double showArea;
@@ -1611,6 +1612,4 @@ class PlPlayerController {
late final RxList dmTrend = [].obs; late final RxList dmTrend = [].obs;
late final RxBool showDmChart = true.obs; late final RxBool showDmChart = true.obs;
late final RxBool showRestoreScaleBtn = false.obs;
} }

View File

@@ -103,6 +103,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
late bool enableQuickDouble; late bool enableQuickDouble;
late bool fullScreenGestureReverse; late bool fullScreenGestureReverse;
late final RxBool showRestoreScaleBtn = false.obs;
Offset _initialFocalPoint = Offset.zero; Offset _initialFocalPoint = Offset.zero;
String? _gestureType; String? _gestureType;
//播放器放缩 //播放器放缩
@@ -702,7 +704,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}, },
onInteractionUpdate: (ScaleUpdateDetails details) { onInteractionUpdate: (ScaleUpdateDetails details) {
plPlayerController.showRestoreScaleBtn.value = showRestoreScaleBtn.value =
transformationController.value.row0.x != 1.0; transformationController.value.row0.x != 1.0;
if (interacting || _initialFocalPoint == Offset.zero) return; if (interacting || _initialFocalPoint == Offset.zero) return;
Offset cumulativeDelta = Offset cumulativeDelta =
@@ -1145,12 +1147,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// ), // ),
Obx( Obx(
() => plPlayerController.showRestoreScaleBtn.value && () =>
plPlayerController.showControls.value showRestoreScaleBtn.value && plPlayerController.showControls.value
? Align( ? Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 75), padding: const EdgeInsets.only(bottom: 95),
child: FilledButton.tonal( child: FilledButton.tonal(
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
@@ -1160,14 +1162,13 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
.withOpacity(0.8), .withOpacity(0.8),
visualDensity: visualDensity:
VisualDensity(horizontal: -2, vertical: -2), VisualDensity(horizontal: -2, vertical: -2),
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.all(15),
horizontal: 15, vertical: 15),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
), ),
onPressed: () async { onPressed: () async {
plPlayerController.showRestoreScaleBtn.value = false; showRestoreScaleBtn.value = false;
final animController = AnimationController( final animController = AnimationController(
vsync: this, vsync: this,
duration: const Duration(milliseconds: 255), duration: const Duration(milliseconds: 255),