fix: shader clean

This commit is contained in:
xkeyC 2025-12-13 17:19:05 +08:00
parent 13875f850f
commit 3f6a9f44d4
2 changed files with 10 additions and 12 deletions

View File

@ -11,6 +11,7 @@ import 'package:starcitizen_doctor/common/utils/base_utils.dart';
import 'package:starcitizen_doctor/data/game_performance_data.dart';
import 'package:starcitizen_doctor/generated/l10n.dart';
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart';
import 'performance_ui.json.dart';
@ -171,15 +172,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
}
Future<void> cleanShaderCache(BuildContext? context) async {
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
final l = await Directory(gameShaderCachePath!).list(recursive: false).toList();
for (var value in l) {
if (value is Directory) {
if (!value.absolute.path.contains("Crashes")) {
await value.delete(recursive: true);
}
}
}
await ToolsUIModel.cleanShaderCache();
await Future.delayed(const Duration(milliseconds: 300));
if (context != null && context.mounted) {
showToast(context, S.current.performance_info_shader_clearing_warning);

View File

@ -27,6 +27,7 @@ import 'dialogs/hosts_booster_dialog_ui.dart';
import 'dialogs/rsi_launcher_enhance_dialog_ui.dart';
part 'tools_ui_model.g.dart';
part 'tools_ui_model.freezed.dart';
class ToolsItemData {
@ -518,8 +519,7 @@ class ToolsUIModel extends _$ToolsUIModel {
state = state.copyWith(working: false);
}
Future<void> _cleanShaderCache(BuildContext context) async {
state = state.copyWith(working: true);
static Future<void> cleanShaderCache() async {
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
final l = await Directory(gameShaderCachePath!).list(recursive: false).toList();
for (var value in l) {
@ -535,13 +535,18 @@ class ToolsUIModel extends _$ToolsUIModel {
}
}
}
}
Future<void> _cleanShaderCache(BuildContext context) async {
state = state.copyWith(working: true);
await cleanShaderCache();
if (!context.mounted) return;
loadToolsCard(context, skipPathScan: true);
state = state.copyWith(working: false);
}
/// GraphicsSettings
Future<void> _cleanShaderCacheDirectory(Directory dir) async {
static Future<void> _cleanShaderCacheDirectory(Directory dir) async {
try {
final contents = await dir.list(recursive: false).toList();
for (var entity in contents) {