feat: 添加启动时清除缓存设置

This commit is contained in:
orz12
2024-04-04 10:44:10 +08:00
parent e3fb4d4b28
commit d43feec713
3 changed files with 11 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:io';
import 'package:PiliPalaX/utils/cache_manage.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@@ -29,6 +30,9 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
MediaKit.ensureInitialized();
await GStrorage.init();
if (GStrorage.setting.get(SettingBoxKey.autoClearCache, defaultValue: false)) {
await CacheManage.clearLibraryCache();
}
if (GStrorage.setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
await SystemChrome.setPreferredOrientations(
//支持竖屏与横屏

View File

@@ -284,6 +284,12 @@ class _ExtraSettingState extends State<ExtraSetting> {
),
),
),
const SetSwitchItem(
title: '自动清除缓存',
subTitle: '每次启动时清除缓存',
setKey: SettingBoxKey.autoClearCache,
defaultVal: false,
),
const SetSwitchItem(
title: '检查更新',
subTitle: '每次启动时检查是否需要更新',

View File

@@ -124,6 +124,7 @@ class SettingBoxKey {
/// 其他
autoUpdate = 'autoUpdate',
autoClearCache = 'autoClearCache',
replySortType = 'replySortType',
defaultDynamicType = 'defaultDynamicType',
enableHotKey = 'enableHotKey',