feat: 移除黑名单、隐藏黑名单上限显示 issues #90

This commit is contained in:
guozhigq
2023-09-11 17:46:27 +08:00
parent ef38844798
commit 09ff01905e
3 changed files with 45 additions and 5 deletions

View File

@ -288,6 +288,9 @@ class Api {
// 黑名单
static const String blackLst = '/x/relation/blacks';
// 移除黑名单
static const String removeBlack = '/x/relation/modify';
// github 获取最新版
static const String latestApp =
'https://api.github.com/repos/guozhigq/pilipala/releases/latest';

View File

@ -23,4 +23,31 @@ class BlackHttp {
};
}
}
// 移除黑名单
static Future removeBlack({required int fid}) async {
var res = await Request().post(
Api.removeBlack,
queryParameters: {
'act': 6,
'csrf': await Request.getCsrf(),
'fid': fid,
'jsonp': 'jsonp',
're_src': 116,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': [],
'msg': '操作成功',
};
} else {
return {
'status': false,
'data': [],
'msg': res.data['message'],
};
}
}
}

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:pilipala/common/widgets/http_error.dart';
@ -60,7 +61,7 @@ class _BlackListPageState extends State<BlackListPage> {
centerTitle: false,
title: Obx(
() => Text(
'黑名单管理 ${_blackListController.blackList.length} / 5000',
'黑名单管理 - ${_blackListController.blackList.length}',
style: Theme.of(context).textTheme.titleMedium,
),
),
@ -104,10 +105,11 @@ class _BlackListPageState extends State<BlackListPage> {
overflow: TextOverflow.ellipsis,
),
dense: true,
// trailing: TextButton(
// onPressed: () {},
// child: const Text('移除'),
// ),
trailing: TextButton(
onPressed: () => _blackListController
.removeBlack(list[index].mid),
child: const Text('移除'),
),
);
},
),
@ -154,4 +156,12 @@ class BlackListController extends GetxController {
}
return result;
}
Future removeBlack(mid) async {
var result = await BlackHttp.removeBlack(fid: mid);
if (result['status']) {
blackList.removeWhere((e) => e.mid == mid);
SmartDialog.showToast(result['msg']);
}
}
}