mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-17 14:50:12 +08:00
opt: webview to video
Closes #209 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -9,11 +9,11 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
|
||||
class SearchPanelController extends CommonController {
|
||||
SearchPanelController({
|
||||
this.keyword,
|
||||
required this.keyword,
|
||||
required this.searchType,
|
||||
required this.tag,
|
||||
});
|
||||
String? keyword;
|
||||
String keyword;
|
||||
SearchType searchType;
|
||||
// 结果排序方式 搜索类型为视频、专栏及相簿时
|
||||
RxString order = ''.obs;
|
||||
@@ -99,7 +99,7 @@ class SearchPanelController extends CommonController {
|
||||
@override
|
||||
Future<LoadingState> customGetData() => SearchHttp.searchByType(
|
||||
searchType: searchType,
|
||||
keyword: keyword!,
|
||||
keyword: keyword,
|
||||
page: currentPage,
|
||||
order: order.value,
|
||||
duration: searchType.name != 'video' ? null : duration.value,
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'widgets/media_bangumi_panel.dart';
|
||||
import 'widgets/user_panel.dart';
|
||||
|
||||
class SearchPanel extends StatefulWidget {
|
||||
final String? keyword;
|
||||
final String keyword;
|
||||
final SearchType searchType;
|
||||
final String tag;
|
||||
const SearchPanel({
|
||||
@@ -46,7 +46,7 @@ class _SearchPanelState extends State<SearchPanel>
|
||||
searchType: widget.searchType,
|
||||
tag: widget.tag,
|
||||
),
|
||||
tag: widget.searchType.name + widget.keyword!,
|
||||
tag: widget.searchType.name + widget.keyword,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ class ArticlePanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'article${searchPanelCtr.keyword!}');
|
||||
tag: 'article${searchPanelCtr.keyword}');
|
||||
ctr.order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
@@ -321,7 +321,7 @@ class ArticlePanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'article${searchPanelCtr.keyword!}');
|
||||
tag: 'article${searchPanelCtr.keyword}');
|
||||
ctr.categoryId = item['categoryId'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
|
||||
@@ -214,7 +214,7 @@ class UserPanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'bili_user${searchPanelCtr.keyword!}');
|
||||
tag: 'bili_user${searchPanelCtr.keyword}');
|
||||
ctr.orderSort = item['orderSort'];
|
||||
ctr.order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
@@ -249,7 +249,7 @@ class UserPanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'bili_user${searchPanelCtr.keyword!}');
|
||||
tag: 'bili_user${searchPanelCtr.keyword}');
|
||||
ctr.userType = item['userType'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
|
||||
@@ -277,7 +277,7 @@ class VideoPanelController extends GetxController {
|
||||
SmartDialog.dismiss();
|
||||
// SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr = Get.find<SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
tag: 'video${searchPanelCtr.keyword}');
|
||||
ctr.pubBegin = DateTime(
|
||||
pubBegin.year,
|
||||
pubBegin.month,
|
||||
@@ -345,7 +345,7 @@ class VideoPanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
tag: 'video${searchPanelCtr.keyword}');
|
||||
DateTime now = DateTime.now();
|
||||
if (item['value'] == 0) {
|
||||
ctr.pubBegin = null;
|
||||
@@ -424,7 +424,7 @@ class VideoPanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
tag: 'video${searchPanelCtr.keyword}');
|
||||
ctr.duration.value = item['value'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
@@ -462,7 +462,7 @@ class VideoPanelController extends GetxController {
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
SearchPanelController ctr =
|
||||
Get.find<SearchPanelController>(
|
||||
tag: 'video${searchPanelCtr.keyword!}');
|
||||
tag: 'video${searchPanelCtr.keyword}');
|
||||
ctr.tids = item['tids'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await ctr.onRefresh();
|
||||
|
||||
@@ -2,16 +2,8 @@ import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SearchResultController extends GetxController {
|
||||
String? keyword;
|
||||
String keyword = Get.parameters['keyword'] ?? '';
|
||||
|
||||
RxList<int> count =
|
||||
List.generate(SearchType.values.length, (_) => -1).toList().obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
if (Get.parameters.keys.isNotEmpty) {
|
||||
keyword = Get.parameters['keyword'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
'${_searchResultController.keyword}',
|
||||
_searchResultController.keyword,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
@@ -110,7 +110,7 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
if (_tabController.indexIsChanging.not) {
|
||||
Get.find<SearchPanelController>(
|
||||
tag: SearchType.values[index].name +
|
||||
_searchResultController.keyword!)
|
||||
_searchResultController.keyword)
|
||||
.animateToTop();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -198,35 +198,38 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||
final String? str =
|
||||
navigationAction.request.url!.pathSegments.getOrNull(0);
|
||||
final Map matchRes = IdUtils.matchAvorBv(input: str);
|
||||
final List matchKeys = matchRes.keys.toList();
|
||||
if (matchKeys.isNotEmpty) {
|
||||
if (matchKeys.first == 'BV') {
|
||||
Get.offAndToNamed(
|
||||
'/searchResult',
|
||||
parameters: {'keyword': matchRes['BV']},
|
||||
);
|
||||
if (str != null) {
|
||||
final Map matchRes = IdUtils.matchAvorBv(input: str);
|
||||
if (matchRes.isNotEmpty) {
|
||||
Get.back();
|
||||
PiliScheme.videoPush(matchRes['AV'], matchRes['BV']);
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
}
|
||||
|
||||
var url = navigationAction.request.url!.toString();
|
||||
|
||||
if (url.startsWith('http')) {
|
||||
if (RegExp(r'https://www.bilibili.com/video/BV[a-zA-Z\d]+')
|
||||
.hasMatch(url)) {
|
||||
PiliScheme.routePush(Uri.parse(url));
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
} else if (url.startsWith('http://m.bilibili.com/playlist/')) {
|
||||
try {
|
||||
String? bvid =
|
||||
RegExp(r'bvid=(BV[a-zA-Z\d]+)').firstMatch(url)?.group(1);
|
||||
if (bvid != null) {
|
||||
PiliScheme.videoPush(null, bvid);
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
if (RegExp(
|
||||
r'^(https?://)?((www|m).)?(bilibili|b23).(com|tv)/video/BV[a-zA-Z\d]+')
|
||||
.hasMatch(url)) {
|
||||
try {
|
||||
String? bvid =
|
||||
RegExp(r'BV[a-zA-Z\d]+').firstMatch(url)?.group(0);
|
||||
if (bvid != null) {
|
||||
Get.back();
|
||||
PiliScheme.videoPush(null, bvid);
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
} catch (_) {}
|
||||
} else if (url.startsWith('http://m.bilibili.com/playlist/')) {
|
||||
try {
|
||||
String? bvid =
|
||||
RegExp(r'bvid=(BV[a-zA-Z\d]+)').firstMatch(url)?.group(1);
|
||||
if (bvid != null) {
|
||||
PiliScheme.videoPush(null, bvid);
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
} catch (_) {}
|
||||
} else {
|
||||
if (url.startsWith('bilibili://video/')) {
|
||||
String? str = Uri.parse(url).pathSegments.getOrNull(0);
|
||||
|
||||
Reference in New Issue
Block a user