mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 06:33:43 +08:00
优化工具加载速度
This commit is contained in:
parent
b195e57a5c
commit
579dc144ec
@ -58,9 +58,21 @@ class ToolsUI extends BaseUI<ToolsUIModel> {
|
|||||||
crossAxisCount: 3,
|
crossAxisCount: 3,
|
||||||
mainAxisSpacing: 12,
|
mainAxisSpacing: 12,
|
||||||
crossAxisSpacing: 12,
|
crossAxisSpacing: 12,
|
||||||
itemCount: model.items.length,
|
itemCount: (model.isItemLoading)
|
||||||
|
? model.items.length + 1
|
||||||
|
: model.items.length,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
|
if (index == model.items.length) {
|
||||||
|
return Container(
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
color: FluentTheme.of(context).cardColor,
|
||||||
|
),
|
||||||
|
child: makeLoading(context));
|
||||||
|
}
|
||||||
final item = model.items[index];
|
final item = model.items[index];
|
||||||
return Container(
|
return Container(
|
||||||
width: 300,
|
width: 300,
|
||||||
|
@ -29,27 +29,16 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
|
|
||||||
var items = <_ToolsItemData>[];
|
var items = <_ToolsItemData>[];
|
||||||
|
|
||||||
|
bool isItemLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future loadData({bool skipPathScan = false}) async {
|
Future loadData({bool skipPathScan = false}) async {
|
||||||
items.clear();
|
items.clear();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
if (!skipPathScan) {
|
if (!skipPathScan) {
|
||||||
await reScanPath();
|
await reScanPath();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final nvmePatchStatus = await SystemHelper.checkNvmePatchStatus();
|
|
||||||
|
|
||||||
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
|
|
||||||
|
|
||||||
double logPathLen = 0;
|
|
||||||
try {
|
|
||||||
logPathLen =
|
|
||||||
(await File(await SCLoggerHelper.getLogFilePath() ?? "").length()) /
|
|
||||||
1024 /
|
|
||||||
1024;
|
|
||||||
} catch (_) {}
|
|
||||||
|
|
||||||
items = [
|
items = [
|
||||||
_ToolsItemData(
|
_ToolsItemData(
|
||||||
"systeminfo",
|
"systeminfo",
|
||||||
@ -78,30 +67,53 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
"在某些情况下 RSI启动器 无法正确获得管理员权限,您可尝试使用该功能以管理员模式运行启动器。",
|
"在某些情况下 RSI启动器 无法正确获得管理员权限,您可尝试使用该功能以管理员模式运行启动器。",
|
||||||
const Icon(FluentIcons.admin, size: 28),
|
const Icon(FluentIcons.admin, size: 28),
|
||||||
onTap: _adminRSILauncher,
|
onTap: _adminRSILauncher,
|
||||||
),
|
)
|
||||||
_ToolsItemData(
|
];
|
||||||
"clean_shaders",
|
isItemLoading = true;
|
||||||
"清理着色器缓存",
|
notifyListeners();
|
||||||
"若游戏画面出现异常或版本更新后可使用本工具清理过期的着色器(当大于500M时,建议清理) \n\n缓存大小:${((await SystemHelper.getDirLen(gameShaderCachePath ?? "", skipPath: [
|
items.addAll(await _addLogCard());
|
||||||
"$gameShaderCachePath\\Crashes"
|
notifyListeners();
|
||||||
])) / 1024 / 1024).toStringAsFixed(4)} MB",
|
items.addAll(await _addNvmePatchCard());
|
||||||
const Icon(FontAwesomeIcons.shapes, size: 28),
|
notifyListeners();
|
||||||
onTap: _cleanShaderCache,
|
items.add(await _addShaderCard());
|
||||||
),
|
isItemLoading = false;
|
||||||
_ToolsItemData(
|
notifyListeners();
|
||||||
"rsilauncher_log_fix",
|
} catch (e) {
|
||||||
"RSI Launcher Log 修复",
|
showToast(context!, "初始化失败,请截图报告给开发者。$e");
|
||||||
"在某些情况下 RSI启动器 的 log 文件会损坏,导致无法完成问题扫描,使用此工具清理损坏的 log 文件。\n\n当前日志文件大小:${(logPathLen.toStringAsFixed(4))} MB",
|
}
|
||||||
const Icon(FontAwesomeIcons.bookBible, size: 28),
|
notifyListeners();
|
||||||
onTap: _rsiLogFix,
|
}
|
||||||
),
|
|
||||||
_ToolsItemData(
|
Future<List<_ToolsItemData>> _addLogCard() async {
|
||||||
"rsilauncher_log_select",
|
double logPathLen = 0;
|
||||||
"RSI Launcher Log 查看",
|
try {
|
||||||
"打开 RSI启动器 Log文件 所在文件夹",
|
logPathLen =
|
||||||
const Icon(FontAwesomeIcons.bookBible, size: 28),
|
(await File(await SCLoggerHelper.getLogFilePath() ?? "").length()) /
|
||||||
onTap: _selectLog,
|
1024 /
|
||||||
),
|
1024;
|
||||||
|
} catch (_) {}
|
||||||
|
return [
|
||||||
|
_ToolsItemData(
|
||||||
|
"rsilauncher_log_select",
|
||||||
|
"RSI Launcher Log 查看",
|
||||||
|
"打开 RSI启动器 Log文件 所在文件夹",
|
||||||
|
const Icon(FontAwesomeIcons.bookBible, size: 28),
|
||||||
|
onTap: _selectLog,
|
||||||
|
),
|
||||||
|
_ToolsItemData(
|
||||||
|
"rsilauncher_log_fix",
|
||||||
|
"RSI Launcher Log 修复",
|
||||||
|
"在某些情况下 RSI启动器 的 log 文件会损坏,导致无法完成问题扫描,使用此工具清理损坏的 log 文件。\n\n当前日志文件大小:${(logPathLen.toStringAsFixed(4))} MB",
|
||||||
|
const Icon(FontAwesomeIcons.bookBible, size: 28),
|
||||||
|
onTap: _rsiLogFix,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<_ToolsItemData>> _addNvmePatchCard() async {
|
||||||
|
final nvmePatchStatus = await SystemHelper.checkNvmePatchStatus();
|
||||||
|
return [
|
||||||
|
if (nvmePatchStatus)
|
||||||
_ToolsItemData(
|
_ToolsItemData(
|
||||||
"remove_nvme_settings",
|
"remove_nvme_settings",
|
||||||
"移除 nvme 注册表补丁",
|
"移除 nvme 注册表补丁",
|
||||||
@ -117,6 +129,7 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
if (!nvmePatchStatus)
|
||||||
_ToolsItemData(
|
_ToolsItemData(
|
||||||
"add_nvme_settings",
|
"add_nvme_settings",
|
||||||
"写入 nvme 注册表补丁",
|
"写入 nvme 注册表补丁",
|
||||||
@ -135,14 +148,28 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
working = false;
|
working = false;
|
||||||
loadData(skipPathScan: true);
|
loadData(skipPathScan: true);
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
} catch (e) {
|
|
||||||
showToast(context!, "初始化失败,请截图报告给开发者。$e");
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<_ToolsItemData> _addShaderCard() async {
|
||||||
|
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
|
||||||
|
return _ToolsItemData(
|
||||||
|
"clean_shaders",
|
||||||
|
"清理着色器缓存",
|
||||||
|
"若游戏画面出现异常或版本更新后可使用本工具清理过期的着色器(当大于500M时,建议清理) \n\n缓存大小:${((await SystemHelper.getDirLen(gameShaderCachePath ?? "", skipPath: [
|
||||||
|
"$gameShaderCachePath\\Crashes"
|
||||||
|
])) / 1024 / 1024).toStringAsFixed(4)} MB",
|
||||||
|
const Icon(FontAwesomeIcons.shapes, size: 28),
|
||||||
|
onTap: _cleanShaderCache,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ---------------------------- func -------------------------------------------------------
|
||||||
|
/// -----------------------------------------------------------------------------------------
|
||||||
|
/// -----------------------------------------------------------------------------------------
|
||||||
|
/// -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Future<void> reScanPath() async {
|
Future<void> reScanPath() async {
|
||||||
scInstallPaths.clear();
|
scInstallPaths.clear();
|
||||||
rsiLauncherInstallPaths.clear();
|
rsiLauncherInstallPaths.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user