mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 16:48:43 +00:00
opt: LoadingState (#1776)
This commit is contained in:
committed by
GitHub
parent
3741fe54ff
commit
17883eb77e
@@ -3,15 +3,14 @@ import 'dart:math' show max;
|
||||
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/pgc.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/video_type.dart';
|
||||
import 'package:PiliPlus/models/pgc_lcf.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
|
||||
import 'package:PiliPlus/models_new/triple/pgc_triple.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/episode.dart'
|
||||
hide EpisodeItem;
|
||||
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
||||
@@ -75,11 +74,10 @@ class PgcIntroController extends CommonIntroController {
|
||||
|
||||
// 获取点赞/投币/收藏状态
|
||||
Future<void> queryPgcLikeCoinFav() async {
|
||||
var result = await VideoHttp.pgcLikeCoinFav(epId: epId);
|
||||
if (result['status']) {
|
||||
PgcLCF data = result['data'];
|
||||
final hasLike = data.like == 1;
|
||||
final hasFav = data.favorite == 1;
|
||||
var result = await VideoHttp.pgcLikeCoinFav(epId: epId!);
|
||||
if (result case Success(:final response)) {
|
||||
final hasLike = response.like == 1;
|
||||
final hasFav = response.favorite == 1;
|
||||
late final stat = pgcItem.stat!;
|
||||
if (hasLike) {
|
||||
stat.like = max(1, stat.like);
|
||||
@@ -88,10 +86,10 @@ class PgcIntroController extends CommonIntroController {
|
||||
stat.favorite = max(1, stat.favorite);
|
||||
}
|
||||
this.hasLike.value = hasLike;
|
||||
coinNum.value = data.coinNumber!;
|
||||
coinNum.value = response.coinNumber!;
|
||||
this.hasFav.value = hasFav;
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,12 +102,12 @@ class PgcIntroController extends CommonIntroController {
|
||||
}
|
||||
final newVal = !hasLike.value;
|
||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: newVal);
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast(newVal ? result['data']['toast'] : '取消赞');
|
||||
if (result case Success(:final response)) {
|
||||
SmartDialog.showToast(newVal ? response : '取消赞');
|
||||
pgcItem.stat!.like += newVal ? 1 : -1;
|
||||
hasLike.value = newVal;
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,20 +329,24 @@ class PgcIntroController extends CommonIntroController {
|
||||
// 追番
|
||||
Future<void> pgcAdd() async {
|
||||
var result = await VideoHttp.pgcAdd(seasonId: pgcItem.seasonId);
|
||||
if (result['status']) {
|
||||
if (result case Success(:final response)) {
|
||||
isFollowed.value = true;
|
||||
followStatus.value = 2;
|
||||
SmartDialog.showToast(response);
|
||||
} else {
|
||||
result.toast();
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
// 取消追番
|
||||
Future<void> pgcDel() async {
|
||||
var result = await VideoHttp.pgcDel(seasonId: pgcItem.seasonId);
|
||||
if (result['status']) {
|
||||
if (result case Success(:final response)) {
|
||||
isFollowed.value = false;
|
||||
SmartDialog.showToast(response);
|
||||
} else {
|
||||
result.toast();
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
Future<void> pgcUpdate(int status) async {
|
||||
@@ -352,10 +354,12 @@ class PgcIntroController extends CommonIntroController {
|
||||
seasonId: pgcItem.seasonId.toString(),
|
||||
status: status,
|
||||
);
|
||||
if (result['status']) {
|
||||
if (result case Success(:final response)) {
|
||||
followStatus.value = status;
|
||||
SmartDialog.showToast(response);
|
||||
} else {
|
||||
result.toast();
|
||||
}
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -419,20 +423,19 @@ class PgcIntroController extends CommonIntroController {
|
||||
SmartDialog.showToast('已三连');
|
||||
return;
|
||||
}
|
||||
var result = await VideoHttp.pgcTriple(epId: epId, seasonId: seasonId);
|
||||
if (result['status']) {
|
||||
PgcTriple data = result['data'];
|
||||
var result = await VideoHttp.pgcTriple(epId: epId!, seasonId: seasonId);
|
||||
if (result case Success(:final response)) {
|
||||
late final stat = pgcItem.stat!;
|
||||
if (data.like == 1 && !hasLike.value) {
|
||||
if (response.like == 1 && !hasLike.value) {
|
||||
stat.like++;
|
||||
hasLike.value = true;
|
||||
}
|
||||
if (data.coin == 1 && !hasCoin) {
|
||||
if (response.coin == 1 && !hasCoin) {
|
||||
stat.coin += 2;
|
||||
coinNum.value = 2;
|
||||
GlobalData().afterCoin(2);
|
||||
}
|
||||
if (data.favorite == 1 && !hasFav.value) {
|
||||
if (response.favorite == 1 && !hasFav.value) {
|
||||
stat.favorite++;
|
||||
hasFav.value = true;
|
||||
}
|
||||
@@ -442,7 +445,7 @@ class PgcIntroController extends CommonIntroController {
|
||||
SmartDialog.showToast('三连成功');
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,9 +475,9 @@ class PgcIntroController extends CommonIntroController {
|
||||
// }
|
||||
// });
|
||||
|
||||
final res = await PgcHttp.seasonStatus(seasonId);
|
||||
final res = await PgcHttp.seasonStatus(seasonId!);
|
||||
if (res['status']) {
|
||||
final data = res['data'];
|
||||
final Map<String, dynamic> data = res['data'];
|
||||
isFollowed.value = data['follow'] == 1;
|
||||
followStatus.value = data['follow_status'];
|
||||
}
|
||||
@@ -496,13 +499,13 @@ class PgcIntroController extends CommonIntroController {
|
||||
|
||||
Future<void> onFavPugv(bool isFav) async {
|
||||
final res = isFav
|
||||
? await FavHttp.delFavPugv(seasonId)
|
||||
: await FavHttp.addFavPugv(seasonId);
|
||||
if (res['status']) {
|
||||
? await FavHttp.delFavPugv(seasonId!)
|
||||
: await FavHttp.addFavPugv(seasonId!);
|
||||
if (res.isSuccess) {
|
||||
this.isFav.value = !isFav;
|
||||
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
res.toast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ import 'package:PiliPlus/http/user.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
import 'package:PiliPlus/models_new/member_card_info/data.dart';
|
||||
import 'package:PiliPlus/models_new/triple/ugc_triple.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_ai_conclusion/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_ai_conclusion/model_result.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/episode.dart';
|
||||
@@ -190,19 +188,18 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
return;
|
||||
}
|
||||
var result = await VideoHttp.ugcTriple(bvid: bvid);
|
||||
if (result['status']) {
|
||||
UgcTriple data = result['data'];
|
||||
if (result case Success(:final response)) {
|
||||
late final stat = videoDetail.value.stat!;
|
||||
if (data.like == true && !hasLike.value) {
|
||||
if (response.like == true && !hasLike.value) {
|
||||
stat.like++;
|
||||
hasLike.value = true;
|
||||
}
|
||||
if (data.coin == true && !hasCoin) {
|
||||
if (response.coin == true && !hasCoin) {
|
||||
stat.coin += 2;
|
||||
coinNum.value = 2;
|
||||
GlobalData().afterCoin(2);
|
||||
}
|
||||
if (data.fav == true && !hasFav.value) {
|
||||
if (response.fav == true && !hasFav.value) {
|
||||
stat.favorite++;
|
||||
hasFav.value = true;
|
||||
}
|
||||
@@ -213,7 +210,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
SmartDialog.showToast('三连成功');
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,15 +226,15 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
final newVal = !hasLike.value;
|
||||
var result = await VideoHttp.likeVideo(bvid: bvid, type: newVal);
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast(newVal ? result['data']['toast'] : '取消赞');
|
||||
if (result case Success(:final response)) {
|
||||
SmartDialog.showToast(newVal ? response : '取消赞');
|
||||
videoDetail.value.stat!.like += newVal ? 1 : -1;
|
||||
hasLike.value = newVal;
|
||||
if (newVal) {
|
||||
hasDislike.value = false;
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +247,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
bvid: bvid,
|
||||
type: !hasDislike.value,
|
||||
);
|
||||
if (result['status']) {
|
||||
if (result.isSuccess) {
|
||||
if (!hasDislike.value) {
|
||||
SmartDialog.showToast('点踩成功');
|
||||
hasDislike.value = true;
|
||||
@@ -263,7 +260,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
hasDislike.value = false;
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
result.toast();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +438,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
act: 6,
|
||||
reSrc: 11,
|
||||
);
|
||||
if (res['status']) {
|
||||
if (res.isSuccess) {
|
||||
followStatus['attribute'] = 0;
|
||||
}
|
||||
return;
|
||||
@@ -762,10 +759,9 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
upMid: mid,
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
if (res['status']) {
|
||||
AiConclusionData data = res['data'];
|
||||
return data.modelResult;
|
||||
} else if (res['handling']) {
|
||||
if (res case Success(:final response)) {
|
||||
return response.modelResult;
|
||||
} else if (res is Error && res.code == 1) {
|
||||
SmartDialog.showToast("AI处理中,请稍后再试");
|
||||
} else {
|
||||
SmartDialog.showToast("当前视频暂不支持AI视频总结");
|
||||
|
||||
Reference in New Issue
Block a user