From d5f1cc99ac4e9cbd467d4cc53e399dbaa4305d92 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:37:46 +0800 Subject: [PATCH] Refactor V2rayUpgrade --- .../ViewModels/CheckUpdateViewModel.cs | 16 +--------------- .../ViewModels/MainWindowViewModel.cs | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index da18f0ce..813c3b9b 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -234,21 +234,7 @@ namespace ServiceLib.ViewModels { return; } - - Process process = new() - { - StartInfo = new ProcessStartInfo - { - FileName = "v2rayUpgrade", - Arguments = fileName.AppendQuotes(), - WorkingDirectory = Utils.StartupPath() - } - }; - process.Start(); - if (process.Id > 0) - { - Locator.Current.GetService()?.MyAppExitAsync(false); - } + Locator.Current.GetService()?.V2rayUpgrade(fileName); } catch (Exception ex) { diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index f5a110ad..c11f6035 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -428,6 +428,24 @@ namespace ServiceLib.ViewModels } } + public async Task V2rayUpgrade(string fileName) + { + Process process = new() + { + StartInfo = new ProcessStartInfo + { + FileName = "v2rayUpgrade", + Arguments = fileName.AppendQuotes(), + WorkingDirectory = Utils.StartupPath() + } + }; + process.Start(); + if (process.Id > 0) + { + await MyAppExitAsync(false); + } + } + #endregion Actions #region Servers && Groups