From f618d776d760f4e976342623f77175fc6ea5949c Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 3 Sep 2024 02:20:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=90=AF=E5=8A=A8=E6=97=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=9A=E4=BD=99=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/Bootstrapper.cs | 14 ++++++++++- .../ViewModels/UI/VersionUpdateViewModel.cs | 23 ++----------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs index fc6bdf57da..45b57d1136 100644 --- a/src/MaaWpfGui/Main/Bootstrapper.cs +++ b/src/MaaWpfGui/Main/Bootstrapper.cs @@ -74,11 +74,23 @@ namespace MaaWpfGui.Main */ Directory.SetCurrentDirectory(AppContext.BaseDirectory); - if (Directory.Exists("debug") is false) + if (!Directory.Exists("debug")) { Directory.CreateDirectory("debug"); } + // TODO: Remove after 5.10.0 + string[] filesToDelete = ["MAA_win7.exe", "启动旧版.cmd"]; + string curDir = Directory.GetCurrentDirectory(); + foreach (var file in filesToDelete) + { + string path = Path.Combine(curDir, file); + if (File.Exists(path)) + { + File.Delete(path); + } + } + const string LogFilename = "debug/gui.log"; const string LogBakFilename = "debug/gui.bak.log"; if (File.Exists(LogFilename) && new FileInfo(LogFilename).Length > 4 * 1024 * 1024) diff --git a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs index e4d975ba3d..34c244b149 100644 --- a/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/VersionUpdateViewModel.cs @@ -222,26 +222,6 @@ namespace MaaWpfGui.ViewModels.UI return false; } - // 如果是 Framework48,把 MAA.exe 复制一份,重命名为 MAA_win7.exe - if (RuntimeInformation.FrameworkDescription.Contains("Framework")) - { - File.Copy(System.Windows.Forms.Application.ExecutablePath, Path.Combine(curDir, "MAA_win7.exe"), true); - const string CmdFileContent = "@echo off\r\nif exist MAA.exe (\r\n ren MAA.exe MAA_v5.exe\r\n)\r\nstart \"\" .\\MAA_win7.exe"; - File.WriteAllText("启动旧版.cmd", CmdFileContent); - } - else - { - if (File.Exists("MAA_win7.exe")) - { - File.Delete("MAA_win7.exe"); - } - - if (File.Exists("启动旧版.cmd")) - { - File.Delete("启动旧版.cmd"); - } - } - string removeListFile = Path.Combine(extractDir, "removelist.txt"); if (File.Exists(removeListFile)) { @@ -538,7 +518,8 @@ namespace MaaWpfGui.ViewModels.UI { Process.Start(new ProcessStartInfo(UpdateUrl) { UseShellExecute = true }); } - }); + } + ); _ = Execute.OnUIThreadAsync(() => { using var toast = new ToastNotification((otaFound ? LocalizationHelper.GetString("NewVersionFoundTitle") : LocalizationHelper.GetString("NewVersionFoundButNoPackageTitle")) + " : " + UpdateTag);