From 3d7454613f9bd76fe1951fcf65498d1a4ec1d134 Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Wed, 6 Dec 2023 20:49:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=B1=89=E5=8C=96?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/conf.dart | 6 +++--- lib/ui/index_ui_model.dart | 6 +++++- lib/ui/settings/settings_ui.dart | 22 ++++++++++++++-------- lib/ui/settings/settings_ui_model.dart | 24 ++++++++++++++++++++++++ windows/corrosion | 2 +- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/lib/common/conf.dart b/lib/common/conf.dart index e07acd4..b5628ee 100644 --- a/lib/common/conf.dart +++ b/lib/common/conf.dart @@ -18,9 +18,9 @@ import 'package:window_manager/window_manager.dart'; import '../base/ui.dart'; class AppConf { - static const String appVersion = "2.9.22 Beta"; - static const int appVersionCode = 33; - static const String appVersionDate = "2023-12-05"; + static const String appVersion = "2.10.0 Beta"; + static const int appVersionCode = 35; + static const String appVersionDate = "2023-12-06"; static const String giteaAttachmentsUrl = "https://git.sctoolbox.sccsgo.com/SCToolBox/Release"; diff --git a/lib/ui/index_ui_model.dart b/lib/ui/index_ui_model.dart index 9e1a73a..a7089c9 100644 --- a/lib/ui/index_ui_model.dart +++ b/lib/ui/index_ui_model.dart @@ -51,6 +51,9 @@ class IndexUIModel extends BaseUIModel { case 1: getCreatedChildUIModel("tools")?.reloadData(); break; + case 2: + getCreatedChildUIModel("settings")?.reloadData(); + break; } notifyListeners(); } @@ -65,7 +68,8 @@ class IndexUIModel extends BaseUIModel { } try { - var result = await Process.run(SystemHelper.powershellPath, ["echo", "ping"]); + var result = + await Process.run(SystemHelper.powershellPath, ["echo", "ping"]); if (result.stdout.toString().startsWith("ping")) { dPrint("powershell check pass"); } else { diff --git a/lib/ui/settings/settings_ui.dart b/lib/ui/settings/settings_ui.dart index f90fbfc..8fd40e6 100644 --- a/lib/ui/settings/settings_ui.dart +++ b/lib/ui/settings/settings_ui.dart @@ -13,20 +13,21 @@ class SettingUI extends BaseUI { child: Column( children: [ if (AppConf.isMSE) ...[ - makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充", + makeSettingsItem( + const Icon(FluentIcons.reset_device, size: 20), "重置自动密码填充", subTitle: "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", onTap: model.onResetAutoLogin), ], const SizedBox(height: 12), - makeSettingsItem(const Icon(FontAwesomeIcons.microchip), + makeSettingsItem(const Icon(FontAwesomeIcons.microchip, size: 20), "启动游戏时忽略能效核心( 适用于Intel 12th+ 处理器 ) [实验性功能,请随时反馈]", subTitle: "已设置的核心数量:${model.inputGameLaunchECore} (此功能适用于首页的盒子一键启动 或 工具中的RSI启动器管理员模式,当为 0 时不启用此功能 )", onTap: model.setGameLaunchECore), const SizedBox(height: 12), - makeSettingsItem( - const Icon(FluentIcons.folder_open), "设置启动器文件(RSI Launcher.exe)", + makeSettingsItem(const Icon(FluentIcons.folder_open, size: 20), + "设置启动器文件(RSI Launcher.exe)", subTitle: model.customLauncherPath != null ? "${model.customLauncherPath}" : "手动设置启动器位置,建议仅在无法自动扫描安装位置时使用", @@ -34,14 +35,19 @@ class SettingUI extends BaseUI { model.delName("custom_launcher_path"); }), const SizedBox(height: 12), - makeSettingsItem( - const Icon(FluentIcons.game), "设置游戏文件 (StarCitizen.exe)", + makeSettingsItem(const Icon(FluentIcons.game, size: 20), + "设置游戏文件 (StarCitizen.exe)", subTitle: model.customGamePath != null ? "${model.customGamePath}" : "手动设置游戏安装位置,建议仅在无法自动扫描安装位置时使用", onTap: model.setGamePath, onDel: () { model.delName("custom_game_path"); }), + const SizedBox(height: 12), + makeSettingsItem(const Icon(FluentIcons.delete, size: 20), "清理汉化文件缓存", + subTitle: + "缓存大小 ${(model.locationCacheSize / 1024 / 1024).toStringAsFixed(2)}MB,清理盒子下载的汉化文件缓存,不会影响已安装的汉化", + onTap: model.cleanLocationCache), ], ), ); @@ -55,14 +61,14 @@ class SettingUI extends BaseUI { padding: const EdgeInsets.only(top: 12, bottom: 12), child: Row( children: [ + icon, + const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - icon, - const SizedBox(width: 12), Text(title), const Spacer(), ], diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart index 610da3a..5a08fec 100644 --- a/lib/ui/settings/settings_ui_model.dart +++ b/lib/ui/settings/settings_ui_model.dart @@ -1,9 +1,12 @@ +import 'dart:io'; + import 'package:file_picker/file_picker.dart'; import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; import 'package:local_auth/local_auth.dart'; import 'package:starcitizen_doctor/base/ui_model.dart'; import 'package:starcitizen_doctor/common/conf.dart'; +import 'package:starcitizen_doctor/common/helper/system_helper.dart'; import 'package:starcitizen_doctor/common/win32/credentials.dart'; class SettingUIModel extends BaseUIModel { @@ -17,8 +20,11 @@ class SettingUIModel extends BaseUIModel { String? customLauncherPath; String? customGamePath; + int locationCacheSize = 0; + @override loadData() async { + dPrint("SettingUIModel.loadData"); final LocalAuthentication localAuth = LocalAuthentication(); isDeviceSupportWinHello = await localAuth.isDeviceSupported(); notifyListeners(); @@ -27,6 +33,7 @@ class SettingUIModel extends BaseUIModel { _updateAutoLoginAccount(); } _loadCustomPath(); + _loadLocationCacheSize(); } Future onResetAutoLogin() async { @@ -125,4 +132,21 @@ class SettingUIModel extends BaseUIModel { await confBox.delete(key); reloadData(); } + + _loadLocationCacheSize() async { + final len = await SystemHelper.getDirLen( + "${AppConf.applicationSupportDir}/Localizations"); + locationCacheSize = len; + notifyListeners(); + } + + Future cleanLocationCache() async { + final ok = await showConfirmDialogs( + context!, "确认清理汉化缓存?", const Text("这不会影响已安装的汉化。")); + if (ok == true) { + final dir = Directory("${AppConf.applicationSupportDir}/Localizations"); + await handleError(() => dir.delete(recursive: true)); + reloadData(); + } + } } diff --git a/windows/corrosion b/windows/corrosion index 03e4617..123be1e 160000 --- a/windows/corrosion +++ b/windows/corrosion @@ -1 +1 @@ -Subproject commit 03e4617c59058d105ac1b325cb24198dbe403878 +Subproject commit 123be1e3d8170c86e121392e8bffa4def7dc3447