mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 11:24:46 +08:00
feat: 多语言 初步引入
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
|
||||
import 'package:starcitizen_doctor/generated/l10n.dart';
|
||||
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
|
||||
class SettingsUI extends HookConsumerWidget {
|
||||
@ -17,59 +18,59 @@ class SettingsUI extends HookConsumerWidget {
|
||||
margin: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
makeSettingsItem(const Icon(FluentIcons.link, size: 20), "创建设置快捷方式",
|
||||
subTitle: "在桌面创建《SC汉化盒子》快捷方式", onTap: ()=> model.addShortCut(context)),
|
||||
makeSettingsItem(const Icon(FluentIcons.link, size: 20), S.current.setting_action_create_settings_shortcut,
|
||||
subTitle: S.current.setting_action_create_desktop_shortcut, onTap: ()=> model.addShortCut(context)),
|
||||
if (ConstConf.isMSE) ...[
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(
|
||||
const Icon(FluentIcons.reset_device, size: 20), "重置自动密码填充",
|
||||
const Icon(FluentIcons.reset_device, size: 20), S.current.setting_action_reset_auto_password_fill,
|
||||
subTitle:
|
||||
"启用:${sate.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${sate.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${sate.autoLoginEmail} 密码:${sate.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
|
||||
onTap: ()=> model.onResetAutoLogin(context)),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(const Icon(FontAwesomeIcons.microchip, size: 20),
|
||||
"启动游戏时忽略能效核心( 适用于Intel 12th+ 处理器 )",
|
||||
S.current.setting_action_ignore_efficiency_cores_on_launch,
|
||||
subTitle:
|
||||
"已设置的核心数量:${sate.inputGameLaunchECore} (此功能适用于首页的盒子一键启动 或 工具中的RSI启动器管理员模式,当为 0 时不启用此功能 )",
|
||||
onTap:()=> model.setGameLaunchECore(context)),
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(const Icon(FluentIcons.folder_open, size: 20),
|
||||
"设置启动器文件(RSI Launcher.exe)",
|
||||
S.current.setting_action_set_launcher_file,
|
||||
subTitle: sate.customLauncherPath != null
|
||||
? "${sate.customLauncherPath}"
|
||||
: "手动设置启动器位置,建议仅在无法自动扫描安装位置时使用",
|
||||
: S.current.setting_action_info_manual_launcher_location_setting,
|
||||
onTap: ()=> model.setLauncherPath(context), onDel: () {
|
||||
model.delName("custom_launcher_path");
|
||||
}),
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(const Icon(FluentIcons.game, size: 20),
|
||||
"设置游戏文件 (StarCitizen.exe)",
|
||||
S.current.setting_action_set_game_file,
|
||||
subTitle: sate.customGamePath != null
|
||||
? "${sate.customGamePath}"
|
||||
: "手动设置游戏安装位置,建议仅在无法自动扫描安装位置时使用",
|
||||
: S.current.setting_action_info_manual_game_location_setting,
|
||||
onTap: ()=> model.setGamePath(context), onDel: () {
|
||||
model.delName("custom_game_path");
|
||||
}),
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(const Icon(FluentIcons.delete, size: 20), "清理汉化文件缓存",
|
||||
makeSettingsItem(const Icon(FluentIcons.delete, size: 20), S.current.setting_action_clear_translation_file_cache,
|
||||
subTitle:
|
||||
"缓存大小 ${(sate.locationCacheSize / 1024 / 1024).toStringAsFixed(2)}MB,清理盒子下载的汉化文件缓存,不会影响已安装的汉化",
|
||||
onTap: ()=> model.cleanLocationCache(context)),
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(
|
||||
const Icon(FluentIcons.speed_high, size: 20), "工具站访问加速",
|
||||
const Icon(FluentIcons.speed_high, size: 20), S.current.setting_action_tool_site_access_acceleration,
|
||||
onTap: () =>
|
||||
model.onChangeToolSiteMirror(!sate.isEnableToolSiteMirrors),
|
||||
subTitle:
|
||||
"使用镜像服务器加速访问 Dps Uex 等工具网站,若访问异常请关闭该功能。 为保护账户安全,任何情况下都不会加速RSI官网。",
|
||||
S.current.setting_action_info_mirror_server_info,
|
||||
onSwitch: model.onChangeToolSiteMirror,
|
||||
switchStatus: sate.isEnableToolSiteMirrors),
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(
|
||||
const Icon(FluentIcons.document_set, size: 20), "查看log",
|
||||
const Icon(FluentIcons.document_set, size: 20), S.current.setting_action_view_log,
|
||||
onTap: () => model.showLogs(),
|
||||
subTitle: "查看汉化盒子的 log 文件,以定位盒子的 bug"),
|
||||
subTitle: S.current.setting_action_info_view_log_file),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -128,4 +129,4 @@ class SettingsUI extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ part 'settings_ui_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class SettingsUIState with _$SettingsUIState {
|
||||
const factory SettingsUIState({
|
||||
factory SettingsUIState({
|
||||
@Default(false) isDeviceSupportWinHello,
|
||||
@Default("-") String autoLoginEmail,
|
||||
@Default(false) bool isEnableAutoLogin,
|
||||
@ -38,7 +38,7 @@ class SettingsUIState with _$SettingsUIState {
|
||||
class SettingsUIModel extends _$SettingsUIModel {
|
||||
@override
|
||||
SettingsUIState build() {
|
||||
state = const SettingsUIState();
|
||||
state = SettingsUIState();
|
||||
_initState();
|
||||
return state;
|
||||
}
|
||||
@ -57,15 +57,15 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
}
|
||||
|
||||
Future<void> onResetAutoLogin(BuildContext context) async {
|
||||
final ok = await showConfirmDialogs(context, "确认重置自动填充?",
|
||||
const Text("这将会删除本地的账号记录,或在下次启动游戏时将自动填充选择 ‘否’ 以禁用自动填充。"));
|
||||
final ok = await showConfirmDialogs(context, S.current.setting_action_info_confirm_reset_autofill,
|
||||
Text(S.current.setting_action_info_delete_local_account_warning));
|
||||
if (ok) {
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
await userBox.deleteFromDisk();
|
||||
Win32Credentials.delete("SCToolbox_RSI_Account_secret");
|
||||
if (!context.mounted) return;
|
||||
|
||||
showToast(context, "已清理自动填充数据");
|
||||
showToast(context, S.current.setting_action_info_autofill_data_cleared);
|
||||
_initState();
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
userBox.get("gameLaunch_eCore_count", defaultValue: "0");
|
||||
if (!context.mounted) return;
|
||||
final input = await showInputDialogs(context,
|
||||
title: "请输入要忽略的 CPU 核心数",
|
||||
title: S.current.setting_action_info_enter_cpu_core_to_ignore,
|
||||
content:
|
||||
"Tip:您的设备拥有几个能效核心就输入几,非大小核设备请保持 0\n\n此功能适用于首页的盒子一键启动 或 工具中的 RSI启动器管理员模式,当为 0 时不启用此功能。",
|
||||
initialValue: defaultInput,
|
||||
@ -108,7 +108,7 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
|
||||
Future<void> setLauncherPath(BuildContext context) async {
|
||||
final r = await FilePicker.platform.pickFiles(
|
||||
dialogTitle: "请选择RSI启动器位置(RSI Launcher.exe)",
|
||||
dialogTitle: S.current.setting_action_info_select_rsi_launcher_location,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ["exe"]);
|
||||
if (r == null || r.files.firstOrNull?.path == null) return;
|
||||
@ -116,17 +116,17 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
if (fileName.endsWith("\\RSI Launcher.exe")) {
|
||||
await _saveCustomPath("custom_launcher_path", fileName);
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "设置成功,在对应页面点击刷新即可扫描出新路径");
|
||||
showToast(context, S.current.setting_action_info_setting_success);
|
||||
_initState();
|
||||
} else {
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "文件有误!");
|
||||
showToast(context, S.current.setting_action_info_file_error);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setGamePath(BuildContext context) async {
|
||||
final r = await FilePicker.platform.pickFiles(
|
||||
dialogTitle: "请选择游戏安装位置(StarCitizen.exe)",
|
||||
dialogTitle: S.current.setting_action_info_select_game_install_location,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ["exe"]);
|
||||
if (r == null || r.files.firstOrNull?.path == null) return;
|
||||
@ -139,11 +139,11 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
String extractedPath = fileName.replaceFirst(pathRegex, '');
|
||||
await _saveCustomPath("custom_game_path", extractedPath);
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "设置成功,在对应页面点击刷新即可扫描出新路径");
|
||||
showToast(context, S.current.setting_action_info_setting_success);
|
||||
_initState();
|
||||
} else {
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "文件有误!");
|
||||
showToast(context, S.current.setting_action_info_file_error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,7 +175,7 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
|
||||
Future<void> cleanLocationCache(BuildContext context) async {
|
||||
final ok = await showConfirmDialogs(
|
||||
context, "确认清理汉化缓存?", const Text("这不会影响已安装的汉化。"));
|
||||
context, "确认清理汉化缓存?", Text(S.current.setting_action_info_clear_cache_warning));
|
||||
if (ok == true) {
|
||||
final dir =
|
||||
Directory("${appGlobalState.applicationSupportDir}/Localizations");
|
||||
@ -187,7 +187,7 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
|
||||
Future<void> addShortCut(BuildContext context) async {
|
||||
if (ConstConf.isMSE) {
|
||||
showToast(context, "因微软版功能限制,请在接下来打开的窗口中 手动将《SC汉化盒子》拖动到桌面,即可创建快捷方式。");
|
||||
showToast(context, S.current.setting_action_info_microsoft_version_limitation);
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
Process.run("explorer.exe", ["shell:AppsFolder"]);
|
||||
return;
|
||||
@ -208,7 +208,7 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
""";
|
||||
await Process.run(SystemHelper.powershellPath, [script]);
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "创建完毕,请返回桌面查看");
|
||||
showToast(context, S.current.setting_action_info_shortcut_created);
|
||||
}
|
||||
|
||||
_loadToolSiteMirrorState() async {
|
||||
@ -228,4 +228,4 @@ class SettingsUIModel extends _$SettingsUIModel {
|
||||
showLogs() async {
|
||||
SystemHelper.openDir(getDPrintFile()?.absolute.path.replaceAll("/", "\\"));
|
||||
}
|
||||
}
|
||||
}
|
@ -197,7 +197,7 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
|
||||
/// @nodoc
|
||||
|
||||
class _$SettingsUIStateImpl implements _SettingsUIState {
|
||||
const _$SettingsUIStateImpl(
|
||||
_$SettingsUIStateImpl(
|
||||
{this.isDeviceSupportWinHello = false,
|
||||
this.autoLoginEmail = "-",
|
||||
this.isEnableAutoLogin = false,
|
||||
@ -287,7 +287,7 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
|
||||
}
|
||||
|
||||
abstract class _SettingsUIState implements SettingsUIState {
|
||||
const factory _SettingsUIState(
|
||||
factory _SettingsUIState(
|
||||
{final dynamic isDeviceSupportWinHello,
|
||||
final String autoLoginEmail,
|
||||
final bool isEnableAutoLogin,
|
||||
|
@ -6,7 +6,7 @@ part of 'settings_ui_model.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$settingsUIModelHash() => r'34ac24f658a081350be7d2b3bda810d101b888a1';
|
||||
String _$settingsUIModelHash() => r'de69e289c526d61a6287a9ca7bae848a4d594c20';
|
||||
|
||||
/// See also [SettingsUIModel].
|
||||
@ProviderFor(SettingsUIModel)
|
||||
|
@ -59,12 +59,12 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (description.value == null) ...[
|
||||
const Center(
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
ProgressRing(),
|
||||
SizedBox(height: 16),
|
||||
Text("正在获取新版本详情...")
|
||||
const ProgressRing(),
|
||||
const SizedBox(height: 16),
|
||||
Text(S.current.app_upgrade_info_getting_new_version_details)
|
||||
],
|
||||
),
|
||||
)
|
||||
@ -85,7 +85,7 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
color: Colors.white.withOpacity(.1),
|
||||
borderRadius: BorderRadius.circular(7)),
|
||||
child: Text(
|
||||
"提示:当前正在使用分流服务器进行更新,可能会出现下载速度下降,但有助于我们进行成本控制,若下载异常请点击这里跳转手动安装。",
|
||||
S.current.app_upgrade_info_update_server_tip,
|
||||
style: TextStyle(
|
||||
fontSize: 14, color: Colors.white.withOpacity(.7)),
|
||||
),
|
||||
@ -97,7 +97,7 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
Row(
|
||||
children: [
|
||||
Text(progress.value == 100
|
||||
? "正在安装: "
|
||||
? S.current.app_upgrade_info_installing
|
||||
: "正在下载: ${progress.value.toStringAsFixed(2)}% "),
|
||||
Expanded(
|
||||
child: ProgressBar(
|
||||
@ -122,18 +122,18 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
description,
|
||||
isUsingDiversion,
|
||||
progress),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4, bottom: 4, left: 8, right: 8),
|
||||
child: Text("立即更新"),
|
||||
child: Text(S.current.app_upgrade_action_update_now),
|
||||
)),
|
||||
if (ConstConf.appVersionCode >= (minVersionCode ?? 0))
|
||||
Button(
|
||||
onPressed: () => _doCancel(context),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.only(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 4, bottom: 4, left: 8, right: 8),
|
||||
child: Text("下次吧"),
|
||||
child: Text(S.current.app_upgrade_action_next_time),
|
||||
)),
|
||||
],
|
||||
),
|
||||
@ -240,7 +240,7 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
isUpgrading.value = false;
|
||||
progress.value = 0;
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "下载失败,请尝试手动安装!");
|
||||
showToast(context, S.current.app_upgrade_info_download_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -255,9 +255,9 @@ class UpgradeDialogUI extends HookConsumerWidget {
|
||||
isUpgrading.value = false;
|
||||
progress.value = 0;
|
||||
if (!context.mounted) return;
|
||||
showToast(context, "运行失败,请尝试手动安装!");
|
||||
showToast(context, S.current.app_upgrade_info_run_failed);
|
||||
Process.run(SystemHelper.powershellPath,
|
||||
["explorer.exe", "/select,\"$fileName\""]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user