Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-21 12:46:34 +08:00
parent 5f3f158932
commit 604d78ad6a
161 changed files with 4873 additions and 4770 deletions

119
lib/utils/accounts.dart Normal file
View File

@@ -0,0 +1,119 @@
import 'dart:io';
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/pages/mine/controller.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/login_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
class Accounts {
static late final Box<LoginAccount> account;
static final Map<AccountType, Account> accountMode = {};
static Account get main => accountMode[AccountType.main]!;
// static set main(Account account) => set(AccountType.main, account);
static Future<void> init() async {
account = await Hive.openBox('account',
compactionStrategy: (int entries, int deletedEntries) {
return deletedEntries > 2;
});
await _migrate();
}
static Future<void> _migrate() async {
final Directory tempDir = await getApplicationSupportDirectory();
final String tempPath = "${tempDir.path}/.plpl/";
final Directory dir = Directory(tempPath);
if (dir.existsSync()) {
if (kDebugMode) debugPrint('migrating...');
final cookieJar =
PersistCookieJar(ignoreExpires: true, storage: FileStorage(tempPath));
await cookieJar.forceInit();
final cookies = DefaultCookieJar(ignoreExpires: true)
..domainCookies.addAll(cookieJar.domainCookies);
final localAccessKey =
GStorage.localCache.get('accessKey', defaultValue: {});
final isLogin =
cookies.domainCookies['bilibili.com']?['/']?['SESSDATA'] != null;
await Future.wait([
GStorage.localCache.delete('accessKey'),
GStorage.localCache.delete('danmakuFilterRule'),
GStorage.localCache.delete('blackMidsList'),
dir.delete(recursive: true),
if (isLogin)
LoginAccount(cookies, localAccessKey['value'],
localAccessKey['refresh'], AccountType.values.toSet())
.onChange()
]);
if (kDebugMode) debugPrint('migrated successfully');
}
}
static void refresh() {
for (var a in account.values) {
for (var t in a.type) {
accountMode[t] = a;
}
}
for (var type in AccountType.values) {
accountMode[type] ??= AnonymousAccount();
}
// await Future.wait((accountMode.values.toSet()
// ..retainWhere((i) => !i.activited))
// .map((i) => Request.buvidActive(i)));
}
static Future<void> clear() async {
await account.clear();
for (var i in AccountType.values) {
accountMode[i] = AnonymousAccount();
}
await AnonymousAccount().delete();
// Request.buvidActive(AnonymousAccount());
}
static void close() {
account
..compact()
..close();
}
static Future<void> deleteAll(Set<Account> accounts) async {
var isloginMain = Accounts.main.isLogin;
Accounts.accountMode
.updateAll((_, a) => accounts.contains(a) ? AnonymousAccount() : a);
await Future.wait(accounts.map((i) => i.delete()));
if (isloginMain && !Accounts.main.isLogin) {
await LoginUtils.onLogoutMain();
}
}
static Future<void> set(AccountType key, Account account) async {
await (accountMode[key]?..type.remove(key))?.onChange();
accountMode[key] = account..type.add(key);
await account.onChange();
// if (!account.activited) await Request.buvidActive(account);
switch (key) {
case AccountType.main:
await (account.isLogin
? LoginUtils.onLoginMain()
: LoginUtils.onLogoutMain());
break;
case AccountType.heartbeat:
MineController.anonymity.value = !account.isLogin;
break;
default:
break;
}
}
static Account get(AccountType key) {
return accountMode[key]!;
}
}

View File

@@ -1,6 +1,6 @@
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:hive/hive.dart';

View File

@@ -5,10 +5,11 @@ import 'dart:io';
import 'package:PiliPlus/http/api.dart';
import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/app_sign.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
@@ -72,7 +73,7 @@ class AccountManager extends Interceptor {
AccountManager();
String blockServer = GStorage.blockServer;
String blockServer = Pref.blockServer;
static String getCookies(List<Cookie> cookies) {
// Sort cookies by path (longer path first).

View File

@@ -1,5 +1,7 @@
import 'package:PiliPlus/http/user.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_key.dart';
class Data {
static Future<void> init() async {

View File

@@ -1,7 +1,7 @@
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:flutter/services.dart' show HapticFeedback;
bool enableFeedback = GStorage.feedBackEnable;
bool enableFeedback = Pref.feedBackEnable;
void feedBack() {
if (enableFeedback) {
HapticFeedback.lightImpact();

View File

@@ -1,7 +1,7 @@
class GlobalData {
int imgQuality = 10;
import 'package:PiliPlus/utils/storage_pref.dart';
int replyLengthLimit = 6;
class GlobalData {
int imgQuality = Pref.picQuality;
num? coins;
@@ -11,6 +11,10 @@ class GlobalData {
}
}
Set<int> blackMids = Pref.blackMids;
bool dynamicsWaterfallFlow = Pref.dynamicsWaterfallFlow;
// 私有构造函数
GlobalData._();

View File

@@ -1,12 +1,12 @@
import 'dart:math';
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class Grid {
static double smallCardWidth = GStorage.smallCardWidth;
static final double smallCardWidth = Pref.smallCardWidth;
static SliverGridDelegateWithExtentAndRatio videoCardHDelegate(
BuildContext context,

View File

@@ -14,6 +14,7 @@ import 'package:PiliPlus/pages/media/controller.dart';
import 'package:PiliPlus/pages/mine/controller.dart';
import 'package:PiliPlus/pages/pgc/controller.dart';
import 'package:PiliPlus/services/account_service.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart' as web;

View File

@@ -21,7 +21,7 @@ import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/feed_back.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/url_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:floating/floating.dart';
@@ -540,7 +540,7 @@ class PageUtils {
String url, {
bool off = false,
}) {
if (GStorage.openInBrowser) {
if (Pref.openInBrowser) {
launchURL(url);
} else {
if (off) {
@@ -579,7 +579,7 @@ class PageUtils {
bool inApp = false,
Map? parameters,
}) async {
if (!inApp && GStorage.openInBrowser) {
if (!inApp && Pref.openInBrowser) {
if (!await PiliScheme.routePushFromUrl(url, selfHandle: true)) {
launchURL(url);
}

View File

@@ -1,33 +1,15 @@
import 'package:PiliPlus/models/model_video.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:hive/hive.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
class RecommendFilter {
static late int minDurationForRcmd;
static late int minPlayForRcmd;
static late int minLikeRatioForRecommend;
static late bool exemptFilterForFollowed;
static late bool applyFilterToRelatedVideos;
static int minDurationForRcmd = Pref.minDurationForRcmd;
static int minPlayForRcmd = Pref.minPlayForRcmd;
static int minLikeRatioForRecommend = Pref.minLikeRatioForRecommend;
static bool exemptFilterForFollowed = Pref.exemptFilterForFollowed;
static bool applyFilterToRelatedVideos = Pref.applyFilterToRelatedVideos;
static RegExp rcmdRegExp =
RegExp(GStorage.banWordForRecommend, caseSensitive: false);
RecommendFilter() {
update();
}
static Box get setting => GStorage.setting;
static void update() {
minDurationForRcmd =
setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
minPlayForRcmd = setting.get(SettingBoxKey.minPlayForRcmd, defaultValue: 0);
minLikeRatioForRecommend =
setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
exemptFilterForFollowed =
setting.get(SettingBoxKey.exemptFilterForFollowed, defaultValue: true);
applyFilterToRelatedVideos = setting
.get(SettingBoxKey.applyFilterToRelatedVideos, defaultValue: true);
}
RegExp(Pref.banWordForRecommend, caseSensitive: false);
static bool enableFilter = rcmdRegExp.pattern.isNotEmpty;
static bool filter(BaseVideoItemModel videoItem) {
//由于相关视频中没有已关注标签,只能视为非关注视频
@@ -48,7 +30,7 @@ class RecommendFilter {
}
static bool filterTitle(String title) {
return (rcmdRegExp.pattern.isNotEmpty && rcmdRegExp.hasMatch(title));
return (enableFilter && rcmdRegExp.hasMatch(title));
}
static bool filterAll(BaseVideoItemModel videoItem) {

View File

@@ -7,10 +7,10 @@ import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/reply.dart';
import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
import 'package:PiliPlus/models_new/reply/data.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/storage.dart' show Accounts;
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';

View File

@@ -23,8 +23,9 @@ import 'package:PiliPlus/pages/common/multi_select_controller.dart';
import 'package:PiliPlus/pages/dynamics_tab/controller.dart';
import 'package:PiliPlus/pages/group_panel/view.dart';
import 'package:PiliPlus/pages/later/controller.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/feed_back.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
@@ -289,7 +290,7 @@ class RequestUtils {
static Future<void> checkCreatedDyn(
{dynamic id, String? dynText, bool isManual = false}) async {
if (isManual || GStorage.enableCreateDynAntifraud) {
if (isManual || Pref.enableCreateDynAntifraud) {
try {
if (id != null) {
if (!isManual) {

View File

@@ -1,47 +1,16 @@
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:PiliPlus/common/widgets/pair.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'
show kDragContainerExtentPercentage, displacement;
import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/models/common/dynamic/dynamic_badge_mode.dart';
import 'package:PiliPlus/models/common/dynamic/up_panel_position.dart';
import 'package:PiliPlus/models/common/home_tab_type.dart';
import 'package:PiliPlus/models/common/member/tab_type.dart';
import 'package:PiliPlus/models/common/msg/msg_unread_type.dart';
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
import 'package:PiliPlus/models/common/theme/theme_type.dart';
import 'package:PiliPlus/models/common/video/audio_quality.dart';
import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/common/video/live_quality.dart';
import 'package:PiliPlus/models/common/video/subtitle_pref_type.dart';
import 'package:PiliPlus/models/common/video/video_decode_type.dart';
import 'package:PiliPlus/models/common/video/video_quality.dart';
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models/user/danmaku_rule.dart';
import 'package:PiliPlus/models/user/danmaku_rule_adapter.dart';
import 'package:PiliPlus/models/user/info.dart';
import 'package:PiliPlus/pages/mine/controller.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/accounts/account_adapter.dart';
import 'package:PiliPlus/utils/accounts/account_type_adapter.dart';
import 'package:PiliPlus/utils/accounts/cookie_jar_adapter.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/login_utils.dart';
import 'package:PiliPlus/utils/set_int_adapter.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:uuid/uuid.dart';
class GStorage {
static late final Box<dynamic> userInfo;
@@ -50,510 +19,6 @@ class GStorage {
static late final Box<dynamic> setting;
static late final Box<dynamic> video;
static List<double> get speedList => List<double>.from(
video.get(
VideoBoxKey.speedsList,
defaultValue: const [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0],
),
);
static List<int> get tabbarSort =>
List<int>.from(setting.get(SettingBoxKey.tabBarSort) ??
HomeTabType.values.map((item) => item.index).toList());
static List<Pair<SegmentType, SkipType>> get blockSettings {
List<int> list = List<int>.from(setting.get(SettingBoxKey.blockSettings) ??
List.generate(SegmentType.values.length, (_) => 1));
return SegmentType.values
.map((item) => Pair<SegmentType, SkipType>(
first: item,
second: SkipType.values[list[item.index]],
))
.toList();
}
static List<Color> get blockColor {
List<String> list = List<String>.from(
setting.get(SettingBoxKey.blockColor) ??
List.generate(SegmentType.values.length, (_) => ''));
return SegmentType.values
.map((item) => list[item.index].isNotEmpty
? Color(
int.tryParse('FF${list[item.index]}', radix: 16) ?? 0xFF000000)
: item.color)
.toList();
}
static bool get hiddenSettingUnlocked =>
setting.get(SettingBoxKey.hiddenSettingUnlocked, defaultValue: false);
static bool get feedBackEnable =>
setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
static double get toastOpacity =>
setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
static int get picQuality =>
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
static ThemeType get themeType => ThemeType.values[themeTypeInt];
static DynamicBadgeMode get dynamicBadgeType =>
DynamicBadgeMode.values[setting.get(
SettingBoxKey.dynamicBadgeMode,
defaultValue: DynamicBadgeMode.number.index,
)];
static DynamicBadgeMode get msgBadgeMode =>
DynamicBadgeMode.values[setting.get(
SettingBoxKey.msgBadgeMode,
defaultValue: DynamicBadgeMode.number.index,
)];
static Set<MsgUnReadType> get msgUnReadTypeV2 =>
(setting.get(SettingBoxKey.msgUnReadTypeV2) as List?)
?.map((index) => MsgUnReadType.values[index])
.toSet() ??
MsgUnReadType.values.toSet();
static int get defaultHomePage =>
setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0);
static int get previewQ =>
setting.get(SettingBoxKey.previewQuality, defaultValue: 100);
static double get smallCardWidth =>
setting.get(SettingBoxKey.smallCardWidth, defaultValue: 240.0);
static UpPanelPosition get upPanelPosition =>
UpPanelPosition.values[setting.get(SettingBoxKey.upPanelPosition,
defaultValue: UpPanelPosition.leftFixed.index)];
static int get defaultFullScreenMode =>
setting.get(SettingBoxKey.fullScreenMode,
defaultValue: FullScreenMode.values.first.code);
static int get defaultBtmProgressBehavior =>
setting.get(SettingBoxKey.btmProgressBehavior,
defaultValue: BtmProgressBehavior.values.first.code);
static String get defaultSubtitlePreference =>
setting.get(SettingBoxKey.subtitlePreference,
defaultValue: SubtitlePrefType.values.first.code);
static bool get useRelativeSlide =>
setting.get(SettingBoxKey.useRelativeSlide, defaultValue: false);
static int get sliderDuration =>
setting.get(SettingBoxKey.sliderDuration, defaultValue: 90);
static int get defaultVideoQa => setting.get(
SettingBoxKey.defaultVideoQa,
defaultValue: VideoQuality.values.last.code,
);
static int get defaultVideoQaCellular => setting.get(
SettingBoxKey.defaultVideoQaCellular,
defaultValue: VideoQuality.high1080.code,
);
static int get defaultAudioQa => setting.get(
SettingBoxKey.defaultAudioQa,
defaultValue: AudioQuality.values.last.code,
);
static int get defaultAudioQaCellular => setting.get(
SettingBoxKey.defaultAudioQaCellular,
defaultValue: AudioQuality.k192.code,
);
static String get defaultDecode => setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormatType.values.last.code,
);
static String get secondDecode => setting.get(
SettingBoxKey.secondDecode,
defaultValue: VideoDecodeFormatType.values[1].code,
);
static String get hardwareDecoding => setting.get(
SettingBoxKey.hardwareDecoding,
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto',
);
static String get videoSync => setting.get(
SettingBoxKey.videoSync,
defaultValue: 'display-resample',
);
static String get defaultCDNService => setting.get(
SettingBoxKey.CDNService,
defaultValue: CDNService.backupUrl.code,
);
static String get banWordForRecommend =>
setting.get(SettingBoxKey.banWordForRecommend, defaultValue: '');
static String get banWordForReply =>
setting.get(SettingBoxKey.banWordForReply, defaultValue: '');
static String get banWordForZone =>
setting.get(SettingBoxKey.banWordForZone, defaultValue: '');
static bool get appRcmd =>
setting.get(SettingBoxKey.appRcmd, defaultValue: true);
static String get defaultSystemProxyHost =>
setting.get(SettingBoxKey.systemProxyHost, defaultValue: '');
static String get defaultSystemProxyPort =>
setting.get(SettingBoxKey.systemProxyPort, defaultValue: '');
static int get defaultReplySort =>
setting.get(SettingBoxKey.replySortType, defaultValue: 1);
static int get defaultDynamicType =>
setting.get(SettingBoxKey.defaultDynamicType, defaultValue: 0);
static double get blockLimit =>
setting.get(SettingBoxKey.blockLimit, defaultValue: 0.0);
static double get refreshDragPercentage =>
setting.get(SettingBoxKey.refreshDragPercentage, defaultValue: 0.25);
static double get refreshDisplacement =>
setting.get(SettingBoxKey.refreshDisplacement, defaultValue: 20.0);
static String get blockUserID {
String blockUserID =
setting.get(SettingBoxKey.blockUserID, defaultValue: '');
if (blockUserID.isEmpty) {
blockUserID = const Uuid().v4().replaceAll('-', '');
setting.put(SettingBoxKey.blockUserID, blockUserID);
}
return blockUserID;
}
static bool get blockToast =>
setting.get(SettingBoxKey.blockToast, defaultValue: true);
static String get blockServer => setting.get(SettingBoxKey.blockServer,
defaultValue: HttpString.sponsorBlockBaseUrl);
static bool get blockTrack =>
setting.get(SettingBoxKey.blockTrack, defaultValue: true);
static bool get checkDynamic =>
setting.get(SettingBoxKey.checkDynamic, defaultValue: true);
static int get dynamicPeriod =>
setting.get(SettingBoxKey.dynamicPeriod, defaultValue: 5);
static int get schemeVariant =>
setting.get(SettingBoxKey.schemeVariant, defaultValue: 10);
static double get danmakuFontScaleFS =>
setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
static bool get danmakuMassiveMode =>
setting.get(SettingBoxKey.danmakuMassiveMode, defaultValue: false);
static double get subtitleFontScale =>
setting.get(SettingBoxKey.subtitleFontScale, defaultValue: 1.0);
static double get subtitleFontScaleFS =>
setting.get(SettingBoxKey.subtitleFontScaleFS, defaultValue: 1.5);
static bool get showViewPoints =>
setting.get(SettingBoxKey.showViewPoints, defaultValue: true);
static bool get showRelatedVideo =>
setting.get(SettingBoxKey.showRelatedVideo, defaultValue: true);
static bool get showVideoReply =>
setting.get(SettingBoxKey.showVideoReply, defaultValue: true);
static bool get showBangumiReply =>
setting.get(SettingBoxKey.showBangumiReply, defaultValue: true);
static bool get alwaysExapndIntroPanel =>
setting.get(SettingBoxKey.alwaysExapndIntroPanel, defaultValue: false);
static bool get exapndIntroPanelH =>
setting.get(SettingBoxKey.exapndIntroPanelH, defaultValue: false);
static bool get horizontalSeasonPanel =>
setting.get(SettingBoxKey.horizontalSeasonPanel, defaultValue: false);
static bool get horizontalMemberPage =>
setting.get(SettingBoxKey.horizontalMemberPage, defaultValue: false);
static int get replyLengthLimit =>
setting.get(SettingBoxKey.replyLengthLimit, defaultValue: 6);
static int get defaultPicQa =>
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
static double get danmakuLineHeight =>
setting.get(SettingBoxKey.danmakuLineHeight, defaultValue: 1.6);
static bool get showArgueMsg =>
setting.get(SettingBoxKey.showArgueMsg, defaultValue: true);
static bool get reverseFromFirst =>
setting.get(SettingBoxKey.reverseFromFirst, defaultValue: true);
static int get subtitlePaddingH =>
setting.get(SettingBoxKey.subtitlePaddingH, defaultValue: 24);
static int get subtitlePaddingB =>
setting.get(SettingBoxKey.subtitlePaddingB, defaultValue: 24);
static double get subtitleBgOpaticy =>
setting.get(SettingBoxKey.subtitleBgOpaticy, defaultValue: 0.67);
static double get subtitleStrokeWidth =>
setting.get(SettingBoxKey.subtitleStrokeWidth, defaultValue: 2.0);
static int get subtitleFontWeight =>
setting.get(SettingBoxKey.subtitleFontWeight, defaultValue: 5);
static bool get badCertificateCallback =>
setting.get(SettingBoxKey.badCertificateCallback, defaultValue: false);
static bool get continuePlayingPart =>
setting.get(SettingBoxKey.continuePlayingPart, defaultValue: true);
static bool get cdnSpeedTest =>
setting.get(SettingBoxKey.cdnSpeedTest, defaultValue: true);
static bool get autoUpdate =>
setting.get(SettingBoxKey.autoUpdate, defaultValue: true);
static bool get horizontalPreview =>
setting.get(SettingBoxKey.horizontalPreview, defaultValue: false);
static bool get openInBrowser =>
setting.get(SettingBoxKey.openInBrowser, defaultValue: false);
static bool get savedRcmdTip =>
setting.get(SettingBoxKey.savedRcmdTip, defaultValue: true);
static bool get showVipDanmaku =>
setting.get(SettingBoxKey.showVipDanmaku, defaultValue: true);
static bool get showSpecialDanmaku =>
setting.get(SettingBoxKey.showSpecialDanmaku, defaultValue: false);
static bool get mergeDanmaku =>
setting.get(SettingBoxKey.mergeDanmaku, defaultValue: false);
static bool get showHotRcmd =>
setting.get(SettingBoxKey.showHotRcmd, defaultValue: false);
static String get audioNormalization =>
setting.get(SettingBoxKey.audioNormalization, defaultValue: '0');
static int get superResolutionType =>
setting.get(SettingBoxKey.superResolutionType, defaultValue: 0);
static bool get preInitPlayer =>
setting.get(SettingBoxKey.preInitPlayer, defaultValue: false);
static bool get mainTabBarView =>
setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
static bool get searchSuggestion =>
setting.get(SettingBoxKey.searchSuggestion, defaultValue: true);
static bool get showDynDecorate =>
setting.get(SettingBoxKey.showDynDecorate, defaultValue: true);
static bool get enableLivePhoto =>
setting.get(SettingBoxKey.enableLivePhoto, defaultValue: true);
static bool get showSeekPreview =>
setting.get(SettingBoxKey.showSeekPreview, defaultValue: true);
static bool get showDmChart =>
setting.get(SettingBoxKey.showDmChart, defaultValue: false);
static bool get enableCommAntifraud =>
setting.get(SettingBoxKey.enableCommAntifraud, defaultValue: false);
static bool get biliSendCommAntifraud =>
setting.get(SettingBoxKey.biliSendCommAntifraud, defaultValue: false);
static bool get enableCreateDynAntifraud =>
setting.get(SettingBoxKey.enableCreateDynAntifraud, defaultValue: false);
static bool get coinWithLike =>
setting.get(SettingBoxKey.coinWithLike, defaultValue: false);
static bool get isPureBlackTheme =>
setting.get(SettingBoxKey.isPureBlackTheme, defaultValue: false);
static bool antiGoodsDyn =
setting.get(SettingBoxKey.antiGoodsDyn, defaultValue: false);
static bool get antiGoodsReply =>
setting.get(SettingBoxKey.antiGoodsReply, defaultValue: false);
static bool get expandDynLivePanel =>
setting.get(SettingBoxKey.expandDynLivePanel, defaultValue: false);
static bool slideDismissReplyPage = setting
.get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS);
static bool get showFSActionItem =>
setting.get(SettingBoxKey.showFSActionItem, defaultValue: true);
static bool get enableShrinkVideoSize =>
setting.get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true);
static bool get showDynActionBar =>
setting.get(SettingBoxKey.showDynActionBar, defaultValue: true);
static bool get darkVideoPage =>
setting.get(SettingBoxKey.darkVideoPage, defaultValue: false);
static bool get enableSlideVolumeBrightness => setting
.get(SettingBoxKey.enableSlideVolumeBrightness, defaultValue: true);
static bool get enableSlideFS =>
setting.get(SettingBoxKey.enableSlideFS, defaultValue: true);
static int get retryCount =>
setting.get(SettingBoxKey.retryCount, defaultValue: 2);
static int get retryDelay =>
setting.get(SettingBoxKey.retryDelay, defaultValue: 500);
static int get liveQuality => setting.get(SettingBoxKey.liveQuality,
defaultValue: LiveQuality.origin.code);
static int get liveQualityCellular =>
setting.get(SettingBoxKey.liveQualityCellular,
defaultValue: LiveQuality.superHD.code);
static int get appFontWeight =>
setting.get(SettingBoxKey.appFontWeight, defaultValue: -1);
static bool get enableDragSubtitle =>
setting.get(SettingBoxKey.enableDragSubtitle, defaultValue: false);
static int get fastForBackwardDuration =>
setting.get(SettingBoxKey.fastForBackwardDuration, defaultValue: 10);
static bool get recordSearchHistory =>
setting.get(SettingBoxKey.recordSearchHistory, defaultValue: true);
static bool get navSearchStreamDebounce =>
setting.get(SettingBoxKey.navSearchStreamDebounce, defaultValue: false);
static String get webdavUri =>
setting.get(SettingBoxKey.webdavUri, defaultValue: '');
static String get webdavUsername =>
setting.get(SettingBoxKey.webdavUsername, defaultValue: '');
static String get webdavPassword =>
setting.get(SettingBoxKey.webdavPassword, defaultValue: '');
static String get webdavDirectory =>
setting.get(SettingBoxKey.webdavDirectory, defaultValue: '/');
static bool get showPgcTimeline =>
setting.get(SettingBoxKey.showPgcTimeline, defaultValue: true);
static Transition pageTransition = Transition.values[setting.get(
SettingBoxKey.pageTransition,
defaultValue: Transition.native.index)];
static num get maxCacheSize =>
setting.get(SettingBoxKey.maxCacheSize) ?? pow(1024, 3);
static bool get optTabletNav =>
setting.get(SettingBoxKey.optTabletNav, defaultValue: true);
static bool get horizontalScreen {
return setting.get(SettingBoxKey.horizontalScreen) ?? isTablet;
}
static bool get isTablet {
bool isTablet;
if (Get.context != null) {
isTablet = Get.context!.isTablet;
} else {
final view = WidgetsBinding.instance.platformDispatcher.views.first;
final screenSize = view.physicalSize / view.devicePixelRatio;
final shortestSide = min(screenSize.width.abs(), screenSize.height.abs());
isTablet = shortestSide >= 600;
}
return isTablet;
}
static String get banWordForDyn =>
GStorage.setting.get(SettingBoxKey.banWordForDyn, defaultValue: '');
static bool get enableLog =>
setting.get(SettingBoxKey.enableLog, defaultValue: true);
static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: const [60.0, 40.0]));
static Set<int> get blackMids =>
localCache.get(LocalCacheKey.blackMids, defaultValue: const <int>{});
static set blackMids(Set<int> blackMidsSet) {
localCache.put(LocalCacheKey.blackMids, blackMidsSet);
}
static RuleFilter get danmakuFilterRule => localCache
.get(LocalCacheKey.danmakuFilterRules, defaultValue: RuleFilter.empty());
static void setBlackMid(int mid) {
localCache.put(LocalCacheKey.blackMids, blackMids..add(mid));
}
static void removeBlackMid(int mid) {
localCache.put(LocalCacheKey.blackMids, blackMids..remove(mid));
}
static MemberTabType get memberTab => MemberTabType
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
static int get themeTypeInt =>
setting.get(SettingBoxKey.themeMode, defaultValue: ThemeType.system.code);
static ThemeMode get themeMode {
return switch (themeTypeInt) {
0 => ThemeMode.light,
1 => ThemeMode.dark,
_ => ThemeMode.system
};
}
// static final SpringDescription _kDefaultSpring = SpringDescription.withDampingRatio(
// mass: 0.5,
// stiffness: 100.0,
// ratio: 1.1,
// );
// damping = ratio * 2.0 * math.sqrt(mass * stiffness)
static final List<double> springDescription = List<double>.from(
setting.get(SettingBoxKey.springDescription) ??
[0.5, 100.0, 2.2 * sqrt(50)], // [mass, stiffness, damping]
);
// static Brightness get brightness {
// return switch (_themeMode) {
// 0 => Brightness.light,
// 1 => Brightness.dark,
// _ => PlatformDispatcher.instance.platformBrightness
// };
// }
static Future<void> init() async {
final Directory dir = await getApplicationSupportDirectory();
final String path = dir.path;
@@ -584,15 +49,8 @@ class GStorage {
);
// 视频设置
video = await Hive.openBox('video');
displacement = refreshDisplacement;
kDragContainerExtentPercentage = refreshDragPercentage;
await Accounts.init();
// 设置全局变量
GlobalData()
..imgQuality = defaultPicQa
..replyLengthLimit = replyLengthLimit;
}
static String exportAllSettings() {
@@ -643,362 +101,3 @@ class GStorage {
Accounts.close();
}
}
class SettingBoxKey {
/// 播放器
static const String btmProgressBehavior = 'btmProgressBehavior',
defaultVideoSpeed = 'defaultVideoSpeed',
autoUpgradeEnable = 'autoUpgradeEnable',
feedBackEnable = 'feedBackEnable',
defaultVideoQa = 'defaultVideoQa',
defaultVideoQaCellular = 'defaultVideoQaCellular',
defaultAudioQa = 'defaultAudioQa',
defaultAudioQaCellular = 'defaultAudioQaCellular',
autoPlayEnable = 'autoPlayEnable',
fullScreenMode = 'fullScreenMode',
defaultDecode = 'defaultDecode',
secondDecode = 'secondDecode',
danmakuEnable = 'danmakuEnable',
defaultToastOp = 'defaultToastOp',
defaultPicQa = 'defaultPicQa',
enableHA = 'enableHA',
useOpenSLES = 'useOpenSLES',
expandBuffer = 'expandBuffer',
hardwareDecoding = 'hardwareDecoding',
videoSync = 'videoSync',
enableVerticalExpand = 'enableVerticalExpand',
enableOnlineTotal = 'enableOnlineTotal',
enableAutoBrightness = 'enableAutoBrightness',
enableAutoEnter = 'enableAutoEnter',
enableAutoExit = 'enableAutoExit',
enableLongShowControl = 'enableLongShowControl',
allowRotateScreen = 'allowRotateScreen',
horizontalScreen = 'horizontalScreen',
p1080 = 'p1080',
// ignore: constant_identifier_names
CDNService = 'CDNService',
disableAudioCDN = 'disableAudioCDN',
autoPiP = 'autoPiP',
pipNoDanmaku = 'pipNoDanmaku',
enableAutoLongPressSpeed = 'enableAutoLongPressSpeed',
subtitlePreference = 'subtitlePreference',
useRelativeSlide = 'useRelativeSlide',
sliderDuration = 'sliderOffset',
// youtube 双击快进快退
enableQuickDouble = 'enableQuickDouble',
fullScreenGestureReverse = 'fullScreenGestureReverse',
enableShowDanmaku = 'enableShowDanmaku',
enableBackgroundPlay = 'enableBackgroundPlay',
continuePlayInBackground = 'continuePlayInBackground',
/// 隐私
// anonymity = 'anonymity',
/// 推荐
enableRcmdDynamic = 'enableRcmdDynamic',
appRcmd = 'appRcmd',
enableSaveLastData = 'enableSaveLastData',
minDurationForRcmd = 'minDurationForRcmd',
minPlayForRcmd = 'minPlayForRcmd',
minLikeRatioForRecommend = 'minLikeRatioForRecommend',
exemptFilterForFollowed = 'exemptFilterForFollowed',
banWordForRecommend = 'banWordForRecommend',
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
/// 其他
autoUpdate = 'autoUpdate',
autoClearCache = 'autoClearCache',
maxCacheSize = 'maxCacheSize',
defaultShowComment = 'defaultShowComment',
replySortType = 'replySortType',
defaultDynamicType = 'defaultDynamicType',
enableHotKey = 'enableHotKey',
enableSearchRcmd = 'enableSearchRcmd',
enableQuickFav = 'enableQuickFav',
enableWordRe = 'enableWordRe',
enableSearchWord = 'enableSearchWord',
enableSystemProxy = 'enableSystemProxy',
enableAi = 'enableAi',
disableLikeMsg = 'disableLikeMsg',
defaultHomePage = 'defaultHomePage',
previewQuality = 'previewQuality',
checkDynamic = 'checkDynamic',
dynamicPeriod = 'dynamicPeriod',
schemeVariant = 'schemeVariant',
showViewPoints = 'showViewPoints',
showRelatedVideo = 'showRelatedVideo',
showVideoReply = 'showVideoReply',
showBangumiReply = 'showBangumiReply',
alwaysExapndIntroPanel = 'alwaysExapndIntroPanel',
exapndIntroPanelH = 'exapndIntroPanelH',
horizontalSeasonPanel = 'horizontalSeasonPanel',
horizontalMemberPage = 'horizontalMemberPage',
replyLengthLimit = 'replyLengthLimit',
showArgueMsg = 'showArgueMsg',
reverseFromFirst = 'reverseFromFirst',
subtitlePaddingH = 'subtitlePaddingH',
subtitlePaddingB = 'subtitlePaddingB',
subtitleBgOpaticy = 'subtitleBgOpaticy',
subtitleStrokeWidth = 'subtitleStrokeWidth',
subtitleFontScale = 'subtitleFontScale',
subtitleFontScaleFS = 'subtitleFontScaleFS',
subtitleFontWeight = 'subtitleFontWeight',
badCertificateCallback = 'badCertificateCallback',
continuePlayingPart = 'continuePlayingPart',
cdnSpeedTest = 'cdnSpeedTest',
horizontalPreview = 'horizontalPreview',
banWordForReply = 'banWordForReply',
banWordForZone = 'banWordForZone',
savedRcmdTip = 'savedRcmdTip',
openInBrowser = 'openInBrowser',
refreshDragPercentage = 'refreshDragPercentage',
refreshDisplacement = 'refreshDisplacement',
showVipDanmaku = 'showVipDanmaku',
showSpecialDanmaku = 'showSpecialDanmaku',
mergeDanmaku = 'mergeDanmaku',
showHotRcmd = 'showHotRcmd',
audioNormalization = 'audioNormalization',
superResolutionType = 'superResolutionType',
preInitPlayer = 'preInitPlayer',
mainTabBarView = 'mainTabBarView',
searchSuggestion = 'searchSuggestion',
showDynDecorate = 'showDynDecorate',
enableLivePhoto = 'enableLivePhoto',
showSeekPreview = 'showSeekPreview',
showDmChart = 'showDmChart',
enableCommAntifraud = 'enableCommAntifraud',
biliSendCommAntifraud = 'biliSendCommAntifraud',
enableCreateDynAntifraud = 'enableCreateDynAntifraud',
coinWithLike = 'coinWithLike',
isPureBlackTheme = 'isPureBlackTheme',
antiGoodsDyn = 'antiGoodsDyn',
antiGoodsReply = 'antiGoodsReply',
expandDynLivePanel = 'expandDynLivePanel',
springDescription = 'springDescription',
enableHttp2 = 'enableHttp2',
slideDismissReplyPage = 'slideDismissReplyPage',
showFSActionItem = 'showFSActionItem',
enableShrinkVideoSize = 'enableShrinkVideoSize',
showDynActionBar = 'showDynActionBar',
darkVideoPage = 'darkVideoPage',
enableSlideVolumeBrightness = 'enableSlideVolumeBrightness',
enableSlideFS = 'enableSlideFS',
retryCount = 'retryCount',
retryDelay = 'retryDelay',
liveQuality = 'liveQuality',
liveQualityCellular = 'liveQualityCellular',
appFontWeight = 'appFontWeight',
enableDragSubtitle = 'enableDragSubtitle',
fastForBackwardDuration = 'fastForBackwardDuration',
recordSearchHistory = 'recordSearchHistory',
navSearchStreamDebounce = 'navSearchStreamDebounce',
showPgcTimeline = 'showPgcTimeline',
pageTransition = 'pageTransition',
optTabletNav = 'optTabletNav',
banWordForDyn = 'banWordForDyn',
enableLog = 'enableLog',
// WebDAV
webdavUri = 'webdavUri',
webdavUsername = 'webdavUsername',
webdavPassword = 'webdavPassword',
webdavDirectory = 'webdavDirectory',
// Sponsor Block
enableSponsorBlock = 'enableSponsorBlock',
blockSettings = 'blockSettings',
blockLimit = 'blockLimit',
blockColor = 'blockColor',
blockUserID = 'blockUserID',
blockToast = 'blockToast',
blockServer = 'blockServer',
blockTrack = 'blockTrack',
// 弹幕相关设置 权重(云屏蔽) 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 描边粗细 字体粗细
danmakuWeight = 'danmakuWeight',
danmakuBlockType = 'danmakuBlockType',
danmakuShowArea = 'danmakuShowArea',
danmakuOpacity = 'danmakuOpacity',
danmakuFontScale = 'danmakuFontScale',
danmakuFontScaleFS = 'danmakuFontScaleFS',
danmakuDuration = 'danmakuDuration',
danmakuStaticDuration = 'danmakuStaticDuration',
danmakuMassiveMode = 'danmakuMassiveMode',
danmakuLineHeight = 'danmakuLineHeight',
strokeWidth = 'strokeWidth',
fontWeight = 'fontWeight',
memberTab = 'memberTab',
dynamicDetailRatio = 'dynamicDetailRatio',
// 代理host port
systemProxyHost = 'systemProxyHost',
systemProxyPort = 'systemProxyPort';
/// 外观
static const String themeMode = 'themeMode',
defaultTextScale = 'textScale',
dynamicColor = 'dynamicColor', // bool
customColor = 'customColor', // 自定义主题色
enableSingleRow = 'enableSingleRow', // 首页单列
displayMode = 'displayMode',
smallCardWidth = 'smallCardWidth',
videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距
dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', // 动态瀑布流
upPanelPosition = 'upPanelPosition', // up主面板位置
dynamicsShowAllFollowedUp = 'dynamicsShowAllFollowedUp', // 动态显示全部关注up
useSideBar = 'useSideBar',
enableMYBar = 'enableMYBar',
hideSearchBar = 'hideSearchBar', // 收起顶栏
hideTabBar = 'hideTabBar', // 收起底栏
tabBarSort = 'tabBarSort', // 首页tabbar
dynamicBadgeMode = 'dynamicBadgeMode',
msgBadgeMode = 'msgBadgeMode',
msgUnReadTypeV2 = 'msgUnReadTypeV2',
hiddenSettingUnlocked = 'hiddenSettingUnlocked',
enableGradientBg = 'enableGradientBg',
navBarSort = 'navBarSort';
}
class LocalCacheKey {
// 历史记录暂停状态 默认false 记录
static const String historyPause = 'historyPause',
// 隐私设置-黑名单管理
blackMids = 'blackMids',
// 弹幕屏蔽规则
danmakuFilterRules = 'danmakuFilterRules',
// // access_key
// accessKey = 'accessKey',
//
mixinKey = 'mixinKey',
timeStamp = 'timeStamp';
}
class VideoBoxKey {
// 视频比例
static const String videoFit = 'videoFit',
// 亮度
videoBrightness = 'videoBrightness',
// 倍速
videoSpeed = 'videoSpeed',
// 播放顺序
playRepeat = 'playRepeat',
// 默认倍速
playSpeedDefault = 'playSpeedDefault',
// 默认长按倍速
longPressSpeedDefault = 'longPressSpeedDefault',
// 倍速集合
speedsList = 'speedsList',
// 画面填充比例
cacheVideoFit = 'cacheVideoFit';
}
class Accounts {
static late final Box<LoginAccount> account;
static final Map<AccountType, Account> accountMode = {};
static Account get main => accountMode[AccountType.main]!;
// static set main(Account account) => set(AccountType.main, account);
static Future<void> init() async {
account = await Hive.openBox('account',
compactionStrategy: (int entries, int deletedEntries) {
return deletedEntries > 2;
});
await _migrate();
}
static Future<void> _migrate() async {
final Directory tempDir = await getApplicationSupportDirectory();
final String tempPath = "${tempDir.path}/.plpl/";
final Directory dir = Directory(tempPath);
if (dir.existsSync()) {
if (kDebugMode) debugPrint('migrating...');
final cookieJar =
PersistCookieJar(ignoreExpires: true, storage: FileStorage(tempPath));
await cookieJar.forceInit();
final cookies = DefaultCookieJar(ignoreExpires: true)
..domainCookies.addAll(cookieJar.domainCookies);
final localAccessKey =
GStorage.localCache.get('accessKey', defaultValue: {});
final isLogin =
cookies.domainCookies['bilibili.com']?['/']?['SESSDATA'] != null;
await Future.wait([
GStorage.localCache.delete('accessKey'),
GStorage.localCache.delete('danmakuFilterRule'),
GStorage.localCache.delete('blackMidsList'),
dir.delete(recursive: true),
if (isLogin)
LoginAccount(cookies, localAccessKey['value'],
localAccessKey['refresh'], AccountType.values.toSet())
.onChange()
]);
if (kDebugMode) debugPrint('migrated successfully');
}
}
static void refresh() {
for (var a in account.values) {
for (var t in a.type) {
accountMode[t] = a;
}
}
for (var type in AccountType.values) {
accountMode[type] ??= AnonymousAccount();
}
// await Future.wait((accountMode.values.toSet()
// ..retainWhere((i) => !i.activited))
// .map((i) => Request.buvidActive(i)));
}
static Future<void> clear() async {
await account.clear();
for (var i in AccountType.values) {
accountMode[i] = AnonymousAccount();
}
await AnonymousAccount().delete();
// Request.buvidActive(AnonymousAccount());
}
static void close() {
account
..compact()
..close();
}
static Future<void> deleteAll(Set<Account> accounts) async {
var isloginMain = Accounts.main.isLogin;
Accounts.accountMode
.updateAll((_, a) => accounts.contains(a) ? AnonymousAccount() : a);
await Future.wait(accounts.map((i) => i.delete()));
if (isloginMain && !Accounts.main.isLogin) {
await LoginUtils.onLogoutMain();
}
}
static Future<void> set(AccountType key, Account account) async {
await (accountMode[key]?..type.remove(key))?.onChange();
accountMode[key] = account..type.add(key);
await account.onChange();
// if (!account.activited) await Request.buvidActive(account);
switch (key) {
case AccountType.main:
await (account.isLogin
? LoginUtils.onLoginMain()
: LoginUtils.onLogoutMain());
break;
case AccountType.heartbeat:
MineController.anonymity.value = !account.isLogin;
break;
default:
break;
}
}
static Account get(AccountType key) {
return accountMode[key]!;
}
}

250
lib/utils/storage_key.dart Normal file
View File

@@ -0,0 +1,250 @@
class SettingBoxKey {
/// 播放器
static const String btmProgressBehavior = 'btmProgressBehavior',
defaultVideoSpeed = 'defaultVideoSpeed',
autoUpgradeEnable = 'autoUpgradeEnable',
feedBackEnable = 'feedBackEnable',
defaultVideoQa = 'defaultVideoQa',
defaultVideoQaCellular = 'defaultVideoQaCellular',
defaultAudioQa = 'defaultAudioQa',
defaultAudioQaCellular = 'defaultAudioQaCellular',
autoPlayEnable = 'autoPlayEnable',
fullScreenMode = 'fullScreenMode',
defaultDecode = 'defaultDecode',
secondDecode = 'secondDecode',
danmakuEnable = 'danmakuEnable',
defaultToastOp = 'defaultToastOp',
defaultPicQa = 'defaultPicQa',
enableHA = 'enableHA',
useOpenSLES = 'useOpenSLES',
expandBuffer = 'expandBuffer',
hardwareDecoding = 'hardwareDecoding',
videoSync = 'videoSync',
enableVerticalExpand = 'enableVerticalExpand',
enableOnlineTotal = 'enableOnlineTotal',
enableAutoBrightness = 'enableAutoBrightness',
enableAutoEnter = 'enableAutoEnter',
enableAutoExit = 'enableAutoExit',
enableLongShowControl = 'enableLongShowControl',
allowRotateScreen = 'allowRotateScreen',
horizontalScreen = 'horizontalScreen',
p1080 = 'p1080',
// ignore: constant_identifier_names
CDNService = 'CDNService',
disableAudioCDN = 'disableAudioCDN',
autoPiP = 'autoPiP',
pipNoDanmaku = 'pipNoDanmaku',
enableAutoLongPressSpeed = 'enableAutoLongPressSpeed',
subtitlePreference = 'subtitlePreference',
useRelativeSlide = 'useRelativeSlide',
sliderDuration = 'sliderOffset',
// youtube 双击快进快退
enableQuickDouble = 'enableQuickDouble',
fullScreenGestureReverse = 'fullScreenGestureReverse',
enableShowDanmaku = 'enableShowDanmaku',
enableBackgroundPlay = 'enableBackgroundPlay',
continuePlayInBackground = 'continuePlayInBackground',
/// 隐私
// anonymity = 'anonymity',
/// 推荐
enableRcmdDynamic = 'enableRcmdDynamic',
appRcmd = 'appRcmd',
enableSaveLastData = 'enableSaveLastData',
minDurationForRcmd = 'minDurationForRcmd',
minPlayForRcmd = 'minPlayForRcmd',
minLikeRatioForRecommend = 'minLikeRatioForRecommend',
exemptFilterForFollowed = 'exemptFilterForFollowed',
banWordForRecommend = 'banWordForRecommend',
applyFilterToRelatedVideos = 'applyFilterToRelatedVideos',
/// 其他
autoUpdate = 'autoUpdate',
autoClearCache = 'autoClearCache',
maxCacheSize = 'maxCacheSize',
defaultShowComment = 'defaultShowComment',
replySortType = 'replySortType',
defaultDynamicType = 'defaultDynamicType',
enableHotKey = 'enableHotKey',
enableSearchRcmd = 'enableSearchRcmd',
enableQuickFav = 'enableQuickFav',
enableWordRe = 'enableWordRe',
enableSearchWord = 'enableSearchWord',
enableSystemProxy = 'enableSystemProxy',
enableAi = 'enableAi',
disableLikeMsg = 'disableLikeMsg',
defaultHomePage = 'defaultHomePage',
previewQuality = 'previewQuality',
checkDynamic = 'checkDynamic',
dynamicPeriod = 'dynamicPeriod',
schemeVariant = 'schemeVariant',
showViewPoints = 'showViewPoints',
showRelatedVideo = 'showRelatedVideo',
showVideoReply = 'showVideoReply',
showBangumiReply = 'showBangumiReply',
alwaysExapndIntroPanel = 'alwaysExapndIntroPanel',
exapndIntroPanelH = 'exapndIntroPanelH',
horizontalSeasonPanel = 'horizontalSeasonPanel',
horizontalMemberPage = 'horizontalMemberPage',
replyLengthLimit = 'replyLengthLimit',
showArgueMsg = 'showArgueMsg',
reverseFromFirst = 'reverseFromFirst',
subtitlePaddingH = 'subtitlePaddingH',
subtitlePaddingB = 'subtitlePaddingB',
subtitleBgOpaticy = 'subtitleBgOpaticy',
subtitleStrokeWidth = 'subtitleStrokeWidth',
subtitleFontScale = 'subtitleFontScale',
subtitleFontScaleFS = 'subtitleFontScaleFS',
subtitleFontWeight = 'subtitleFontWeight',
badCertificateCallback = 'badCertificateCallback',
continuePlayingPart = 'continuePlayingPart',
cdnSpeedTest = 'cdnSpeedTest',
horizontalPreview = 'horizontalPreview',
banWordForReply = 'banWordForReply',
banWordForZone = 'banWordForZone',
savedRcmdTip = 'savedRcmdTip',
openInBrowser = 'openInBrowser',
refreshDragPercentage = 'refreshDragPercentage',
refreshDisplacement = 'refreshDisplacement',
showVipDanmaku = 'showVipDanmaku',
showSpecialDanmaku = 'showSpecialDanmaku',
mergeDanmaku = 'mergeDanmaku',
showHotRcmd = 'showHotRcmd',
audioNormalization = 'audioNormalization',
superResolutionType = 'superResolutionType',
preInitPlayer = 'preInitPlayer',
mainTabBarView = 'mainTabBarView',
searchSuggestion = 'searchSuggestion',
showDynDecorate = 'showDynDecorate',
enableLivePhoto = 'enableLivePhoto',
showSeekPreview = 'showSeekPreview',
showDmChart = 'showDmChart',
enableCommAntifraud = 'enableCommAntifraud',
biliSendCommAntifraud = 'biliSendCommAntifraud',
enableCreateDynAntifraud = 'enableCreateDynAntifraud',
coinWithLike = 'coinWithLike',
isPureBlackTheme = 'isPureBlackTheme',
antiGoodsDyn = 'antiGoodsDyn',
antiGoodsReply = 'antiGoodsReply',
expandDynLivePanel = 'expandDynLivePanel',
springDescription = 'springDescription',
enableHttp2 = 'enableHttp2',
slideDismissReplyPage = 'slideDismissReplyPage',
showFSActionItem = 'showFSActionItem',
enableShrinkVideoSize = 'enableShrinkVideoSize',
showDynActionBar = 'showDynActionBar',
darkVideoPage = 'darkVideoPage',
enableSlideVolumeBrightness = 'enableSlideVolumeBrightness',
enableSlideFS = 'enableSlideFS',
retryCount = 'retryCount',
retryDelay = 'retryDelay',
liveQuality = 'liveQuality',
liveQualityCellular = 'liveQualityCellular',
appFontWeight = 'appFontWeight',
enableDragSubtitle = 'enableDragSubtitle',
fastForBackwardDuration = 'fastForBackwardDuration',
recordSearchHistory = 'recordSearchHistory',
navSearchStreamDebounce = 'navSearchStreamDebounce',
showPgcTimeline = 'showPgcTimeline',
pageTransition = 'pageTransition',
optTabletNav = 'optTabletNav',
banWordForDyn = 'banWordForDyn',
enableLog = 'enableLog',
// WebDAV
webdavUri = 'webdavUri',
webdavUsername = 'webdavUsername',
webdavPassword = 'webdavPassword',
webdavDirectory = 'webdavDirectory',
// Sponsor Block
enableSponsorBlock = 'enableSponsorBlock',
blockSettings = 'blockSettings',
blockLimit = 'blockLimit',
blockColor = 'blockColor',
blockUserID = 'blockUserID',
blockToast = 'blockToast',
blockServer = 'blockServer',
blockTrack = 'blockTrack',
// 弹幕相关设置 权重(云屏蔽) 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 描边粗细 字体粗细
danmakuWeight = 'danmakuWeight',
danmakuBlockType = 'danmakuBlockType',
danmakuShowArea = 'danmakuShowArea',
danmakuOpacity = 'danmakuOpacity',
danmakuFontScale = 'danmakuFontScale',
danmakuFontScaleFS = 'danmakuFontScaleFS',
danmakuDuration = 'danmakuDuration',
danmakuStaticDuration = 'danmakuStaticDuration',
danmakuMassiveMode = 'danmakuMassiveMode',
danmakuLineHeight = 'danmakuLineHeight',
strokeWidth = 'strokeWidth',
fontWeight = 'fontWeight',
memberTab = 'memberTab',
dynamicDetailRatio = 'dynamicDetailRatio',
// 代理host port
systemProxyHost = 'systemProxyHost',
systemProxyPort = 'systemProxyPort';
/// 外观
static const String themeMode = 'themeMode',
defaultTextScale = 'textScale',
dynamicColor = 'dynamicColor', // bool
customColor = 'customColor', // 自定义主题色
enableSingleRow = 'enableSingleRow', // 首页单列
displayMode = 'displayMode',
smallCardWidth = 'smallCardWidth',
videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距
dynamicsWaterfallFlow = 'dynamicsWaterfallFlow', // 动态瀑布流
upPanelPosition = 'upPanelPosition', // up主面板位置
dynamicsShowAllFollowedUp = 'dynamicsShowAllFollowedUp', // 动态显示全部关注up
useSideBar = 'useSideBar',
enableMYBar = 'enableMYBar',
hideSearchBar = 'hideSearchBar', // 收起顶栏
hideTabBar = 'hideTabBar', // 收起底栏
tabBarSort = 'tabBarSort', // 首页tabbar
dynamicBadgeMode = 'dynamicBadgeMode',
msgBadgeMode = 'msgBadgeMode',
msgUnReadTypeV2 = 'msgUnReadTypeV2',
hiddenSettingUnlocked = 'hiddenSettingUnlocked',
enableGradientBg = 'enableGradientBg',
navBarSort = 'navBarSort';
}
class LocalCacheKey {
// 历史记录暂停状态 默认false 记录
static const String historyPause = 'historyPause',
// 隐私设置-黑名单管理
blackMids = 'blackMids',
// 弹幕屏蔽规则
danmakuFilterRules = 'danmakuFilterRules',
// // access_key
// accessKey = 'accessKey',
//
mixinKey = 'mixinKey',
timeStamp = 'timeStamp';
}
class VideoBoxKey {
// 视频比例
static const String videoFit = 'videoFit',
// 亮度
videoBrightness = 'videoBrightness',
// 倍速
videoSpeed = 'videoSpeed',
// 播放顺序
playRepeat = 'playRepeat',
// 默认倍速
playSpeedDefault = 'playSpeedDefault',
// 默认长按倍速
longPressSpeedDefault = 'longPressSpeedDefault',
// 倍速集合
speedsList = 'speedsList',
// 画面填充比例
cacheVideoFit = 'cacheVideoFit';
}

717
lib/utils/storage_pref.dart Normal file
View File

@@ -0,0 +1,717 @@
import 'dart:io';
import 'dart:math' show pow, min, sqrt;
import 'package:PiliPlus/common/widgets/pair.dart';
import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/models/common/dynamic/dynamic_badge_mode.dart';
import 'package:PiliPlus/models/common/dynamic/up_panel_position.dart';
import 'package:PiliPlus/models/common/home_tab_type.dart';
import 'package:PiliPlus/models/common/member/tab_type.dart';
import 'package:PiliPlus/models/common/msg/msg_unread_type.dart';
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
import 'package:PiliPlus/models/common/theme/theme_type.dart';
import 'package:PiliPlus/models/common/video/audio_quality.dart';
import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/common/video/live_quality.dart';
import 'package:PiliPlus/models/common/video/subtitle_pref_type.dart';
import 'package:PiliPlus/models/common/video/video_decode_type.dart';
import 'package:PiliPlus/models/common/video/video_quality.dart';
import 'package:PiliPlus/models/user/danmaku_rule.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_key.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:uuid/uuid.dart';
class Pref {
static final Box _setting = GStorage.setting;
static final Box _video = GStorage.video;
static final Box _localCache = GStorage.localCache;
static List<double> get dynamicDetailRatio => List<double>.from(_setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: const [60.0, 40.0]));
static Set<int> get blackMids =>
_localCache.get(LocalCacheKey.blackMids, defaultValue: const <int>{});
static set blackMids(Set<int> blackMidsSet) {
_localCache.put(LocalCacheKey.blackMids, blackMidsSet);
}
static RuleFilter get danmakuFilterRule => _localCache
.get(LocalCacheKey.danmakuFilterRules, defaultValue: RuleFilter.empty());
static void setBlackMid(int mid) {
_localCache.put(LocalCacheKey.blackMids, GlobalData().blackMids..add(mid));
}
static void removeBlackMid(int mid) {
_localCache.put(
LocalCacheKey.blackMids, GlobalData().blackMids..remove(mid));
}
static MemberTabType get memberTab => MemberTabType
.values[_setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
static int get themeTypeInt => _setting.get(SettingBoxKey.themeMode,
defaultValue: ThemeType.system.index);
static ThemeMode get themeMode {
return switch (themeTypeInt) {
0 => ThemeMode.light,
1 => ThemeMode.dark,
_ => ThemeMode.system
};
}
static List<double> get springDescription => List<double>.from(
_setting.get(SettingBoxKey.springDescription) ??
[0.5, 100.0, 2.2 * sqrt(50)], // [mass, stiffness, damping]
);
static List<double> get speedList => List<double>.from(
_video.get(
VideoBoxKey.speedsList,
defaultValue: const [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0],
),
);
static List<int> get tabbarSort =>
List<int>.from(_setting.get(SettingBoxKey.tabBarSort) ??
HomeTabType.values.map((item) => item.index).toList());
static List<Pair<SegmentType, SkipType>> get blockSettings {
List<int> list = List<int>.from(_setting.get(SettingBoxKey.blockSettings) ??
List.generate(SegmentType.values.length, (_) => 1));
return SegmentType.values
.map((item) => Pair<SegmentType, SkipType>(
first: item,
second: SkipType.values[list[item.index]],
))
.toList();
}
static List<Color> get blockColor {
List<String> list = List<String>.from(
_setting.get(SettingBoxKey.blockColor) ??
List.generate(SegmentType.values.length, (_) => ''));
return SegmentType.values
.map((item) => list[item.index].isNotEmpty
? Color(
int.tryParse('FF${list[item.index]}', radix: 16) ?? 0xFF000000)
: item.color)
.toList();
}
static bool get hiddenSettingUnlocked =>
_setting.get(SettingBoxKey.hiddenSettingUnlocked, defaultValue: false);
static bool get feedBackEnable =>
_setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
static int get picQuality =>
_setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
static ThemeType get themeType => ThemeType.values[themeTypeInt];
static DynamicBadgeMode get dynamicBadgeType =>
DynamicBadgeMode.values[_setting.get(
SettingBoxKey.dynamicBadgeMode,
defaultValue: DynamicBadgeMode.number.index,
)];
static DynamicBadgeMode get msgBadgeMode =>
DynamicBadgeMode.values[_setting.get(
SettingBoxKey.msgBadgeMode,
defaultValue: DynamicBadgeMode.number.index,
)];
static Set<MsgUnReadType> get msgUnReadTypeV2 =>
(_setting.get(SettingBoxKey.msgUnReadTypeV2) as List?)
?.map((index) => MsgUnReadType.values[index])
.toSet() ??
MsgUnReadType.values.toSet();
static int get defaultHomePage =>
_setting.get(SettingBoxKey.defaultHomePage, defaultValue: 0);
static int get previewQ =>
_setting.get(SettingBoxKey.previewQuality, defaultValue: 100);
static double get smallCardWidth =>
_setting.get(SettingBoxKey.smallCardWidth, defaultValue: 240.0);
static UpPanelPosition get upPanelPosition =>
UpPanelPosition.values[_setting.get(SettingBoxKey.upPanelPosition,
defaultValue: UpPanelPosition.leftFixed.index)];
static int get fullScreenMode => _setting.get(SettingBoxKey.fullScreenMode,
defaultValue: FullScreenMode.auto.index);
static int get btmProgressBehavior =>
_setting.get(SettingBoxKey.btmProgressBehavior,
defaultValue: BtmProgressBehavior.alwaysShow.index);
static String get subtitlePreference =>
_setting.get(SettingBoxKey.subtitlePreference,
defaultValue: SubtitlePrefType.off.code);
static bool get useRelativeSlide =>
_setting.get(SettingBoxKey.useRelativeSlide, defaultValue: false);
static int get sliderDuration =>
_setting.get(SettingBoxKey.sliderDuration, defaultValue: 90);
static int get defaultVideoQa => _setting.get(
SettingBoxKey.defaultVideoQa,
defaultValue: VideoQuality.values.last.code,
);
static int get defaultVideoQaCellular => _setting.get(
SettingBoxKey.defaultVideoQaCellular,
defaultValue: VideoQuality.high1080.code,
);
static int get defaultAudioQa => _setting.get(
SettingBoxKey.defaultAudioQa,
defaultValue: AudioQuality.values.last.code,
);
static int get defaultAudioQaCellular => _setting.get(
SettingBoxKey.defaultAudioQaCellular,
defaultValue: AudioQuality.k192.code,
);
static String get defaultDecode => _setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormatType.values.last.code,
);
static String get secondDecode => _setting.get(
SettingBoxKey.secondDecode,
defaultValue: VideoDecodeFormatType.AV1.code,
);
static String get hardwareDecoding => _setting.get(
SettingBoxKey.hardwareDecoding,
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto',
);
static String get videoSync =>
_setting.get(SettingBoxKey.videoSync, defaultValue: 'display-resample');
static String get defaultCDNService => _setting.get(
SettingBoxKey.CDNService,
defaultValue: CDNService.backupUrl.code,
);
static String get banWordForRecommend =>
_setting.get(SettingBoxKey.banWordForRecommend, defaultValue: '');
static String get banWordForReply =>
_setting.get(SettingBoxKey.banWordForReply, defaultValue: '');
static String get banWordForZone =>
_setting.get(SettingBoxKey.banWordForZone, defaultValue: '');
static bool get appRcmd =>
_setting.get(SettingBoxKey.appRcmd, defaultValue: true);
static String get systemProxyHost =>
_setting.get(SettingBoxKey.systemProxyHost, defaultValue: '');
static String get systemProxyPort =>
_setting.get(SettingBoxKey.systemProxyPort, defaultValue: '');
static int get defaultDynamicType =>
_setting.get(SettingBoxKey.defaultDynamicType, defaultValue: 0);
static double get blockLimit =>
_setting.get(SettingBoxKey.blockLimit, defaultValue: 0.0);
static double get refreshDragPercentage =>
_setting.get(SettingBoxKey.refreshDragPercentage, defaultValue: 0.25);
static double get refreshDisplacement =>
_setting.get(SettingBoxKey.refreshDisplacement, defaultValue: 20.0);
static String get blockUserID {
String blockUserID =
_setting.get(SettingBoxKey.blockUserID, defaultValue: '');
if (blockUserID.isEmpty) {
blockUserID = const Uuid().v4().replaceAll('-', '');
_setting.put(SettingBoxKey.blockUserID, blockUserID);
}
return blockUserID;
}
static bool get blockToast =>
_setting.get(SettingBoxKey.blockToast, defaultValue: true);
static String get blockServer => _setting.get(SettingBoxKey.blockServer,
defaultValue: HttpString.sponsorBlockBaseUrl);
static bool get blockTrack =>
_setting.get(SettingBoxKey.blockTrack, defaultValue: true);
static bool get checkDynamic =>
_setting.get(SettingBoxKey.checkDynamic, defaultValue: true);
static int get dynamicPeriod =>
_setting.get(SettingBoxKey.dynamicPeriod, defaultValue: 5);
static int get schemeVariant =>
_setting.get(SettingBoxKey.schemeVariant, defaultValue: 10);
static double get danmakuFontScaleFS =>
_setting.get(SettingBoxKey.danmakuFontScaleFS, defaultValue: 1.2);
static bool get danmakuMassiveMode =>
_setting.get(SettingBoxKey.danmakuMassiveMode, defaultValue: false);
static double get subtitleFontScale =>
_setting.get(SettingBoxKey.subtitleFontScale, defaultValue: 1.0);
static double get subtitleFontScaleFS =>
_setting.get(SettingBoxKey.subtitleFontScaleFS, defaultValue: 1.5);
static bool get showViewPoints =>
_setting.get(SettingBoxKey.showViewPoints, defaultValue: true);
static bool get showRelatedVideo =>
_setting.get(SettingBoxKey.showRelatedVideo, defaultValue: true);
static bool get showVideoReply =>
_setting.get(SettingBoxKey.showVideoReply, defaultValue: true);
static bool get showBangumiReply =>
_setting.get(SettingBoxKey.showBangumiReply, defaultValue: true);
static bool get alwaysExapndIntroPanel =>
_setting.get(SettingBoxKey.alwaysExapndIntroPanel, defaultValue: false);
static bool get exapndIntroPanelH =>
_setting.get(SettingBoxKey.exapndIntroPanelH, defaultValue: false);
static bool get horizontalSeasonPanel =>
_setting.get(SettingBoxKey.horizontalSeasonPanel, defaultValue: false);
static bool get horizontalMemberPage =>
_setting.get(SettingBoxKey.horizontalMemberPage, defaultValue: false);
static int get replyLengthLimit =>
_setting.get(SettingBoxKey.replyLengthLimit, defaultValue: 6);
static int get defaultPicQa =>
_setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10);
static double get danmakuLineHeight =>
_setting.get(SettingBoxKey.danmakuLineHeight, defaultValue: 1.6);
static bool get showArgueMsg =>
_setting.get(SettingBoxKey.showArgueMsg, defaultValue: true);
static bool get reverseFromFirst =>
_setting.get(SettingBoxKey.reverseFromFirst, defaultValue: true);
static int get subtitlePaddingH =>
_setting.get(SettingBoxKey.subtitlePaddingH, defaultValue: 24);
static int get subtitlePaddingB =>
_setting.get(SettingBoxKey.subtitlePaddingB, defaultValue: 24);
static double get subtitleBgOpaticy =>
_setting.get(SettingBoxKey.subtitleBgOpaticy, defaultValue: 0.67);
static double get subtitleStrokeWidth =>
_setting.get(SettingBoxKey.subtitleStrokeWidth, defaultValue: 2.0);
static int get subtitleFontWeight =>
_setting.get(SettingBoxKey.subtitleFontWeight, defaultValue: 5);
static bool get badCertificateCallback =>
_setting.get(SettingBoxKey.badCertificateCallback, defaultValue: false);
static bool get continuePlayingPart =>
_setting.get(SettingBoxKey.continuePlayingPart, defaultValue: true);
static bool get cdnSpeedTest =>
_setting.get(SettingBoxKey.cdnSpeedTest, defaultValue: true);
static bool get autoUpdate =>
_setting.get(SettingBoxKey.autoUpdate, defaultValue: true);
static bool get horizontalPreview =>
_setting.get(SettingBoxKey.horizontalPreview, defaultValue: false);
static bool get openInBrowser =>
_setting.get(SettingBoxKey.openInBrowser, defaultValue: false);
static bool get savedRcmdTip =>
_setting.get(SettingBoxKey.savedRcmdTip, defaultValue: true);
static bool get showVipDanmaku =>
_setting.get(SettingBoxKey.showVipDanmaku, defaultValue: true);
static bool get showSpecialDanmaku =>
_setting.get(SettingBoxKey.showSpecialDanmaku, defaultValue: false);
static bool get mergeDanmaku =>
_setting.get(SettingBoxKey.mergeDanmaku, defaultValue: false);
static bool get showHotRcmd =>
_setting.get(SettingBoxKey.showHotRcmd, defaultValue: false);
static String get audioNormalization =>
_setting.get(SettingBoxKey.audioNormalization, defaultValue: '0');
static int get superResolutionType =>
_setting.get(SettingBoxKey.superResolutionType, defaultValue: 0);
static bool get preInitPlayer =>
_setting.get(SettingBoxKey.preInitPlayer, defaultValue: false);
static bool get mainTabBarView =>
_setting.get(SettingBoxKey.mainTabBarView, defaultValue: false);
static bool get searchSuggestion =>
_setting.get(SettingBoxKey.searchSuggestion, defaultValue: true);
static bool get showDynDecorate =>
_setting.get(SettingBoxKey.showDynDecorate, defaultValue: true);
static bool get enableLivePhoto =>
_setting.get(SettingBoxKey.enableLivePhoto, defaultValue: true);
static bool get showSeekPreview =>
_setting.get(SettingBoxKey.showSeekPreview, defaultValue: true);
static bool get showDmChart =>
_setting.get(SettingBoxKey.showDmChart, defaultValue: false);
static bool get enableCommAntifraud =>
_setting.get(SettingBoxKey.enableCommAntifraud, defaultValue: false);
static bool get biliSendCommAntifraud =>
_setting.get(SettingBoxKey.biliSendCommAntifraud, defaultValue: false);
static bool get enableCreateDynAntifraud =>
_setting.get(SettingBoxKey.enableCreateDynAntifraud, defaultValue: false);
static bool get coinWithLike =>
_setting.get(SettingBoxKey.coinWithLike, defaultValue: false);
static bool get isPureBlackTheme =>
_setting.get(SettingBoxKey.isPureBlackTheme, defaultValue: false);
static bool get antiGoodsDyn =>
_setting.get(SettingBoxKey.antiGoodsDyn, defaultValue: false);
static bool get antiGoodsReply =>
_setting.get(SettingBoxKey.antiGoodsReply, defaultValue: false);
static bool get expandDynLivePanel =>
_setting.get(SettingBoxKey.expandDynLivePanel, defaultValue: false);
static bool get slideDismissReplyPage => _setting
.get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS);
static bool get showFSActionItem =>
_setting.get(SettingBoxKey.showFSActionItem, defaultValue: true);
static bool get enableShrinkVideoSize =>
_setting.get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true);
static bool get showDynActionBar =>
_setting.get(SettingBoxKey.showDynActionBar, defaultValue: true);
static bool get darkVideoPage =>
_setting.get(SettingBoxKey.darkVideoPage, defaultValue: false);
static bool get enableSlideVolumeBrightness => _setting
.get(SettingBoxKey.enableSlideVolumeBrightness, defaultValue: true);
static bool get enableSlideFS =>
_setting.get(SettingBoxKey.enableSlideFS, defaultValue: true);
static int get retryCount =>
_setting.get(SettingBoxKey.retryCount, defaultValue: 2);
static int get retryDelay =>
_setting.get(SettingBoxKey.retryDelay, defaultValue: 500);
static int get liveQuality => _setting.get(SettingBoxKey.liveQuality,
defaultValue: LiveQuality.origin.code);
static int get liveQualityCellular =>
_setting.get(SettingBoxKey.liveQualityCellular,
defaultValue: LiveQuality.superHD.code);
static int get appFontWeight =>
_setting.get(SettingBoxKey.appFontWeight, defaultValue: -1);
static bool get enableDragSubtitle =>
_setting.get(SettingBoxKey.enableDragSubtitle, defaultValue: false);
static int get fastForBackwardDuration =>
_setting.get(SettingBoxKey.fastForBackwardDuration, defaultValue: 10);
static bool get recordSearchHistory =>
_setting.get(SettingBoxKey.recordSearchHistory, defaultValue: true);
static bool get navSearchStreamDebounce =>
_setting.get(SettingBoxKey.navSearchStreamDebounce, defaultValue: false);
static String get webdavUri =>
_setting.get(SettingBoxKey.webdavUri, defaultValue: '');
static String get webdavUsername =>
_setting.get(SettingBoxKey.webdavUsername, defaultValue: '');
static String get webdavPassword =>
_setting.get(SettingBoxKey.webdavPassword, defaultValue: '');
static String get webdavDirectory =>
_setting.get(SettingBoxKey.webdavDirectory, defaultValue: '/');
static bool get showPgcTimeline =>
_setting.get(SettingBoxKey.showPgcTimeline, defaultValue: true);
static num get maxCacheSize =>
_setting.get(SettingBoxKey.maxCacheSize) ?? pow(1024, 3);
static bool get optTabletNav =>
_setting.get(SettingBoxKey.optTabletNav, defaultValue: true);
static bool get horizontalScreen {
return _setting.get(SettingBoxKey.horizontalScreen) ?? isTablet;
}
static bool get isTablet {
bool isTablet;
if (Get.context != null) {
isTablet = Get.context!.isTablet;
} else {
final view = WidgetsBinding.instance.platformDispatcher.views.first;
final screenSize = view.physicalSize / view.devicePixelRatio;
final shortestSide = min(screenSize.width.abs(), screenSize.height.abs());
isTablet = shortestSide >= 600;
}
return isTablet;
}
static String get banWordForDyn =>
_setting.get(SettingBoxKey.banWordForDyn, defaultValue: '');
static bool get enableLog =>
_setting.get(SettingBoxKey.enableLog, defaultValue: true);
static bool get disableAudioCDN =>
_setting.get(SettingBoxKey.disableAudioCDN, defaultValue: true);
static int get minDurationForRcmd =>
_setting.get(SettingBoxKey.minDurationForRcmd, defaultValue: 0);
static int get minPlayForRcmd =>
_setting.get(SettingBoxKey.minPlayForRcmd, defaultValue: 0);
static int get minLikeRatioForRecommend =>
_setting.get(SettingBoxKey.minLikeRatioForRecommend, defaultValue: 0);
static bool get exemptFilterForFollowed =>
_setting.get(SettingBoxKey.exemptFilterForFollowed, defaultValue: true);
static bool get applyFilterToRelatedVideos => _setting
.get(SettingBoxKey.applyFilterToRelatedVideos, defaultValue: true);
static bool get enableBackgroundPlay =>
_setting.get(SettingBoxKey.enableBackgroundPlay, defaultValue: true);
static bool get allowRotateScreen =>
_setting.get(SettingBoxKey.allowRotateScreen, defaultValue: true);
static bool get disableLikeMsg =>
_setting.get(SettingBoxKey.disableLikeMsg, defaultValue: false);
static bool get enableWordRe =>
_setting.get(SettingBoxKey.enableWordRe, defaultValue: false);
static bool get autoExitFullscreen =>
_setting.get(SettingBoxKey.enableAutoExit, defaultValue: true);
static bool get autoPlayEnable =>
_setting.get(SettingBoxKey.autoPlayEnable, defaultValue: false);
static bool get pipNoDanmaku =>
_setting.get(SettingBoxKey.pipNoDanmaku, defaultValue: false);
static bool get enableVerticalExpand =>
_setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false);
static bool get removeSafeArea => _setting
.get(SettingBoxKey.videoPlayerRemoveSafeArea, defaultValue: false);
static double get defaultTextScale =>
_setting.get(SettingBoxKey.defaultTextScale, defaultValue: 1.0);
static bool get dynamicsWaterfallFlow =>
_setting.get(SettingBoxKey.dynamicsWaterfallFlow, defaultValue: true);
static bool get hideSearchBar =>
_setting.get(SettingBoxKey.hideSearchBar, defaultValue: true);
static bool get enableSearchWord =>
_setting.get(SettingBoxKey.enableSearchWord, defaultValue: true);
static bool get useSideBar =>
_setting.get(SettingBoxKey.useSideBar, defaultValue: false);
static bool get dynamicsShowAllFollowedUp => _setting
.get(SettingBoxKey.dynamicsShowAllFollowedUp, defaultValue: false);
static bool get enableShowDanmaku =>
_setting.get(SettingBoxKey.enableShowDanmaku, defaultValue: true);
static bool get enableQuickFav =>
_setting.get(SettingBoxKey.enableQuickFav, defaultValue: false);
static bool get p1080 =>
_setting.get(SettingBoxKey.p1080, defaultValue: true);
static int get customColor =>
_setting.get(SettingBoxKey.customColor, defaultValue: 0);
static bool get dynamicColor =>
_setting.get(SettingBoxKey.dynamicColor, defaultValue: true);
static bool get autoClearCache =>
_setting.get(SettingBoxKey.autoClearCache, defaultValue: false);
static bool get enableSystemProxy =>
_setting.get(SettingBoxKey.enableSystemProxy, defaultValue: false);
static bool get enableHttp2 =>
_setting.get(SettingBoxKey.enableHttp2, defaultValue: false);
static bool get enableRcmdDynamic =>
_setting.get(SettingBoxKey.enableRcmdDynamic, defaultValue: true);
static int get replySortType =>
_setting.get(SettingBoxKey.replySortType, defaultValue: 1);
static bool get hideTabBar =>
_setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
static int get dynamicBadgeMode =>
_setting.get(SettingBoxKey.dynamicBadgeMode,
defaultValue: DynamicBadgeMode.number.index);
static bool get enableMYBar =>
_setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
static int get pageTransition => _setting.get(SettingBoxKey.pageTransition,
defaultValue: Transition.native.index);
static bool get enableQuickDouble =>
_setting.get(SettingBoxKey.enableQuickDouble, defaultValue: true);
static bool get fullScreenGestureReverse =>
_setting.get(SettingBoxKey.fullScreenGestureReverse, defaultValue: false);
static bool get autoPiP =>
_setting.get(SettingBoxKey.autoPiP, defaultValue: false);
static bool get enableSponsorBlock =>
_setting.get(SettingBoxKey.enableSponsorBlock, defaultValue: false);
static bool get enableHA =>
_setting.get(SettingBoxKey.enableHA, defaultValue: true);
static Set<int> get danmakuBlockType =>
(_setting.get(SettingBoxKey.danmakuBlockType, defaultValue: <int>[])
as Iterable)
.cast<int>()
.toSet();
static int get danmakuWeight =>
_setting.get(SettingBoxKey.danmakuWeight, defaultValue: 0);
static double get danmakuShowArea =>
_setting.get(SettingBoxKey.danmakuShowArea, defaultValue: 0.5);
static double get danmakuOpacity =>
_setting.get(SettingBoxKey.danmakuOpacity, defaultValue: 1.0);
static double get danmakuFontScale =>
_setting.get(SettingBoxKey.danmakuFontScale, defaultValue: 1.0);
static double get danmakuDuration =>
_setting.get(SettingBoxKey.danmakuDuration, defaultValue: 7.0);
static double get danmakuStaticDuration =>
_setting.get(SettingBoxKey.danmakuStaticDuration, defaultValue: 4.0);
static double get strokeWidth =>
_setting.get(SettingBoxKey.strokeWidth, defaultValue: 1.5);
static int get fontWeight =>
_setting.get(SettingBoxKey.fontWeight, defaultValue: 5);
static bool get enableLongShowControl =>
_setting.get(SettingBoxKey.enableLongShowControl, defaultValue: false);
static bool get expandBuffer =>
_setting.get(SettingBoxKey.expandBuffer, defaultValue: false);
static bool get useOpenSLES =>
_setting.get(SettingBoxKey.useOpenSLES, defaultValue: true);
static bool get enableAi =>
_setting.get(SettingBoxKey.enableAi, defaultValue: false);
static bool get enableOnlineTotal =>
_setting.get(SettingBoxKey.enableOnlineTotal, defaultValue: false);
static bool get enableAutoEnter =>
_setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
static bool get enableAutoLongPressSpeed =>
_setting.get(SettingBoxKey.enableAutoLongPressSpeed, defaultValue: false);
static double get playSpeedDefault =>
_video.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
static double get longPressSpeedDefault =>
_video.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 3.0);
static bool get defaultShowComment =>
_setting.get(SettingBoxKey.defaultShowComment, defaultValue: false);
static bool get enableHotKey =>
_setting.get(SettingBoxKey.enableHotKey, defaultValue: true);
static bool get enableSearchRcmd =>
_setting.get(SettingBoxKey.enableSearchRcmd, defaultValue: true);
static bool get enableSaveLastData =>
_setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
static double get defaultToastOp =>
_setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0);
static int get playRepeat =>
(_video.get(VideoBoxKey.playRepeat) as num?)?.toInt() ??
PlayRepeat.pause.index;
static int get cacheVideoFit =>
_video.get(VideoBoxKey.cacheVideoFit, defaultValue: 1);
static bool get continuePlayInBackground =>
_setting.get(SettingBoxKey.continuePlayInBackground, defaultValue: false);
}

View File

@@ -1,6 +1,6 @@
import 'package:PiliPlus/main.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
import 'package:flutter/material.dart';
@@ -12,7 +12,7 @@ class ThemeUtils {
required FlexSchemeVariant variant,
}) {
final appFontWeight =
GStorage.appFontWeight.clamp(-1, FontWeight.values.length - 1);
Pref.appFontWeight.clamp(-1, FontWeight.values.length - 1);
final fontWeight =
appFontWeight == -1 ? null : FontWeight.values[appFontWeight];
late final textStyle = TextStyle(fontWeight: fontWeight);
@@ -111,10 +111,10 @@ class ThemeUtils {
),
);
if (isDark) {
if (GStorage.isPureBlackTheme) {
if (Pref.isPureBlackTheme) {
themeData = darkenTheme(themeData);
}
if (GStorage.darkVideoPage) {
if (Pref.darkVideoPage) {
MyApp.darkThemeData = themeData;
}
}

View File

@@ -5,6 +5,7 @@ import 'package:PiliPlus/http/api.dart';
import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_key.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';

View File

@@ -2,16 +2,18 @@ import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/video/play/url.dart';
import 'package:PiliPlus/models_new/live/live_room_play_info/codec.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
class VideoUtils {
static String cdnService = Pref.defaultCDNService;
static bool disableAudioCDN = Pref.disableAudioCDN;
static String getCdnUrl(dynamic item, [String? defaultCDNService]) {
String? backupUrl;
String? videoUrl;
defaultCDNService ??= GStorage.defaultCDNService;
defaultCDNService ??= cdnService;
if (item is AudioItem) {
if (GStorage.setting
.get(SettingBoxKey.disableAudioCDN, defaultValue: true)) {
if (disableAudioCDN) {
return item.backupUrl?.isNotEmpty == true
? item.backupUrl!
: item.baseUrl ?? "";

View File

@@ -7,13 +7,14 @@ import 'dart:convert';
import 'package:PiliPlus/http/api.dart';
import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_key.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:crypto/crypto.dart';
import 'package:hive/hive.dart';
import 'package:synchronized/synchronized.dart';
class WbiSign {
static Box get localCache => GStorage.localCache;
static Box localCache = GStorage.localCache;
static final Lock lock = Lock();
static final RegExp chrFilter = RegExp(r"[!\'\(\)\*]");
static const mixinKeyEncTab = <int>[