From 49e33e3c08c02691627557441a4ac351120a2137 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Tue, 19 Jul 2022 12:39:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=90=8E=E7=9A=84=E9=80=80=E5=87=BA=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E9=94=80=E6=AF=81=E6=89=98=E7=9B=98=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 2239c198d0..6d18b8f9ec 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -884,11 +884,9 @@ namespace MeoAsstGui break; case ActionType.ExitSelf: - if (new ToastNotification().CheckToastSystem()) - { - ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知 - } - Environment.Exit(0); + // Shutdown 会调用 OnExit 但 Exit 不会 + Application.Current.Shutdown(); + // Enviroment.Exit(0); break; case ActionType.ExitEmulator: @@ -903,11 +901,9 @@ namespace MeoAsstGui { AddLog("模拟器关闭失败", "DarkRed"); } - if (new ToastNotification().CheckToastSystem()) - { - ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知 - } - Environment.Exit(0); + // Shutdown 会调用 OnExit 但 Exit 不会 + Application.Current.Shutdown(); + // Enviroment.Exit(0); break; case ActionType.Shutdown: From 6ccba48aeca0a5c6d8863bec022f7f6e559929df Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Tue, 19 Jul 2022 13:47:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=87=BA=E7=8E=B0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=97=B6=E4=B9=9F=E6=89=A7=E8=A1=8C=20Shutdown=20?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E5=BC=BA=E5=88=B6=E5=81=9C=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/Helper/AsstProxy.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index cba2363d61..c1e7c35b9a 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -153,7 +153,7 @@ namespace MeoAsstGui Execute.OnUIThread(() => { _windowManager.ShowMessageBox("出现未知异常", "错误", icon: MessageBoxImage.Error); - Environment.Exit(0); + App.Current.Shutdown(); }); } var mainModel = _container.Get(); @@ -217,7 +217,7 @@ namespace MeoAsstGui case AsstMsg.InitFailed: _windowManager.ShowMessageBox("初始化错误!请检查是否使用了中文路径", "错误", icon: MessageBoxImage.Error); - Environment.Exit(0); + App.Current.Shutdown(); break; case AsstMsg.ConnectionInfo: From dc477e9642d3bab8e49b74e642290bb574f84839 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Tue, 19 Jul 2022 13:47:42 +0800 Subject: [PATCH 3/3] =?UTF-8?q?style:=20=E7=BB=9F=E4=B8=80=20Application?= =?UTF-8?q?=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/Helper/ToastNotification.cs | 2 +- src/MeoAsstGui/Helper/TrayIcon.cs | 2 +- src/MeoAsstGui/ViewModels/RootViewModel.cs | 2 +- src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs | 4 ++-- src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/MeoAsstGui/Helper/ToastNotification.cs b/src/MeoAsstGui/Helper/ToastNotification.cs index f67dc394fd..d3a3f7206f 100644 --- a/src/MeoAsstGui/Helper/ToastNotification.cs +++ b/src/MeoAsstGui/Helper/ToastNotification.cs @@ -553,7 +553,7 @@ namespace MeoAsstGui { var fInfo = new FLASHWINFO(); fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); - fInfo.hwnd = hWnd != default ? hWnd : new WindowInteropHelper(Application.Current.MainWindow).Handle; + fInfo.hwnd = hWnd != default ? hWnd : new WindowInteropHelper(App.Current.MainWindow).Handle; fInfo.dwFlags = (uint)type; fInfo.uCount = count; fInfo.dwTimeout = 0; diff --git a/src/MeoAsstGui/Helper/TrayIcon.cs b/src/MeoAsstGui/Helper/TrayIcon.cs index 6c92d40b91..7b6e6ab49a 100644 --- a/src/MeoAsstGui/Helper/TrayIcon.cs +++ b/src/MeoAsstGui/Helper/TrayIcon.cs @@ -102,7 +102,7 @@ namespace MeoAsstGui private void App_exit(object sender, EventArgs e) { - System.Windows.Application.Current.Shutdown(); + App.Current.Shutdown(); } private void App_show(object sender, EventArgs e) diff --git a/src/MeoAsstGui/ViewModels/RootViewModel.cs b/src/MeoAsstGui/ViewModels/RootViewModel.cs index 17d137013a..56663013e3 100644 --- a/src/MeoAsstGui/ViewModels/RootViewModel.cs +++ b/src/MeoAsstGui/ViewModels/RootViewModel.cs @@ -99,7 +99,7 @@ namespace MeoAsstGui protected override void OnClose() { - System.Windows.Application.Current.Shutdown(); + App.Current.Shutdown(); } } } diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 6d18b8f9ec..c13fb0e907 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -885,7 +885,7 @@ namespace MeoAsstGui case ActionType.ExitSelf: // Shutdown 会调用 OnExit 但 Exit 不会 - Application.Current.Shutdown(); + App.Current.Shutdown(); // Enviroment.Exit(0); break; @@ -902,7 +902,7 @@ namespace MeoAsstGui AddLog("模拟器关闭失败", "DarkRed"); } // Shutdown 会调用 OnExit 但 Exit 不会 - Application.Current.Shutdown(); + App.Current.Shutdown(); // Enviroment.Exit(0); break; diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 6379b96f2d..00861a35ca 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -242,7 +242,7 @@ namespace MeoAsstGui newProcess.StartInfo.FileName = AppDomain.CurrentDomain.FriendlyName; newProcess.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory(); newProcess.Start(); - Application.Current.Shutdown(); + App.Current.Shutdown(); return true; }