diff --git a/lib/common/pages_bottom_sheet.dart b/lib/common/pages_bottom_sheet.dart index a6e73ae2..41e713b4 100644 --- a/lib/common/pages_bottom_sheet.dart +++ b/lib/common/pages_bottom_sheet.dart @@ -3,7 +3,9 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/constants.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/video_detail_res.dart'; +import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/utils/utils.dart'; import 'package:scrollview_observer/scrollview_observer.dart'; import '../models/common/video_episode_type.dart'; @@ -20,6 +22,8 @@ class EpisodeBottomSheet { final double? sheetHeight; bool isFullScreen = false; final UgcSeason? ugcSeason; + final int? currentEpisodeIndex; + final int? currentIndex; EpisodeBottomSheet({ required this.episodes, @@ -30,6 +34,8 @@ class EpisodeBottomSheet { this.sheetHeight, this.isFullScreen = false, this.ugcSeason, + this.currentEpisodeIndex, + this.currentIndex, }); Widget buildShowContent() { @@ -42,6 +48,8 @@ class EpisodeBottomSheet { sheetHeight: sheetHeight, isFullScreen: isFullScreen, ugcSeason: ugcSeason, + currentEpisodeIndex: currentEpisodeIndex, + currentIndex: currentIndex, ); } @@ -67,6 +75,8 @@ class PagesBottomSheet extends StatefulWidget { this.sheetHeight, this.isFullScreen = false, this.ugcSeason, + this.currentEpisodeIndex, + this.currentIndex, }); final List episodes; @@ -77,41 +87,38 @@ class PagesBottomSheet extends StatefulWidget { final double? sheetHeight; final bool isFullScreen; final UgcSeason? ugcSeason; + final int? currentEpisodeIndex; + final int? currentIndex; @override State createState() => _PagesBottomSheetState(); } -class _PagesBottomSheetState extends State { +class _PagesBottomSheetState extends State + with TickerProviderStateMixin { final ScrollController _listScrollController = ScrollController(); late ListObserverController _listObserverController; final ScrollController _scrollController = ScrollController(); late int currentIndex; + TabController? tabController; + List? _listObserverControllerList; + List? _listScrollControllerList; + final String heroTag = Get.arguments['heroTag']; + VideoDetailController? _videoDetailController; + RxInt isSubscribe = (-1).obs; + bool isVisible = false; @override void initState() { super.initState(); - currentIndex = + currentIndex = widget.currentIndex ?? widget.episodes.indexWhere((dynamic e) => e.cid == widget.currentCid); - _listObserverController = - ListObserverController(controller: _listScrollController); + _scrollToInit(); + _scrollPositionInit(); if (widget.dataType == VideoEpidoesType.videoEpisode) { - _listObserverController.initialIndexModel = ObserverIndexPositionModel( - index: currentIndex, - isFixedHeight: true, - ); + _videoDetailController = Get.find(tag: heroTag); + _getSubscribeStatus(); } - - WidgetsBinding.instance.addPostFrameCallback((_) { - if (widget.dataType != VideoEpidoesType.videoEpisode) { - double itemHeight = (widget.isFullScreen - ? 400 - : Get.size.width - 3 * StyleString.safeSpace) / - 5.2; - double offset = ((currentIndex - 1) / 2).ceil() * itemHeight; - _scrollController.jumpTo(offset); - } - }); } String prefix() { @@ -126,9 +133,117 @@ class _PagesBottomSheetState extends State { return '选集'; } + // 滚动器初始化 + void _scrollToInit() { + /// 单个 + _listObserverController = + ListObserverController(controller: _listScrollController); + + if (widget.dataType == VideoEpidoesType.videoEpisode && + widget.ugcSeason?.sections != null && + widget.ugcSeason!.sections!.length > 1) { + tabController = TabController( + length: widget.ugcSeason!.sections!.length, + vsync: this, + initialIndex: widget.currentEpisodeIndex ?? 0, + ); + + /// 多tab + _listScrollControllerList = List.generate( + widget.ugcSeason!.sections!.length, + (index) { + return ScrollController(); + }, + ); + _listObserverControllerList = List.generate( + widget.ugcSeason!.sections!.length, + (index) { + return ListObserverController( + controller: _listScrollControllerList![index], + ); + }, + ); + } + } + + // 滚动器位置初始化 + void _scrollPositionInit() { + if (widget.dataType == VideoEpidoesType.videoEpisode) { + // 单个 多tab + if (widget.ugcSeason?.sections != null) { + if (widget.ugcSeason!.sections!.length == 1) { + _listObserverController.initialIndexModel = + ObserverIndexPositionModel( + index: currentIndex, + isFixedHeight: true, + ); + } else { + _listObserverControllerList![widget.currentEpisodeIndex!] + .initialIndexModel = ObserverIndexPositionModel( + index: currentIndex, + isFixedHeight: true, + ); + } + } + } + + WidgetsBinding.instance.addPostFrameCallback((_) { + if (widget.dataType != VideoEpidoesType.videoEpisode) { + double itemHeight = (widget.isFullScreen + ? 400 + : Get.size.width - 3 * StyleString.safeSpace) / + 5.2; + double offset = ((currentIndex - 1) / 2).ceil() * itemHeight; + _scrollController.jumpTo(offset); + } + }); + } + + // 获取订阅状态 + void _getSubscribeStatus() async { + var res = + await VideoHttp.getSubscribeStatus(bvid: _videoDetailController!.bvid); + if (res['status']) { + isSubscribe.value = res['data']['season_fav'] ? 1 : 0; + } + } + + // 更改订阅状态 + void _changeSubscribeStatus() async { + if (isSubscribe.value == -1) { + return; + } + dynamic result = await VideoHttp.seasonFav( + isFav: isSubscribe.value == 1, + seasonId: widget.ugcSeason!.id, + ); + if (result['status']) { + SmartDialog.showToast(isSubscribe.value == 1 ? '取消订阅成功' : '订阅成功'); + isSubscribe.value = isSubscribe.value == 1 ? 0 : 1; + } else { + SmartDialog.showToast(result['msg']); + } + } + + // 更改展开状态 + void _changeVisible() { + setState(() { + isVisible = !isVisible; + }); + } + @override void dispose() { - _listObserverController.controller?.dispose(); + try { + _listObserverController.controller?.dispose(); + _listScrollController.dispose(); + for (var element in _listObserverControllerList!) { + element.controller?.dispose(); + } + for (var element in _listScrollControllerList!) { + element.dispose(); + } + } catch (_) {} super.dispose(); } @@ -145,36 +260,46 @@ class _PagesBottomSheetState extends State { isFullScreen: widget.isFullScreen, ), if (widget.ugcSeason != null) ...[ - UgcSeasonBuild(ugcSeason: widget.ugcSeason!), + UgcSeasonBuild( + ugcSeason: widget.ugcSeason!, + isSubscribe: isSubscribe, + isVisible: isVisible, + changeFucCall: _changeSubscribeStatus, + changeVisible: _changeVisible, + ), ], Expanded( child: Material( child: widget.dataType == VideoEpidoesType.videoEpisode - ? ListViewObserver( - controller: _listObserverController, - child: ListView.builder( - controller: _listScrollController, - itemCount: widget.episodes.length + 1, - itemBuilder: (BuildContext context, int index) { - bool isLastItem = index == widget.episodes.length; - bool isCurrentIndex = currentIndex == index; - return isLastItem - ? SizedBox( - height: - MediaQuery.of(context).padding.bottom + + ? (widget.ugcSeason!.sections!.length == 1 + ? ListViewObserver( + controller: _listObserverController, + child: ListView.builder( + controller: _listScrollController, + itemCount: widget.episodes.length + 1, + itemBuilder: (BuildContext context, int index) { + bool isLastItem = + index == widget.episodes.length; + bool isCurrentIndex = currentIndex == index; + return isLastItem + ? SizedBox( + height: MediaQuery.of(context) + .padding + .bottom + 20, - ) - : EpisodeListItem( - episode: widget.episodes[index], - index: index, - isCurrentIndex: isCurrentIndex, - dataType: widget.dataType, - changeFucCall: widget.changeFucCall, - isFullScreen: widget.isFullScreen, - ); - }, - ), - ) + ) + : EpisodeListItem( + episode: widget.episodes[index], + index: index, + isCurrentIndex: isCurrentIndex, + dataType: widget.dataType, + changeFucCall: widget.changeFucCall, + isFullScreen: widget.isFullScreen, + ); + }, + ), + ) + : buildTabBar()) : Padding( padding: const EdgeInsets.symmetric( horizontal: 12.0), // 设置左右间距为12 @@ -206,6 +331,65 @@ class _PagesBottomSheetState extends State { ); }); } + + Widget buildTabBar() { + return Column( + children: [ + // 背景色 + Container( + color: Theme.of(context).colorScheme.surface, + child: TabBar( + controller: tabController, + isScrollable: true, + indicatorSize: TabBarIndicatorSize.label, + tabAlignment: TabAlignment.start, + splashBorderRadius: BorderRadius.circular(4), + tabs: [ + ...widget.ugcSeason!.sections!.map((SectionItem section) { + return Tab( + text: section.title, + ); + }).toList() + ], + ), + ), + Expanded( + child: TabBarView( + controller: tabController, + children: [ + ...widget.ugcSeason!.sections!.map((SectionItem section) { + final int fIndex = widget.ugcSeason!.sections!.indexOf(section); + return ListViewObserver( + controller: _listObserverControllerList![fIndex], + child: ListView.builder( + controller: _listScrollControllerList![fIndex], + itemCount: section.episodes!.length + 1, + itemBuilder: (BuildContext context, int index) { + final bool isLastItem = index == section.episodes!.length; + return isLastItem + ? SizedBox( + height: + MediaQuery.of(context).padding.bottom + 20, + ) + : EpisodeListItem( + episode: section.episodes![index], // 调整索引 + index: index, // 调整索引 + isCurrentIndex: widget.currentCid == + section.episodes![index].cid, + dataType: widget.dataType, + changeFucCall: widget.changeFucCall, + isFullScreen: widget.isFullScreen, + ); + }, + ), + ); + }).toList() + ], + ), + ), + ], + ); + } } class TitleBar extends StatelessWidget { @@ -507,77 +691,134 @@ class EpisodeGridItem extends StatelessWidget { class UgcSeasonBuild extends StatelessWidget { final UgcSeason ugcSeason; + final RxInt isSubscribe; + final bool isVisible; + final Function changeFucCall; + final Function changeVisible; const UgcSeasonBuild({ Key? key, required this.ugcSeason, + required this.isSubscribe, + required this.isVisible, + required this.changeFucCall, + required this.changeVisible, }) : super(key: key); @override Widget build(BuildContext context) { - return Container( - padding: const EdgeInsets.fromLTRB(12, 0, 12, 8), - color: Theme.of(context).colorScheme.surface, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Divider( - height: 1, - thickness: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), - const SizedBox(height: 10), - Text( - '合集:${ugcSeason.title}', - style: Theme.of(context).textTheme.titleMedium, - overflow: TextOverflow.ellipsis, - ), - if (ugcSeason.intro != null && ugcSeason.intro != '') ...[ - const SizedBox(height: 4), - Row( + final ThemeData theme = Theme.of(context); + final Color outline = theme.colorScheme.outline; + final Color surface = theme.colorScheme.surface; + final Color primary = theme.colorScheme.primary; + final Color onPrimary = theme.colorScheme.onPrimary; + final Color onInverseSurface = theme.colorScheme.onInverseSurface; + final TextStyle titleMedium = theme.textTheme.titleMedium!; + final TextStyle labelMedium = theme.textTheme.labelMedium!; + final Color dividerColor = theme.dividerColor.withOpacity(0.1); + + return isVisible + ? Container( + padding: const EdgeInsets.fromLTRB(12, 0, 12, 0), + color: surface, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: Text(ugcSeason.intro ?? '', - style: TextStyle( - color: Theme.of(context).colorScheme.outline)), + Divider(height: 1, thickness: 1, color: dividerColor), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: Text( + '合集:${ugcSeason.title}', + style: titleMedium, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + const SizedBox(width: 10), + Obx( + () => isSubscribe.value == -1 + ? const SizedBox(height: 32) + : SizedBox( + height: 32, + child: FilledButton.tonal( + onPressed: () => changeFucCall.call(), + style: TextButton.styleFrom( + padding: + const EdgeInsets.only(left: 8, right: 8), + foregroundColor: isSubscribe.value == 1 + ? outline + : onPrimary, + backgroundColor: isSubscribe.value == 1 + ? onInverseSurface + : primary, + ), + child: + Text(isSubscribe.value == 1 ? '已订阅' : '订阅'), + ), + ), + ), + ], ), - // SizedBox( - // height: 32, - // child: FilledButton.tonal( - // onPressed: () {}, - // style: ButtonStyle( - // padding: MaterialStateProperty.all(EdgeInsets.zero), - // ), - // child: const Text('订阅'), - // ), - // ), - // const SizedBox(width: 6), + if (ugcSeason.intro != null && ugcSeason.intro != '') ...[ + const SizedBox(height: 4), + Text( + ugcSeason.intro!, + style: TextStyle(color: outline, fontSize: 12), + ), + ], + const SizedBox(height: 4), + Text.rich( + TextSpan( + style: TextStyle( + fontSize: labelMedium.fontSize, color: outline), + children: [ + TextSpan( + text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'), + const TextSpan(text: ' · '), + TextSpan( + text: + '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'), + ], + ), + ), + const SizedBox(height: 14), + Align( + alignment: Alignment.center, + child: Material( + color: surface, + child: InkWell( + onTap: () => changeVisible.call(), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 10, horizontal: 0), + child: Text( + '收起简介', + style: TextStyle(color: primary, fontSize: 12), + ), + ), + ), + ), + ), + Divider(height: 1, thickness: 1, color: dividerColor), ], ), - ], - const SizedBox(height: 4), - Text.rich( - TextSpan( - style: TextStyle( - fontSize: Theme.of(context).textTheme.labelMedium!.fontSize, - color: Theme.of(context).colorScheme.outline, + ) + : Align( + alignment: Alignment.center, + child: InkWell( + onTap: () => changeVisible.call(), + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 10, horizontal: 0), + child: Text( + '展开简介', + style: TextStyle(color: primary, fontSize: 12), + ), ), - children: [ - TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.view)}播放'), - const TextSpan(text: ' · '), - TextSpan(text: '${Utils.numFormat(ugcSeason.stat!.danmaku)}弹幕'), - ], ), - ), - const SizedBox(height: 14), - Divider( - height: 1, - thickness: 1, - color: Theme.of(context).dividerColor.withOpacity(0.1), - ), - ], - ), - ); + ); } } diff --git a/lib/common/widgets/custom_toast.dart b/lib/common/widgets/custom_toast.dart index f732fd85..93695e0d 100644 --- a/lib/common/widgets/custom_toast.dart +++ b/lib/common/widgets/custom_toast.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/utils/storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class CustomToast extends StatelessWidget { const CustomToast({super.key, required this.msg}); diff --git a/lib/common/widgets/network_img_layer.dart b/lib/common/widgets/network_img_layer.dart index d5903b71..4980e2fc 100644 --- a/lib/common/widgets/network_img_layer.dart +++ b/lib/common/widgets/network_img_layer.dart @@ -6,7 +6,7 @@ import 'package:pilipala/utils/global_data_cache.dart'; import '../../utils/storage.dart'; import '../constants.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class NetworkImgLayer extends StatelessWidget { const NetworkImgLayer({ diff --git a/lib/http/api.dart b/lib/http/api.dart index 078e615e..40b4fd5d 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -495,7 +495,7 @@ class Api { static const activateBuvidApi = '/x/internal/gaia-gateway/ExClimbWuzhi'; /// 获取字幕配置 - static const getSubtitleConfig = '/x/player/v2'; + static const getSubtitleConfig = '/x/player/wbi/v2'; /// 我的订阅 static const userSubFolder = '/x/v3/fav/folder/collected/list'; @@ -609,4 +609,14 @@ class Api { /// @我的 static const String messageAtAPi = '/x/msgfeed/at?'; + + /// 订阅 + static const String confirmSub = '/x/v3/fav/season/fav'; + + /// 订阅状态 + static const String videoRelation = '/x/web-interface/archive/relation'; + + /// 获取空降区间 + static const String getSkipSegments = + '${HttpString.sponsorBlockBaseUrl}/api/skipSegments'; } diff --git a/lib/http/common.dart b/lib/http/common.dart index d711a7e7..2f5f0e84 100644 --- a/lib/http/common.dart +++ b/lib/http/common.dart @@ -1,3 +1,5 @@ +import 'package:pilipala/models/sponsor_block/segment.dart'; + import 'index.dart'; class CommonHttp { @@ -14,4 +16,31 @@ class CommonHttp { }; } } + + static Future querySkipSegments({required String bvid}) async { + var res = await Request().getWithoutCookie(Api.getSkipSegments, data: { + 'videoID': bvid, + }); + if (res.data is List && res.data.isNotEmpty) { + try { + return { + 'status': true, + 'data': res.data + .map((e) => SegmentDataModel.fromJson(e)) + .toList(), + }; + } catch (err) { + return { + 'status': false, + 'data': [], + 'msg': 'sponsorBlock数据解析失败: $err', + }; + } + } else { + return { + 'status': false, + 'data': [], + }; + } + } } diff --git a/lib/http/constants.dart b/lib/http/constants.dart index b734c279..07d06958 100644 --- a/lib/http/constants.dart +++ b/lib/http/constants.dart @@ -7,6 +7,7 @@ class HttpString { static const String passBaseUrl = 'https://passport.bilibili.com'; static const String messageBaseUrl = 'https://message.bilibili.com'; static const String bangumiBaseUrl = 'https://bili.meark.me'; + static const String sponsorBlockBaseUrl = 'https://www.bsbsb.top'; static const List validateStatusCodes = [ 302, 304, diff --git a/lib/http/init.dart b/lib/http/init.dart index 3117666e..e820102a 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -21,8 +21,8 @@ class Request { static late CookieManager cookieManager; static late final Dio dio; factory Request() => _instance; - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late bool enableSystemProxy; late String systemProxyHost; late String systemProxyPort; @@ -32,8 +32,8 @@ class Request { /// 设置cookie static setCookie() async { - Box userInfoCache = GStrorage.userInfo; - Box setting = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box setting = GStorage.setting; final String cookiePath = await Utils.getCookiePath(); final PersistCookieJar cookieJar = PersistCookieJar( ignoreExpires: true, @@ -217,6 +217,13 @@ class Request { if (extra['ua'] != null) { options.headers = {'user-agent': headerUa(type: extra['ua'])}; } + if (extra['opus-goback'] != null) { + if (extra['opus-goback'] != null) { + String cookieHeader = dio.options.headers['cookie']; + options.headers!['cookie'] = + '$cookieHeader; opus-goback = ${extra['opus-goback']}'; + } + } } options.responseType = resType; diff --git a/lib/http/member.dart b/lib/http/member.dart index fc99c987..53e14eae 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -470,8 +470,8 @@ class MemberHttp { SmartDialog.dismiss(); if (res.data['code'] == 0) { String accessKey = res.data['data']['access_token']; - Box localCache = GStrorage.localCache; - Box userInfoCache = GStrorage.userInfo; + Box localCache = GStorage.localCache; + Box userInfoCache = GStorage.userInfo; var userInfo = userInfoCache.get('userInfoCache'); localCache.put( LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey}); diff --git a/lib/http/read.dart b/lib/http/read.dart index 68e72e59..5ea33519 100644 --- a/lib/http/read.dart +++ b/lib/http/read.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:dio/dio.dart'; import 'package:html/parser.dart'; import 'package:pilipala/models/read/opus.dart'; import 'package:pilipala/models/read/read.dart'; @@ -64,7 +65,7 @@ class ReadHttp { static Future parseArticleCv({required String id}) async { var res = await Request().get( 'https://www.bilibili.com/read/cv$id', - extra: {'ua': 'pc'}, + extra: {'ua': 'pc', 'opus-goback': '1'}, ); String scriptContent = extractScriptContents(parse(res.data).body!.outerHtml)[0]; diff --git a/lib/http/search.dart b/lib/http/search.dart index 00e51497..a61ff406 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -11,7 +11,7 @@ import '../utils/storage.dart'; import 'index.dart'; class SearchHttp { - static Box setting = GStrorage.setting; + static Box setting = GStorage.setting; static Future hotSearchList() async { var res = await Request().get(Api.hotSearchList); if (res.data is String) { diff --git a/lib/http/video.dart b/lib/http/video.dart index eeef5751..b5d47fa3 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:developer'; import 'package:dio/dio.dart'; import 'package:hive/hive.dart'; +import 'package:pilipala/utils/id_utils.dart'; import '../common/constants.dart'; import '../models/common/reply_type.dart'; import '../models/home/rcmd/result.dart'; @@ -24,11 +25,11 @@ import 'init.dart'; /// 返回{'status': bool, 'data': List} /// view层根据 status 判断渲染逻辑 class VideoHttp { - static Box localCache = GStrorage.localCache; - static Box setting = GStrorage.setting; + static Box localCache = GStorage.localCache; + static Box setting = GStorage.setting; static bool enableRcmdDynamic = setting.get(SettingBoxKey.enableRcmdDynamic, defaultValue: true); - static Box userInfoCache = GStrorage.userInfo; + static Box userInfoCache = GStorage.userInfo; // 首页推荐视频 static Future rcmdVideoList({required int ps, required int freshIdx}) async { @@ -509,10 +510,11 @@ class VideoHttp { } } - static Future getSubtitle({int? cid, String? bvid}) async { + static Future getSubtitle({int? cid, String? bvid, String? aid}) async { var res = await Request().get(Api.getSubtitleConfig, data: { 'cid': cid, - 'bvid': bvid, + if (bvid != null) 'bvid': bvid, + if (aid != null) 'aid': aid, }); try { if (res.data['code'] == 0) { @@ -559,4 +561,50 @@ class VideoHttp { final List body = res.data['body']; return {'content': content, 'body': body}; } + + static Future> getSubscribeStatus( + {required dynamic bvid}) async { + var res = await Request().get( + Api.videoRelation, + data: { + 'aid': IdUtils.bv2av(bvid), + 'bvid': bvid, + }, + ); + if (res.data['code'] == 0) { + return { + 'status': true, + 'data': res.data['data'], + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } + + static Future seasonFav({ + required bool isFav, + required dynamic seasonId, + }) async { + var res = await Request().post( + isFav ? Api.cancelSub : Api.confirmSub, + data: { + 'platform': 'web', + 'season_id': seasonId, + 'csrf': await Request.getCsrf(), + }, + ); + if (res.data['code'] == 0) { + return { + 'status': true, + }; + } else { + return { + 'status': false, + 'msg': res.data['message'], + }; + } + } } diff --git a/lib/main.dart b/lib/main.dart index 3ac97b25..80dcf9f9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -32,7 +32,7 @@ void main() async { MediaKit.ensureInitialized(); await SystemChrome.setPreferredOrientations( [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]); - await GStrorage.init(); + await GStorage.init(); clearLogs(); Request(); await Request.setCookie(); @@ -73,7 +73,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; // 主题色 Color defaultColor = colorThemeTypes[setting.get(SettingBoxKey.customColor, defaultValue: 0)] diff --git a/lib/models/sponsor_block/action_type.dart b/lib/models/sponsor_block/action_type.dart new file mode 100644 index 00000000..d89fcf08 --- /dev/null +++ b/lib/models/sponsor_block/action_type.dart @@ -0,0 +1,26 @@ +// 片段类型枚举 +enum ActionType { + skip, + mute, + full, + poi, + chapter, +} + +extension ActionTypeExtension on ActionType { + String get value => [ + 'skip', + 'mute', + 'full', + 'poi', + 'chapter', + ][index]; + + String get label => [ + '跳过', + '静音', + '完整观看', + '亮点', + '章节切换', + ][index]; +} diff --git a/lib/models/sponsor_block/segment.dart b/lib/models/sponsor_block/segment.dart new file mode 100644 index 00000000..7e6a387f --- /dev/null +++ b/lib/models/sponsor_block/segment.dart @@ -0,0 +1,43 @@ +import 'action_type.dart'; +import 'segment_type.dart'; + +class SegmentDataModel { + final SegmentType? category; + final ActionType? actionType; + final List? segment; + final String? uuid; + final num? videoDuration; + final int? locked; + final int? votes; + final String? description; + // 是否已经跳过 + bool isSkip = false; + + SegmentDataModel({ + this.category, + this.actionType, + this.segment, + this.uuid, + this.videoDuration, + this.locked, + this.votes, + this.description, + }); + + factory SegmentDataModel.fromJson(Map json) { + return SegmentDataModel( + category: SegmentType.values.firstWhere( + (e) => e.value == json['category'], + orElse: () => SegmentType.sponsor), + actionType: ActionType.values.firstWhere( + (e) => e.value == json['actionType'], + orElse: () => ActionType.skip), + segment: json['segment'], + uuid: json['UUID'], + videoDuration: json['videoDuration'], + locked: json['locked'], + votes: json['votes'], + description: json['description'], + ); + } +} diff --git a/lib/models/sponsor_block/segment_type.dart b/lib/models/sponsor_block/segment_type.dart new file mode 100644 index 00000000..b4e3075c --- /dev/null +++ b/lib/models/sponsor_block/segment_type.dart @@ -0,0 +1,46 @@ +// 片段类型枚举 +// ignore_for_file: constant_identifier_names + +enum SegmentType { + sponsor, + intro, + outro, + interaction, + selfpromo, + music_offtopic, + preview, + poi_highlight, + filler, + exclusive_access, + chapter, +} + +extension SegmentTypeExtension on SegmentType { + String get value => [ + 'sponsor', + 'intro', + 'outro', + 'interaction', + 'selfpromo', + 'music_offtopic', + 'preview', + 'poi_highlight', + 'filler', + 'exclusive_access', + 'chapter', + ][index]; + + String get label => [ + '赞助', + '开场介绍', + '片尾致谢', + '互动', + '自我推广', + '音乐', + '预览', + '亮点', + '无效填充', + '独家访问', + '章节', + ][index]; +} diff --git a/lib/models/video/reply/member.dart b/lib/models/video/reply/member.dart index 0801d110..ad10c143 100644 --- a/lib/models/video/reply/member.dart +++ b/lib/models/video/reply/member.dart @@ -29,7 +29,7 @@ class ReplyMember { avatar = json['avatar']; level = json['level_info']['current_level']; pendant = Pendant.fromJson(json['pendant']); - officialVerify = json['officia_verify']; + officialVerify = json['official_verify']; vip = json['vip']; fansDetail = json['fans_detail']; userSailing = json['user_sailing'] != null diff --git a/lib/models/video_detail_res.dart b/lib/models/video_detail_res.dart index 3401d809..ad52a840 100644 --- a/lib/models/video_detail_res.dart +++ b/lib/models/video_detail_res.dart @@ -641,6 +641,7 @@ class EpisodeItem { this.page, this.bvid, this.cover, + this.pages, }); int? seasonId; int? sectionId; @@ -655,6 +656,7 @@ class EpisodeItem { int? pubdate; int? duration; Stat? stat; + List? pages; EpisodeItem.fromJson(Map json) { seasonId = json['season_id']; @@ -670,6 +672,7 @@ class EpisodeItem { pubdate = json['arc']['pubdate']; duration = json['arc']['duration']; stat = Stat.fromJson(json['arc']['stat']); + pages = json['pages'].map((e) => Page.fromJson(e)).toList(); } } @@ -712,3 +715,18 @@ class Vip { status = json['status']; } } + +class Page { + Page({ + this.cid, + this.page, + }); + + int? cid; + int? page; + + Page.fromJson(Map json) { + cid = json['cid']; + page = json['page']; + } +} diff --git a/lib/pages/bangumi/controller.dart b/lib/pages/bangumi/controller.dart index 29dd15d1..746808bf 100644 --- a/lib/pages/bangumi/controller.dart +++ b/lib/pages/bangumi/controller.dart @@ -12,7 +12,7 @@ class BangumiController extends GetxController { RxInt total = 0.obs; int _currentPage = 1; bool isLoadingMore = true; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; late int mid; var userInfo; diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index d79eef79..2e6cd392 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -48,7 +48,7 @@ class BangumiIntroController extends GetxController { RxBool hasCoin = false.obs; // 是否收藏 RxBool hasFav = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; bool userLogin = false; Rx favFolderData = FavFolderData().obs; List addMediaIdsNew = []; diff --git a/lib/pages/bangumi/introduction/view.dart b/lib/pages/bangumi/introduction/view.dart index 429b109a..3ad0625f 100644 --- a/lib/pages/bangumi/introduction/view.dart +++ b/lib/pages/bangumi/introduction/view.dart @@ -116,7 +116,7 @@ class _BangumiInfoState extends State { String heroTag = Get.arguments['heroTag']; late final BangumiIntroController bangumiIntroController; late final VideoDetailController videoDetailCtr; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; late double sheetHeight; int? cid; bool isProcessing = false; diff --git a/lib/pages/bangumi/introduction/widgets/intro_detail.dart b/lib/pages/bangumi/introduction/widgets/intro_detail.dart index 409474a9..a4c469de 100644 --- a/lib/pages/bangumi/introduction/widgets/intro_detail.dart +++ b/lib/pages/bangumi/introduction/widgets/intro_detail.dart @@ -4,7 +4,7 @@ import 'package:pilipala/common/widgets/stat/danmu.dart'; import 'package:pilipala/common/widgets/stat/view.dart'; import 'package:pilipala/utils/storage.dart'; -Box localCache = GStrorage.localCache; +Box localCache = GStorage.localCache; late double sheetHeight; class IntroDetail extends StatelessWidget { diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index cdca500c..f6f1ff22 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -36,7 +36,7 @@ class BangumiPanel extends StatefulWidget { class _BangumiPanelState extends State { late RxInt currentIndex = (-1).obs; final ScrollController listViewScrollCtr = ScrollController(); - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; dynamic userInfo; // 默认未开通 int vipStatus = 0; diff --git a/lib/pages/blacklist/index.dart b/lib/pages/blacklist/index.dart index 0616c1dc..96eff255 100644 --- a/lib/pages/blacklist/index.dart +++ b/lib/pages/blacklist/index.dart @@ -22,7 +22,7 @@ class _BlackListPageState extends State { final ScrollController scrollController = ScrollController(); Future? _futureBuilderFuture; bool _isLoadingMore = false; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void initState() { diff --git a/lib/pages/danmaku/view.dart b/lib/pages/danmaku/view.dart index 3cf1ed8a..5209d437 100644 --- a/lib/pages/danmaku/view.dart +++ b/lib/pages/danmaku/view.dart @@ -32,7 +32,7 @@ class _PlDanmakuState extends State { late PlDanmakuController _plDanmakuController; DanmakuController? _controller; // bool danmuPlayStatus = true; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late bool enableShowDanmaku; late List blockTypes; late double showArea; diff --git a/lib/pages/dynamics/controller.dart b/lib/pages/dynamics/controller.dart index df5b154e..ff5c959a 100644 --- a/lib/pages/dynamics/controller.dart +++ b/lib/pages/dynamics/controller.dart @@ -50,11 +50,11 @@ class DynamicsController extends GetxController { ]; bool flag = false; RxInt initialValue = 0.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; RxBool userLogin = false.obs; var userInfo; RxBool isLoadingDynamic = false.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/dynamics/detail/controller.dart b/lib/pages/dynamics/detail/controller.dart index e7c179f3..88c11f1d 100644 --- a/lib/pages/dynamics/detail/controller.dart +++ b/lib/pages/dynamics/detail/controller.dart @@ -24,7 +24,7 @@ class DynamicDetailController extends GetxController { ReplySortType _sortType = ReplySortType.time; RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt replyReqCode = 200.obs; bool isEnd = false; @@ -37,13 +37,13 @@ class DynamicDetailController extends GetxController { acount.value = int.parse(item!.modules!.moduleStat!.comment!.count ?? '0'); } - int deaultReplySortIndex = + int defaultReplySortIndex = setting.get(SettingBoxKey.replySortType, defaultValue: 0); - if (deaultReplySortIndex == 2) { + if (defaultReplySortIndex == 2) { setting.put(SettingBoxKey.replySortType, 0); - deaultReplySortIndex = 0; + defaultReplySortIndex = 0; } - _sortType = ReplySortType.values[deaultReplySortIndex]; + _sortType = ReplySortType.values[defaultReplySortIndex]; sortTypeTitle.value = _sortType.titles; sortTypeLabel.value = _sortType.labels; } diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 939d6d1f..257ecd49 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -9,9 +9,7 @@ import 'package:pilipala/common/skeleton/dynamic_card.dart'; import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/common/widgets/no_data.dart'; import 'package:pilipala/models/dynamics/result.dart'; -import 'package:pilipala/plugin/pl_popup/index.dart'; import 'package:pilipala/utils/feed_back.dart'; -import 'package:pilipala/utils/global_data_cache.dart'; import 'package:pilipala/utils/main_stream.dart'; import 'package:pilipala/utils/route_push.dart'; import 'package:pilipala/utils/storage.dart'; @@ -19,7 +17,6 @@ import 'package:pilipala/utils/storage.dart'; import '../mine/controller.dart'; import 'controller.dart'; import 'widgets/dynamic_panel.dart'; -import 'up_dynamic/route_panel.dart'; import 'widgets/up_panel.dart'; class DynamicsPage extends StatefulWidget { @@ -35,7 +32,7 @@ class _DynamicsPageState extends State final MineController mineController = Get.put(MineController()); late Future _futureBuilderFuture; late Future _futureBuilderFutureUp; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late ScrollController scrollController; @override @@ -209,21 +206,7 @@ class _DynamicsPageState extends State return Obx( () => UpPanel( upData: _dynamicsController.upData.value, - onClickUpCb: (data) { - if (GlobalDataCache().enableDynamicSwitch) { - Navigator.push( - context, - PlPopupRoute( - child: OverlayPanel( - ctr: _dynamicsController, - upInfo: data, - ), - ), - ); - } else { - _dynamicsController.onTapUp(data); - } - }, + dynamicsController: _dynamicsController, ), ); } else { diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index f45214e3..d5d7958e 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -4,18 +4,22 @@ import 'package:get/get.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/models/dynamics/up.dart'; import 'package:pilipala/models/live/item.dart'; +import 'package:pilipala/plugin/pl_popup/index.dart'; import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/global_data_cache.dart'; import 'package:pilipala/utils/utils.dart'; +import '../controller.dart'; +import '../up_dynamic/route_panel.dart'; + class UpPanel extends StatefulWidget { final FollowUpModel upData; - final Function? onClickUpCb; + final DynamicsController dynamicsController; const UpPanel({ super.key, required this.upData, - this.onClickUpCb, + required this.dynamicsController, }); @override @@ -39,7 +43,15 @@ class _UpPanelState extends State { void onClickUp(data, i) { currentMid.value = data.mid; - widget.onClickUpCb?.call(data); + Navigator.push( + context, + PlPopupRoute( + child: OverlayPanel( + ctr: widget.dynamicsController, + upInfo: data, + ), + ), + ).then((value) => {currentMid.value = -1}); } void onClickUpAni(data, i) { @@ -49,7 +61,7 @@ class _UpPanelState extends State { final upLen = upList.length; currentMid.value = data.mid; - widget.onClickUpCb?.call(data); + widget.dynamicsController.onTapUp(data); double moveDistance = 0.0; final totalItemsWidth = itemWidth * (upLen + liveLen); diff --git a/lib/pages/fan/controller.dart b/lib/pages/fan/controller.dart index 6661d9fe..1a82b538 100644 --- a/lib/pages/fan/controller.dart +++ b/lib/pages/fan/controller.dart @@ -6,7 +6,7 @@ import 'package:pilipala/models/fans/result.dart'; import 'package:pilipala/utils/storage.dart'; class FansController extends GetxController { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int pn = 1; int ps = 20; int total = 0; diff --git a/lib/pages/fav/controller.dart b/lib/pages/fav/controller.dart index 5be46bf0..6ab36bfb 100644 --- a/lib/pages/fav/controller.dart +++ b/lib/pages/fav/controller.dart @@ -11,7 +11,7 @@ class FavController extends GetxController { final ScrollController scrollController = ScrollController(); Rx favFolderData = FavFolderData().obs; RxList favFolderList = [].obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; int currentPage = 1; int pageSize = 60; diff --git a/lib/pages/follow/controller.dart b/lib/pages/follow/controller.dart index fe4b6100..e39eb3cd 100644 --- a/lib/pages/follow/controller.dart +++ b/lib/pages/follow/controller.dart @@ -11,7 +11,7 @@ import 'package:pilipala/utils/storage.dart'; /// 查看自己的关注时,可以查看分类 /// 查看其他人的关注时,只可以看全部 class FollowController extends GetxController with GetTickerProviderStateMixin { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int pn = 1; int ps = 20; int total = 0; diff --git a/lib/pages/history/controller.dart b/lib/pages/history/controller.dart index 64953e3b..7b366d10 100644 --- a/lib/pages/history/controller.dart +++ b/lib/pages/history/controller.dart @@ -12,11 +12,11 @@ class HistoryController extends GetxController { RxList historyList = [].obs; RxBool isLoadingMore = false.obs; RxBool pauseStatus = false.obs; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; RxBool isLoading = false.obs; RxBool enableMultiple = false.obs; RxInt checkedCount = 0.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; @override diff --git a/lib/pages/home/controller.dart b/lib/pages/home/controller.dart index ea6e72ba..91f16c9f 100644 --- a/lib/pages/home/controller.dart +++ b/lib/pages/home/controller.dart @@ -14,12 +14,12 @@ class HomeController extends GetxController with GetTickerProviderStateMixin { late TabController tabController; late List tabsCtrList; late List tabsPageList; - Box userInfoCache = GStrorage.userInfo; - Box settingStorage = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box settingStorage = GStorage.setting; RxBool userLogin = false.obs; RxString userFace = ''.obs; var userInfo; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); late bool hideSearchBar; diff --git a/lib/pages/home/widgets/app_bar.dart b/lib/pages/home/widgets/app_bar.dart index 35cb9d4e..4bf5200a 100644 --- a/lib/pages/home/widgets/app_bar.dart +++ b/lib/pages/home/widgets/app_bar.dart @@ -5,7 +5,7 @@ import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/utils/storage.dart'; -Box userInfoCache = GStrorage.userInfo; +Box userInfoCache = GStorage.userInfo; class HomeAppBar extends StatelessWidget { const HomeAppBar({super.key}); diff --git a/lib/pages/html/controller.dart b/lib/pages/html/controller.dart index 7ba41966..2c45fbe6 100644 --- a/lib/pages/html/controller.dart +++ b/lib/pages/html/controller.dart @@ -25,7 +25,7 @@ class HtmlRenderController extends GetxController { ReplySortType _sortType = ReplySortType.time; RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index e8170d0a..6cb8a3c0 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -13,7 +13,7 @@ class LaterController extends GetxController { RxList laterList = [].obs; int count = 0; RxBool isLoading = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; @override diff --git a/lib/pages/live/controller.dart b/lib/pages/live/controller.dart index 492024e5..a2434624 100644 --- a/lib/pages/live/controller.dart +++ b/lib/pages/live/controller.dart @@ -17,7 +17,7 @@ class LiveController extends GetxController { RxInt liveFollowingCount = 0.obs; bool flag = false; OverlayEntry? popupDialog; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; @override void onInit() { diff --git a/lib/pages/live_follow/controller.dart b/lib/pages/live_follow/controller.dart index 65c99384..049da1f6 100644 --- a/lib/pages/live_follow/controller.dart +++ b/lib/pages/live_follow/controller.dart @@ -7,7 +7,7 @@ import 'package:pilipala/utils/storage.dart'; class LiveFollowController extends GetxController { RxInt crossAxisCount = 2.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; int _currentPage = 1; RxInt liveFollowingCount = 0.obs; RxList liveFollowingList = diff --git a/lib/pages/live_room/controller.dart b/lib/pages/live_room/controller.dart index 0d347bf2..a918ec7b 100644 --- a/lib/pages/live_room/controller.dart +++ b/lib/pages/live_room/controller.dart @@ -33,7 +33,7 @@ class LiveRoomController extends GetxController { int? tempCurrentQn; late List> acceptQnList; RxString currentQnDesc = ''.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; int userId = 0; PlSocket? plSocket; List danmuHostList = []; diff --git a/lib/pages/live_room/widgets/bottom_control.dart b/lib/pages/live_room/widgets/bottom_control.dart index 4dd7c538..aa3d51b8 100644 --- a/lib/pages/live_room/widgets/bottom_control.dart +++ b/lib/pages/live_room/widgets/bottom_control.dart @@ -35,7 +35,7 @@ class _BottomControlState extends State { TextStyle subTitleStyle = const TextStyle(fontSize: 12); TextStyle titleStyle = const TextStyle(fontSize: 14); Size get preferredSize => const Size(double.infinity, kToolbarHeight); - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; @override void initState() { diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 37c8d174..3a3cc9eb 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -20,12 +20,12 @@ class MainController extends GetxController { late List navBarSort; final StreamController bottomBarStream = StreamController.broadcast(); - Box setting = GStrorage.setting; + Box setting = GStorage.setting; DateTime? _lastPressedAt; late bool hideTabBar; late PageController pageController; int selectedIndex = 0; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; dynamic userInfo; RxBool userLogin = false.obs; late Rx dynamicBadgeType = DynamicBadgeMode.number.obs; diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 82df1af9..01fae4bf 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -30,7 +30,7 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { late MineController _mineController; int? _lastSelectTime; //上次点击时间 - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late bool enableMYBar; @override @@ -113,14 +113,14 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { @override void dispose() async { - await GStrorage.close(); + await GStorage.close(); EventBus().off(EventName.loginEvent); super.dispose(); } @override Widget build(BuildContext context) { - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; double statusBarHeight = MediaQuery.of(context).padding.top; double sheetHeight = MediaQuery.sizeOf(context).height - MediaQuery.of(context).padding.top - diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index b805b33d..6e66b5ed 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -18,7 +18,7 @@ class MemberController extends GetxController { late Map userStat; RxString face = ''.obs; String? heroTag; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late int ownerMid; // 投稿列表 RxList? archiveList = [].obs; diff --git a/lib/pages/member/widgets/seasons.dart b/lib/pages/member/widgets/seasons.dart index 615fc44c..497e68e1 100644 --- a/lib/pages/member/widgets/seasons.dart +++ b/lib/pages/member/widgets/seasons.dart @@ -41,6 +41,7 @@ class MemberSeasonsPanel extends StatelessWidget { 'category': '1', 'mid': item.meta!.mid.toString(), 'seriesId': item.meta!.seriesId.toString(), + 'seasonId': item.meta!.seasonId.toString(), 'seasonName': item.meta!.name!, }; } diff --git a/lib/pages/member_seasons/controller.dart b/lib/pages/member_seasons/controller.dart index 4e7c9762..ef85398b 100644 --- a/lib/pages/member_seasons/controller.dart +++ b/lib/pages/member_seasons/controller.dart @@ -24,7 +24,8 @@ class MemberSeasonsController extends GetxController { seasonId = int.parse(Get.parameters['seasonId']!); } if (category == '1') { - seriesId = int.parse(Get.parameters['seriesId']!); + seriesId = int.tryParse(Get.parameters['seriesId']!); + seasonId = int.tryParse(Get.parameters['seasonId']!); } } @@ -73,7 +74,27 @@ class MemberSeasonsController extends GetxController { getSeasonDetail('onLoad'); } if (category == '1') { - getSeriesDetail('onLoad'); + if (seasonId != null) { + getSeasonDetail('onLoad'); + } + if (seriesId != null) { + getSeriesDetail('onLoad'); + } + } + } + + // 下拉刷新 + Future onRefresh() async { + if (category == '0') { + return getSeasonDetail('onRefresh'); + } + if (category == '1') { + if (seasonId != null) { + return getSeasonDetail('onRefresh'); + } + if (seriesId != null) { + return getSeriesDetail('onRefresh'); + } } } } diff --git a/lib/pages/member_seasons/view.dart b/lib/pages/member_seasons/view.dart index b8c0407d..244b0a67 100644 --- a/lib/pages/member_seasons/view.dart +++ b/lib/pages/member_seasons/view.dart @@ -23,9 +23,7 @@ class _MemberSeasonsPageState extends State { void initState() { super.initState(); category = Get.parameters['category']!; - _futureBuilderFuture = category == '0' - ? _memberSeasonsController.getSeasonDetail('onRefresh') - : _memberSeasonsController.getSeriesDetail('onRefresh'); + _futureBuilderFuture = _memberSeasonsController.onRefresh(); scrollController = _memberSeasonsController.scrollController; scrollController.addListener( () { diff --git a/lib/pages/message/utils/index.dart b/lib/pages/message/utils/index.dart index c14e4d0a..d45203ba 100644 --- a/lib/pages/message/utils/index.dart +++ b/lib/pages/message/utils/index.dart @@ -136,6 +136,7 @@ class MessageUtils { .replaceAll('}', ''); result[linkText] = match.group(0)!; } + print('str: $str'); message += str; } } else { @@ -144,6 +145,10 @@ class MessageUtils { } lastMatchEnd = end; } + // 处理剩余的未匹配部分 + if (lastMatchEnd < text.length) { + message += text.substring(lastMatchEnd + 1); + } result['message'] = message; } else { result['message'] = text; diff --git a/lib/pages/mine/controller.dart b/lib/pages/mine/controller.dart index 24401711..6c7c0fda 100644 --- a/lib/pages/mine/controller.dart +++ b/lib/pages/mine/controller.dart @@ -17,8 +17,8 @@ class MineController extends GetxController { Rx userInfo = UserInfoData().obs; Rx themeType = ThemeType.system.obs; Rx favFolderData = FavFolderData().obs; - Box setting = GStrorage.setting; - Box userInfoCache = GStrorage.userInfo; + Box setting = GStorage.setting; + Box userInfoCache = GStorage.userInfo; List menuList = [ { 'icon': Icons.history, diff --git a/lib/pages/mine_edit/controller.dart b/lib/pages/mine_edit/controller.dart index 9bc43246..148aaccc 100644 --- a/lib/pages/mine_edit/controller.dart +++ b/lib/pages/mine_edit/controller.dart @@ -6,7 +6,7 @@ import 'package:pilipala/http/user.dart'; import 'package:pilipala/utils/storage.dart'; class MineEditController extends GetxController { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; final formKey = GlobalKey(); final TextEditingController unameCtr = TextEditingController(); final TextEditingController useridCtr = TextEditingController(); diff --git a/lib/pages/rank/controller.dart b/lib/pages/rank/controller.dart index bb34b13f..ad986772 100644 --- a/lib/pages/rank/controller.dart +++ b/lib/pages/rank/controller.dart @@ -14,7 +14,7 @@ class RankController extends GetxController with GetTickerProviderStateMixin { late TabController tabController; late List tabsCtrList; late List tabsPageList; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 2d606b12..464ab254 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -14,7 +14,7 @@ class RcmdController extends GetxController { // RxList webVideoList = [].obs; bool isLoadingMore = true; OverlayEntry? popupDialog; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt crossAxisCount = 2.obs; late bool enableSaveLastData; late String defaultRcmdType = 'web'; diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 8c478fd1..2da2acff 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -15,7 +15,7 @@ class SSearchController extends GetxController { RxString searchKeyWord = ''.obs; Rx controller = TextEditingController().obs; RxList hotSearchList = [].obs; - Box localCache = GStrorage.localCache; + Box localCache = GStorage.localCache; List historyCacheList = []; RxList historyList = [].obs; RxList searchSuggestList = [].obs; @@ -23,7 +23,7 @@ class SSearchController extends GetxController { Debouncer(delay: const Duration(milliseconds: 200)); // 设置延迟时间 String hintText = '搜索'; RxString defaultSearch = ''.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; bool enableHotKey = true; bool enableSearchSuggest = true; diff --git a/lib/pages/setting/controller.dart b/lib/pages/setting/controller.dart index 49c4d1b7..ca027832 100644 --- a/lib/pages/setting/controller.dart +++ b/lib/pages/setting/controller.dart @@ -13,9 +13,9 @@ import '../main/index.dart'; import 'widgets/select_dialog.dart'; class SettingController extends GetxController { - Box userInfoCache = GStrorage.userInfo; - Box setting = GStrorage.setting; - Box localCache = GStrorage.localCache; + Box userInfoCache = GStorage.userInfo; + Box setting = GStorage.setting; + Box localCache = GStorage.localCache; RxBool userLogin = false.obs; RxBool feedBackEnable = false.obs; diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 5a7dadfb..44add757 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -19,8 +19,8 @@ class ExtraSetting extends StatefulWidget { } class _ExtraSettingState extends State { - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late dynamic defaultReplySort; late dynamic defaultDynamicType; late dynamic enableSystemProxy; diff --git a/lib/pages/setting/pages/action_menu_set.dart b/lib/pages/setting/pages/action_menu_set.dart index 3655df73..cbbd0e84 100644 --- a/lib/pages/setting/pages/action_menu_set.dart +++ b/lib/pages/setting/pages/action_menu_set.dart @@ -13,7 +13,7 @@ class ActionMenuSetPage extends StatefulWidget { } class _ActionMenuSetPageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late List actionTypeSort; late List allLabels; diff --git a/lib/pages/setting/pages/color_select.dart b/lib/pages/setting/pages/color_select.dart index d0e34bcb..e144eb88 100644 --- a/lib/pages/setting/pages/color_select.dart +++ b/lib/pages/setting/pages/color_select.dart @@ -142,7 +142,7 @@ class _ColorSelectPageState extends State { } class ColorSelectController extends GetxController { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxBool dynamicColor = true.obs; RxInt type = 0.obs; late final List> colorThemes; diff --git a/lib/pages/setting/pages/display_mode.dart b/lib/pages/setting/pages/display_mode.dart index 0dcf1958..180accb9 100644 --- a/lib/pages/setting/pages/display_mode.dart +++ b/lib/pages/setting/pages/display_mode.dart @@ -16,7 +16,7 @@ class _SetDiaplayModeState extends State { List modes = []; DisplayMode? active; DisplayMode? preferred; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; final ValueNotifier page = ValueNotifier(0); late final PageController controller = PageController() diff --git a/lib/pages/setting/pages/font_size_select.dart b/lib/pages/setting/pages/font_size_select.dart index f5ca6be3..97c0c402 100644 --- a/lib/pages/setting/pages/font_size_select.dart +++ b/lib/pages/setting/pages/font_size_select.dart @@ -11,7 +11,7 @@ class FontSizeSelectPage extends StatefulWidget { } class _FontSizeSelectPageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; List list = [0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3]; late double minsize; late double maxSize; diff --git a/lib/pages/setting/pages/home_tabbar_set.dart b/lib/pages/setting/pages/home_tabbar_set.dart index 63e87d02..1550a3f2 100644 --- a/lib/pages/setting/pages/home_tabbar_set.dart +++ b/lib/pages/setting/pages/home_tabbar_set.dart @@ -12,7 +12,7 @@ class TabbarSetPage extends StatefulWidget { } class _TabbarSetPageState extends State { - Box settingStorage = GStrorage.setting; + Box settingStorage = GStorage.setting; late List defaultTabs; late List tabbarSort; diff --git a/lib/pages/setting/pages/navigation_bar_set.dart b/lib/pages/setting/pages/navigation_bar_set.dart index 49540163..24796451 100644 --- a/lib/pages/setting/pages/navigation_bar_set.dart +++ b/lib/pages/setting/pages/navigation_bar_set.dart @@ -13,7 +13,7 @@ class NavigationBarSetPage extends StatefulWidget { } class _NavigationbarSetPageState extends State { - Box settingStorage = GStrorage.setting; + Box settingStorage = GStorage.setting; late List defaultNavTabs; late List navBarSort; diff --git a/lib/pages/setting/pages/play_gesture_set.dart b/lib/pages/setting/pages/play_gesture_set.dart index 9659e58a..b901ade9 100644 --- a/lib/pages/setting/pages/play_gesture_set.dart +++ b/lib/pages/setting/pages/play_gesture_set.dart @@ -16,7 +16,7 @@ class PlayGesturePage extends StatefulWidget { } class _PlayGesturePageState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late int fullScreenGestureMode; @override diff --git a/lib/pages/setting/pages/play_speed_set.dart b/lib/pages/setting/pages/play_speed_set.dart index eb81f586..4636d579 100644 --- a/lib/pages/setting/pages/play_speed_set.dart +++ b/lib/pages/setting/pages/play_speed_set.dart @@ -14,8 +14,8 @@ class PlaySpeedPage extends StatefulWidget { } class _PlaySpeedPageState extends State { - Box videoStorage = GStrorage.video; - Box settingStorage = GStrorage.setting; + Box videoStorage = GStorage.video; + Box settingStorage = GStorage.setting; late double playSpeedDefault; late List playSpeedSystem; late double longPressSpeedDefault; diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index a3c75ab5..bcf071dd 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -23,7 +23,7 @@ class PlaySetting extends StatefulWidget { } class _PlaySettingState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late dynamic defaultVideoQa; late dynamic defaultLiveQa; late dynamic defaultAudioQa; diff --git a/lib/pages/setting/privacy_setting.dart b/lib/pages/setting/privacy_setting.dart index 07a02318..493795c2 100644 --- a/lib/pages/setting/privacy_setting.dart +++ b/lib/pages/setting/privacy_setting.dart @@ -14,7 +14,7 @@ class PrivacySetting extends StatefulWidget { class _PrivacySettingState extends State { bool userLogin = false; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; var userInfo; @override diff --git a/lib/pages/setting/recommend_setting.dart b/lib/pages/setting/recommend_setting.dart index ab8ec063..91631db8 100644 --- a/lib/pages/setting/recommend_setting.dart +++ b/lib/pages/setting/recommend_setting.dart @@ -17,10 +17,10 @@ class RecommendSetting extends StatefulWidget { } class _RecommendSettingState extends State { - Box setting = GStrorage.setting; - static Box localCache = GStrorage.localCache; + Box setting = GStorage.setting; + static Box localCache = GStorage.localCache; late dynamic defaultRcmdType; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; late dynamic userInfo; bool userLogin = false; late dynamic accessKeyInfo; @@ -247,10 +247,9 @@ class _RecommendSettingState extends State { '* 其它(如热门视频、手动搜索、链接跳转等)均不受过滤器影响。\n' '* 设定较严苛的条件可导致推荐项数锐减或多次请求,请酌情选择。\n' '* 后续可能会增加更多过滤条件,敬请期待。', - style: Theme.of(context) - .textTheme - .labelSmall! - .copyWith(color: Theme.of(context).colorScheme.outline.withOpacity(0.7)), + style: Theme.of(context).textTheme.labelSmall!.copyWith( + color: + Theme.of(context).colorScheme.outline.withOpacity(0.7)), ), ) ], diff --git a/lib/pages/setting/style_setting.dart b/lib/pages/setting/style_setting.dart index 930a6bde..a94cef29 100644 --- a/lib/pages/setting/style_setting.dart +++ b/lib/pages/setting/style_setting.dart @@ -28,7 +28,7 @@ class _StyleSettingState extends State { final ColorSelectController colorSelectController = Get.put(ColorSelectController()); - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late int picQuality; late ThemeType _tempThemeValue; late dynamic defaultCustomRows; diff --git a/lib/pages/setting/widgets/select_item.dart b/lib/pages/setting/widgets/select_item.dart index a18754a1..8eeaad92 100644 --- a/lib/pages/setting/widgets/select_item.dart +++ b/lib/pages/setting/widgets/select_item.dart @@ -19,7 +19,7 @@ class SetSelectItem extends StatefulWidget { } class _SetSelectItemState extends State { - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late dynamic currentVal; late int currentIndex; late List menus; diff --git a/lib/pages/setting/widgets/switch_item.dart b/lib/pages/setting/widgets/switch_item.dart index d0c2bbf2..9ccda6a7 100644 --- a/lib/pages/setting/widgets/switch_item.dart +++ b/lib/pages/setting/widgets/switch_item.dart @@ -28,7 +28,7 @@ class SetSwitchItem extends StatefulWidget { class _SetSwitchItemState extends State { // ignore: non_constant_identifier_names - Box Setting = GStrorage.setting; + Box Setting = GStorage.setting; late bool val; @override diff --git a/lib/pages/subscription/controller.dart b/lib/pages/subscription/controller.dart index b59a42f0..11fddf3f 100644 --- a/lib/pages/subscription/controller.dart +++ b/lib/pages/subscription/controller.dart @@ -11,7 +11,7 @@ import '../../models/user/sub_folder.dart'; class SubController extends GetxController { final ScrollController scrollController = ScrollController(); Rx subFolderData = SubFolderModelData().obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; UserInfoData? userInfo; int currentPage = 1; int pageSize = 20; diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 925f770b..e09dd20f 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -6,11 +6,14 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:ns_danmaku/ns_danmaku.dart'; +import 'package:pilipala/http/common.dart'; import 'package:pilipala/http/constants.dart'; import 'package:pilipala/http/user.dart'; import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/search_type.dart'; +import 'package:pilipala/models/sponsor_block/segment.dart'; +import 'package:pilipala/models/sponsor_block/segment_type.dart'; import 'package:pilipala/models/video/later.dart'; import 'package:pilipala/models/video/play/quality.dart'; import 'package:pilipala/models/video/play/url.dart'; @@ -68,9 +71,9 @@ class VideoDetailController extends GetxController RxBool enableHA = false.obs; /// 本地存储 - Box userInfoCache = GStrorage.userInfo; - Box localCache = GStrorage.localCache; - Box setting = GStrorage.setting; + Box userInfoCache = GStorage.userInfo; + Box localCache = GStorage.localCache; + Box setting = GStorage.setting; RxInt oid = 0.obs; // 评论id 请求楼中楼评论使用 @@ -120,6 +123,8 @@ class VideoDetailController extends GetxController RxBool isWatchLaterVisible = false.obs; RxString watchLaterTitle = ''.obs; RxInt watchLaterCount = 0.obs; + List skipSegments = []; + int? lastPosition; @override void onInit() { @@ -188,6 +193,11 @@ class VideoDetailController extends GetxController tabCtr.addListener(() { onTabChanged(); }); + + /// 仅投稿视频skip + if (videoType == SearchType.video) { + querySkipSegments(); + } } showReplyReplyPanel(oid, fRpid, firstFloor, currentReply, loadMore) { @@ -305,6 +315,7 @@ class VideoDetailController extends GetxController plPlayerController.headerControl = headerControl; plPlayerController.subtitles.value = subtitles; + onPositionChanged(); } // 视频链接 @@ -706,6 +717,53 @@ class VideoDetailController extends GetxController isWatchLaterVisible.value = tabCtr.index == 0; } + // 获取sponsorBlock数据 + Future querySkipSegments() async { + var res = await CommonHttp.querySkipSegments(bvid: bvid); + if (res['status']) { + /// TODO 根据segmentType过滤数据 + skipSegments = res['data'] ?? []; + } + } + + // 监听视频进度 + void onPositionChanged() async { + final List sponsorSkipSegments = skipSegments + .where((e) => e.category!.value == SegmentType.sponsor.value) + .toList(); + if (sponsorSkipSegments.isEmpty) { + return; + } + + plPlayerController.videoPlayerController?.stream.position + .listen((Duration position) async { + final int positionMs = position.inSeconds; + + // 如果当前秒与上次处理的秒相同,则直接返回 + if (lastPosition != null && lastPosition! == positionMs) { + return; + } + + lastPosition = positionMs; + for (SegmentDataModel segment in sponsorSkipSegments) { + try { + final segmentStart = segment.segment!.first.toInt(); + final segmentEnd = segment.segment!.last.toInt(); + + /// 只有顺序播放时才skip,跳转时间点不会skip + if (positionMs == segmentStart && !segment.isSkip) { + await plPlayerController.videoPlayerController + ?.seek(Duration(seconds: segmentEnd)); + segment.isSkip = true; + SmartDialog.showToast('已跳过${segment.category!.label}片段'); + } + } catch (err) { + SmartDialog.showToast('skipSegments error: $err'); + } + } + }); + } + @override void onClose() { super.onClose(); diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index e78d8121..cfd65b2f 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -41,7 +41,7 @@ class VideoIntroController extends GetxController { RxBool hasFav = false.obs; // 是否不喜欢 RxBool hasDisLike = false.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; bool userLogin = false; Rx favFolderData = FavFolderData().obs; List addMediaIdsNew = []; @@ -63,6 +63,7 @@ class VideoIntroController extends GetxController { PersistentBottomSheetController? bottomSheetController; late bool enableRelatedVideo; UgcSeason? ugcSeason; + RxList pages = [].obs; @override void onInit() { @@ -84,18 +85,20 @@ class VideoIntroController extends GetxController { } // 获取视频简介&分p - Future queryVideoIntro() async { + Future queryVideoIntro({cover}) async { var result = await VideoHttp.videoIntro(bvid: bvid); if (result['status']) { videoDetail.value = result['data']!; ugcSeason = result['data']!.ugcSeason; - if (videoDetail.value.pages!.isNotEmpty && lastPlayCid.value == 0) { - lastPlayCid.value = videoDetail.value.pages!.first.cid!; + pages.value = result['data']!.pages!; + lastPlayCid.value = videoDetail.value.cid!; + if (pages.isNotEmpty) { + lastPlayCid.value = pages.first.cid!; } final VideoDetailController videoDetailCtr = Get.find(tag: heroTag); videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}']; - videoDetailCtr.cover.value = result['data'].pic ?? ''; + videoDetailCtr.cover.value = cover ?? result['data'].pic ?? ''; // 获取到粉丝数再返回 await queryUserStat(); } @@ -470,8 +473,7 @@ class VideoIntroController extends GetxController { videoReplyCtr.queryReplyList(type: 'init'); } catch (_) {} this.bvid = bvid; - lastPlayCid.value = cid; - await queryVideoIntro(); + await queryVideoIntro(cover: cover); } void startTimer() { @@ -521,9 +523,8 @@ class VideoIntroController extends GetxController { final List episodesList = sections[i].episodes!; episodes.addAll(episodesList); } - } else if (videoDetail.value.pages != null) { + } else if (pages.isNotEmpty) { isPages = true; - final List pages = videoDetail.value.pages!; episodes.addAll(pages); } @@ -621,10 +622,9 @@ class VideoIntroController extends GetxController { } } } - if (videoDetail.value.pages != null && - videoDetail.value.pages!.length > 1) { + if (pages.length > 1) { dataType = VideoEpidoesType.videoPart; - episodes = videoDetail.value.pages!; + episodes = pages; } DrawerUtils.showRightDialog( diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 80176a7b..f6b6ed65 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -137,8 +137,8 @@ class _VideoInfoState extends State with TickerProviderStateMixin { late String heroTag; late final VideoIntroController videoIntroController; late final VideoDetailController videoDetailCtr; - final Box localCache = GStrorage.localCache; - final Box setting = GStrorage.setting; + final Box localCache = GStorage.localCache; + final Box setting = GStorage.setting; late double sheetHeight; late final dynamic owner; late int mid; @@ -404,27 +404,18 @@ class _VideoInfoState extends State with TickerProviderStateMixin { Obx( () => SeasonPanel( ugcSeason: widget.videoDetail!.ugcSeason!, - cid: videoIntroController.lastPlayCid.value != 0 - ? videoIntroController.lastPlayCid.value - : widget.videoDetail!.pages!.first.cid, + cid: videoIntroController.lastPlayCid.value, sheetHeight: videoDetailCtr.sheetHeight.value, - changeFuc: (bvid, cid, aid, cover) => - videoIntroController.changeSeasonOrbangu( - bvid, - cid, - aid, - cover, - ), + changeFuc: videoIntroController.changeSeasonOrbangu, videoIntroCtr: videoIntroController, ), ) ], // 合集 videoEpisode - if (widget.videoDetail!.pages != null && - widget.videoDetail!.pages!.length > 1) ...[ + if (videoIntroController.pages.length > 1) ...[ Obx( () => PagesPanel( - pages: widget.videoDetail!.pages!, + pages: videoIntroController.pages, cid: videoIntroController.lastPlayCid.value, sheetHeight: videoDetailCtr.sheetHeight.value, changeFuc: (cid, cover) => diff --git a/lib/pages/video/detail/introduction/widgets/fav_panel.dart b/lib/pages/video/detail/introduction/widgets/fav_panel.dart index acccf862..4a8f57ed 100644 --- a/lib/pages/video/detail/introduction/widgets/fav_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/fav_panel.dart @@ -16,7 +16,7 @@ class FavPanel extends StatefulWidget { } class _FavPanelState extends State { - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; late Future _futureBuilderFuture; @override diff --git a/lib/pages/video/detail/introduction/widgets/group_panel.dart b/lib/pages/video/detail/introduction/widgets/group_panel.dart index bafebf50..1292bcdc 100644 --- a/lib/pages/video/detail/introduction/widgets/group_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/group_panel.dart @@ -18,7 +18,7 @@ class GroupPanel extends StatefulWidget { } class _GroupPanelState extends State { - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; late Future _futureBuilderFuture; late List tagsList; bool showDefault = true; diff --git a/lib/pages/video/detail/introduction/widgets/page_panel.dart b/lib/pages/video/detail/introduction/widgets/page_panel.dart index f75a6989..400d8a62 100644 --- a/lib/pages/video/detail/introduction/widgets/page_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/page_panel.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:pilipala/models/video_detail_res.dart'; -import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/introduction/index.dart'; import '../../../../../common/pages_bottom_sheet.dart'; import '../../../../../models/common/video_episode_type.dart'; @@ -32,25 +31,26 @@ class _PagesPanelState extends State { late int cid; late RxInt currentIndex = (-1).obs; final String heroTag = Get.arguments['heroTag']; - late VideoDetailController _videoDetailController; final ScrollController listViewScrollCtr = ScrollController(); - late PersistentBottomSheetController? _bottomSheetController; + PersistentBottomSheetController? _bottomSheetController; @override void initState() { super.initState(); cid = widget.cid; episodes = widget.pages; - _videoDetailController = Get.find(tag: heroTag); - currentIndex.value = episodes.indexWhere((Part e) => e.cid == cid); - scrollToIndex(); - _videoDetailController.cid.listen((int p0) { + updateCurrentIndexAndScroll(); + widget.videoIntroCtr.lastPlayCid.listen((int p0) { cid = p0; - currentIndex.value = episodes.indexWhere((Part e) => e.cid == cid); - scrollToIndex(); + updateCurrentIndexAndScroll(); }); } + void updateCurrentIndexAndScroll() { + currentIndex.value = widget.pages.indexWhere((Part e) => e.cid == cid); + scrollToIndex(); + } + @override void dispose() { listViewScrollCtr.dispose(); @@ -60,7 +60,10 @@ class _PagesPanelState extends State { void changeFucCall(item, i) async { widget.changeFuc?.call(item.cid, item.cover); currentIndex.value = i; - _bottomSheetController?.close(); + cid = item.cid; + if (_bottomSheetController != null) { + _bottomSheetController?.close(); + } scrollToIndex(); } @@ -112,7 +115,7 @@ class _PagesPanelState extends State { widget.videoIntroCtr.bottomSheetController = _bottomSheetController = EpisodeBottomSheet( currentCid: cid, - episodes: episodes, + episodes: widget.pages, changeFucCall: changeFucCall, sheetHeight: widget.sheetHeight, dataType: VideoEpidoesType.videoPart, diff --git a/lib/pages/video/detail/introduction/widgets/season_panel.dart b/lib/pages/video/detail/introduction/widgets/season_panel.dart index 7161bc92..d86394d2 100644 --- a/lib/pages/video/detail/introduction/widgets/season_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/season_panel.dart @@ -33,6 +33,7 @@ class _SeasonPanelState extends State { final String heroTag = Get.arguments['heroTag']; late VideoDetailController _videoDetailController; late PersistentBottomSheetController? _bottomSheetController; + int currentEpisodeIndex = -1; @override void initState() { @@ -41,13 +42,12 @@ class _SeasonPanelState extends State { _videoDetailController = Get.find(tag: heroTag); /// 根据 cid 找到对应集,找到对应 episodes - /// 有多个episodes时,只显示其中一个 - /// TODO 同时显示多个合集 final List sections = widget.ugcSeason.sections!; for (int i = 0; i < sections.length; i++) { final List episodesList = sections[i].episodes!; for (int j = 0; j < episodesList.length; j++) { if (episodesList[j].cid == cid) { + currentEpisodeIndex = i; episodes = episodesList; continue; } @@ -55,10 +55,10 @@ class _SeasonPanelState extends State { } /// 取对应 season_id 的 episodes - currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid); + getCurrentIndex(); _videoDetailController.cid.listen((int p0) { cid = p0; - currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid); + getCurrentIndex(); }); } @@ -73,6 +73,23 @@ class _SeasonPanelState extends State { _bottomSheetController?.close(); } + // 获取currentIndex + void getCurrentIndex() { + currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid); + final List sections = widget.ugcSeason.sections!; + if (sections.length == 1 && sections.first.type == 1) { + final List episodesList = sections.first.episodes!; + for (int i = 0; i < episodesList.length; i++) { + for (int j = 0; j < episodesList[i].pages!.length; j++) { + if (episodesList[i].pages![j].cid == cid) { + currentIndex.value = i; + continue; + } + } + } + } + } + Widget buildEpisodeListItem( EpisodeItem episode, int index, @@ -125,6 +142,8 @@ class _SeasonPanelState extends State { sheetHeight: widget.sheetHeight, dataType: VideoEpidoesType.videoEpisode, ugcSeason: widget.ugcSeason, + currentEpisodeIndex: currentEpisodeIndex, + currentIndex: currentIndex.value, ).show(context); }, child: Padding( diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index a5797c7b..ab4fc9e3 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -32,20 +32,20 @@ class VideoReplyController extends GetxController { RxString sortTypeTitle = ReplySortType.time.titles.obs; RxString sortTypeLabel = ReplySortType.time.labels.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; RxInt replyReqCode = 200.obs; bool isEnd = false; @override void onInit() { super.onInit(); - int deaultReplySortIndex = + int defaultReplySortIndex = setting.get(SettingBoxKey.replySortType, defaultValue: 0) as int; - if (deaultReplySortIndex == 2) { + if (defaultReplySortIndex == 2) { setting.put(SettingBoxKey.replySortType, 0); - deaultReplySortIndex = 0; + defaultReplySortIndex = 0; } - _sortType = ReplySortType.values[deaultReplySortIndex]; + _sortType = ReplySortType.values[defaultReplySortIndex]; sortTypeTitle.value = _sortType.titles; sortTypeLabel.value = _sortType.labels; } diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index be69d99c..84c0a62f 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -26,7 +26,7 @@ import 'package:pilipala/utils/utils.dart'; import 'reply_save.dart'; import 'zan.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class ReplyItem extends StatelessWidget { const ReplyItem({ @@ -235,32 +235,33 @@ class ReplyItem extends StatelessWidget { // title Container( margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4), - child: !replySave - ? LayoutBuilder(builder: - (BuildContext context, BoxConstraints boxConstraints) { - String text = replyItem?.content?.message ?? ''; - bool didExceedMaxLines = false; - final double maxWidth = boxConstraints.maxWidth; - TextPainter? textPainter; - final int maxLines = - replyItem!.content!.isText! && replyLevel == '1' - ? 6 - : 999; - try { - textPainter = TextPainter( - text: TextSpan(text: text), - maxLines: maxLines, - textDirection: Directionality.of(context), - ); - textPainter.layout(maxWidth: maxWidth); - didExceedMaxLines = textPainter.didExceedMaxLines; - } catch (e) { - debugPrint('Error while measuring text: $e'); - didExceedMaxLines = false; - } - return replyContent(context, didExceedMaxLines, textPainter); - }) - : replyContent(context, false, null), + child: Text.rich( + overflow: TextOverflow.ellipsis, + maxLines: + replyLevel == '1' && replyItem!.content!.isText! ? 5 : 999, + style: const TextStyle(height: 1.75), + TextSpan( + children: [ + if (replyItem!.isTop!) + const WidgetSpan( + alignment: PlaceholderAlignment.top, + child: PBadge( + text: 'TOP', + size: 'small', + stack: 'normal', + type: 'line', + fs: 9, + ), + ), + buildContent( + context, + replyItem!, + replyReply, + null, + ), + ], + ), + ), ), // 操作区域 bottonAction(context, replyItem!.replyControl, replySave), @@ -281,36 +282,6 @@ class ReplyItem extends StatelessWidget { ); } - Widget replyContent( - BuildContext context, bool? didExceedMaxLines, TextPainter? textPainter) { - return Text.rich( - style: const TextStyle(height: 1.75), - TextSpan( - children: [ - if (replyItem!.isTop!) - const WidgetSpan( - alignment: PlaceholderAlignment.top, - child: PBadge( - text: 'TOP', - size: 'small', - stack: 'normal', - type: 'line', - fs: 9, - ), - ), - buildContent( - context, - replyItem!, - replyReply, - null, - didExceedMaxLines ?? false, - textPainter, - ), - ], - ), - ); - } - // 感谢、回复、复制 Widget bottonAction(BuildContext context, replyControl, replySave) { ColorScheme colorScheme = Theme.of(context).colorScheme; @@ -493,8 +464,12 @@ class ReplyItemRow extends StatelessWidget { fs: 9, ), ), - buildContent(context, replies![i], replyReply, - replyItem, false, null), + buildContent( + context, + replies![i], + replyReply, + replyItem, + ), ], ), ), @@ -540,8 +515,6 @@ InlineSpan buildContent( replyItem, replyReply, fReplyItem, - bool didExceedMaxLines, - TextPainter? textPainter, ) { final String routePath = Get.currentRoute; bool isVideoPage = routePath.startsWith('/video'); @@ -553,25 +526,6 @@ InlineSpan buildContent( final content = replyItem.content; final List spanChilds = []; - if (didExceedMaxLines && content.message != '') { - final textSize = textPainter!.size; - var position = textPainter.getPositionForOffset( - Offset( - textSize.width, - textSize.height, - ), - ); - final endOffset = textPainter.getOffsetBefore(position.offset); - - if (endOffset != null && endOffset > 0) { - content.message = content.message.substring(0, endOffset); - } else { - content.message = content.message.substring(0, position.offset); - } - } else { - content.message = content.message2; - } - // 投票 if (content.vote.isNotEmpty) { content.message.splitMapJoin(RegExp(r"\{vote:.*?\}"), @@ -921,17 +875,6 @@ InlineSpan buildContent( } } - if (didExceedMaxLines) { - spanChilds.add( - TextSpan( - text: '\n查看更多', - style: TextStyle( - color: colorScheme.primary, - ), - ), - ); - } - // 图片渲染 if (content.pictures.isNotEmpty) { final List picList = []; diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 8da8e535..592ea684 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -42,7 +42,7 @@ class VideoReplyReplyPanel extends StatefulWidget { class _VideoReplyReplyPanelState extends State { late VideoReplyReplyController _videoReplyReplyController; late AnimationController replyAnimationCtl; - final Box localCache = GStrorage.localCache; + final Box localCache = GStorage.localCache; Future? _futureBuilderFuture; late ScrollController scrollController; diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 57523dd0..a176841e 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -54,8 +54,8 @@ class _VideoDetailPageState extends State Rx playerStatus = PlayerStatus.playing.obs; double doubleOffset = 0; - final Box localCache = GStrorage.localCache; - final Box setting = GStrorage.setting; + final Box localCache = GStorage.localCache; + final Box setting = GStorage.setting; late double statusBarHeight; final double videoHeight = Get.size.width * 9 / 16; late Future _futureBuilderFuture; @@ -101,7 +101,9 @@ class _VideoDetailPageState extends State videoSourceInit(); appbarStreamListen(); - fullScreenStatusListener(); + if (autoPlayEnable) { + fullScreenStatusListener(); + } if (Platform.isAndroid) { floating = vdCtr.floating!; } @@ -137,7 +139,7 @@ class _VideoDetailPageState extends State autoEnterPip(status: status); if (status == PlayerStatus.completed) { // 结束播放退出全屏 - if (autoExitFullcreen) { + if (autoExitFullcreen && plPlayerController!.isFullScreen.value) { plPlayerController!.triggerFullScreen(status: false); } shutdownTimerService.handleWaitingFinished(); @@ -184,6 +186,7 @@ class _VideoDetailPageState extends State await vdCtr.playerInit(autoplay: true); plPlayerController = vdCtr.plPlayerController; plPlayerController!.addStatusLister(playerListener); + fullScreenStatusListener(); vdCtr.autoPlay.value = true; vdCtr.isShowCover.value = false; isShowing.value = true; diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index b2bed21c..f2857398 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -52,8 +52,8 @@ class _HeaderControlState extends State { static const TextStyle subTitleStyle = TextStyle(fontSize: 12); static const TextStyle titleStyle = TextStyle(fontSize: 14); Size get preferredSize => const Size(double.infinity, kToolbarHeight); - final Box localCache = GStrorage.localCache; - final Box videoStorage = GStrorage.video; + final Box localCache = GStorage.localCache; + final Box videoStorage = GStorage.video; late List speedsList; double buttonSpace = 8; RxBool isFullScreen = false.obs; diff --git a/lib/pages/whisper_detail/controller.dart b/lib/pages/whisper_detail/controller.dart index ec828afb..54d6a2c4 100644 --- a/lib/pages/whisper_detail/controller.dart +++ b/lib/pages/whisper_detail/controller.dart @@ -20,7 +20,7 @@ class WhisperDetailController extends GetxController { //表情转换图片规则 RxList eInfos = [].obs; final TextEditingController replyContentController = TextEditingController(); - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; List emoteList = []; List picList = []; diff --git a/lib/pages/whisper_detail/view.dart b/lib/pages/whisper_detail/view.dart index 3ea59343..f79c241d 100644 --- a/lib/pages/whisper_detail/view.dart +++ b/lib/pages/whisper_detail/view.dart @@ -30,7 +30,7 @@ class _WhisperDetailPageState extends State late double emoteHeight = 230.0; double keyboardHeight = 0.0; // 键盘高度 RxString toolbarType = ''.obs; - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; @override void initState() { diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 60a04f74..973dca5e 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -56,8 +56,7 @@ class ChatItem extends StatelessWidget { @override Widget build(BuildContext context) { - bool isOwner = - item.senderUid == GStrorage.userInfo.get('userInfoCache').mid; + bool isOwner = item.senderUid == GStorage.userInfo.get('userInfoCache').mid; bool isPic = item.msgType == MsgType.pic.value; // 图片 bool isText = item.msgType == MsgType.text.value; // 文本 diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 0bd7950c..de4cd9df 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -27,9 +27,9 @@ import '../../models/video/subTitile/content.dart'; import '../../models/video/subTitile/result.dart'; // import 'package:wakelock_plus/wakelock_plus.dart'; -Box videoStorage = GStrorage.video; -Box setting = GStrorage.setting; -Box localCache = GStrorage.localCache; +Box videoStorage = GStorage.video; +Box setting = GStorage.setting; +Box localCache = GStorage.localCache; class PlPlayerController { Player? _videoPlayerController; @@ -1033,6 +1033,8 @@ class PlPlayerController { if (progress >= content['from']! && progress <= content['to']!) { subtitleContent.value = content['content']!; return; + } else { + subtitleContent.value = ''; } } } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index a88bc86f..990661bc 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -82,7 +82,7 @@ class _PLVideoPlayerState extends State final RxDouble _distance = 0.0.obs; final RxBool _volumeInterceptEventStream = false.obs; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; late FullScreenMode mode; late int defaultBtmProgressBehavior; late bool enableQuickDouble; diff --git a/lib/router/app_pages.dart b/lib/router/app_pages.dart index 2d581293..31749764 100644 --- a/lib/router/app_pages.dart +++ b/lib/router/app_pages.dart @@ -66,7 +66,7 @@ import '../pages/whisper/index.dart'; import '../pages/whisper_detail/index.dart'; import '../utils/storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; class Routes { static final List> getPages = [ diff --git a/lib/services/audio_handler.dart b/lib/services/audio_handler.dart index 853c58d0..7aa91eac 100644 --- a/lib/services/audio_handler.dart +++ b/lib/services/audio_handler.dart @@ -24,7 +24,7 @@ Future initAudioService() async { class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { static final List _item = []; - Box setting = GStrorage.setting; + Box setting = GStorage.setting; bool enableBackgroundPlay = false; PlPlayerController player = PlPlayerController(); diff --git a/lib/services/disable_battery_opt.dart b/lib/services/disable_battery_opt.dart index ae018977..d2de0bc3 100644 --- a/lib/services/disable_battery_opt.dart +++ b/lib/services/disable_battery_opt.dart @@ -9,7 +9,7 @@ void DisableBatteryOpt() async { } // 本地缓存中读取 是否禁用了电池优化 默认未禁用 bool isDisableBatteryOptLocal = - GStrorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false); + GStorage.localCache.get('isDisableBatteryOptLocal', defaultValue: false); if (!isDisableBatteryOptLocal) { final isBatteryOptimizationDisabled = await DisableBatteryOptimization.isBatteryOptimizationDisabled; @@ -17,11 +17,11 @@ void DisableBatteryOpt() async { final hasDisabled = await DisableBatteryOptimization .showDisableBatteryOptimizationSettings(); // 设置为已禁用 - GStrorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true); + GStorage.localCache.put('isDisableBatteryOptLocal', hasDisabled == true); } } - bool isManufacturerBatteryOptimizationDisabled = GStrorage.localCache + bool isManufacturerBatteryOptimizationDisabled = GStorage.localCache .get('isManufacturerBatteryOptimizationDisabled', defaultValue: false); if (!isManufacturerBatteryOptimizationDisabled) { final isManBatteryOptimizationDisabled = await DisableBatteryOptimization @@ -33,7 +33,7 @@ void DisableBatteryOpt() async { "按照步骤操作以禁用电池优化,以保证应用在后台正常运行", ); // 设置为已禁用 - GStrorage.localCache.put( + GStorage.localCache.put( 'isManufacturerBatteryOptimizationDisabled', hasDisabled == true); } } diff --git a/lib/utils/data.dart b/lib/utils/data.dart index 7cf00bae..667a7e0d 100644 --- a/lib/utils/data.dart +++ b/lib/utils/data.dart @@ -9,8 +9,8 @@ class Data { } static Future historyStatus() async { - Box localCache = GStrorage.localCache; - Box userInfoCache = GStrorage.userInfo; + Box localCache = GStorage.localCache; + Box userInfoCache = GStorage.userInfo; if (userInfoCache.get('userInfoCache') == null) { return; } diff --git a/lib/utils/feed_back.dart b/lib/utils/feed_back.dart index b0f9f035..4a29af21 100644 --- a/lib/utils/feed_back.dart +++ b/lib/utils/feed_back.dart @@ -2,7 +2,7 @@ import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; import 'storage.dart'; -Box setting = GStrorage.setting; +Box setting = GStorage.setting; void feedBack() { // 设置中是否开启 final bool enable = diff --git a/lib/utils/global_data_cache.dart b/lib/utils/global_data_cache.dart index 794d4737..3321c660 100644 --- a/lib/utils/global_data_cache.dart +++ b/lib/utils/global_data_cache.dart @@ -5,10 +5,10 @@ import 'package:pilipala/plugin/pl_player/models/play_speed.dart'; import 'package:pilipala/utils/storage.dart'; import '../models/common/index.dart'; -Box setting = GStrorage.setting; -Box localCache = GStrorage.localCache; -Box videoStorage = GStrorage.video; -Box userInfoCache = GStrorage.userInfo; +Box setting = GStorage.setting; +Box localCache = GStorage.localCache; +Box videoStorage = GStorage.video; +Box userInfoCache = GStorage.userInfo; class GlobalDataCache { late int imgQuality; diff --git a/lib/utils/login.dart b/lib/utils/login.dart index 841251b8..9dde1cb1 100644 --- a/lib/utils/login.dart +++ b/lib/utils/login.dart @@ -18,9 +18,6 @@ import 'package:pilipala/utils/storage.dart'; import 'package:uuid/uuid.dart'; class LoginUtils { - static Box userInfoCache = GStrorage.userInfo; - static Box localCache = GStrorage.localCache; - static Future refreshLoginStatus(bool status) async { try { // 更改我的页面登录状态 @@ -76,7 +73,7 @@ class LoginUtils { if (result['status'] && result['data'].isLogin) { SmartDialog.showToast('登录成功'); try { - Box userInfoCache = GStrorage.userInfo; + Box userInfoCache = GStorage.userInfo; if (!userInfoCache.isOpen) { userInfoCache = await Hive.openBox('userInfo'); } diff --git a/lib/utils/recommend_filter.dart b/lib/utils/recommend_filter.dart index 113e2261..29907c63 100644 --- a/lib/utils/recommend_filter.dart +++ b/lib/utils/recommend_filter.dart @@ -13,7 +13,7 @@ class RecommendFilter { } static void update() { - var setting = GStrorage.setting; + var setting = GStorage.setting; // filterUnfollowedRatio = // setting.get(SettingBoxKey.filterUnfollowedRatio, defaultValue: 0); minDurationForRcmd = diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index ed14b8df..a5b36768 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -3,7 +3,7 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:path_provider/path_provider.dart'; import 'package:pilipala/models/user/info.dart'; -class GStrorage { +class GStorage { static late final Box userInfo; static late final Box localCache; static late final Box setting; diff --git a/lib/utils/wbi_sign.dart b/lib/utils/wbi_sign.dart index 4f831f16..3dd72150 100644 --- a/lib/utils/wbi_sign.dart +++ b/lib/utils/wbi_sign.dart @@ -9,7 +9,7 @@ import '../http/index.dart'; import 'storage.dart'; class WbiSign { - static Box localCache = GStrorage.localCache; + static Box localCache = GStorage.localCache; final List mixinKeyEncTab = [ 46, 47, diff --git a/pubspec.lock b/pubspec.lock index 35e34ab9..b0839e19 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -533,18 +533,18 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" + sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2" url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.2+1" + version: "0.9.3" file_selector_macos: dependency: transitive description: name: file_selector_macos - sha256: cb284e267f8e2a45a904b5c094d2ba51d0aabfc20b1538ab786d9ef7dc2bf75c + sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc" url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.4+1" + version: "0.9.4+2" file_selector_platform_interface: dependency: transitive description: @@ -557,10 +557,10 @@ packages: dependency: transitive description: name: file_selector_windows - sha256: "2ad726953f6e8affbc4df8dc78b77c3b4a060967a291e528ef72ae846c60fb69" + sha256: "8f5d2f6590d51ecd9179ba39c64f722edc15226cc93dcc8698466ad36a4a85a4" url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.3+2" + version: "0.9.3+3" fixnum: dependency: transitive description: @@ -842,10 +842,10 @@ packages: dependency: transitive description: name: image_picker_ios - sha256: "6703696ad49f5c3c8356d576d7ace84d1faf459afb07accbb0fae780753ff447" + sha256: "4f0568120c6fcc0aaa04511cb9f9f4d29fc3d0139884b1d06be88dcec7641d6b" url: "https://pub.flutter-io.cn" source: hosted - version: "0.8.12" + version: "0.8.12+1" image_picker_linux: dependency: transitive description: @@ -1438,10 +1438,10 @@ packages: dependency: "direct main" description: name: scrollview_observer - sha256: fa408bcfd41e19da841eb53fc471f8f952d5ef818b854d2505c4bb3f0c876381 + sha256: "8537ba32e5a15ade301e5c77ae858fd8591695defaad1821eca9eeb4ac28a157" url: "https://pub.flutter-io.cn" source: hosted - version: "1.22.0" + version: "1.23.0" sentry: dependency: transitive description: