Skip to content

Commit

Permalink
Check for updates mihomo
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jun 24, 2024
1 parent 8ee5304 commit c9a278b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 51 deletions.
1 change: 0 additions & 1 deletion v2rayN/v2rayN/Handler/CoreHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.IO;
using System.Reactive.Linq;
using System.Text;
using v2rayN.Enums;
using v2rayN.Handler.CoreConfig;
Expand Down
4 changes: 4 additions & 0 deletions v2rayN/v2rayN/Handler/LazyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
38 changes: 9 additions & 29 deletions v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,10 @@ public class MainWindowViewModel : ReactiveObject

//CheckUpdate
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }

//public ReactiveCommand<Unit, Unit> CheckUpdateV2flyCoreCmd { get; }

//public ReactiveCommand<Unit, Unit> CheckUpdateSagerNetCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { get; }

//public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
//public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
public ReactiveCommand<Unit, Unit> CheckUpdateSingBoxCoreCmd { get; }

public ReactiveCommand<Unit, Unit> CheckUpdateGeoCmd { get; }

public ReactiveCommand<Unit, Unit> ReloadCmd { get; }

[Reactive]
Expand Down Expand Up @@ -520,29 +512,17 @@ public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, Action<EV
{
CheckUpdateN();
});
//CheckUpdateV2flyCoreCmd = ReactiveCommand.Create(() =>
//{
// 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(() =>
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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()
Expand Down
20 changes: 3 additions & 17 deletions v2rayN/v2rayN/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
</Window.Resources>

<materialDesign:DialogHost
Identifier="RootDialog"
materialDesign:TransitionAssist.DisableTransitions="True"
Identifier="RootDialog"
SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}"
Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
<Grid>
Expand Down Expand Up @@ -231,28 +231,14 @@
x:Name="menuCheckUpdateN"
Height="{StaticResource MenuItemHeight}"
Header="V2rayN" />
<!--<MenuItem
x:Name="menuCheckUpdateV2flyCore"
Height="{StaticResource MenuItemHeight}"
Header="V2fly v5 Core" />
<MenuItem
x:Name="menuCheckUpdateSagerNetCore"
Height="{StaticResource MenuItemHeight}"
Header="SagerNet Core" />-->
<MenuItem
x:Name="menuCheckUpdateXrayCore"
Height="{StaticResource MenuItemHeight}"
Header="Xray Core" />
<!--<Separator Margin="-40,5" />
<MenuItem
x:Name="menuCheckUpdateClashCore"
Height="{StaticResource MenuItemHeight}"
Header="Clash Core" />
<MenuItem
x:Name="menuCheckUpdateClashMetaCore"
x:Name="menuCheckUpdateMihomoCore"
Height="{StaticResource MenuItemHeight}"
Header="Clash.Meta Core" />
<Separator Margin="-40,5" />-->
Header="Mihomo Core" />
<MenuItem
x:Name="menuCheckUpdateSingBoxCore"
Height="{StaticResource MenuItemHeight}"
Expand Down
5 changes: 1 addition & 4 deletions v2rayN/v2rayN/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,8 @@ public MainWindow()

//check update
this.BindCommand(ViewModel, vm => 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);

Expand Down

0 comments on commit c9a278b

Please sign in to comment.