opt scheme

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-09 20:22:53 +08:00
parent 829b966382
commit e240a6caae
2 changed files with 28 additions and 31 deletions

View File

@@ -715,24 +715,22 @@ class ReplyItemGrpc extends StatelessWidget {
} else if (_timeRegExp.hasMatch(matchStr)) { } else if (_timeRegExp.hasMatch(matchStr)) {
matchStr = matchStr.replaceAll('', ':'); matchStr = matchStr.replaceAll('', ':');
bool isValid = false; bool isValid = false;
if (Get.currentRoute.startsWith('/video')) { try {
try { final ctr = Get.find<VideoDetailController>(
final ctr = Get.find<VideoDetailController>( tag: getTag?.call() ?? Get.arguments['heroTag']);
tag: getTag?.call() ?? Get.arguments['heroTag']); int duration = ctr.data.timeLength!;
int duration = ctr.data.timeLength!; List<int> split = matchStr
List<int> split = matchStr .split(':')
.split(':') .reversed
.reversed .map((item) => int.parse(item))
.map((item) => int.parse(item)) .toList();
.toList(); int seek = 0;
int seek = 0; for (int i = 0; i < split.length; i++) {
for (int i = 0; i < split.length; i++) { seek += split[i] * pow(60, i).toInt();
seek += split[i] * pow(60, i).toInt();
}
isValid = seek * 1000 <= duration;
} catch (e) {
if (kDebugMode) debugPrint('failed to validate: $e');
} }
isValid = seek * 1000 <= duration;
} catch (e) {
if (kDebugMode) debugPrint('failed to validate: $e');
} }
spanChildren.add( spanChildren.add(
TextSpan( TextSpan(

View File

@@ -8,7 +8,6 @@ import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/url_utils.dart'; import 'package:PiliPlus/utils/url_utils.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:app_links/app_links.dart'; import 'package:app_links/app_links.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -459,7 +458,7 @@ class PiliScheme {
return false; return false;
default: default:
if (!selfHandle) { if (!selfHandle) {
if (kDebugMode) debugPrint('$uri'); // if (kDebugMode) debugPrint('$uri');
SmartDialog.showToast('未知路径:$uri,请截图反馈给开发者'); SmartDialog.showToast('未知路径:$uri,请截图反馈给开发者');
} }
return false; return false;
@@ -483,7 +482,7 @@ class PiliScheme {
return true; return true;
} }
if (!selfHandle) { if (!selfHandle) {
if (kDebugMode) debugPrint('$uri'); // if (kDebugMode) debugPrint('$uri');
SmartDialog.showToast('未知路径:$uri,请截图反馈给开发者'); SmartDialog.showToast('未知路径:$uri,请截图反馈给开发者');
} }
return false; return false;
@@ -583,11 +582,11 @@ class PiliScheme {
launchURL(); launchURL();
return false; return false;
} }
final String? area = final first = pathSegments.first;
pathSegments.first == 'mobile' || pathSegments.first == 'h5' final String? area = const ['mobile', 'h5', 'v'].contains(first)
? pathSegments.getOrNull(1) ? pathSegments.getOrNull(1)
: pathSegments.first; : first;
if (kDebugMode) debugPrint('area: $area'); // if (kDebugMode) debugPrint('area: $area');
switch (area) { switch (area) {
case 'note' || 'note-app': case 'note' || 'note-app':
String? id = uri.queryParameters['cvid']; String? id = uri.queryParameters['cvid'];
@@ -643,7 +642,7 @@ class PiliScheme {
return false; return false;
case 'bangumi': case 'bangumi':
// www.bilibili.com/bangumi/play/ep{eid}?start_progress={offset}&thumb_up_dm_id={dmid} // www.bilibili.com/bangumi/play/ep{eid}?start_progress={offset}&thumb_up_dm_id={dmid}
if (kDebugMode) debugPrint('番剧'); // if (kDebugMode) debugPrint('番剧');
bool hasMatch = PageUtils.viewPgcFromUri( bool hasMatch = PageUtils.viewPgcFromUri(
path, path,
progress: uri.queryParameters['start_progress'], progress: uri.queryParameters['start_progress'],
@@ -654,7 +653,7 @@ class PiliScheme {
launchURL(); launchURL();
return false; return false;
case 'video': case 'video':
if (kDebugMode) debugPrint('投稿'); // if (kDebugMode) debugPrint('投稿');
final Map<String, dynamic> map = IdUtils.matchAvorBv(input: path); final Map<String, dynamic> map = IdUtils.matchAvorBv(input: path);
if (map.isNotEmpty) { if (map.isNotEmpty) {
final queryParameters = uri.queryParameters; final queryParameters = uri.queryParameters;
@@ -685,7 +684,7 @@ class PiliScheme {
launchURL(); launchURL();
return false; return false;
} }
if (kDebugMode) debugPrint('专栏'); // if (kDebugMode) debugPrint('专栏');
String? id = String? id =
RegExp(r'cv(\d+)', caseSensitive: false).firstMatch(path)?.group(1); RegExp(r'cv(\d+)', caseSensitive: false).firstMatch(path)?.group(1);
if (id != null) { if (id != null) {
@@ -702,7 +701,7 @@ class PiliScheme {
launchURL(); launchURL();
return false; return false;
case 'space': case 'space':
if (kDebugMode) debugPrint('个人空间'); // if (kDebugMode) debugPrint('个人空间');
String? mid = uriDigitRegExp.firstMatch(path)?.group(1); String? mid = uriDigitRegExp.firstMatch(path)?.group(1);
if (mid != null) { if (mid != null) {
PageUtils.toDupNamed( PageUtils.toDupNamed(
@@ -728,7 +727,7 @@ class PiliScheme {
} }
launchURL(); launchURL();
return false; return false;
case 'topic-detail': case 'topic' || 'topic-detail':
String? id = uri.queryParameters['topic_id']; String? id = uri.queryParameters['topic_id'];
if (id != null) { if (id != null) {
PageUtils.toDupNamed( PageUtils.toDupNamed(
@@ -791,7 +790,7 @@ class PiliScheme {
} }
launchURL(); launchURL();
return false; return false;
case 'match' || 'v': case 'match' || 'game':
if (path.contains('match/data/detail') || if (path.contains('match/data/detail') ||
path.contains('match/singledata')) { path.contains('match/singledata')) {
String? cid = uriDigitRegExp.firstMatch(path)?.group(1); String? cid = uriDigitRegExp.firstMatch(path)?.group(1);