mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 21:28:51 +00:00
Code clean
This commit is contained in:
parent
8343a1002f
commit
7901a59aa4
4 changed files with 6 additions and 143 deletions
|
@ -61,7 +61,7 @@
|
|||
{
|
||||
if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0)
|
||||
{
|
||||
updateHandle.UpdateGeoFileAll(config, (bool success, string msg) =>
|
||||
await updateHandle.UpdateGeoFileAll(config, (bool success, string msg) =>
|
||||
{
|
||||
update(false, msg);
|
||||
});
|
||||
|
|
|
@ -71,13 +71,6 @@ namespace ServiceLib.ViewModels
|
|||
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { get; }
|
||||
|
||||
//CheckUpdate
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateNCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateXrayCoreCmd { 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]
|
||||
|
@ -295,28 +288,6 @@ namespace ServiceLib.ViewModels
|
|||
Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}");
|
||||
});
|
||||
|
||||
//CheckUpdate
|
||||
CheckUpdateNCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateN();
|
||||
});
|
||||
CheckUpdateXrayCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(ECoreType.Xray, null);
|
||||
});
|
||||
CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(ECoreType.mihomo, false);
|
||||
});
|
||||
CheckUpdateSingBoxCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(ECoreType.sing_box, null);
|
||||
});
|
||||
CheckUpdateGeoCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateGeo();
|
||||
});
|
||||
|
||||
ReloadCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
Reload();
|
||||
|
@ -718,99 +689,6 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
#endregion Setting
|
||||
|
||||
#region CheckUpdate
|
||||
|
||||
private void CheckUpdateN()
|
||||
{
|
||||
//Check for standalone windows .Net version
|
||||
if (Utils.IsWindows()
|
||||
&& File.Exists(Path.Combine(Utils.StartupPath(), "wpfgfx_cor3.dll"))
|
||||
&& File.Exists(Path.Combine(Utils.StartupPath(), "D3DCompiler_47_cor3.dll"))
|
||||
)
|
||||
{
|
||||
_noticeHandler?.SendMessageAndEnqueue(ResUI.UpdateStandalonePackageTip);
|
||||
return;
|
||||
}
|
||||
|
||||
void _updateUI(bool success, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessage(msg);
|
||||
if (success)
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileName = msg;
|
||||
Process process = new()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "v2rayUpgrade",
|
||||
Arguments = fileName.AppendQuotes(),
|
||||
WorkingDirectory = Utils.StartupPath()
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
if (process.Id > 0)
|
||||
{
|
||||
MyAppExitAsync(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_noticeHandler?.SendMessage(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
(new UpdateHandler()).CheckUpdateGuiN(_config, _updateUI, _config.guiItem.checkPreReleaseUpdate);
|
||||
}
|
||||
|
||||
private void CheckUpdateCore(ECoreType type, bool? preRelease)
|
||||
{
|
||||
void _updateUI(bool success, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessage(msg);
|
||||
if (success)
|
||||
{
|
||||
CloseCore();
|
||||
|
||||
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(msg));
|
||||
string toPath = Utils.GetBinPath("", type.ToString());
|
||||
|
||||
if (fileName.Contains(".tar.gz"))
|
||||
{
|
||||
//It's too complicated to unzip. TODO
|
||||
}
|
||||
else if (fileName.Contains(".gz"))
|
||||
{
|
||||
FileManager.UncompressedFile(fileName, toPath, type.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : "");
|
||||
}
|
||||
|
||||
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfullyMore);
|
||||
|
||||
Reload();
|
||||
|
||||
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfully);
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
(new UpdateHandler()).CheckUpdateCore(type, _config, _updateUI, preRelease ?? _config.guiItem.checkPreReleaseUpdate);
|
||||
}
|
||||
|
||||
private void CheckUpdateGeo()
|
||||
{
|
||||
(new UpdateHandler()).UpdateGeoFileAll(_config, UpdateTaskHandler);
|
||||
}
|
||||
|
||||
#endregion CheckUpdate
|
||||
|
||||
#region core job
|
||||
|
||||
public void Reload()
|
||||
|
|
|
@ -22,32 +22,25 @@
|
|||
Orientation="Horizontal">
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsEnableCheckPreReleaseUpdate}" />
|
||||
<ToggleButton
|
||||
x:Name="togEnableCheckPreReleaseUpdate"
|
||||
Grid.Row="9"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<Button
|
||||
x:Name="btnCheckUpdate"
|
||||
Grid.Row="2"
|
||||
Width="100"
|
||||
Margin="8"
|
||||
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
|
||||
Content="{x:Static resx:ResUI.menuCheckUpdate}"
|
||||
IsCancel="True"
|
||||
IsDefault="True"
|
||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Width="100"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
|
|
|
@ -71,14 +71,6 @@ namespace v2rayN.Views
|
|||
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.ImportOldGuiConfigCmd, v => v.menuImportOldGuiConfig).DisposeWith(disposables);
|
||||
|
||||
//check update
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).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);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||
|
|
Loading…
Reference in a new issue