feat: 评论+关注

This commit is contained in:
guozhigq
2023-05-21 16:19:11 +08:00
parent e384486ab6
commit 51c4a082ac
18 changed files with 897 additions and 258 deletions

View File

@ -1,5 +1,6 @@
class Api {
// 推荐视频
// http://app.bilibili.com/x/v2/feed/index
static const String recommendList = '/x/web-interface/index/top/feed/rcmd';
// 热门视频
@ -85,6 +86,12 @@ class Api {
// 视频详情页 相关视频
static const String relatedList = '/x/web-interface/archive/related';
// 查询用户与自己关系_仅查关注
static const String hasFollow = '/x/relation';
// 操作用户关系
static const String relationMod = '/x/relation/modify';
// 评论列表
static const String replyList = '/x/v2/reply';

View File

@ -25,11 +25,12 @@ class ReplyHttp {
-404: '无此项',
12002: '评论区已关闭',
12009: '评论主体的type不合法',
12061: 'UP主已关闭评论区',
};
return {
'status': false,
'date': [],
'msg': errMap[res.data['code']] ?? '请求异常',
'msg': errMap[res.data['code']] ?? res.data['message'],
};
}
}

View File

@ -205,13 +205,10 @@ class VideoHttp {
if (message == '') {
return {'status': false, 'data': [], 'msg': '请输入评论内容'};
}
print('root:$root');
print('parent: $parent');
var res = await Request().post(Api.replyAdd, queryParameters: {
'type': type.index,
'oid': oid,
'root': root ?? '',
'root': root == null || root == 0 ? '' : root,
'parent': parent == null || parent == 0 ? '' : parent,
'message': message,
'csrf': await Request.getCsrf(),
@ -223,4 +220,30 @@ class VideoHttp {
return {'status': false, 'data': []};
}
}
// 查询是否关注up
static Future hasFollow({required int mid}) async {
var res = await Request().get(Api.hasFollow, data: {'fid': mid});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {'status': true, 'data': []};
}
}
// 操作用户关系
static Future relationMod(
{required int mid, required int act, required int reSrc}) async {
var res = await Request().post(Api.relationMod, queryParameters: {
'fid': mid,
'act': act,
're_src': reSrc,
'csrf': await Request.getCsrf(),
});
if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']};
} else {
return {'status': true, 'data': []};
}
}
}