mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-04 09:09:48 +08:00
55 lines
1.5 KiB
Dart
55 lines
1.5 KiB
Dart
import 'package:PiliPlus/http/api.dart';
|
|
import 'package:PiliPlus/http/error_msg.dart';
|
|
import 'package:PiliPlus/http/init.dart';
|
|
import 'package:PiliPlus/http/loading_state.dart';
|
|
import 'package:PiliPlus/models_new/follow/data.dart';
|
|
import 'package:PiliPlus/utils/accounts.dart';
|
|
import 'package:dio/dio.dart' show Options, Headers;
|
|
|
|
abstract final class FollowHttp {
|
|
static Future<LoadingState<FollowData>> followings({
|
|
int? vmid,
|
|
int? pn,
|
|
int ps = 20,
|
|
String orderType = '', // ''=>最近关注,'attention'=>最常访问
|
|
}) async {
|
|
final res = await Request().get(
|
|
Api.followings,
|
|
queryParameters: {
|
|
'vmid': vmid,
|
|
'pn': pn,
|
|
'ps': ps,
|
|
'order': 'desc',
|
|
'order_type': orderType,
|
|
},
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
return Success(FollowData.fromJson(res.data['data']));
|
|
} else {
|
|
return Error(errorMsg[res.data['code']] ?? res.data['message']);
|
|
}
|
|
}
|
|
|
|
static Future<LoadingState<void>> sortFollowTag({
|
|
required String tagids,
|
|
}) async {
|
|
final res = await Request().post(
|
|
Api.sortFollowTag,
|
|
queryParameters: {
|
|
'x-bili-device-req-json':
|
|
'{"platform":"web","device":"pc","spmid":"333.1387"}',
|
|
},
|
|
data: {
|
|
'tagids': tagids,
|
|
'csrf': Accounts.main.csrf,
|
|
},
|
|
options: Options(contentType: Headers.formUrlEncodedContentType),
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
return const Success(null);
|
|
} else {
|
|
return Error(res.data['message']);
|
|
}
|
|
}
|
|
}
|