mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-05 01:27:49 +08:00
@@ -14,8 +14,9 @@ import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/cache_manage.dart';
|
||||
import 'package:PiliPlus/utils/data.dart';
|
||||
import 'package:PiliPlus/utils/date_util.dart';
|
||||
import 'package:PiliPlus/utils/recommend_filter.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/theme_utils.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
@@ -27,7 +28,6 @@ import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc.
|
||||
|
||||
void main() async {
|
||||
@@ -35,10 +35,10 @@ void main() async {
|
||||
MediaKit.ensureInitialized();
|
||||
await GStorage.init();
|
||||
Get.put(AccountService());
|
||||
if (GStorage.setting.get(SettingBoxKey.autoClearCache, defaultValue: false)) {
|
||||
if (Pref.autoClearCache) {
|
||||
await CacheManage.clearLibraryCache();
|
||||
} else {
|
||||
final num maxCacheSize = GStorage.maxCacheSize;
|
||||
final num maxCacheSize = Pref.maxCacheSize;
|
||||
if (maxCacheSize != 0) {
|
||||
final double currCache = await CacheManage().loadApplicationCache();
|
||||
if (currCache >= maxCacheSize) {
|
||||
@@ -46,7 +46,7 @@ void main() async {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GStorage.horizontalScreen) {
|
||||
if (Pref.horizontalScreen) {
|
||||
await SystemChrome.setPreferredOrientations(
|
||||
//支持竖屏与横屏
|
||||
[
|
||||
@@ -68,9 +68,8 @@ void main() async {
|
||||
await setupServiceLocator();
|
||||
Request();
|
||||
await Request.setCookie();
|
||||
RecommendFilter();
|
||||
|
||||
if (GStorage.enableLog) {
|
||||
if (Pref.enableLog) {
|
||||
// 异常捕获 logo记录
|
||||
String buildConfig = '''\n
|
||||
Build Time: ${DateUtil.format(BuildConfig.buildTime, format: DateUtil.longFormatDs)}
|
||||
@@ -129,34 +128,20 @@ Commit Hash: ${BuildConfig.commitHash}''';
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
Box get setting => GStorage.setting;
|
||||
|
||||
static ThemeData? darkThemeData;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 主题色
|
||||
Color defaultColor =
|
||||
colorThemeTypes[setting.get(SettingBoxKey.customColor, defaultValue: 0)]
|
||||
.color;
|
||||
Color brandColor = defaultColor;
|
||||
// 是否动态取色
|
||||
bool isDynamicColor =
|
||||
setting.get(SettingBoxKey.dynamicColor, defaultValue: true);
|
||||
// 字体缩放大小
|
||||
double textScale =
|
||||
setting.get(SettingBoxKey.defaultTextScale, defaultValue: 1.0);
|
||||
// DynamicSchemeVariant dynamicSchemeVariant =
|
||||
// DynamicSchemeVariant.values[GStorage.schemeVariant];
|
||||
FlexSchemeVariant variant =
|
||||
FlexSchemeVariant.values[GStorage.schemeVariant];
|
||||
Color brandColor = colorThemeTypes[Pref.customColor].color;
|
||||
bool isDynamicColor = Pref.dynamicColor;
|
||||
FlexSchemeVariant variant = FlexSchemeVariant.values[Pref.schemeVariant];
|
||||
|
||||
// 强制设置高帧率
|
||||
if (Platform.isAndroid) {
|
||||
late List modes;
|
||||
FlutterDisplayMode.supported.then((value) {
|
||||
modes = value;
|
||||
var storageDisplay = setting.get(SettingBoxKey.displayMode);
|
||||
var storageDisplay = GStorage.setting.get(SettingBoxKey.displayMode);
|
||||
DisplayMode f = DisplayMode.auto;
|
||||
if (storageDisplay != null) {
|
||||
f = modes.firstWhere((e) => e.toString() == storageDisplay,
|
||||
@@ -209,7 +194,7 @@ class MyApp extends StatelessWidget {
|
||||
isDark: true,
|
||||
variant: variant,
|
||||
),
|
||||
themeMode: GStorage.themeMode,
|
||||
themeMode: Pref.themeMode,
|
||||
localizationsDelegates: const [
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
@@ -225,8 +210,8 @@ class MyApp extends StatelessWidget {
|
||||
loadingBuilder: (msg) => LoadingWidget(msg: msg),
|
||||
builder: (context, child) {
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(context)
|
||||
.copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
textScaler: TextScaler.linear(Pref.defaultTextScale)),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
@@ -243,7 +228,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _CustomHttpOverrides extends HttpOverrides {
|
||||
final badCertificateCallback = kDebugMode || GStorage.badCertificateCallback;
|
||||
final badCertificateCallback = kDebugMode || Pref.badCertificateCallback;
|
||||
|
||||
@override
|
||||
HttpClient createHttpClient(SecurityContext? context) {
|
||||
|
||||
Reference in New Issue
Block a user