mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
122 lines
3.1 KiB
Dart
122 lines
3.1 KiB
Dart
import 'package:PiliPlus/http/loading_state.dart';
|
|
import 'package:PiliPlus/utils/accounts/account.dart';
|
|
import 'package:PiliPlus/utils/storage.dart';
|
|
import 'package:dio/dio.dart';
|
|
|
|
import '../models/dynamics/result.dart';
|
|
import '../models/dynamics/up.dart';
|
|
import 'index.dart';
|
|
|
|
class DynamicsHttp {
|
|
static Future<LoadingState<DynamicsDataModel>> followDynamic({
|
|
String? type,
|
|
String? offset,
|
|
int? mid,
|
|
}) async {
|
|
Map<String, dynamic> data = {
|
|
'type': type ?? 'all',
|
|
'timezone_offset': '-480',
|
|
'offset': offset,
|
|
'features': 'itemOpusStyle,listOnlyfans'
|
|
};
|
|
if (mid != -1) {
|
|
data['host_mid'] = mid;
|
|
data.remove('timezone_offset');
|
|
}
|
|
var res = await Request().get(Api.followDynamic, queryParameters: data);
|
|
if (res.data['code'] == 0) {
|
|
try {
|
|
DynamicsDataModel data = DynamicsDataModel.fromJson(res.data['data']);
|
|
if (GStorage.antiGoodsDyn) {
|
|
data.items?.removeWhere(
|
|
(item) =>
|
|
item.orig?.modules?.moduleDynamic?.additional?.type ==
|
|
'ADDITIONAL_TYPE_GOODS' ||
|
|
item.modules?.moduleDynamic?.additional?.type ==
|
|
'ADDITIONAL_TYPE_GOODS',
|
|
);
|
|
}
|
|
return LoadingState.success(data);
|
|
} catch (err) {
|
|
return LoadingState.error(err.toString());
|
|
}
|
|
} else {
|
|
return LoadingState.error(res.data['message']);
|
|
}
|
|
}
|
|
|
|
static Future followUp() async {
|
|
var res = await Request().get(Api.followUp);
|
|
if (res.data['code'] == 0) {
|
|
return {
|
|
'status': true,
|
|
'data': FollowUpModel.fromJson(res.data['data']),
|
|
};
|
|
} else {
|
|
return {'status': false, 'msg': res.data['message']};
|
|
}
|
|
}
|
|
|
|
// 动态点赞
|
|
static Future likeDynamic({
|
|
required String? dynamicId,
|
|
required int? up,
|
|
}) async {
|
|
var res = await Request().post(
|
|
Api.likeDynamic,
|
|
queryParameters: {
|
|
'dynamic_id': dynamicId,
|
|
'up': up,
|
|
'csrf': await Request.getCsrf(),
|
|
},
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
return {
|
|
'status': true,
|
|
'data': res.data['data'],
|
|
};
|
|
} else {
|
|
return {'status': false, 'msg': res.data['message']};
|
|
}
|
|
}
|
|
|
|
//
|
|
static Future dynamicDetail({
|
|
dynamic id,
|
|
dynamic rid,
|
|
dynamic type,
|
|
bool clearCookie = false,
|
|
}) async {
|
|
var res = await Request().get(
|
|
Api.dynamicDetail,
|
|
queryParameters: {
|
|
'timezone_offset': -480,
|
|
if (id != null) 'id': id,
|
|
if (rid != null) 'rid': rid,
|
|
if (type != null) 'type': type,
|
|
'features': 'itemOpusStyle,listOnlyfans',
|
|
},
|
|
options:
|
|
clearCookie ? Options(extra: {'account': AnonymousAccount()}) : null,
|
|
);
|
|
if (res.data['code'] == 0) {
|
|
try {
|
|
return {
|
|
'status': true,
|
|
'data': DynamicItemModel.fromJson(res.data['data']['item']),
|
|
};
|
|
} catch (err) {
|
|
return {
|
|
'status': false,
|
|
'msg': err.toString(),
|
|
};
|
|
}
|
|
} else {
|
|
return {
|
|
'status': false,
|
|
'msg': res.data['message'],
|
|
};
|
|
}
|
|
}
|
|
}
|