mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: fav article page
Closes #402 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -735,4 +735,13 @@ class Api {
|
||||
static const String delPublishNote = '/x/note/publish/del';
|
||||
|
||||
static const String archiveNote = '/x/note/list/archive';
|
||||
|
||||
static const String favArticle = '/x/polymer/web-dynamic/v1/opus/feed/fav';
|
||||
|
||||
static const String communityAction =
|
||||
'/x/community/cosmo/interface/simple_action';
|
||||
|
||||
static const String delFavArticle = '/x/article/favorites/del';
|
||||
|
||||
static const String addFavArticle = '/x/article/favorites/add';
|
||||
}
|
||||
|
||||
@@ -468,6 +468,84 @@ class UserHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> favArticle({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(Api.favArticle, queryParameters: {
|
||||
'page_size': 20,
|
||||
'page': page,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['items']);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future addFavArticle({
|
||||
required int id,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.addFavArticle,
|
||||
data: {
|
||||
'id': id,
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future delFavArticle({
|
||||
required int id,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.delFavArticle,
|
||||
data: {
|
||||
'id': id,
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future communityAction({
|
||||
required dynamic opusId,
|
||||
required dynamic action,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.communityAction,
|
||||
queryParameters: {
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
data: {
|
||||
"entity": {
|
||||
"object_id_str": opusId,
|
||||
"type": {"biz": 2}
|
||||
},
|
||||
"action": action, // 3 fav, 4 unfav
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future favResourceList({
|
||||
required int id,
|
||||
required int pn,
|
||||
|
||||
Reference in New Issue
Block a user