mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-04 08:10:20 +08:00
opt: LoadingState (#1776)
This commit is contained in:
committed by
GitHub
parent
3741fe54ff
commit
17883eb77e
@@ -10,6 +10,7 @@ import 'package:PiliPlus/models_new/live/live_area_list/area_item.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_area_list/area_list.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_block/data.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_block/shield_info.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_block/shield_user_list.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_dm_info/data.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_emote/data.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_emote/datum.dart';
|
||||
@@ -29,7 +30,7 @@ import 'package:dio/dio.dart';
|
||||
abstract final class LiveHttp {
|
||||
static Account get recommend => Accounts.get(AccountType.recommend);
|
||||
|
||||
static Future sendLiveMsg({
|
||||
static Future<LoadingState<Null>> sendLiveMsg({
|
||||
required Object roomId,
|
||||
required Object msg,
|
||||
Object? dmType,
|
||||
@@ -64,15 +65,9 @@ abstract final class LiveHttp {
|
||||
}),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,12 +107,9 @@ abstract final class LiveHttp {
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': RoomInfoH5Data.fromJson(res.data['data']),
|
||||
};
|
||||
return Success(RoomInfoH5Data.fromJson(res.data['data']));
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,12 +140,9 @@ abstract final class LiveHttp {
|
||||
}),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': LiveDmInfoData.fromJson(res.data['data']),
|
||||
};
|
||||
return Success(LiveDmInfoData.fromJson(res.data['data']));
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +371,7 @@ abstract final class LiveHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future setLiveFavTag({
|
||||
static Future<LoadingState<Null>> setLiveFavTag({
|
||||
required String ids,
|
||||
}) async {
|
||||
final data = {
|
||||
@@ -410,9 +399,9 @@ abstract final class LiveHttp {
|
||||
);
|
||||
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +497,7 @@ abstract final class LiveHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future liveSetSilent({
|
||||
static Future<LoadingState<Null>> liveSetSilent({
|
||||
required String type,
|
||||
required int level,
|
||||
}) async {
|
||||
@@ -524,13 +513,13 @@ abstract final class LiveHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future addShieldKeyword({
|
||||
static Future<LoadingState<Null>> addShieldKeyword({
|
||||
required String keyword,
|
||||
}) async {
|
||||
final csrf = Accounts.main.csrf;
|
||||
@@ -544,13 +533,13 @@ abstract final class LiveHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future delShieldKeyword({
|
||||
static Future<LoadingState<Null>> delShieldKeyword({
|
||||
required String keyword,
|
||||
}) async {
|
||||
final csrf = Accounts.main.csrf;
|
||||
@@ -564,9 +553,9 @@ abstract final class LiveHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,13 +577,13 @@ abstract final class LiveHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
return Success(ShieldUserList.fromJson(res.data['data']));
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future liveLikeReport({
|
||||
static Future<LoadingState<Null>> liveLikeReport({
|
||||
required int clickTime,
|
||||
required dynamic roomId,
|
||||
required dynamic uid,
|
||||
@@ -613,9 +602,9 @@ abstract final class LiveHttp {
|
||||
options: Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true};
|
||||
return const Success(null);
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
return Error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user