diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index e7c2223..13310c2 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -402,6 +402,9 @@ class MessageLookup extends MessageLookupByLibrary { "Loading images...", ), "app_common_network_error": m1, + "app_common_recommended": MessageLookupByLibrary.simpleMessage( + "Recommended", + ), "app_common_tip": MessageLookupByLibrary.simpleMessage("Tip"), "app_common_tip_cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "app_common_tip_confirm": MessageLookupByLibrary.simpleMessage("Confirm"), @@ -2166,6 +2169,9 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage( "Hosts Acceleration (Experimental)", ), + "tools_action_info_cleaning": MessageLookupByLibrary.simpleMessage( + "Cleaning...", + ), "tools_action_info_cleanup_complete": MessageLookupByLibrary.simpleMessage( "Cleanup complete, please complete one installation / game launch operation.", ), @@ -2277,6 +2283,9 @@ class MessageLookup extends MessageLookupByLibrary { "tools_action_rsi_launcher_log_fix": MessageLookupByLibrary.simpleMessage( "RSI Launcher Log Fix", ), + "tools_action_start_cleaning": MessageLookupByLibrary.simpleMessage( + "Start Cleaning", + ), "tools_action_switch_graphics_renderer": MessageLookupByLibrary.simpleMessage("Switch DirectX/Vulkan Renderer"), "tools_action_switch_graphics_renderer_info": m104, @@ -2407,12 +2416,18 @@ class MessageLookup extends MessageLookupByLibrary { "Installing patch, this will take some time depending on your computer\'s performance...", ), "tools_shader_clean_all": MessageLookupByLibrary.simpleMessage("Clean All"), + "tools_shader_clean_all_desc": MessageLookupByLibrary.simpleMessage( + "Clean all version caches (only keep GraphicsSettings). Suitable for graphics anomalies or post-update cleaning.", + ), "tools_shader_clean_dialog_title": MessageLookupByLibrary.simpleMessage( "Clear Shader Cache", ), "tools_shader_clean_keep_latest": MessageLookupByLibrary.simpleMessage( "Keep Latest", ), + "tools_shader_clean_keep_latest_desc": MessageLookupByLibrary.simpleMessage( + "Suitable for use after game updates and completing the first launch. Keep all files in the latest version, clean other old versions (only keep GraphicsSettings).", + ), "tools_unp4k_action_cancel_multi_select": MessageLookupByLibrary.simpleMessage("Cancel Multi-Select"), "tools_unp4k_action_deselect_all": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_ja.dart b/lib/generated/intl/messages_ja.dart index 5b57ab6..7744147 100644 --- a/lib/generated/intl/messages_ja.dart +++ b/lib/generated/intl/messages_ja.dart @@ -349,6 +349,7 @@ class MessageLookup extends MessageLookupByLibrary { "画像を読み込み中...", ), "app_common_network_error": m1, + "app_common_recommended": MessageLookupByLibrary.simpleMessage("推奨"), "app_common_tip": MessageLookupByLibrary.simpleMessage("ヒント"), "app_common_tip_cancel": MessageLookupByLibrary.simpleMessage("キャンセル"), "app_common_tip_confirm": MessageLookupByLibrary.simpleMessage("確認"), @@ -1844,6 +1845,9 @@ class MessageLookup extends MessageLookupByLibrary { ), "tools_action_hosts_acceleration_experimental": MessageLookupByLibrary.simpleMessage("Hosts加速(実験的)"), + "tools_action_info_cleaning": MessageLookupByLibrary.simpleMessage( + "クリーニング中...", + ), "tools_action_info_cleanup_complete": MessageLookupByLibrary.simpleMessage( "クリーンアップが完了しました。インストールまたはゲーム起動操作を完了してください。", ), @@ -1945,6 +1949,9 @@ class MessageLookup extends MessageLookupByLibrary { "tools_action_rsi_launcher_log_fix": MessageLookupByLibrary.simpleMessage( "RSI Launcher ログ修復", ), + "tools_action_start_cleaning": MessageLookupByLibrary.simpleMessage( + "クリーニング開始", + ), "tools_action_unp4k": MessageLookupByLibrary.simpleMessage("P4Kビューア"), "tools_action_unp4k_info": MessageLookupByLibrary.simpleMessage( "Star Citizen p4kファイルを解凍", @@ -2037,12 +2044,18 @@ class MessageLookup extends MessageLookupByLibrary { "パッチをインストール中、これはコンピュータのパフォーマンスによって時間がかかります...", ), "tools_shader_clean_all": MessageLookupByLibrary.simpleMessage("すべてクリア"), + "tools_shader_clean_all_desc": MessageLookupByLibrary.simpleMessage( + "すべてのバージョンのキャッシュをクリア(GraphicsSettingsのみ保持)。グラフィック異常またはアップデート後のクリーニングに適しています。", + ), "tools_shader_clean_dialog_title": MessageLookupByLibrary.simpleMessage( "シェーダーキャッシュをクリア", ), "tools_shader_clean_keep_latest": MessageLookupByLibrary.simpleMessage( "最新を保持", ), + "tools_shader_clean_keep_latest_desc": MessageLookupByLibrary.simpleMessage( + "ゲームアップデート後と初回起動完了後の使用に適しています。最新バージョンのすべてのファイルを保持し、他の古いバージョンをクリア(GraphicsSettingsのみ保持)。", + ), "tools_unp4k_missing_runtime": MessageLookupByLibrary.simpleMessage( "ランタイムがありません", ), diff --git a/lib/generated/intl/messages_ru.dart b/lib/generated/intl/messages_ru.dart index 4a740fe..cffdbb9 100644 --- a/lib/generated/intl/messages_ru.dart +++ b/lib/generated/intl/messages_ru.dart @@ -372,6 +372,9 @@ class MessageLookup extends MessageLookupByLibrary { "Загрузка изображений...", ), "app_common_network_error": m1, + "app_common_recommended": MessageLookupByLibrary.simpleMessage( + "Рекомендуется", + ), "app_common_tip": MessageLookupByLibrary.simpleMessage("Подсказка"), "app_common_tip_cancel": MessageLookupByLibrary.simpleMessage("Отмена"), "app_common_tip_confirm": MessageLookupByLibrary.simpleMessage( @@ -2078,6 +2081,9 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage( "Ускорение через Hosts (экспериментально)", ), + "tools_action_info_cleaning": MessageLookupByLibrary.simpleMessage( + "Очистка...", + ), "tools_action_info_cleanup_complete": MessageLookupByLibrary.simpleMessage( "Очистка завершена, пожалуйста, выполните установку или запуск игры.", ), @@ -2190,6 +2196,9 @@ class MessageLookup extends MessageLookupByLibrary { "tools_action_rsi_launcher_log_fix": MessageLookupByLibrary.simpleMessage( "Исправление лог-файла RSI Launcher", ), + "tools_action_start_cleaning": MessageLookupByLibrary.simpleMessage( + "Начать очистку", + ), "tools_action_unp4k": MessageLookupByLibrary.simpleMessage( "Просмотрщик P4K", ), @@ -2296,12 +2305,18 @@ class MessageLookup extends MessageLookupByLibrary { "tools_shader_clean_all": MessageLookupByLibrary.simpleMessage( "Очистить всё", ), + "tools_shader_clean_all_desc": MessageLookupByLibrary.simpleMessage( + "Очистить кеш всех версий (сохранить только GraphicsSettings). Подходит для графических аномалий или очистки после обновления.", + ), "tools_shader_clean_dialog_title": MessageLookupByLibrary.simpleMessage( "Очистить кеш шейдеров", ), "tools_shader_clean_keep_latest": MessageLookupByLibrary.simpleMessage( "Сохранить последнее", ), + "tools_shader_clean_keep_latest_desc": MessageLookupByLibrary.simpleMessage( + "Подходит для использования после обновления игры и завершения первого запуска. Сохранить все файлы последней версии, очистить другие старые версии (сохранить только GraphicsSettings).", + ), "tools_unp4k_missing_runtime": MessageLookupByLibrary.simpleMessage( "Отсутствует среда выполнения", ), diff --git a/lib/generated/intl/messages_zh_CN.dart b/lib/generated/intl/messages_zh_CN.dart index 8dad938..1f69f50 100644 --- a/lib/generated/intl/messages_zh_CN.dart +++ b/lib/generated/intl/messages_zh_CN.dart @@ -363,6 +363,7 @@ class MessageLookup extends MessageLookupByLibrary { "加载图片...", ), "app_common_network_error": m1, + "app_common_recommended": MessageLookupByLibrary.simpleMessage("推荐"), "app_common_tip": MessageLookupByLibrary.simpleMessage("提示"), "app_common_tip_cancel": MessageLookupByLibrary.simpleMessage("取消"), "app_common_tip_confirm": MessageLookupByLibrary.simpleMessage("确认"), @@ -1834,6 +1835,9 @@ class MessageLookup extends MessageLookupByLibrary { ), "tools_action_hosts_acceleration_experimental": MessageLookupByLibrary.simpleMessage("Hosts 加速(实验性)"), + "tools_action_info_cleaning": MessageLookupByLibrary.simpleMessage( + "正在清理...", + ), "tools_action_info_cleanup_complete": MessageLookupByLibrary.simpleMessage( "清理完毕,请完成一次安装 / 游戏启动 操作。", ), @@ -1929,6 +1933,7 @@ class MessageLookup extends MessageLookupByLibrary { "tools_action_rsi_launcher_log_fix": MessageLookupByLibrary.simpleMessage( "RSI Launcher Log 修复", ), + "tools_action_start_cleaning": MessageLookupByLibrary.simpleMessage("开始清理"), "tools_action_switch_graphics_renderer": MessageLookupByLibrary.simpleMessage("切换 DirectX/Vulkan 渲染器"), "tools_action_switch_graphics_renderer_info": m104, @@ -2045,12 +2050,18 @@ class MessageLookup extends MessageLookupByLibrary { "tools_rsi_launcher_enhance_working_msg2": MessageLookupByLibrary.simpleMessage("安装补丁,这需要一点时间,取决于您的计算机性能 ..."), "tools_shader_clean_all": MessageLookupByLibrary.simpleMessage("全部清理"), + "tools_shader_clean_all_desc": MessageLookupByLibrary.simpleMessage( + "清理所有版本的缓存。适合画面异常或更新后清理。", + ), "tools_shader_clean_dialog_title": MessageLookupByLibrary.simpleMessage( "清理着色器缓存", ), "tools_shader_clean_keep_latest": MessageLookupByLibrary.simpleMessage( "保留最新", ), + "tools_shader_clean_keep_latest_desc": MessageLookupByLibrary.simpleMessage( + "适合游戏更新并完成首次启动后使用。保留最新版本的所有文件,清理其他旧版本。", + ), "tools_unp4k_action_cancel_multi_select": MessageLookupByLibrary.simpleMessage("取消多选"), "tools_unp4k_action_deselect_all": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index 925f009..afe84a0 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -334,6 +334,7 @@ class MessageLookup extends MessageLookupByLibrary { "載入圖片...", ), "app_common_network_error": m1, + "app_common_recommended": MessageLookupByLibrary.simpleMessage("推薦"), "app_common_tip": MessageLookupByLibrary.simpleMessage("提示"), "app_common_tip_cancel": MessageLookupByLibrary.simpleMessage("取消"), "app_common_tip_confirm": MessageLookupByLibrary.simpleMessage("確認"), @@ -1729,6 +1730,9 @@ class MessageLookup extends MessageLookupByLibrary { ), "tools_action_hosts_acceleration_experimental": MessageLookupByLibrary.simpleMessage("Hosts 加速(Beta)"), + "tools_action_info_cleaning": MessageLookupByLibrary.simpleMessage( + "正在清理...", + ), "tools_action_info_cleanup_complete": MessageLookupByLibrary.simpleMessage( "清理完畢,請完成一次安裝 / 遊戲啟動 操作。", ), @@ -1822,6 +1826,7 @@ class MessageLookup extends MessageLookupByLibrary { "tools_action_rsi_launcher_log_fix": MessageLookupByLibrary.simpleMessage( "啟動器日誌修復", ), + "tools_action_start_cleaning": MessageLookupByLibrary.simpleMessage("開始清理"), "tools_action_unp4k": MessageLookupByLibrary.simpleMessage("P4K 查看器"), "tools_action_unp4k_info": MessageLookupByLibrary.simpleMessage( "解包星際公民 p4k 文件", @@ -1908,12 +1913,18 @@ class MessageLookup extends MessageLookupByLibrary { "tools_rsi_launcher_enhance_working_msg2": MessageLookupByLibrary.simpleMessage("安裝補丁,這需要一點時間,取決於您的電腦性能 ..."), "tools_shader_clean_all": MessageLookupByLibrary.simpleMessage("全部清理"), + "tools_shader_clean_all_desc": MessageLookupByLibrary.simpleMessage( + "清理所有版本的快取(僅保留 GraphicsSettings)。適合畫面異常或更新後清理。", + ), "tools_shader_clean_dialog_title": MessageLookupByLibrary.simpleMessage( "清理著色器緩存", ), "tools_shader_clean_keep_latest": MessageLookupByLibrary.simpleMessage( "保留最新", ), + "tools_shader_clean_keep_latest_desc": MessageLookupByLibrary.simpleMessage( + "適合遊戲更新並完成首次啟動後使用。保留最新版本的所有檔案,清理其他舊版本(僅保留 GraphicsSettings)。", + ), "tools_unp4k_missing_runtime": MessageLookupByLibrary.simpleMessage( "缺少運行庫", ), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 9be0454..f7eccc3 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -9576,6 +9576,56 @@ class S { args: [], ); } + + /// `Suitable for use after game updates and completing the first launch. Keep all files in the latest version, clean other old versions (only keep GraphicsSettings).` + String get tools_shader_clean_keep_latest_desc { + return Intl.message( + 'Suitable for use after game updates and completing the first launch. Keep all files in the latest version, clean other old versions (only keep GraphicsSettings).', + name: 'tools_shader_clean_keep_latest_desc', + desc: '', + args: [], + ); + } + + /// `Clean all version caches (only keep GraphicsSettings). Suitable for graphics anomalies or post-update cleaning.` + String get tools_shader_clean_all_desc { + return Intl.message( + 'Clean all version caches (only keep GraphicsSettings). Suitable for graphics anomalies or post-update cleaning.', + name: 'tools_shader_clean_all_desc', + desc: '', + args: [], + ); + } + + /// `Cleaning...` + String get tools_action_info_cleaning { + return Intl.message( + 'Cleaning...', + name: 'tools_action_info_cleaning', + desc: '', + args: [], + ); + } + + /// `Start Cleaning` + String get tools_action_start_cleaning { + return Intl.message( + 'Start Cleaning', + name: 'tools_action_start_cleaning', + desc: '', + args: [], + ); + } + + /// `Recommended` + String get app_common_recommended { + return Intl.message( + 'Recommended', + name: 'app_common_recommended', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index beda9ac..0c5602f 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -1918,5 +1918,15 @@ "tools_shader_clean_keep_latest": "Keep Latest", "@tools_shader_clean_keep_latest": {}, "tools_shader_clean_all": "Clean All", - "@tools_shader_clean_all": {} + "@tools_shader_clean_all": {}, + "tools_shader_clean_keep_latest_desc": "Suitable for use after game updates and completing the first launch. Keep all files in the latest version, clean other old versions (only keep GraphicsSettings).", + "@tools_shader_clean_keep_latest_desc": {}, + "tools_shader_clean_all_desc": "Clean all version caches (only keep GraphicsSettings). Suitable for graphics anomalies or post-update cleaning.", + "@tools_shader_clean_all_desc": {}, + "tools_action_info_cleaning": "Cleaning...", + "@tools_action_info_cleaning": {}, + "tools_action_start_cleaning": "Start Cleaning", + "@tools_action_start_cleaning": {}, + "app_common_recommended": "Recommended", + "@app_common_recommended": {} } diff --git a/lib/l10n/intl_ja.arb b/lib/l10n/intl_ja.arb index 5b5a570..563149b 100644 --- a/lib/l10n/intl_ja.arb +++ b/lib/l10n/intl_ja.arb @@ -1740,5 +1740,15 @@ "tools_shader_clean_keep_latest": "最新を保持", "@tools_shader_clean_keep_latest": {}, "tools_shader_clean_all": "すべてクリア", - "@tools_shader_clean_all": {} + "@tools_shader_clean_all": {}, + "tools_shader_clean_keep_latest_desc": "ゲームアップデート後と初回起動完了後の使用に適しています。最新バージョンのすべてのファイルを保持し、他の古いバージョンをクリア(GraphicsSettingsのみ保持)。", + "@tools_shader_clean_keep_latest_desc": {}, + "tools_shader_clean_all_desc": "すべてのバージョンのキャッシュをクリア(GraphicsSettingsのみ保持)。グラフィック異常またはアップデート後のクリーニングに適しています。", + "@tools_shader_clean_all_desc": {}, + "tools_action_info_cleaning": "クリーニング中...", + "@tools_action_info_cleaning": {}, + "tools_action_start_cleaning": "クリーニング開始", + "@tools_action_start_cleaning": {}, + "app_common_recommended": "推奨", + "@app_common_recommended": {} } diff --git a/lib/l10n/intl_ru.arb b/lib/l10n/intl_ru.arb index 9dad5b4..ba4b4f1 100644 --- a/lib/l10n/intl_ru.arb +++ b/lib/l10n/intl_ru.arb @@ -1740,5 +1740,15 @@ "tools_shader_clean_keep_latest": "Сохранить последнее", "@tools_shader_clean_keep_latest": {}, "tools_shader_clean_all": "Очистить всё", - "@tools_shader_clean_all": {} + "@tools_shader_clean_all": {}, + "tools_shader_clean_keep_latest_desc": "Подходит для использования после обновления игры и завершения первого запуска. Сохранить все файлы последней версии, очистить другие старые версии (сохранить только GraphicsSettings).", + "@tools_shader_clean_keep_latest_desc": {}, + "tools_shader_clean_all_desc": "Очистить кеш всех версий (сохранить только GraphicsSettings). Подходит для графических аномалий или очистки после обновления.", + "@tools_shader_clean_all_desc": {}, + "tools_action_info_cleaning": "Очистка...", + "@tools_action_info_cleaning": {}, + "tools_action_start_cleaning": "Начать очистку", + "@tools_action_start_cleaning": {}, + "app_common_recommended": "Рекомендуется", + "@app_common_recommended": {} } diff --git a/lib/l10n/intl_zh_CN.arb b/lib/l10n/intl_zh_CN.arb index 4abc2b0..7797c1a 100644 --- a/lib/l10n/intl_zh_CN.arb +++ b/lib/l10n/intl_zh_CN.arb @@ -1331,5 +1331,10 @@ "yearly_report_card_desc": "查看您在{year}年的星际公民游玩统计,数据来自本地 log ,请确保在常用电脑上查看。", "tools_shader_clean_dialog_title": "清理着色器缓存", "tools_shader_clean_keep_latest": "保留最新", - "tools_shader_clean_all": "全部清理" + "tools_shader_clean_all": "全部清理", + "tools_shader_clean_keep_latest_desc": "适合游戏更新并完成首次启动后使用。保留最新版本的所有文件,清理其他旧版本。", + "tools_shader_clean_all_desc": "清理所有版本的缓存。适合画面异常或更新后清理。", + "tools_action_info_cleaning": "正在清理...", + "tools_action_start_cleaning": "开始清理", + "app_common_recommended": "推荐" } \ No newline at end of file diff --git a/lib/l10n/intl_zh_TW.arb b/lib/l10n/intl_zh_TW.arb index 1d022ac..67d4fd3 100644 --- a/lib/l10n/intl_zh_TW.arb +++ b/lib/l10n/intl_zh_TW.arb @@ -1673,5 +1673,10 @@ "yearly_report_card_desc": "查看您在{year}年的星際公民遊玩統計,數據來自本地 log ,請確保在常用電腦上查看。", "tools_shader_clean_dialog_title": "清理著色器緩存", "tools_shader_clean_keep_latest": "保留最新", - "tools_shader_clean_all": "全部清理" + "tools_shader_clean_all": "全部清理", + "tools_shader_clean_keep_latest_desc": "適合遊戲更新並完成首次啟動後使用。保留最新版本的所有檔案,清理其他舊版本(僅保留 GraphicsSettings)。", + "tools_shader_clean_all_desc": "清理所有版本的快取(僅保留 GraphicsSettings)。適合畫面異常或更新後清理。", + "tools_action_info_cleaning": "正在清理...", + "tools_action_start_cleaning": "開始清理", + "app_common_recommended": "推薦" } diff --git a/lib/ui/home/localization/localization_ui_model.dart b/lib/ui/home/localization/localization_ui_model.dart index a54f796..11b9092 100644 --- a/lib/ui/home/localization/localization_ui_model.dart +++ b/lib/ui/home/localization/localization_ui_model.dart @@ -677,9 +677,11 @@ class LocalizationUIModel extends _$LocalizationUIModel { child: Row( children: [ Expanded( - child: Text( - item.value.note ?? S.current.home_localization_msg_no_note, - style: const TextStyle(fontSize: 15), + child: SelectionArea( + child: Text( + item.value.note ?? S.current.home_localization_msg_no_note, + style: const TextStyle(fontSize: 15), + ), ), ), ], diff --git a/lib/ui/tools/dialogs/shader_cache_clean_dialog.dart b/lib/ui/tools/dialogs/shader_cache_clean_dialog.dart new file mode 100644 index 0000000..832b9e8 --- /dev/null +++ b/lib/ui/tools/dialogs/shader_cache_clean_dialog.dart @@ -0,0 +1,196 @@ +import 'package:fluent_ui/fluent_ui.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:starcitizen_doctor/generated/l10n.dart'; + +/// 着色器缓存清理对话框 +class ShaderCacheCleanDialog extends StatefulWidget { + final Future Function(String mode) onClean; + + const ShaderCacheCleanDialog({super.key, required this.onClean}); + + @override + State createState() => _ShaderCacheCleanDialogState(); +} + +class _ShaderCacheCleanDialogState extends State { + bool _isCleaning = false; + String? _selectedMode; + + @override + Widget build(BuildContext context) { + return ContentDialog( + title: Row( + children: [ + const Icon(FontAwesomeIcons.shapes, size: 20), + const SizedBox(width: 12), + Text(S.current.tools_shader_clean_dialog_title), + ], + ), + constraints: const BoxConstraints(maxWidth: 500), + content: _isCleaning + ? SizedBox( + height: 120, + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const ProgressRing(), + const SizedBox(height: 16), + Text(S.current.tools_action_info_cleaning), + ], + ), + ), + ) + : Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 12), + // 保留最新模式 + _CleanModeOption( + icon: FluentIcons.save, + title: S.current.tools_shader_clean_keep_latest, + description: S.current.tools_shader_clean_keep_latest_desc, + isSelected: _selectedMode == "keep_latest", + isRecommended: true, + onTap: () { + setState(() { + _selectedMode = "keep_latest"; + }); + }, + ), + const SizedBox(height: 12), + // 全部清理模式 + _CleanModeOption( + icon: FluentIcons.delete, + title: S.current.tools_shader_clean_all, + description: S.current.tools_shader_clean_all_desc, + isSelected: _selectedMode == "clean_all", + onTap: () { + setState(() { + _selectedMode = "clean_all"; + }); + }, + ), + ], + ), + actions: [ + if (!_isCleaning) ...[ + Button(onPressed: () => Navigator.of(context).pop(), child: Text(S.current.app_common_tip_cancel)), + FilledButton( + onPressed: _selectedMode == null + ? null + : () async { + setState(() { + _isCleaning = true; + }); + try { + await widget.onClean(_selectedMode!); + } finally { + if (mounted) { + setState(() { + _isCleaning = false; + }); + } + } + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + child: Text(S.current.tools_action_start_cleaning), + ), + ), + ], + ], + ); + } +} + +/// 清理模式选项组件 +class _CleanModeOption extends StatelessWidget { + final IconData icon; + final String title; + final String description; + final bool isSelected; + final bool isRecommended; + final VoidCallback onTap; + + const _CleanModeOption({ + required this.icon, + required this.title, + required this.description, + required this.isSelected, + this.isRecommended = false, + required this.onTap, + }); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: isSelected + ? FluentTheme.of(context).accentColor.withValues(alpha: .15) + : FluentTheme.of(context).cardColor, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: isSelected ? FluentTheme.of(context).accentColor : Colors.transparent, width: 2), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon( + icon, + size: 20, + color: isSelected ? FluentTheme.of(context).accentColor : Colors.white.withValues(alpha: .7), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + title, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: isSelected ? FluentTheme.of(context).accentColor : Colors.white, + ), + ), + ), + if (isRecommended) + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: const Color(0xFF4CAF50), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + S.current.app_common_recommended, + style: const TextStyle(fontSize: 11, color: Colors.white, fontWeight: FontWeight.w600), + ), + ), + ], + ), + const SizedBox(height: 8), + Text( + description, + style: TextStyle(fontSize: 13, color: Colors.white.withValues(alpha: .6), height: 1.4), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/ui/tools/tools_ui_model.dart b/lib/ui/tools/tools_ui_model.dart index ce92fd0..2331fba 100644 --- a/lib/ui/tools/tools_ui_model.dart +++ b/lib/ui/tools/tools_ui_model.dart @@ -25,6 +25,7 @@ import 'package:xml/xml.dart'; import 'dialogs/hosts_booster_dialog_ui.dart'; import 'dialogs/rsi_launcher_enhance_dialog_ui.dart'; +import 'dialogs/shader_cache_clean_dialog.dart'; import 'yearly_report_ui/yearly_report_ui.dart'; part 'tools_ui_model.g.dart'; @@ -627,62 +628,28 @@ class ToolsUIModel extends _$ToolsUIModel { // 全部清理模式: // 前两个:仅保留 GraphicsSettings // 其他:仅保留 GraphicsSettings - await _cleanShaderCacheDirectory(scDir); } } } Future _cleanShaderCache(BuildContext context) async { - // 显示对话框让用户选择清理模式 - final result = await showDialog( + await showDialog( context: context, - builder: (dialogContext) => ContentDialog( - constraints: BoxConstraints(maxWidth: 380), - title: Text(S.current.tools_shader_clean_dialog_title), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(height: 12), - SizedBox( - width: double.infinity, - child: FilledButton( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Text(S.current.tools_shader_clean_keep_latest), - ), - onPressed: () => Navigator.pop(dialogContext, "keep_latest"), - ), - ), - const SizedBox(height: 12), - SizedBox( - width: double.infinity, - child: Button( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Text(S.current.tools_shader_clean_all), - ), - onPressed: () => Navigator.pop(dialogContext, "clean_all"), - ), - ), - ], - ), - actions: [Button(child: Text(S.current.app_common_tip_cancel), onPressed: () => Navigator.pop(dialogContext))], + builder: (dialogContext) => ShaderCacheCleanDialog( + onClean: (mode) async { + state = state.copyWith(working: true); + if (mode == "keep_latest") { + await cleanShaderCacheKeepLatest(); + } else { + await cleanShaderCache(); + } + if (!context.mounted) return; + loadToolsCard(context, skipPathScan: true); + state = state.copyWith(working: false); + Navigator.of(dialogContext).pop(); + }, ), ); - - if (result == null || !context.mounted) return; - - state = state.copyWith(working: true); - - if (result == "keep_latest") { - await cleanShaderCacheKeepLatest(); - } else { - await cleanShaderCache(); - } - - if (!context.mounted) return; - loadToolsCard(context, skipPathScan: true); - state = state.copyWith(working: false); } /// 清理着色器缓存目录,保留 GraphicsSettings 文件夹