mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: bangumi like/coin/fav state
This commit is contained in:
@@ -123,6 +123,7 @@ class _ListSheetContentState extends State<ListSheetContent> {
|
||||
SmartDialog.showToast('切换到:$title');
|
||||
widget.onClose();
|
||||
widget.changeFucCall(
|
||||
episode is bangumi.EpisodeItem ? episode.epId : null,
|
||||
episode.runtimeType.toString() == "EpisodeItem"
|
||||
? episode.bvid
|
||||
: widget.bvid,
|
||||
|
||||
@@ -51,6 +51,8 @@ class Api {
|
||||
// https://api.bilibili.com/x/web-interface/archive/has/like
|
||||
static const String hasLikeVideo = '/x/web-interface/archive/has/like';
|
||||
|
||||
static const String bangumiLikeCoinFav = '/pgc/season/episode/community';
|
||||
|
||||
// 视频点踩 web端不支持
|
||||
|
||||
// 点踩 Post(app端)
|
||||
|
||||
@@ -295,6 +295,19 @@ class VideoHttp {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取点赞/投币/收藏状态 bangumi
|
||||
static Future bangumiLikeCoinFav({dynamic epId}) async {
|
||||
var res = await Request().get(
|
||||
Api.bangumiLikeCoinFav,
|
||||
data: {'ep_id': epId},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'data': []};
|
||||
}
|
||||
}
|
||||
|
||||
// 获取点赞状态
|
||||
static Future hasLikeVideo({required String bvid}) async {
|
||||
var res = await Request().get(Api.hasLikeVideo, data: {'bvid': bvid});
|
||||
|
||||
@@ -86,12 +86,13 @@ class BangumiIntroController extends CommonController {
|
||||
userLogin = userInfo != null;
|
||||
|
||||
if (userLogin) {
|
||||
// 获取点赞状态
|
||||
queryHasLikeVideo();
|
||||
// 获取投币状态
|
||||
queryHasCoinVideo();
|
||||
// 获取收藏状态
|
||||
queryHasFavVideo();
|
||||
// // 获取点赞状态
|
||||
// queryHasLikeVideo();
|
||||
// // 获取投币状态
|
||||
// queryHasCoinVideo();
|
||||
// // 获取收藏状态
|
||||
// queryHasFavVideo();
|
||||
queryBangumiLikeCoinFav();
|
||||
}
|
||||
|
||||
queryData();
|
||||
@@ -116,6 +117,14 @@ class BangumiIntroController extends CommonController {
|
||||
Future<LoadingState> customGetData() =>
|
||||
SearchHttp.bangumiInfoNew(seasonId: seasonId, epId: epId);
|
||||
|
||||
// 获取点赞/投币/收藏状态
|
||||
Future queryBangumiLikeCoinFav() async {
|
||||
var result = await VideoHttp.bangumiLikeCoinFav(epId: epId);
|
||||
hasLike.value = result["data"]['like'] == 1;
|
||||
hasCoin.value = result["data"]['coin_number'] != 0;
|
||||
hasFav.value = result["data"]['favorite'] == 1;
|
||||
}
|
||||
|
||||
// 获取点赞状态
|
||||
Future queryHasLikeVideo() async {
|
||||
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
|
||||
@@ -308,10 +317,11 @@ class BangumiIntroController extends CommonController {
|
||||
}
|
||||
|
||||
// 修改分P或番剧分集
|
||||
Future changeSeasonOrbangu(bvid, cid, aid, cover) async {
|
||||
Future changeSeasonOrbangu(epId, bvid, cid, aid, cover) async {
|
||||
// 重新获取视频资源
|
||||
VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
||||
this.epId = epId;
|
||||
videoDetailCtr.bvid = bvid;
|
||||
videoDetailCtr.cid.value = cid;
|
||||
videoDetailCtr.danmakuCid.value = cid;
|
||||
@@ -327,6 +337,9 @@ class BangumiIntroController extends CommonController {
|
||||
videoReplyCtr.aid = aid;
|
||||
videoReplyCtr.onRefresh();
|
||||
} catch (_) {}
|
||||
if (userLogin) {
|
||||
queryBangumiLikeCoinFav();
|
||||
}
|
||||
}
|
||||
|
||||
// 追番
|
||||
@@ -370,11 +383,12 @@ class BangumiIntroController extends CommonController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int epid = episodes[prevIndex].epid!;
|
||||
int cid = episodes[prevIndex].cid!;
|
||||
String bvid = episodes[prevIndex].bvid!;
|
||||
int aid = episodes[prevIndex].aid!;
|
||||
dynamic cover = episodes[prevIndex].cover;
|
||||
changeSeasonOrbangu(bvid, cid, aid, cover);
|
||||
changeSeasonOrbangu(epid, bvid, cid, aid, cover);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -405,11 +419,12 @@ class BangumiIntroController extends CommonController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int epid = episodes[nextIndex].epid!;
|
||||
int cid = episodes[nextIndex].cid!;
|
||||
String bvid = episodes[nextIndex].bvid!;
|
||||
int aid = episodes[nextIndex].aid!;
|
||||
dynamic cover = episodes[nextIndex].cover;
|
||||
changeSeasonOrbangu(bvid, cid, aid, cover);
|
||||
changeSeasonOrbangu(epid, bvid, cid, aid, cover);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
return;
|
||||
}
|
||||
widget.changeFuc(
|
||||
widget.pages[i].epId,
|
||||
widget.pages[i].bvid,
|
||||
widget.pages[i].cid,
|
||||
widget.pages[i].aid,
|
||||
|
||||
@@ -486,7 +486,7 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
|
||||
// 修改分P或番剧分集
|
||||
Future changeSeasonOrbangu(bvid, cid, aid, cover) async {
|
||||
Future changeSeasonOrbangu(epid, bvid, cid, aid, cover) async {
|
||||
// 重新获取视频资源
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: heroTag);
|
||||
@@ -581,7 +581,7 @@ class VideoIntroController extends GetxController {
|
||||
final int cid = episodes[prevIndex].cid!;
|
||||
final String rBvid = isPages ? bvid : episodes[prevIndex].bvid;
|
||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[prevIndex].aid!;
|
||||
changeSeasonOrbangu(rBvid, cid, rAid, null);
|
||||
changeSeasonOrbangu(null, rBvid, cid, rAid, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ class VideoIntroController extends GetxController {
|
||||
final int cid = episodes[nextIndex].cid!;
|
||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||
changeSeasonOrbangu(rBvid, cid, rAid, null);
|
||||
changeSeasonOrbangu(null, rBvid, cid, rAid, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ class ActionItem extends StatefulWidget {
|
||||
|
||||
class ActionItemState extends State<ActionItem>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController? controller;
|
||||
late Animation<double>? _animation;
|
||||
AnimationController? controller;
|
||||
Animation<double>? _animation;
|
||||
|
||||
bool get _isThumbUp => widget.semanticsLabel == '点赞';
|
||||
late int _lastTime;
|
||||
|
||||
@@ -126,6 +126,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
child: InkWell(
|
||||
onTap: () => {
|
||||
widget.changeFuc(
|
||||
null,
|
||||
widget.bvid,
|
||||
widget.pages[i].cid,
|
||||
IdUtils.bv2av(widget.bvid),
|
||||
|
||||
@@ -104,25 +104,27 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
videoPlayerServiceHandler.onVideoDetailChange(
|
||||
value, videoDetailController.cid.value);
|
||||
});
|
||||
bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag);
|
||||
bangumiIntroController.loadingState.listen((value) {
|
||||
if (!context.mounted) return;
|
||||
if (value is Success) {
|
||||
videoPlayerServiceHandler.onVideoDetailChange(
|
||||
value.response,
|
||||
videoDetailController.cid.value,
|
||||
);
|
||||
}
|
||||
});
|
||||
videoDetailController.cid.listen((p0) {
|
||||
if (!context.mounted) return;
|
||||
if (bangumiIntroController.loadingState.value is Success) {
|
||||
videoPlayerServiceHandler.onVideoDetailChange(
|
||||
(bangumiIntroController.loadingState.value as Success).response,
|
||||
p0,
|
||||
);
|
||||
}
|
||||
});
|
||||
if (videoDetailController.videoType == SearchType.media_bangumi) {
|
||||
bangumiIntroController = Get.put(BangumiIntroController(), tag: heroTag);
|
||||
bangumiIntroController.loadingState.listen((value) {
|
||||
if (!context.mounted) return;
|
||||
if (value is Success) {
|
||||
videoPlayerServiceHandler.onVideoDetailChange(
|
||||
value.response,
|
||||
videoDetailController.cid.value,
|
||||
);
|
||||
}
|
||||
});
|
||||
videoDetailController.cid.listen((p0) {
|
||||
if (!context.mounted) return;
|
||||
if (bangumiIntroController.loadingState.value is Success) {
|
||||
videoPlayerServiceHandler.onVideoDetailChange(
|
||||
(bangumiIntroController.loadingState.value as Success).response,
|
||||
p0,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
autoExitFullscreen =
|
||||
setting.get(SettingBoxKey.enableAutoExit, defaultValue: true);
|
||||
horizontalScreen =
|
||||
@@ -200,8 +202,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
plPlayerController!.playRepeat != PlayRepeat.singleCycle) {
|
||||
if (videoDetailController.videoType == SearchType.video) {
|
||||
notExitFlag = videoIntroController.nextPlay();
|
||||
}
|
||||
if (videoDetailController.videoType == SearchType.media_bangumi) {
|
||||
} else if (videoDetailController.videoType ==
|
||||
SearchType.media_bangumi) {
|
||||
notExitFlag = bangumiIntroController.nextPlay();
|
||||
}
|
||||
}
|
||||
@@ -1317,7 +1319,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
bvid: bvid,
|
||||
aid: aid,
|
||||
currentCid: cid,
|
||||
changeFucCall: videoIntroController.changeSeasonOrbangu,
|
||||
changeFucCall: videoDetailController.videoType == SearchType.media_bangumi
|
||||
? bangumiIntroController.changeSeasonOrbangu
|
||||
: videoIntroController.changeSeasonOrbangu,
|
||||
context: context,
|
||||
scaffoldState: isFullScreen
|
||||
? videoDetailController.scaffoldKey.currentState
|
||||
|
||||
Reference in New Issue
Block a user