mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
fix: 评论区链接跳转改用app_scheme处理
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPalaX/http/video.dart';
|
import 'package:PiliPalaX/http/video.dart';
|
||||||
|
import 'package:appscheme/appscheme.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -16,6 +17,7 @@ import 'package:PiliPalaX/utils/feed_back.dart';
|
|||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:PiliPalaX/utils/url_utils.dart';
|
import 'package:PiliPalaX/utils/url_utils.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
|
import '../../../../../utils/app_scheme.dart';
|
||||||
import 'zan.dart';
|
import 'zan.dart';
|
||||||
|
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
@@ -681,30 +683,41 @@ InlineSpan buildContent(
|
|||||||
} else {
|
} else {
|
||||||
final String redirectUrl =
|
final String redirectUrl =
|
||||||
await UrlUtils.parseRedirectUrl(matchStr);
|
await UrlUtils.parseRedirectUrl(matchStr);
|
||||||
if (redirectUrl == matchStr) {
|
// if (redirectUrl == matchStr) {
|
||||||
Clipboard.setData(ClipboardData(text: matchStr));
|
// Clipboard.setData(ClipboardData(text: matchStr));
|
||||||
SmartDialog.showToast('地址可能有误');
|
// SmartDialog.showToast('地址可能有误');
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
final String pathSegment = Uri.parse(redirectUrl).path;
|
Uri uri = Uri.parse(redirectUrl);
|
||||||
final String lastPathSegment =
|
SchemeEntity scheme = SchemeEntity(
|
||||||
pathSegment.split('/').last;
|
scheme: uri.scheme,
|
||||||
if (lastPathSegment.startsWith('BV')) {
|
host: uri.host,
|
||||||
UrlUtils.matchUrlPush(
|
port: uri.port,
|
||||||
lastPathSegment,
|
path: uri.path,
|
||||||
title,
|
query: uri.queryParameters,
|
||||||
redirectUrl,
|
source: '',
|
||||||
|
dataString: redirectUrl,
|
||||||
);
|
);
|
||||||
} else {
|
PiliSchame.routePush(scheme);
|
||||||
Get.toNamed(
|
// final String pathSegment = Uri.parse(redirectUrl).path;
|
||||||
'/webview',
|
// final String lastPathSegment =
|
||||||
parameters: {
|
// pathSegment.split('/').last;
|
||||||
'url': redirectUrl,
|
// if (lastPathSegment.startsWith('BV')) {
|
||||||
'type': 'url',
|
// UrlUtils.matchUrlPush(
|
||||||
'pageTitle': title
|
// lastPathSegment,
|
||||||
},
|
// title,
|
||||||
);
|
// redirectUrl,
|
||||||
}
|
// );
|
||||||
|
// } else {
|
||||||
|
// Get.toNamed(
|
||||||
|
// '/webview',
|
||||||
|
// parameters: {
|
||||||
|
// 'url': redirectUrl,
|
||||||
|
// 'type': 'url',
|
||||||
|
// 'pageTitle': title
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (appUrlSchema.startsWith('bilibili://search')) {
|
if (appUrlSchema.startsWith('bilibili://search')) {
|
||||||
|
|||||||
@@ -14,29 +14,29 @@ class PiliSchame {
|
|||||||
///
|
///
|
||||||
final SchemeEntity? value = await appScheme.getInitScheme();
|
final SchemeEntity? value = await appScheme.getInitScheme();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
_routePush(value);
|
routePush(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 完整链接进入 b23.无效
|
/// 完整链接进入 b23.无效
|
||||||
appScheme.getLatestScheme().then((SchemeEntity? value) {
|
appScheme.getLatestScheme().then((SchemeEntity? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
_routePush(value);
|
routePush(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/// 注册从外部打开的Scheme监听信息 #
|
/// 注册从外部打开的Scheme监听信息 #
|
||||||
appScheme.registerSchemeListener().listen((SchemeEntity? event) {
|
appScheme.registerSchemeListener().listen((SchemeEntity? event) {
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
_routePush(event);
|
routePush(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 路由跳转
|
/// 路由跳转
|
||||||
static void _routePush(value) async {
|
static void routePush(SchemeEntity value) async {
|
||||||
final String scheme = value.scheme;
|
final String scheme = value.scheme!;
|
||||||
final String host = value.host;
|
final String host = value.host!;
|
||||||
final String path = value.path;
|
final String path = value.path!;
|
||||||
|
|
||||||
if (scheme == 'bilibili') {
|
if (scheme == 'bilibili') {
|
||||||
if (host == 'root') {
|
if (host == 'root') {
|
||||||
@@ -56,9 +56,9 @@ class PiliSchame {
|
|||||||
}
|
}
|
||||||
Map map = IdUtils.matchAvorBv(input: pathQuery);
|
Map map = IdUtils.matchAvorBv(input: pathQuery);
|
||||||
if (map.containsKey('AV')) {
|
if (map.containsKey('AV')) {
|
||||||
_videoPush(map['AV'], null);
|
videoPush(map['AV'], null);
|
||||||
} else if (map.containsKey('BV')) {
|
} else if (map.containsKey('BV')) {
|
||||||
_videoPush(null, map['BV']);
|
videoPush(null, map['BV']);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('投稿匹配失败');
|
SmartDialog.showToast('投稿匹配失败');
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ class PiliSchame {
|
|||||||
} else if (host == 'bangumi') {
|
} else if (host == 'bangumi') {
|
||||||
if (path.startsWith('/season')) {
|
if (path.startsWith('/season')) {
|
||||||
final String seasonId = path.split('/').last;
|
final String seasonId = path.split('/').last;
|
||||||
_bangumiPush(int.parse(seasonId), null);
|
bangumiPush(int.parse(seasonId), null);
|
||||||
}
|
}
|
||||||
} else if (host == 'opus') {
|
} else if (host == 'opus') {
|
||||||
if (path.startsWith('/detail')) {
|
if (path.startsWith('/detail')) {
|
||||||
@@ -109,12 +109,12 @@ class PiliSchame {
|
|||||||
// );
|
// );
|
||||||
}
|
}
|
||||||
} else if (scheme == 'https') {
|
} else if (scheme == 'https') {
|
||||||
_fullPathPush(value);
|
fullPathPush(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 投稿跳转
|
// 投稿跳转
|
||||||
static Future<void> _videoPush(int? aidVal, String? bvidVal) async {
|
static Future<void> videoPush(int? aidVal, String? bvidVal) async {
|
||||||
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
||||||
try {
|
try {
|
||||||
int? aid = aidVal;
|
int? aid = aidVal;
|
||||||
@@ -141,7 +141,8 @@ class PiliSchame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 番剧跳转
|
// 番剧跳转
|
||||||
static Future<void> _bangumiPush(int? seasonId, int? epId) async {
|
static Future<void> bangumiPush(int? seasonId, int? epId) async {
|
||||||
|
print('seasonId: $seasonId, epId: $epId');
|
||||||
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
||||||
try {
|
try {
|
||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
|
||||||
@@ -169,7 +170,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
|
||||||
// https | m.bilibili.com | /bangumi/play/ss39708
|
// https | m.bilibili.com | /bangumi/play/ss39708
|
||||||
// final String scheme = value.scheme!;
|
// final String scheme = value.scheme!;
|
||||||
@@ -200,16 +201,16 @@ class PiliSchame {
|
|||||||
final Map<String, dynamic> map =
|
final Map<String, dynamic> map =
|
||||||
IdUtils.matchAvorBv(input: lastPathSegment);
|
IdUtils.matchAvorBv(input: lastPathSegment);
|
||||||
if (map.containsKey('AV')) {
|
if (map.containsKey('AV')) {
|
||||||
_videoPush(map['AV']! as int, null);
|
videoPush(map['AV']! as int, null);
|
||||||
} else if (map.containsKey('BV')) {
|
} else if (map.containsKey('BV')) {
|
||||||
_videoPush(null, map['BV'] as String);
|
videoPush(null, map['BV'] as String);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('投稿匹配失败');
|
SmartDialog.showToast('投稿匹配失败');
|
||||||
}
|
}
|
||||||
} else if (lastPathSegment.startsWith('ep')) {
|
} else if (lastPathSegment.startsWith('ep')) {
|
||||||
_handleEpisodePath(lastPathSegment, redirectUrl);
|
handleEpisodePath(lastPathSegment, redirectUrl);
|
||||||
} else if (lastPathSegment.startsWith('ss')) {
|
} else if (lastPathSegment.startsWith('ss')) {
|
||||||
_handleSeasonPath(lastPathSegment, redirectUrl);
|
handleSeasonPath(lastPathSegment, redirectUrl);
|
||||||
} else if (lastPathSegment.startsWith('BV')) {
|
} else if (lastPathSegment.startsWith('BV')) {
|
||||||
UrlUtils.matchUrlPush(
|
UrlUtils.matchUrlPush(
|
||||||
lastPathSegment,
|
lastPathSegment,
|
||||||
@@ -231,19 +232,25 @@ class PiliSchame {
|
|||||||
switch (area) {
|
switch (area) {
|
||||||
case 'bangumi':
|
case 'bangumi':
|
||||||
print('番剧');
|
print('番剧');
|
||||||
if (area.startsWith('ep')) {
|
for (var pathSegment in pathPart) {
|
||||||
_bangumiPush(null, matchNum(area).first);
|
if (pathSegment.startsWith('ss')) {
|
||||||
} else if (area.startsWith('ss')) {
|
print(pathSegment);
|
||||||
_bangumiPush(matchNum(area).first, null);
|
bangumiPush(matchNum(pathSegment).first, null);
|
||||||
|
break;
|
||||||
|
} else if (pathSegment.startsWith('ep')) {
|
||||||
|
print(pathSegment);
|
||||||
|
bangumiPush(null, matchNum(pathSegment).first);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
print('投稿');
|
print('投稿');
|
||||||
final Map<String, dynamic> map = IdUtils.matchAvorBv(input: path);
|
final Map<String, dynamic> map = IdUtils.matchAvorBv(input: path);
|
||||||
if (map.containsKey('AV')) {
|
if (map.containsKey('AV')) {
|
||||||
_videoPush(map['AV']! as int, null);
|
videoPush(map['AV']! as int, null);
|
||||||
} else if (map.containsKey('BV')) {
|
} else if (map.containsKey('BV')) {
|
||||||
_videoPush(null, map['BV'] as String);
|
videoPush(null, map['BV'] as String);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('投稿匹配失败');
|
SmartDialog.showToast('投稿匹配失败');
|
||||||
}
|
}
|
||||||
@@ -270,9 +277,9 @@ class PiliSchame {
|
|||||||
default:
|
default:
|
||||||
var res = IdUtils.matchAvorBv(input: area.split('?').first);
|
var res = IdUtils.matchAvorBv(input: area.split('?').first);
|
||||||
if (res.containsKey('AV')) {
|
if (res.containsKey('AV')) {
|
||||||
_videoPush(res['AV']! as int, null);
|
videoPush(res['AV']! as int, null);
|
||||||
} else if (res.containsKey('BV')) {
|
} else if (res.containsKey('BV')) {
|
||||||
_videoPush(null, res['BV'] as String);
|
videoPush(null, res['BV'] as String);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast('未知路径或匹配错误:${value.dataString},先采用浏览器打开');
|
SmartDialog.showToast('未知路径或匹配错误:${value.dataString},先采用浏览器打开');
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
@@ -295,17 +302,17 @@ class PiliSchame {
|
|||||||
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleEpisodePath(String lastPathSegment, String redirectUrl) {
|
static void handleEpisodePath(String lastPathSegment, String redirectUrl) {
|
||||||
final String seasonId = _extractIdFromPath(lastPathSegment);
|
final String seasonId = extractIdFromPath(lastPathSegment);
|
||||||
_bangumiPush(null, matchNum(seasonId).first);
|
bangumiPush(null, matchNum(seasonId).first);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleSeasonPath(String lastPathSegment, String redirectUrl) {
|
static void handleSeasonPath(String lastPathSegment, String redirectUrl) {
|
||||||
final String seasonId = _extractIdFromPath(lastPathSegment);
|
final String seasonId = extractIdFromPath(lastPathSegment);
|
||||||
_bangumiPush(matchNum(seasonId).first, null);
|
bangumiPush(matchNum(seasonId).first, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String _extractIdFromPath(String lastPathSegment) {
|
static String extractIdFromPath(String lastPathSegment) {
|
||||||
return lastPathSegment.split('/').last;
|
return lastPathSegment.split('/').last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user