diff --git a/lib/common/helper/system_helper.dart b/lib/common/helper/system_helper.dart index ff13e5e..300606b 100644 --- a/lib/common/helper/system_helper.dart +++ b/lib/common/helper/system_helper.dart @@ -130,14 +130,21 @@ class SystemHelper { // check running and kill await killRSILauncher(); // launch - final r = await Process.run(powershellPath, [ - 'Start-Process', - "'$path'", - '-Verb RunAs', - ]); + final processorAffinity = await SystemHelper.getCpuAffinity(); + if (processorAffinity == null) { + Process.run(path, []); + } else { + Process.run("cmd.exe", [ + '/C', + 'Start', + '""', + '/High', + '/Affinity', + processorAffinity, + path, + ]); + } dPrint(path); - dPrint(r.stdout); - dPrint(r.stderr); } static Future getSystemMemorySizeGB() async { @@ -218,7 +225,11 @@ foreach ($adapter in $adapterMemory) { return int.tryParse(cpuNumberResult.stdout.toString().trim()) ?? 0; } - static Future getCpuAffinity(int eCoreCount) async { + static Future getCpuAffinity() async { + final confBox = await Hive.openBox("app_conf"); + final eCoreCount = int.tryParse( + confBox.get("gameLaunch_eCore_count", defaultValue: "0")) ?? + 0; final cpuNumber = await getNumberOfLogicalProcessors(); if (cpuNumber == 0 || eCoreCount == 0 || eCoreCount > cpuNumber) { return null; diff --git a/lib/main.dart b/lib/main.dart index 00ac9af..819cb6c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -31,14 +31,19 @@ class AppUI extends BaseUI { restorationScopeId: "Doctor", themeMode: ThemeMode.dark, theme: FluentThemeData( - brightness: Brightness.dark, - fontFamily: "SourceHanSansCN-Regular", - navigationPaneTheme: NavigationPaneThemeData( - backgroundColor: AppConf.colorBackground, - ), - menuColor: AppConf.colorMenu, - micaBackgroundColor: AppConf.colorMica, - ), + brightness: Brightness.dark, + fontFamily: "SourceHanSansCN-Regular", + navigationPaneTheme: NavigationPaneThemeData( + backgroundColor: AppConf.colorBackground, + ), + menuColor: AppConf.colorMenu, + micaBackgroundColor: AppConf.colorMica, + buttonTheme: ButtonThemeData( + defaultButtonStyle: ButtonStyle( + shape: ButtonState.all(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4), + side: BorderSide(color: Colors.white.withOpacity(.01)))), + ))), debugShowCheckedModeBanner: false, home: BaseUIContainer( uiCreate: () => IndexUI(), modelCreate: () => IndexUIModel()), diff --git a/lib/ui/home/home_ui_model.dart b/lib/ui/home/home_ui_model.dart index c36d1db..60e2ebd 100644 --- a/lib/ui/home/home_ui_model.dart +++ b/lib/ui/home/home_ui_model.dart @@ -537,7 +537,7 @@ class HomeUIModel extends BaseUIModel { dPrint('stdout: ${result.stdout}'); dPrint('stderr: ${result.stderr}'); } else { - dPrint("set Affinity === $processorAffinity "); + dPrint("set Affinity === $processorAffinity launchExe === $launchExe"); ProcessResult result = await Process.run("cmd.exe", [ '/C', 'Start', diff --git a/lib/ui/home/login/login_dialog_ui_model.dart b/lib/ui/home/login/login_dialog_ui_model.dart index 960a706..b205c50 100644 --- a/lib/ui/home/login/login_dialog_ui_model.dart +++ b/lib/ui/home/login/login_dialog_ui_model.dart @@ -220,14 +220,9 @@ class LoginDialogModel extends BaseUIModel { await Future.delayed(const Duration(seconds: 1)); await Future.delayed(const Duration(seconds: 3)); - final confBox = await Hive.openBox("app_conf"); - final inputGameLaunchECore = int.tryParse( - confBox.get("gameLaunch_eCore_count", defaultValue: "0")) ?? - 0; final processorAffinity = - await SystemHelper.getCpuAffinity(inputGameLaunchECore); + await SystemHelper.getCpuAffinity(); - // TODO 更新启动方式 homeUIModel.doLaunchGame( '$installPath\\$executable', ["-no_login_dialog", ...launchOptions.toString().split(" ")], diff --git a/lib/ui/settings/settings_ui.dart b/lib/ui/settings/settings_ui.dart index 358d365..f90fbfc 100644 --- a/lib/ui/settings/settings_ui.dart +++ b/lib/ui/settings/settings_ui.dart @@ -17,14 +17,14 @@ class SettingUI extends BaseUI { subTitle: "启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}", onTap: model.onResetAutoLogin), - const SizedBox(height: 12), - makeSettingsItem(const Icon(FontAwesomeIcons.microchip), - "启动游戏时忽略能效核心( 适用于Intel 12th+ 处理器 ) [实验性功能,请随时反馈]", - subTitle: - "已设置的核心数量:${model.inputGameLaunchECore} ( 设置需要忽略的处理器的能效心数量,盒子将在使用启动游戏功能时为您修改游戏所运行的CPU参数,当为 0 时不启用此功能 )", - onTap: model.setGameLaunchECore), - const SizedBox(height: 12), ], + const SizedBox(height: 12), + makeSettingsItem(const Icon(FontAwesomeIcons.microchip), + "启动游戏时忽略能效核心( 适用于Intel 12th+ 处理器 ) [实验性功能,请随时反馈]", + subTitle: + "已设置的核心数量:${model.inputGameLaunchECore} (此功能适用于首页的盒子一键启动 或 工具中的RSI启动器管理员模式,当为 0 时不启用此功能 )", + onTap: model.setGameLaunchECore), + const SizedBox(height: 12), makeSettingsItem( const Icon(FluentIcons.folder_open), "设置启动器文件(RSI Launcher.exe)", subTitle: model.customLauncherPath != null diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart index edc8919..06b75ee 100644 --- a/lib/ui/settings/settings_ui_model.dart +++ b/lib/ui/settings/settings_ui_model.dart @@ -56,7 +56,8 @@ class SettingUIModel extends BaseUIModel { userBox.get("gameLaunch_eCore_count", defaultValue: "0"); final input = await showInputDialogs(context!, title: "请输入要忽略的 CPU 核心数", - content: "tip:您的设备拥有几个能效核心就输入几,非大小核设备请保持0", + content: + "Tip:您的设备拥有几个能效核心就输入几,非大小核设备请保持 0\n\n此功能适用于首页的盒子一键启动 或 工具中的 RSI启动器管理员模式,当为 0 时不启用此功能。", initialValue: defaultInput, inputFormatters: [FilteringTextInputFormatter.digitsOnly]); if (input == null) return; diff --git a/lib/ui/tools/tools_ui_model.dart b/lib/ui/tools/tools_ui_model.dart index e406579..4c6cac3 100644 --- a/lib/ui/tools/tools_ui_model.dart +++ b/lib/ui/tools/tools_ui_model.dart @@ -68,7 +68,7 @@ class ToolsUIModel extends BaseUIModel { _ToolsItemData( "rsilauncher_admin_mode", "RSI Launcher 管理员模式", - "在某些情况下 RSI启动器 无法正确获得管理员权限,您可尝试使用该功能以管理员模式运行启动器。", + "以管理员身份运行RSI启动器,可能会解决一些问题。\n\n若设置了能效核心屏蔽参数,也会在此应用。", const Icon(FluentIcons.admin, size: 28), onTap: _adminRSILauncher, ) diff --git a/pubspec.yaml b/pubspec.yaml index 98af9fc..f6baedd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: sdk: flutter flutter_riverpod: ^2.3.6 window_manager: ^0.3.2 - fluent_ui: ^4.7.4 + fluent_ui: ^4.8.1 flutter_staggered_grid_view: ^0.7.0 flutter_acrylic: ^1.1.0 url_launcher: ^6.1.10