From 4a7bafd01121698886319f5fa89d2b40f6c12930 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 5 Jan 2025 10:22:18 +0800 Subject: [PATCH] Fix Linux restore backup function Fixed the issue that the guiNConfig.json file cannot be restored in the backup and restore function --- .../ServiceLib/ViewModels/BackupAndRestoreViewModel.cs | 2 +- v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs | 6 +++--- v2rayN/v2rayN.Desktop/App.axaml.cs | 10 +++------- v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs | 4 ++++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index cbf6beb3..b359f5c1 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -154,7 +154,7 @@ namespace ServiceLib.ViewModels ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath()); } } - service?.Shutdown(); + service?.Shutdown(true); } else { diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 929ea1eb..3d569d4e 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -303,7 +303,7 @@ namespace ServiceLib.ViewModels { if (!blWindowsShutDown) { - _updateView?.Invoke(EViewAction.Shutdown, null); + _updateView?.Invoke(EViewAction.Shutdown, false); } } } @@ -329,9 +329,9 @@ namespace ServiceLib.ViewModels _updateView?.Invoke(EViewAction.ShowHideWindow, blShow); } - public void Shutdown() + public void Shutdown(bool byUser) { - _updateView?.Invoke(EViewAction.Shutdown, null); + _updateView?.Invoke(EViewAction.Shutdown, byUser); } #endregion Actions diff --git a/v2rayN/v2rayN.Desktop/App.axaml.cs b/v2rayN/v2rayN.Desktop/App.axaml.cs index 82f52a9a..06b59d53 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml.cs +++ b/v2rayN/v2rayN.Desktop/App.axaml.cs @@ -71,12 +71,8 @@ public partial class App : Application private async void MenuExit_Click(object? sender, EventArgs e) { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - var service = Locator.Current.GetService(); - if (service != null) await service.MyAppExitAsync(false); - - desktop.Shutdown(); - } + var service = Locator.Current.GetService(); + if (service != null) await service.MyAppExitAsync(true); + service?.Shutdown(true); } } \ No newline at end of file diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index e73fda5d..9071145c 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -223,6 +223,10 @@ namespace v2rayN.Desktop.Views break; case EViewAction.Shutdown: + if (obj != null && _blCloseByUser == false) + { + _blCloseByUser = (bool)obj; + } StorageUI(); if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {