mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 16:48:16 +08:00
@@ -1,4 +1,6 @@
|
|||||||
import 'dart:async';
|
// ignore_for_file: constant_identifier_names
|
||||||
|
|
||||||
|
import 'dart:async' show StreamSubscription;
|
||||||
|
|
||||||
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
|
import 'package:PiliPlus/common/widgets/view_safe_area.dart';
|
||||||
import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pbenum.dart'
|
import 'package:PiliPlus/grpc/bilibili/app/listener/v1.pbenum.dart'
|
||||||
@@ -324,7 +326,7 @@ abstract final class PiliScheme {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case 'm.bilibili.com':
|
case bilibili_m:
|
||||||
// bilibili://m.bilibili.com/topic-detail?topic_id=1028161&frommodule=H5&h5awaken=xxx
|
// bilibili://m.bilibili.com/topic-detail?topic_id=1028161&frommodule=H5&h5awaken=xxx
|
||||||
final id = uri.queryParameters['topic_id'];
|
final id = uri.queryParameters['topic_id'];
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@@ -434,6 +436,15 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const b23_tv = 'b23.tv';
|
||||||
|
static const bilibili = 'bilibili.com';
|
||||||
|
static const bilibili_m = 'm.bilibili.com';
|
||||||
|
static const bilibili_t = 't.bilibili.com';
|
||||||
|
static const bilibili_live = 'live.bilibili.com';
|
||||||
|
static const bilibili_space = 'space.bilibili.com';
|
||||||
|
static const bilibili_search = 'search.bilibili.com';
|
||||||
|
static const bilibili_music = 'music.bilibili.com';
|
||||||
|
|
||||||
static Future<bool> _fullPathPush(
|
static Future<bool> _fullPathPush(
|
||||||
Uri uri, {
|
Uri uri, {
|
||||||
bool selfHandle = false,
|
bool selfHandle = false,
|
||||||
@@ -445,34 +456,25 @@ abstract final class PiliScheme {
|
|||||||
|
|
||||||
String host = uri.host;
|
String host = uri.host;
|
||||||
|
|
||||||
if (selfHandle &&
|
|
||||||
!host.contains('bilibili.com') &&
|
|
||||||
!host.contains('b23.tv')) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void launchURL() {
|
void launchURL() {
|
||||||
if (!selfHandle) {
|
if (!selfHandle) {
|
||||||
_toWebview(uri.toString(), off, parameters);
|
_toWebview(uri.toString(), off, parameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// b23.tv
|
if (!host.contains(bilibili) && !host.contains(b23_tv)) {
|
||||||
// bilibili.com
|
launchURL();
|
||||||
// m.bilibili.com
|
return false;
|
||||||
// www.bilibili.com
|
}
|
||||||
// space.bilibili.com
|
|
||||||
// live.bilibili.com
|
|
||||||
// search.bilibili.com
|
|
||||||
|
|
||||||
// redirect
|
// redirect
|
||||||
if (host.contains('b23.tv')) {
|
if (host.contains(b23_tv)) {
|
||||||
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;
|
host = uri.host;
|
||||||
}
|
}
|
||||||
if (!host.contains('bilibili.com')) {
|
if (!host.contains(bilibili)) {
|
||||||
launchURL();
|
launchURL();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -481,7 +483,7 @@ abstract final class PiliScheme {
|
|||||||
final String path = uri.path;
|
final String path = uri.path;
|
||||||
late final queryParameters = uri.queryParameters;
|
late final queryParameters = uri.queryParameters;
|
||||||
|
|
||||||
if (host.contains('t.bilibili.com')) {
|
if (host.contains(bilibili_t)) {
|
||||||
if (_onPushDynDetail(uri, off)) {
|
if (_onPushDynDetail(uri, off)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (path.startsWith('/vote')) {
|
} else if (path.startsWith('/vote')) {
|
||||||
@@ -498,7 +500,7 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
launchURL();
|
launchURL();
|
||||||
return false;
|
return false;
|
||||||
} else if (host.contains('live.bilibili.com')) {
|
} else if (host.contains(bilibili_live)) {
|
||||||
String? roomId = uriDigitRegExp.firstMatch(path)?.group(1);
|
String? roomId = uriDigitRegExp.firstMatch(path)?.group(1);
|
||||||
if (roomId != null) {
|
if (roomId != null) {
|
||||||
PageUtils.toLiveRoom(int.parse(roomId), off: off);
|
PageUtils.toLiveRoom(int.parse(roomId), off: off);
|
||||||
@@ -506,7 +508,7 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
launchURL();
|
launchURL();
|
||||||
return false;
|
return false;
|
||||||
} else if (host.contains('space.bilibili.com')) {
|
} else if (host.contains(bilibili_space)) {
|
||||||
void toType({
|
void toType({
|
||||||
required String mid,
|
required String mid,
|
||||||
required String? type,
|
required String? type,
|
||||||
@@ -556,7 +558,7 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
launchURL();
|
launchURL();
|
||||||
return false;
|
return false;
|
||||||
} else if (host.contains('search.bilibili.com')) {
|
} else if (host.contains(bilibili_search)) {
|
||||||
String? keyword = uri.queryParameters['keyword'];
|
String? keyword = uri.queryParameters['keyword'];
|
||||||
if (keyword != null) {
|
if (keyword != null) {
|
||||||
PageUtils.toDupNamed(
|
PageUtils.toDupNamed(
|
||||||
@@ -568,7 +570,7 @@ abstract final class PiliScheme {
|
|||||||
}
|
}
|
||||||
launchURL();
|
launchURL();
|
||||||
return false;
|
return false;
|
||||||
} else if (host.contains('music.bilibili.com')) {
|
} else if (host.contains(bilibili_music)) {
|
||||||
// music.bilibili.com/pc/music-detail?music_id=MA***
|
// music.bilibili.com/pc/music-detail?music_id=MA***
|
||||||
// music.bilibili.com/h5-music-detail?music_id=MA***
|
// music.bilibili.com/h5-music-detail?music_id=MA***
|
||||||
if (path.contains('music-detail')) {
|
if (path.contains('music-detail')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user