mod: scheme (#804)

This commit is contained in:
My-Responsitories
2025-05-03 09:56:21 +08:00
committed by GitHub
parent 36bf6f4ceb
commit b7b3460248

View File

@@ -67,7 +67,7 @@ class PiliScheme {
int? oid, int? oid,
}) async { }) async {
final String scheme = uri.scheme; final String scheme = uri.scheme;
final String host = uri.host.toLowerCase(); final String host = uri.host;
final String path = uri.path; final String path = uri.path;
switch (scheme) { switch (scheme) {
@@ -207,12 +207,16 @@ class PiliScheme {
bool hasMatch = await _onPushDynDetail(path, off); bool hasMatch = await _onPushDynDetail(path, off);
return hasMatch; return hasMatch;
case 'search': case 'search':
PageUtils.toDupNamed( final keyword = uri.queryParameters['keyword'];
'/searchResult', if (keyword != null) {
parameters: {'keyword': ''}, PageUtils.toDupNamed(
off: off, '/searchResult',
); parameters: {'keyword': keyword},
return true; off: off,
);
return true;
}
return false;
case 'article': case 'article':
// bilibili://article/40679479?jump_opus=1&jump_opus_type=1&opus_type=article&h5awaken=random // bilibili://article/40679479?jump_opus=1&jump_opus_type=1&opus_type=article&h5awaken=random
String? id = uriDigitRegExp.firstMatch(path)?.group(1); String? id = uriDigitRegExp.firstMatch(path)?.group(1);
@@ -434,6 +438,14 @@ class PiliScheme {
return true; return true;
} }
return false; return false;
// bilibili://browser/?url=https%3A%2F%2Fwww.bilibili.com%2F
case 'browser':
final url = uri.queryParameters['url'];
if (url != null) {
_toWebview(url, off, parameters);
return true;
}
return false;
default: default:
if (selfHandle.not) { if (selfHandle.not) {
debugPrint('$uri'); debugPrint('$uri');
@@ -480,7 +492,7 @@ class PiliScheme {
// 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
String host = uri.host.toLowerCase(); String host = uri.host;
if (selfHandle && if (selfHandle &&
host.contains('bilibili.com').not && host.contains('bilibili.com').not &&
@@ -507,7 +519,7 @@ class PiliScheme {
String? redirectUrl = await UrlUtils.parseRedirectUrl(uri.toString()); String? redirectUrl = await UrlUtils.parseRedirectUrl(uri.toString());
if (redirectUrl != null) { if (redirectUrl != null) {
uri = Uri.parse(redirectUrl); uri = Uri.parse(redirectUrl);
host = uri.host.toLowerCase(); host = uri.host;
} }
if (host.contains('bilibili.com').not) { if (host.contains('bilibili.com').not) {
launchURL(); launchURL();