opt: PiliScheme

This commit is contained in:
bggRGjQaUbCoE
2024-10-03 14:47:13 +08:00
parent 712aa39570
commit 5395ca91cd
3 changed files with 60 additions and 39 deletions

View File

@@ -70,44 +70,33 @@ class DynamicsController extends GetxController
initialValue.value = value; initialValue.value = value;
} }
toDupNamed(
String page, {
dynamic arguments,
Map<String, String>? parameters,
}) {
Get.toNamed(
page,
arguments: arguments,
parameters: parameters,
preventDuplicates: false,
);
}
pushDetail(item, floor, {action = 'all'}) async { pushDetail(item, floor, {action = 'all'}) async {
feedBack(); feedBack();
/// 点击评论action 直接查看评论 /// 点击评论action 直接查看评论
if (action == 'comment') { if (action == 'comment') {
toDupNamed('/dynamicDetail', Utils.toDupNamed('/dynamicDetail',
arguments: {'item': item, 'floor': floor, 'action': action}); arguments: {'item': item, 'floor': floor, 'action': action});
return false; return false;
} }
switch (item!.type) { switch (item!.type) {
/// 转发的动态 /// 转发的动态
case 'DYNAMIC_TYPE_FORWARD': case 'DYNAMIC_TYPE_FORWARD':
toDupNamed('/dynamicDetail', arguments: {'item': item, 'floor': floor}); Utils.toDupNamed('/dynamicDetail',
arguments: {'item': item, 'floor': floor});
break; break;
/// 图文动态查看 /// 图文动态查看
case 'DYNAMIC_TYPE_DRAW': case 'DYNAMIC_TYPE_DRAW':
toDupNamed('/dynamicDetail', arguments: {'item': item, 'floor': floor}); Utils.toDupNamed('/dynamicDetail',
arguments: {'item': item, 'floor': floor});
break; break;
case 'DYNAMIC_TYPE_AV': case 'DYNAMIC_TYPE_AV':
String bvid = item.modules.moduleDynamic.major.archive.bvid; String bvid = item.modules.moduleDynamic.major.archive.bvid;
String cover = item.modules.moduleDynamic.major.archive.cover; String cover = item.modules.moduleDynamic.major.archive.cover;
try { try {
int cid = await SearchHttp.ab2c(bvid: bvid); int cid = await SearchHttp.ab2c(bvid: bvid);
toDupNamed('/video?bvid=$bvid&cid=$cid', Utils.toDupNamed('/video?bvid=$bvid&cid=$cid',
arguments: {'pic': cover, 'heroTag': bvid}); arguments: {'pic': cover, 'heroTag': bvid});
} catch (err) { } catch (err) {
SmartDialog.showToast(err.toString()); SmartDialog.showToast(err.toString());
@@ -125,14 +114,14 @@ class DynamicsController extends GetxController
if (url.contains('read')) { if (url.contains('read')) {
number = 'cv$number'; number = 'cv$number';
} }
toDupNamed('/htmlRender', parameters: { Utils.toDupNamed('/htmlRender', parameters: {
'url': url.startsWith('//') ? url.split('//').last : url, 'url': url.startsWith('//') ? url.split('//').last : url,
'title': title, 'title': title,
'id': number, 'id': number,
'dynamicType': url.split('//').last.split('/')[1] 'dynamicType': url.split('//').last.split('/')[1]
}); });
} else { } else {
toDupNamed( Utils.toDupNamed(
'/webviewnew', '/webviewnew',
parameters: { parameters: {
'url': 'https:$url', 'url': 'https:$url',
@@ -151,7 +140,8 @@ class DynamicsController extends GetxController
/// 纯文字动态查看 /// 纯文字动态查看
case 'DYNAMIC_TYPE_WORD': case 'DYNAMIC_TYPE_WORD':
print('纯文本'); print('纯文本');
toDupNamed('/dynamicDetail', arguments: {'item': item, 'floor': floor}); Utils.toDupNamed('/dynamicDetail',
arguments: {'item': item, 'floor': floor});
break; break;
case 'DYNAMIC_TYPE_LIVE_RCMD': case 'DYNAMIC_TYPE_LIVE_RCMD':
DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd; DynamicLiveModel liveRcmd = item.modules.moduleDynamic.major.liveRcmd;
@@ -165,7 +155,7 @@ class DynamicsController extends GetxController
'roomid': liveRcmd.roomId, 'roomid': liveRcmd.roomId,
'watched_show': liveRcmd.watchedShow, 'watched_show': liveRcmd.watchedShow,
}); });
toDupNamed('/liveRoom?roomid=${liveItem.roomId}', arguments: { Utils.toDupNamed('/liveRoom?roomid=${liveItem.roomId}', arguments: {
'liveItem': liveItem, 'liveItem': liveItem,
'heroTag': liveItem.roomId.toString() 'heroTag': liveItem.roomId.toString()
}); });
@@ -179,7 +169,7 @@ class DynamicsController extends GetxController
String bvid = IdUtils.av2bv(aid); String bvid = IdUtils.av2bv(aid);
String cover = ugcSeason.cover!; String cover = ugcSeason.cover!;
int cid = await SearchHttp.ab2c(bvid: bvid); int cid = await SearchHttp.ab2c(bvid: bvid);
toDupNamed('/video?bvid=$bvid&cid=$cid', Utils.toDupNamed('/video?bvid=$bvid&cid=$cid',
arguments: {'pic': cover, 'heroTag': bvid}); arguments: {'pic': cover, 'heroTag': bvid});
break; break;
@@ -207,7 +197,7 @@ class DynamicsController extends GetxController
dynamic cid = episode.cid; dynamic cid = episode.cid;
dynamic pic = episode.cover; dynamic pic = episode.cover;
dynamic heroTag = Utils.makeHeroTag(cid); dynamic heroTag = Utils.makeHeroTag(cid);
toDupNamed( Utils.toDupNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}&epId=$epId', '/video?bvid=$bvid&cid=$cid&seasonId=${res['data'].seasonId}&epId=$epId',
arguments: { arguments: {
'pic': pic, 'pic': pic,

View File

@@ -40,7 +40,7 @@ class PiliScheme {
Get.context!, (Route<dynamic> route) => route.isFirst); Get.context!, (Route<dynamic> route) => route.isFirst);
} else if (host == 'space') { } else if (host == 'space') {
final String mid = path.split('/').last; final String mid = path.split('/').last;
Get.toNamed<dynamic>( Utils.toDupNamed(
'/member?mid=$mid', '/member?mid=$mid',
arguments: <String, dynamic>{'face': null}, arguments: <String, dynamic>{'face': null},
); );
@@ -92,7 +92,7 @@ class PiliScheme {
} }
} else if (host == 'live') { } else if (host == 'live') {
final String roomId = path.split('/').last; final String roomId = path.split('/').last;
Get.toNamed<dynamic>('/liveRoom?roomid=$roomId', Utils.toDupNamed('/liveRoom?roomid=$roomId',
arguments: <String, String?>{'liveItem': null, 'heroTag': roomId}); arguments: <String, String?>{'liveItem': null, 'heroTag': roomId});
} else if (host == 'bangumi') { } else if (host == 'bangumi') {
if (path.startsWith('/season')) { if (path.startsWith('/season')) {
@@ -102,7 +102,7 @@ class PiliScheme {
} else if (host == 'opus') { } else if (host == 'opus') {
if (path.startsWith('/detail')) { if (path.startsWith('/detail')) {
var opusId = path.split('/').last; var opusId = path.split('/').last;
Get.toNamed( Utils.toDupNamed(
'/webviewnew', '/webviewnew',
parameters: { parameters: {
'url': 'https://www.bilibili.com/opus/$opusId', 'url': 'https://www.bilibili.com/opus/$opusId',
@@ -112,10 +112,10 @@ class PiliScheme {
); );
} }
} else if (host == 'search') { } else if (host == 'search') {
Get.toNamed('/searchResult', parameters: {'keyword': ''}); Utils.toDupNamed('/searchResult', parameters: {'keyword': ''});
} else if (host == 'article') { } else if (host == 'article') {
final String id = path.split('/').last.split('?').first; final String id = path.split('/').last.split('?').first;
Get.toNamed( Utils.toDupNamed(
'/htmlRender', '/htmlRender',
parameters: { parameters: {
'url': 'www.bilibili.com/read/cv$id', 'url': 'www.bilibili.com/read/cv$id',
@@ -169,7 +169,7 @@ class PiliScheme {
} else if (host == 'following' && path.startsWith("/detail/")) { } else if (host == 'following' && path.startsWith("/detail/")) {
void getToOpusWeb() { void getToOpusWeb() {
var opusId = path.split('/').last; var opusId = path.split('/').last;
Get.toNamed( Utils.toDupNamed(
'/webviewnew', '/webviewnew',
parameters: { parameters: {
'url': 'https://m.bilibili.com/dynamic/$opusId', 'url': 'https://m.bilibili.com/dynamic/$opusId',
@@ -213,7 +213,7 @@ class PiliScheme {
} else { } else {
print(value); print(value);
SmartDialog.showToast('未知路径:$value,请截图反馈给开发者'); SmartDialog.showToast('未知路径:$value,请截图反馈给开发者');
// Get.toNamed( //Utils.toDupNamed(
// '/webviewnew', // '/webviewnew',
// parameters: { // parameters: {
// 'url': value.dataString ?? "", // 'url': value.dataString ?? "",
@@ -224,6 +224,18 @@ class PiliScheme {
} }
} else if (scheme == 'https') { } else if (scheme == 'https') {
fullPathPush(value); fullPathPush(value);
} else if (path.toLowerCase().startsWith('av')) {
try {
videoPush(int.parse(path.substring(2)), null);
} catch (e) {
debugPrint(e.toString());
}
} else if (path.toLowerCase().startsWith('bv')) {
try {
videoPush(null, path);
} catch (e) {
debugPrint(e.toString());
}
} }
} }
@@ -242,13 +254,12 @@ class PiliScheme {
final int cid = await SearchHttp.ab2c(bvid: bvidVal, aid: aidVal); final int cid = await SearchHttp.ab2c(bvid: bvidVal, aid: aidVal);
SmartDialog.dismiss(); SmartDialog.dismiss();
final String heroTag = Utils.makeHeroTag(aid); final String heroTag = Utils.makeHeroTag(aid);
Get.toNamed<dynamic>( Utils.toDupNamed(
'/video?bvid=$bvid&cid=$cid', '/video?bvid=$bvid&cid=$cid',
arguments: <String, String?>{ arguments: <String, String?>{
'pic': null, 'pic': null,
'heroTag': heroTag, 'heroTag': heroTag,
}, },
preventDuplicates: false,
); );
} catch (e) { } catch (e) {
SmartDialog.dismiss(); SmartDialog.dismiss();
@@ -269,7 +280,7 @@ class PiliScheme {
final String heroTag = Utils.makeHeroTag(cid); final String heroTag = Utils.makeHeroTag(cid);
var epId = bangumiDetail.episodes!.first.id; var epId = bangumiDetail.episodes!.first.id;
SmartDialog.dismiss().then( SmartDialog.dismiss().then(
(e) => Get.toNamed( (e) => Utils.toDupNamed(
'/video?bvid=$bvid&cid=$cid&seasonId=$seasonId&epId=$epId', '/video?bvid=$bvid&cid=$cid&seasonId=$seasonId&epId=$epId',
arguments: <String, dynamic>{ arguments: <String, dynamic>{
'pic': bangumiDetail.cover, 'pic': bangumiDetail.cover,
@@ -298,14 +309,14 @@ class PiliScheme {
print('bilibili.com'); print('bilibili.com');
} else if (host.contains('live')) { } else if (host.contains('live')) {
int roomId = int.parse(path!.split('/').last); int roomId = int.parse(path!.split('/').last);
Get.toNamed( Utils.toDupNamed(
'/liveRoom?roomid=$roomId', '/liveRoom?roomid=$roomId',
arguments: {'liveItem': null, 'heroTag': roomId.toString()}, arguments: {'liveItem': null, 'heroTag': roomId.toString()},
); );
return; return;
} else if (host.contains('space')) { } else if (host.contains('space')) {
var mid = path!.split('/').last; var mid = path!.split('/').last;
Get.toNamed('/member?mid=$mid', arguments: {'face': ''}); Utils.toDupNamed('/member?mid=$mid', arguments: {'face': ''});
return; return;
} else if (host == 'b23.tv') { } else if (host == 'b23.tv') {
final String fullPath = 'https://$host$path'; final String fullPath = 'https://$host$path';
@@ -334,7 +345,7 @@ class PiliScheme {
redirectUrl, redirectUrl,
); );
} else { } else {
Get.toNamed( Utils.toDupNamed(
'/webviewnew', '/webviewnew',
parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''}, parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''},
); );
@@ -344,6 +355,13 @@ class PiliScheme {
if (path != null) { if (path != null) {
List<String> pathPart = path.split('/'); List<String> pathPart = path.split('/');
if (pathPart.length < 3) {
Utils.toDupNamed(
'/webviewnew',
parameters: {'url': value.toString()},
);
return;
}
final String area = pathPart[1] == 'mobile' ? pathPart[2] : pathPart[1]; final String area = pathPart[1] == 'mobile' ? pathPart[2] : pathPart[1];
switch (area) { switch (area) {
case 'bangumi': case 'bangumi':
@@ -379,7 +397,7 @@ class PiliScheme {
} else { } else {
id = 'cv${matchNum(path).first}'; id = 'cv${matchNum(path).first}';
} }
Get.toNamed('/htmlRender', parameters: { Utils.toDupNamed('/htmlRender', parameters: {
'url': value.toString(), 'url': value.toString(),
'title': '', 'title': '',
'id': id, 'id': id,
@@ -388,7 +406,7 @@ class PiliScheme {
break; break;
case 'space': case 'space':
print('个人空间'); print('个人空间');
Get.toNamed('/member?mid=$area', arguments: {'face': ''}); Utils.toDupNamed('/member?mid=$area', arguments: {'face': ''});
break; break;
default: default:
var res = IdUtils.matchAvorBv(input: area.split('?').first); var res = IdUtils.matchAvorBv(input: area.split('?').first);
@@ -398,7 +416,7 @@ class PiliScheme {
videoPush(null, res['BV'] as String); videoPush(null, res['BV'] as String);
} else { } else {
SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开'); SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开');
Get.toNamed( Utils.toDupNamed(
'/webviewnew', '/webviewnew',
parameters: { parameters: {
'url': value.toString(), 'url': value.toString(),

View File

@@ -22,6 +22,19 @@ import '../models/github/latest.dart';
class Utils { class Utils {
static final Random random = Random(); static final Random random = Random();
static void toDupNamed(
String page, {
dynamic arguments,
Map<String, String>? parameters,
}) {
Get.toNamed(
page,
arguments: arguments,
parameters: parameters,
preventDuplicates: false,
);
}
static void copyText(String text) { static void copyText(String text) {
Clipboard.setData(ClipboardData(text: text)); Clipboard.setData(ClipboardData(text: text));
SmartDialog.showToast('已复制'); SmartDialog.showToast('已复制');