From eb8feb5773a13a62b9e1c8b9f5aefef8a6402bf7 Mon Sep 17 00:00:00 2001 From: orz12 Date: Fri, 22 Dec 2023 14:18:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E9=9D=9E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=92=AD=E6=94=BE=E4=B8=8B=E7=A9=BA=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/view.dart | 318 +++++++++++++++---------------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index f02fcd6d..184a38ec 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -237,17 +237,17 @@ class _VideoDetailPageState extends State final double pinnedHeaderHeight = statusBarHeight + kToolbarHeight + videoHeight; if (MediaQuery.of(context).orientation == Orientation.landscape || - plPlayerController!.isFullScreen.value) { + plPlayerController?.isFullScreen.value == true) { enterFullScreen(); } else { exitFullScreen(); } Widget childWhenDisabled = SafeArea( top: MediaQuery.of(context).orientation == Orientation.portrait, - bottom: MediaQuery.of(context).orientation == Orientation.portrait - && plPlayerController!.isFullScreen.value, - left: !plPlayerController!.isFullScreen.value, - right: !plPlayerController!.isFullScreen.value, + bottom: MediaQuery.of(context).orientation == Orientation.portrait && + plPlayerController?.isFullScreen.value == true, + left: plPlayerController?.isFullScreen.value != true, + right: plPlayerController?.isFullScreen.value != true, child: Stack( children: [ Scaffold( @@ -259,169 +259,168 @@ class _VideoDetailPageState extends State headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ - Obx(() => PopScope( - canPop: !plPlayerController!.isFullScreen.value, - onPopInvoked: (bool didPop) { - if (plPlayerController!.isFullScreen.value) { - plPlayerController! - .triggerFullScreen(status: false); - } - if (MediaQuery.of(context).orientation == - Orientation.landscape) { - verticalScreen(); - } - }, - child: SliverAppBar( - automaticallyImplyLeading: false, - pinned: false, - elevation: 0, - scrolledUnderElevation: 0, - forceElevated: innerBoxIsScrolled, - expandedHeight: - plPlayerController!.isFullScreen.value || - MediaQuery.of(context).orientation == - Orientation.landscape - ? MediaQuery.of(context).size.height - - (MediaQuery.of(context).orientation == - Orientation.landscape - ? 0 - : statusBarHeight) - : videoHeight, - backgroundColor: Colors.black, - flexibleSpace: FlexibleSpaceBar( - background: LayoutBuilder( - builder: (context, boxConstraints) { - double maxWidth = boxConstraints.maxWidth; - double maxHeight = boxConstraints.maxHeight; - return Stack( - children: [ - FutureBuilder( - future: _futureBuilderFuture, - builder: ((context, snapshot) { - if (snapshot.hasData && - snapshot.data['status']) { - return Obx( - () => !videoDetailController - .autoPlay.value - ? const SizedBox() - : PLVideoPlayer( - controller: - plPlayerController!, - headerControl: - videoDetailController - .headerControl, - danmuWidget: Obx( - () => PlDanmaku( - key: Key( - videoDetailController - .danmakuCid - .value - .toString()), - cid: - videoDetailController - .danmakuCid - .value, - playerController: - plPlayerController!, - ), + SliverAppBar( + automaticallyImplyLeading: false, + pinned: false, + elevation: 0, + scrolledUnderElevation: 0, + forceElevated: innerBoxIsScrolled, + expandedHeight: + plPlayerController?.isFullScreen.value == true || + MediaQuery.of(context).orientation == + Orientation.landscape + ? MediaQuery.of(context).size.height - + (MediaQuery.of(context).orientation == + Orientation.landscape + ? 0 + : statusBarHeight) + : videoHeight, + backgroundColor: Colors.black, + flexibleSpace: FlexibleSpaceBar( + background: PopScope( + canPop: + plPlayerController?.isFullScreen.value != true, + onPopInvoked: (bool didPop) { + if (plPlayerController?.isFullScreen.value == + true) { + plPlayerController! + .triggerFullScreen(status: false); + } + if (MediaQuery.of(context).orientation == + Orientation.landscape) { + verticalScreen(); + } + }, + child: LayoutBuilder( + builder: (context, boxConstraints) { + double maxWidth = boxConstraints.maxWidth; + double maxHeight = boxConstraints.maxHeight; + return Stack( + children: [ + FutureBuilder( + future: _futureBuilderFuture, + builder: ((context, snapshot) { + if (snapshot.hasData && + snapshot.data['status']) { + return Obx( + () => !videoDetailController + .autoPlay.value + ? const SizedBox() + : PLVideoPlayer( + controller: + plPlayerController!, + headerControl: + videoDetailController + .headerControl, + danmuWidget: Obx( + () => PlDanmaku( + key: Key( + videoDetailController + .danmakuCid + .value + .toString()), + cid: + videoDetailController + .danmakuCid + .value, + playerController: + plPlayerController!, ), ), - ); - } else { - return const SizedBox(); - } - }), - ), + ), + ); + } else { + return const SizedBox(); + } + }), + ), - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value, - child: Positioned( - top: 0, - left: 0, - right: 0, - child: NetworkImgLayer( - type: 'emote', - src: videoDetailController - .videoItem['pic'], - width: maxWidth, - height: maxHeight, - ), + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value, + child: Positioned( + top: 0, + left: 0, + right: 0, + child: NetworkImgLayer( + type: 'emote', + src: videoDetailController + .videoItem['pic'], + width: maxWidth, + height: maxHeight, ), ), ), + ), - /// 关闭自动播放时 手动播放 - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value && - videoDetailController - .isEffective.value && - !videoDetailController - .autoPlay.value, - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: AppBar( - primary: false, - foregroundColor: - Colors.white, + /// 关闭自动播放时 手动播放 + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value && + videoDetailController + .isEffective.value && + !videoDetailController + .autoPlay.value, + child: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: AppBar( + primary: false, + foregroundColor: Colors.white, + backgroundColor: + Colors.transparent, + actions: [ + IconButton( + tooltip: '稍后再看', + onPressed: () async { + var res = await UserHttp + .toViewLater( + bvid: + videoDetailController + .bvid); + SmartDialog.showToast( + res['msg']); + }, + icon: const Icon(Icons + .history_outlined), + ), + const SizedBox(width: 14) + ], + ), + ), + Positioned( + right: 12, + bottom: 10, + child: TextButton.icon( + style: ButtonStyle( backgroundColor: - Colors.transparent, - actions: [ - IconButton( - tooltip: '稍后再看', - onPressed: () async { - var res = await UserHttp - .toViewLater( - bvid: - videoDetailController - .bvid); - SmartDialog.showToast( - res['msg']); - }, - icon: const Icon(Icons - .history_outlined), - ), - const SizedBox(width: 14) - ], + MaterialStateProperty + .resolveWith( + (states) { + return Theme.of(context) + .colorScheme + .primaryContainer; + }), ), - ), - Positioned( - right: 12, - bottom: 10, - child: TextButton.icon( - style: ButtonStyle( - backgroundColor: - MaterialStateProperty - .resolveWith( - (states) { - return Theme.of(context) - .colorScheme - .primaryContainer; - }), - ), - onPressed: () => - handlePlay(), - icon: const Icon( - Icons.play_circle_outline, - size: 20, - ), - label: const Text('Play'), + onPressed: () => handlePlay(), + icon: const Icon( + Icons.play_circle_outline, + size: 20, ), + label: const Text('Play'), ), - ], - )), - ), - ], - ); - }, - ), + ), + ], + )), + ), + ], + ); + }, )), )), ]; @@ -433,8 +432,9 @@ class _VideoDetailPageState extends State // }, /// 不收回 pinnedHeaderSliverHeightBuilder: () { - return plPlayerController!.isFullScreen.value ? - MediaQuery.of(context).size.height: pinnedHeaderHeight; + return plPlayerController?.isFullScreen.value == true + ? MediaQuery.of(context).size.height + : pinnedHeaderHeight; }, onlyOneScrollInBody: true, body: Container( From 2b51ec26749e813c6700cad8778435b70db7a4bb Mon Sep 17 00:00:00 2001 From: orz12 Date: Sat, 23 Dec 2023 17:25:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20profile=E9=A1=B5=E6=9C=AA=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=85=B3=E6=B3=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 经测试,原接口会返回{"code":-403,"message":"访问权限不足","ttl":1},所以统一为hasFollow接口,并收录了更多的状态文本 --- lib/http/api.dart | 4 +-- lib/http/user.dart | 42 ++++++++++++++++++++------------ lib/pages/member/controller.dart | 30 ++++++++++++++++------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/lib/http/api.dart b/lib/http/api.dart index 3db3c617..75a121ac 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -97,8 +97,8 @@ class Api { // 操作用户关系 static const String relationMod = '/x/relation/modify'; - // 相互关系查询 - static const String relationSearch = '/x/space/wbi/acc/relation'; + // 相互关系查询 // 失效 + // static const String relationSearch = '/x/space/wbi/acc/relation'; // 评论列表 // https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11 diff --git a/lib/http/user.dart b/lib/http/user.dart index f439b815..2a8c81b6 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -250,31 +250,43 @@ class UserHttp { return {'status': false, 'msg': res.data['message']}; } } - - // 相互关系查询 - static Future relationSearch(int mid) async { - Map params = await WbiSign().makSign({ - 'mid': mid, - 'token': '', - 'platform': 'web', - 'web_location': 1550101, - }); + static Future hasFollow(int mid) async { var res = await Request().get( - Api.relationSearch, + Api.hasFollow, data: { - 'mid': mid, - 'w_rid': params['w_rid'], - 'wts': params['wts'], + 'fid': mid, }, ); if (res.data['code'] == 0) { - // relation 主动状态 - // 被动状态 return {'status': true, 'data': res.data['data']}; } else { return {'status': false, 'msg': res.data['message']}; } } + // // 相互关系查询 + // static Future relationSearch(int mid) async { + // Map params = await WbiSign().makSign({ + // 'mid': mid, + // 'token': '', + // 'platform': 'web', + // 'web_location': 1550101, + // }); + // var res = await Request().get( + // Api.relationSearch, + // data: { + // 'mid': mid, + // 'w_rid': params['w_rid'], + // 'wts': params['wts'], + // }, + // ); + // if (res.data['code'] == 0) { + // // relation 主动状态 + // // 被动状态 + // return {'status': true, 'data': res.data['data']}; + // } else { + // return {'status': false, 'msg': res.data['message']}; + // } + // } // 搜索历史记录 static Future searchHistory( diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 14ede4d3..70169e3d 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -116,16 +116,28 @@ class MemberController extends GetxController { Future relationSearch() async { if (userInfo == null) return; if (mid == ownerMid) return; - var res = await UserHttp.relationSearch(mid); + var res = await UserHttp.hasFollow(mid); if (res['status']) { - attribute.value = res['data']['relation']['attribute']; - attributeText.value = attribute.value == 0 - ? '关注' - : attribute.value == 2 - ? '已关注' - : attribute.value == 6 - ? '已互粉' - : '已拉黑'; + attribute.value = res['data']['attribute']; + switch (attribute.value) { + case 1: + attributeText.value = '悄悄关注'; + break; + case 2: + attributeText.value = '已关注'; + break; + case 6: + attributeText.value = '已互关'; + break; + case 128: + attributeText.value = '已拉黑'; + break; + default: + attributeText.value = '关注'; + } + if (res['data']['special'] == 1) { + attributeText.value += 'SP'; + } } }