From 980982990357fb5df5422dc5b8977bd983c7bc13 Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Tue, 12 Dec 2023 20:06:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=9B=E5=BB=BA=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=20=E5=BE=AE=E8=BD=AF=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/conf.dart | 2 -- lib/ui/settings/settings_ui_model.dart | 14 +++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/common/conf.dart b/lib/common/conf.dart index be30690..22b4a76 100644 --- a/lib/common/conf.dart +++ b/lib/common/conf.dart @@ -48,8 +48,6 @@ class AppConf { static const gameChannels = ["LIVE", "PTU", "EPTU"]; - static const appShortCutName = "SC汉化盒子${AppConf.isMSE ? "" : "DEV"}.lnk"; - static late final String applicationSupportDir; static AppVersionData? networkVersionData; diff --git a/lib/ui/settings/settings_ui_model.dart b/lib/ui/settings/settings_ui_model.dart index 0de1939..887db97 100644 --- a/lib/ui/settings/settings_ui_model.dart +++ b/lib/ui/settings/settings_ui_model.dart @@ -151,10 +151,16 @@ class SettingUIModel extends BaseUIModel { } Future addShortCut() async { + if (AppConf.isMSE) { + showToast(context!, "因微软版功能限制,请在接下来打开的窗口中 手动将《SC汉化盒子》拖动到桌面,即可创建快捷方式。"); + await Future.delayed(const Duration(seconds: 1)); + Process.run("explorer.exe", ["shell:AppsFolder"]); + return; + } dPrint(Platform.resolvedExecutable); final script = """ \$targetPath = "${Platform.resolvedExecutable}"; - \$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory), "${AppConf.appShortCutName}"); + \$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory), "SC汉化盒子DEV.lnk"); \$shell = New-Object -ComObject WScript.Shell \$shortcut = \$shell.CreateShortcut(\$shortcutPath) if (\$shortcut -eq \$null) { @@ -165,9 +171,7 @@ class SettingUIModel extends BaseUIModel { Write-Host "Shortcut created successfully." } """; - final r = await Process.run(SystemHelper.powershellPath, [script]); - dPrint(r.exitCode); - dPrint(r.stdout); - dPrint(r.stderr); + await Process.run(SystemHelper.powershellPath, [script]); + showToast(context!, "创建完毕,请返回桌面查看"); } }