feat: create/update/del follow tag

opt: owner follow page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-23 11:12:17 +08:00
parent e212144250
commit 0d27d88719
9 changed files with 405 additions and 87 deletions

View File

@@ -286,10 +286,6 @@ class Api {
// order_type 排序规则 最近访问传空,最常访问传 attention
static const String followings = '/x/relation/followings';
// 指定分类的关注
// https://api.bilibili.com/x/relation/tag?mid=17340771&tagid=-10&pn=1&ps=20
static const String tagFollowings = '/x/relation/tag';
// 搜索follow
static const followSearch = '/x/relation/followings/search';
@@ -469,6 +465,12 @@ class Api {
// 获取指定分组下的up
static const String followUpGroup = '/x/relation/tag';
static const String createFollowTag = '/x/relation/tag/create';
static const String updateFollowTag = '/x/relation/tag/update';
static const String delFollowTag = '/x/relation/tag/del';
// 获取未读私信数
// https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread
static const String msgUnread =

View File

@@ -4,8 +4,12 @@ import '../models/follow/result.dart';
import 'index.dart';
class FollowHttp {
static Future followings(
{int? vmid, int? pn, int? ps, String? orderType}) async {
static Future followings({
int? vmid,
int? pn,
int? ps,
String orderType = '',
}) async {
var res = await Request().get(Api.followings, queryParameters: {
'vmid': vmid,
'pn': pn,
@@ -23,8 +27,12 @@ class FollowHttp {
}
}
static Future<LoadingState<List<FollowItemModel>?>> followingsNew(
{int? vmid, int? pn, int? ps, String? orderType}) async {
static Future<LoadingState<FollowDataModel>> followingsNew({
int? vmid,
int? pn,
int? ps,
String orderType = '', // ''=>最近关注,'attention'=>最常访问
}) async {
var res = await Request().get(Api.followings, queryParameters: {
'vmid': vmid,
'pn': pn,
@@ -35,7 +43,8 @@ class FollowHttp {
if (res.data['code'] == 0) {
return LoadingState.success(
FollowDataModel.fromJson(res.data['data']).list);
FollowDataModel.fromJson(res.data['data']),
);
} else {
return LoadingState.error(res.data['message']);
}

View File

@@ -470,8 +470,8 @@ class MemberHttp {
if (res.data['code'] == 0) {
return {
'status': true,
'data': (res.data['data'] as List?)
?.map<MemberTagItemModel>((e) => MemberTagItemModel.fromJson(e))
'data': res.data['data']
.map<MemberTagItemModel>((e) => MemberTagItemModel.fromJson(e))
.toList()
};
} else {
@@ -525,7 +525,7 @@ class MemberHttp {
}
// 获取某分组下的up
static Future<LoadingState<List<FollowItemModel>?>> followUpGroup(
static Future<LoadingState<FollowDataModel>> followUpGroup(
int? mid,
int? tagid,
int? pn,
@@ -541,14 +541,82 @@ class MemberHttp {
},
);
if (res.data['code'] == 0) {
return LoadingState.success((res.data['data'] as List?)
?.map<FollowItemModel>((e) => FollowItemModel.fromJson(e))
.toList());
return LoadingState.success(FollowDataModel(
list: (res.data['data'] as List?)
?.map<FollowItemModel>((e) => FollowItemModel.fromJson(e))
.toList()));
} else {
return LoadingState.error(res.data['message']);
}
}
static Future createFollowTag(tagName) async {
var res = await Request().post(
Api.createFollowTag,
queryParameters: {
'x-bili-device-req-json':
'{"platform":"web","device":"pc","spmid":"333.1387"}',
},
data: {
'tag': tagName,
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future updateFollowTag(tagid, name) async {
var res = await Request().post(
Api.updateFollowTag,
queryParameters: {
'x-bili-device-req-json':
'{"platform":"web","device":"pc","spmid":"333.1387"}',
},
data: {
'tagid': tagid,
'name': name,
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
static Future delFollowTag(tagid) async {
var res = await Request().post(
Api.delFollowTag,
queryParameters: {
'x-bili-device-req-json':
'{"platform":"web","device":"pc","spmid":"333.1387"}',
},
data: {
'tagid': tagid,
'csrf': Accounts.main.csrf,
},
options: Options(
contentType: Headers.formUrlEncodedContentType,
),
);
if (res.data['code'] == 0) {
return {'status': true};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
// 获取up置顶
static Future getTopVideo(String? vmid) async {
var res = await Request().get(Api.getTopVideoApi);