mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: rcmd(app)/hot: filter zone
Closes #119 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -144,6 +144,12 @@ class VideoHttp {
|
|||||||
(!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) &&
|
(!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) &&
|
||||||
(i['args'] != null &&
|
(i['args'] != null &&
|
||||||
!blackMidsList.contains(i['args']['up_id']))) {
|
!blackMidsList.contains(i['args']['up_id']))) {
|
||||||
|
String banWordForZone = GStorage.banWordForZone;
|
||||||
|
if (banWordForZone.isNotEmpty &&
|
||||||
|
RegExp(banWordForZone, caseSensitive: false)
|
||||||
|
.hasMatch(i['args']['rname'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RecVideoItemAppModel videoItem = RecVideoItemAppModel.fromJson(i);
|
RecVideoItemAppModel videoItem = RecVideoItemAppModel.fromJson(i);
|
||||||
if (!RecommendFilter.filter(videoItem)) {
|
if (!RecommendFilter.filter(videoItem)) {
|
||||||
list.add(videoItem);
|
list.add(videoItem);
|
||||||
@@ -171,6 +177,12 @@ class VideoHttp {
|
|||||||
!RecommendFilter.filterTitle(i['title']) &&
|
!RecommendFilter.filterTitle(i['title']) &&
|
||||||
!RecommendFilter.filterLikeRatio(
|
!RecommendFilter.filterLikeRatio(
|
||||||
i['stat']['like'], i['stat']['view'])) {
|
i['stat']['like'], i['stat']['view'])) {
|
||||||
|
String banWordForZone = GStorage.banWordForZone;
|
||||||
|
if (banWordForZone.isNotEmpty &&
|
||||||
|
RegExp(banWordForZone, caseSensitive: false)
|
||||||
|
.hasMatch(i['tname'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
list.add(HotVideoItemModel.fromJson(i));
|
list.add(HotVideoItemModel.fromJson(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1149,66 +1149,15 @@ List<SettingsModel> get recommendSettings => [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsModel(
|
getBanwordModel(
|
||||||
settingsType: SettingsType.normal,
|
|
||||||
leading: const Icon(Icons.title_outlined),
|
|
||||||
title: '标题关键词过滤',
|
title: '标题关键词过滤',
|
||||||
getSubtitle: () {
|
key: SettingBoxKey.banWordForRecommend,
|
||||||
String banWordForRecommend = GStorage.banWordForRecommend;
|
getBanWord: () => GStorage.banWordForRecommend,
|
||||||
return banWordForRecommend.isEmpty ? "点击添加" : banWordForRecommend;
|
),
|
||||||
},
|
getBanwordModel(
|
||||||
onTap: (setState) async {
|
title: '推荐(app端)/热门: 视频分区关键词过滤',
|
||||||
String banWordForRecommend = GStorage.banWordForRecommend;
|
key: SettingBoxKey.banWordForZone,
|
||||||
await showDialog(
|
getBanWord: () => GStorage.banWordForZone,
|
||||||
context: Get.context!,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text(
|
|
||||||
'标题关键词过滤',
|
|
||||||
style: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text('使用|隔开,如:尝试|测试'),
|
|
||||||
TextFormField(
|
|
||||||
autofocus: true,
|
|
||||||
initialValue: banWordForRecommend,
|
|
||||||
textInputAction: TextInputAction.newline,
|
|
||||||
minLines: 1,
|
|
||||||
maxLines: 4,
|
|
||||||
onChanged: (value) => banWordForRecommend = value,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: Get.back,
|
|
||||||
child: Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('保存'),
|
|
||||||
onPressed: () async {
|
|
||||||
Get.back();
|
|
||||||
await GStorage.setting.put(
|
|
||||||
SettingBoxKey.banWordForRecommend,
|
|
||||||
banWordForRecommend,
|
|
||||||
);
|
|
||||||
setState();
|
|
||||||
RecommendFilter.update();
|
|
||||||
SmartDialog.showToast('已保存');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.normal,
|
settingsType: SettingsType.normal,
|
||||||
@@ -1665,65 +1614,10 @@ List<SettingsModel> get extraSettings => [
|
|||||||
setKey: SettingBoxKey.horizontalPreview,
|
setKey: SettingBoxKey.horizontalPreview,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
SettingsModel(
|
getBanwordModel(
|
||||||
settingsType: SettingsType.normal,
|
|
||||||
leading: const Icon(Icons.filter_alt_outlined),
|
|
||||||
title: '评论关键词过滤',
|
title: '评论关键词过滤',
|
||||||
getSubtitle: () {
|
key: SettingBoxKey.banWordForReply,
|
||||||
String banWordForReply = GStorage.banWordForReply;
|
getBanWord: () => GStorage.banWordForReply,
|
||||||
return banWordForReply.isEmpty ? "点击添加" : banWordForReply;
|
|
||||||
},
|
|
||||||
onTap: (setState) async {
|
|
||||||
String banWordForReply = GStorage.banWordForReply;
|
|
||||||
await showDialog(
|
|
||||||
context: Get.context!,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text(
|
|
||||||
'评论关键词过滤',
|
|
||||||
style: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text('使用|隔开,如:尝试|测试'),
|
|
||||||
TextFormField(
|
|
||||||
autofocus: true,
|
|
||||||
initialValue: banWordForReply,
|
|
||||||
textInputAction: TextInputAction.newline,
|
|
||||||
minLines: 1,
|
|
||||||
maxLines: 4,
|
|
||||||
onChanged: (value) => banWordForReply = value,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: Get.back,
|
|
||||||
child: Text(
|
|
||||||
'取消',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.outline),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: const Text('保存'),
|
|
||||||
onPressed: () async {
|
|
||||||
Get.back();
|
|
||||||
await GStorage.setting.put(
|
|
||||||
SettingBoxKey.banWordForReply,
|
|
||||||
banWordForReply,
|
|
||||||
);
|
|
||||||
setState();
|
|
||||||
SmartDialog.showToast('已保存');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
SettingsModel(
|
SettingsModel(
|
||||||
settingsType: SettingsType.sw1tch,
|
settingsType: SettingsType.sw1tch,
|
||||||
@@ -1971,3 +1865,70 @@ List<SettingsModel> get extraSettings => [
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
SettingsModel getBanwordModel({
|
||||||
|
required String title,
|
||||||
|
required String key,
|
||||||
|
required Function getBanWord,
|
||||||
|
}) {
|
||||||
|
return SettingsModel(
|
||||||
|
settingsType: SettingsType.normal,
|
||||||
|
leading: const Icon(Icons.filter_alt_outlined),
|
||||||
|
title: title,
|
||||||
|
getSubtitle: () {
|
||||||
|
String banWord = getBanWord();
|
||||||
|
return banWord.isEmpty ? "点击添加" : banWord;
|
||||||
|
},
|
||||||
|
onTap: (setState) async {
|
||||||
|
String banWord = getBanWord();
|
||||||
|
await showDialog(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('使用|隔开,如:尝试|测试'),
|
||||||
|
TextFormField(
|
||||||
|
autofocus: true,
|
||||||
|
initialValue: banWord,
|
||||||
|
textInputAction: TextInputAction.newline,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 4,
|
||||||
|
onChanged: (value) => banWord = value,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: Get.back,
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('保存'),
|
||||||
|
onPressed: () async {
|
||||||
|
Get.back();
|
||||||
|
await GStorage.setting.put(
|
||||||
|
key,
|
||||||
|
banWord,
|
||||||
|
);
|
||||||
|
setState();
|
||||||
|
SmartDialog.showToast('已保存');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ class GStorage {
|
|||||||
static String get banWordForReply =>
|
static String get banWordForReply =>
|
||||||
setting.get(SettingBoxKey.banWordForReply, defaultValue: '');
|
setting.get(SettingBoxKey.banWordForReply, defaultValue: '');
|
||||||
|
|
||||||
|
static String get banWordForZone =>
|
||||||
|
setting.get(SettingBoxKey.banWordForZone, defaultValue: '');
|
||||||
|
|
||||||
static int get minLikeRatioForRecommend =>
|
static int get minLikeRatioForRecommend =>
|
||||||
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
|
||||||
|
|
||||||
@@ -522,6 +525,7 @@ class SettingBoxKey {
|
|||||||
cdnSpeedTest = 'cdnSpeedTest',
|
cdnSpeedTest = 'cdnSpeedTest',
|
||||||
horizontalPreview = 'horizontalPreview',
|
horizontalPreview = 'horizontalPreview',
|
||||||
banWordForReply = 'banWordForReply',
|
banWordForReply = 'banWordForReply',
|
||||||
|
banWordForZone = 'banWordForZone',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user