From c9a278b4a20f76c0737522422f5b028f3be54ac2 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:41:53 +0800 Subject: [PATCH] Check for updates mihomo --- v2rayN/v2rayN/Handler/CoreHandler.cs | 1 - v2rayN/v2rayN/Handler/LazyConfig.cs | 4 ++ .../v2rayN/ViewModels/MainWindowViewModel.cs | 38 +++++-------------- v2rayN/v2rayN/Views/MainWindow.xaml | 20 ++-------- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 5 +-- 5 files changed, 17 insertions(+), 51 deletions(-) diff --git a/v2rayN/v2rayN/Handler/CoreHandler.cs b/v2rayN/v2rayN/Handler/CoreHandler.cs index c24f674053d..e35234a298c 100644 --- a/v2rayN/v2rayN/Handler/CoreHandler.cs +++ b/v2rayN/v2rayN/Handler/CoreHandler.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.IO; -using System.Reactive.Linq; using System.Text; using v2rayN.Enums; using v2rayN.Handler.CoreConfig; diff --git a/v2rayN/v2rayN/Handler/LazyConfig.cs b/v2rayN/v2rayN/Handler/LazyConfig.cs index d2c58faf130..f7e366ea065 100644 --- a/v2rayN/v2rayN/Handler/LazyConfig.cs +++ b/v2rayN/v2rayN/Handler/LazyConfig.cs @@ -336,7 +336,11 @@ private void InitCoreInfo() arguments = "-f config.json", coreUrl = Global.MihomoCoreUrl, coreReleaseApiUrl = Global.MihomoCoreUrl.Replace(Global.GithubUrl, Global.GithubApiUrl), + coreDownloadUrl32 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-386-{0}.zip", + coreDownloadUrl64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-amd64-compatible-{0}.zip", + coreDownloadUrlArm64 = Global.ClashMetaCoreUrl + "/download/{0}/mihomo-windows-arm64-{0}.zip", match = "Mihomo", + versionArg = "-v", redirectInfo = true, }); diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index 0bdee0a4758..f7cd4585d83 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -150,18 +150,10 @@ public class MainWindowViewModel : ReactiveObject //CheckUpdate public ReactiveCommand CheckUpdateNCmd { get; } - - //public ReactiveCommand CheckUpdateV2flyCoreCmd { get; } - - //public ReactiveCommand CheckUpdateSagerNetCoreCmd { get; } public ReactiveCommand CheckUpdateXrayCoreCmd { get; } - - //public ReactiveCommand CheckUpdateClashCoreCmd { get; } - //public ReactiveCommand CheckUpdateClashMetaCoreCmd { get; } + public ReactiveCommand CheckUpdateClashMetaCoreCmd { get; } public ReactiveCommand CheckUpdateSingBoxCoreCmd { get; } - public ReactiveCommand CheckUpdateGeoCmd { get; } - public ReactiveCommand ReloadCmd { get; } [Reactive] @@ -520,29 +512,17 @@ public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, Action - //{ - // CheckUpdateCore(ECoreType.v2fly_v5); - //}); - //CheckUpdateSagerNetCoreCmd = ReactiveCommand.Create(() => - //{ - // CheckUpdateCore(ECoreType.SagerNet); - //}); CheckUpdateXrayCoreCmd = ReactiveCommand.Create(() => { - CheckUpdateCore(ECoreType.Xray); + CheckUpdateCore(ECoreType.Xray, null); + }); + CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() => + { + CheckUpdateCore(ECoreType.mihomo, false); }); - //CheckUpdateClashCoreCmd = ReactiveCommand.Create(() => - //{ - // CheckUpdateCore(ECoreType.clash); - //}); - //CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() => - //{ - // CheckUpdateCore(ECoreType.clash_meta); - //}); CheckUpdateSingBoxCoreCmd = ReactiveCommand.Create(() => { - CheckUpdateCore(ECoreType.sing_box); + CheckUpdateCore(ECoreType.sing_box, null); }); CheckUpdateGeoCmd = ReactiveCommand.Create(() => { @@ -1473,7 +1453,7 @@ void _updateUI(bool success, string msg) (new UpdateHandle()).CheckUpdateGuiN(_config, _updateUI, _config.guiItem.checkPreReleaseUpdate); } - private void CheckUpdateCore(ECoreType type) + private void CheckUpdateCore(ECoreType type, bool? preRelease) { void _updateUI(bool success, string msg) { @@ -1499,7 +1479,7 @@ void _updateUI(bool success, string msg) } } } - (new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.guiItem.checkPreReleaseUpdate); + (new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, preRelease ?? _config.guiItem.checkPreReleaseUpdate); } private void CheckUpdateGeo() diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index 2dcf97880bd..f889cc53ba5 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -37,8 +37,8 @@ @@ -231,28 +231,14 @@ x:Name="menuCheckUpdateN" Height="{StaticResource MenuItemHeight}" Header="V2rayN" /> - - + Header="Mihomo Core" /> vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables); - //this.BindCommand(ViewModel, vm => vm.CheckUpdateV2flyCoreCmd, v => v.menuCheckUpdateV2flyCore).DisposeWith(disposables); - //this.BindCommand(ViewModel, vm => vm.CheckUpdateSagerNetCoreCmd, v => v.menuCheckUpdateSagerNetCore).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables); - //this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.menuCheckUpdateClashCore).DisposeWith(disposables); - //this.BindCommand(ViewModel, vm => vm.CheckUpdateClashMetaCoreCmd, v => v.menuCheckUpdateClashMetaCore).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.CheckUpdateClashMetaCoreCmd, v => v.menuCheckUpdateMihomoCore).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.CheckUpdateSingBoxCoreCmd, v => v.menuCheckUpdateSingBoxCore).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoCmd, v => v.menuCheckUpdateGeo).DisposeWith(disposables);