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

View File

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

View File

@@ -22,6 +22,19 @@ import '../models/github/latest.dart';
class Utils {
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) {
Clipboard.setData(ClipboardData(text: text));
SmartDialog.showToast('已复制');