mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 弹幕过滤规则与黑名单从Setting移至LocalCache
This commit is contained in:
@@ -262,14 +262,14 @@ class VideoPopupMenu extends StatelessWidget {
|
||||
act: 5,
|
||||
reSrc: 11,
|
||||
);
|
||||
List<int> blackMidsList = GStorage.setting
|
||||
.get(SettingBoxKey.blackMidsList,
|
||||
List<int> blackMidsList = GStorage.localCache
|
||||
.get(LocalCacheKey.blackMidsList,
|
||||
defaultValue: [-1])
|
||||
.map<int>((i) => i as int)
|
||||
.toList();
|
||||
blackMidsList.insert(0, videoItem.owner.mid);
|
||||
GStorage.setting
|
||||
.put(SettingBoxKey.blackMidsList, blackMidsList);
|
||||
GStorage.localCache
|
||||
.put(LocalCacheKey.blackMidsList, blackMidsList);
|
||||
Get.back();
|
||||
SmartDialog.showToast(res['msg'] ?? '成功');
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import '../utils/storage.dart';
|
||||
import 'index.dart';
|
||||
|
||||
class SearchHttp {
|
||||
static Box setting = GStorage.setting;
|
||||
static Box localCache = GStorage.localCache;
|
||||
static Future hotSearchList() async {
|
||||
var res = await Request().get(Api.hotSearchList);
|
||||
if (res.data is String) {
|
||||
@@ -89,8 +89,8 @@ class SearchHttp {
|
||||
try {
|
||||
switch (searchType) {
|
||||
case SearchType.video:
|
||||
List<int> blackMidsList = setting
|
||||
.get(SettingBoxKey.blackMidsList, defaultValue: [-1])
|
||||
List<int> blackMidsList = localCache
|
||||
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
|
||||
.map<int>((i) => i as int)
|
||||
.toList();
|
||||
for (var i in res.data['data']['result']) {
|
||||
|
||||
@@ -46,8 +46,8 @@ class VideoHttp {
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<RecVideoItemModel> list = [];
|
||||
List<int> blackMidsList = setting
|
||||
.get(SettingBoxKey.blackMidsList, defaultValue: [-1])
|
||||
List<int> blackMidsList = localCache
|
||||
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
|
||||
.map<int>((e) => e as int)
|
||||
.toList();
|
||||
for (var i in res.data['data']['item']) {
|
||||
@@ -94,8 +94,8 @@ class VideoHttp {
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<RecVideoItemAppModel> list = [];
|
||||
List<int> blackMidsList = setting
|
||||
.get(SettingBoxKey.blackMidsList, defaultValue: [-1])
|
||||
List<int> blackMidsList = localCache
|
||||
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
|
||||
.map<int>((e) => e as int)
|
||||
.toList();
|
||||
for (var i in res.data['data']['items']) {
|
||||
@@ -128,8 +128,8 @@ class VideoHttp {
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = [];
|
||||
List<int> blackMidsList = setting
|
||||
.get(SettingBoxKey.blackMidsList, defaultValue: [-1])
|
||||
List<int> blackMidsList = localCache
|
||||
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
|
||||
.map<int>((e) => e as int)
|
||||
.toList();
|
||||
for (var i in res.data['data']['list']) {
|
||||
@@ -711,8 +711,8 @@ class VideoHttp {
|
||||
var res = await Request().get(rankApi);
|
||||
if (res.data['code'] == 0) {
|
||||
List<HotVideoItemModel> list = [];
|
||||
List<int> blackMidsList = setting
|
||||
.get(SettingBoxKey.blackMidsList, defaultValue: [-1])
|
||||
List<int> blackMidsList = localCache
|
||||
.get(LocalCacheKey.blackMidsList, defaultValue: [-1])
|
||||
.map<int>((e) => e as int)
|
||||
.toList();
|
||||
for (var i in res.data['data']['list']) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class _BlackListPageState extends State<BlackListPage> {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
Future? _futureBuilderFuture;
|
||||
bool _isLoadingMore = false;
|
||||
Box setting = GStorage.setting;
|
||||
Box localCache = GStorage.localCache;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -46,7 +46,7 @@ class _BlackListPageState extends State<BlackListPage> {
|
||||
void dispose() {
|
||||
List<int> blackMidsList =
|
||||
_blackListController.blackList.map<int>((e) => e.mid!).toList();
|
||||
setting.put(SettingBoxKey.blackMidsList, blackMidsList);
|
||||
localCache.put(LocalCacheKey.blackMidsList, blackMidsList);
|
||||
scrollController.removeListener(() {});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
|
||||
final DanmakuBlockController _danmakuBlockController =
|
||||
Get.put(DanmakuBlockController());
|
||||
final ScrollController scrollController = ScrollController();
|
||||
Box setting = GStorage.setting;
|
||||
Box localCache = GStorage.localCache;
|
||||
late PlPlayerController plPlayerController;
|
||||
|
||||
static const Map<int, String> ruleLabels = {
|
||||
@@ -50,7 +50,7 @@ class _DanmakuBlockPageState extends State<DanmakuBlockPage> {
|
||||
return e.toMap();
|
||||
}).toList();
|
||||
print("simpleRuleList:$simpleRuleList");
|
||||
setting.put(SettingBoxKey.danmakuFilterRule, simpleRuleList);
|
||||
localCache.put(LocalCacheKey.danmakuFilterRule, simpleRuleList);
|
||||
plPlayerController.danmakuFilterRule.value = simpleRuleList;
|
||||
scrollController.removeListener(() {});
|
||||
scrollController.dispose();
|
||||
|
||||
@@ -87,45 +87,8 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
);
|
||||
if (result != null) {
|
||||
if (result == 'app') {
|
||||
// app端推荐需要access_key
|
||||
if (accessKeyInfo == null) {
|
||||
if (!userLogin) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
// 显示一个确认框,告知用户可能会导致账号被风控
|
||||
if (!context.mounted) return;
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text(
|
||||
'使用app端推荐需获取access_key,有小概率触发风控导致账号退出(在官方版本app重新登录即可解除),是否继续?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
result = null;
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
var res = await MemberHttp.cookieToKey();
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
} else {
|
||||
SmartDialog.showToast(
|
||||
'获取access_key失败:${res['msg']}');
|
||||
}
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
SmartDialog.showToast('尚未登录,无法收到个性化推荐');
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
|
||||
@@ -129,7 +129,6 @@ class SettingBoxKey {
|
||||
continuePlayInBackground = 'continuePlayInBackground',
|
||||
|
||||
/// 隐私
|
||||
blackMidsList = 'blackMidsList',
|
||||
anonymity = 'anonymity',
|
||||
|
||||
/// 推荐
|
||||
@@ -166,7 +165,6 @@ class SettingBoxKey {
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
strokeWidth = 'strokeWidth',
|
||||
fontWeight = 'fontWeight',
|
||||
danmakuFilterRule = 'danmakuFilterRule',
|
||||
|
||||
// 代理host port
|
||||
systemProxyHost = 'systemProxyHost',
|
||||
@@ -198,6 +196,11 @@ class SettingBoxKey {
|
||||
class LocalCacheKey {
|
||||
// 历史记录暂停状态 默认false 记录
|
||||
static const String historyPause = 'historyPause',
|
||||
|
||||
// 隐私设置-黑名单管理
|
||||
blackMidsList = 'blackMidsList',
|
||||
// 弹幕屏蔽规则
|
||||
danmakuFilterRule = 'danmakuFilterRule',
|
||||
// access_key
|
||||
accessKey = 'accessKey',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user