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)
|
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);
|
update(false, msg);
|
||||||
});
|
});
|
||||||
|
|
|
@ -71,13 +71,6 @@ namespace ServiceLib.ViewModels
|
||||||
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
|
public ReactiveCommand<Unit, Unit> ClearServerStatisticsCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> OpenTheFileLocationCmd { 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; }
|
public ReactiveCommand<Unit, Unit> ReloadCmd { get; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
|
@ -295,28 +288,6 @@ namespace ServiceLib.ViewModels
|
||||||
Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}");
|
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(() =>
|
ReloadCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Reload();
|
Reload();
|
||||||
|
@ -718,99 +689,6 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#endregion Setting
|
#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
|
#region core job
|
||||||
|
|
||||||
public void Reload()
|
public void Reload()
|
||||||
|
|
|
@ -21,33 +21,26 @@
|
||||||
DockPanel.Dock="Bottom"
|
DockPanel.Dock="Bottom"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="9"
|
|
||||||
Grid.Column="0"
|
|
||||||
Margin="{StaticResource SettingItemMargin}"
|
Margin="{StaticResource SettingItemMargin}"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Style="{StaticResource ToolbarTextBlock}"
|
Style="{StaticResource ToolbarTextBlock}"
|
||||||
Text="{x:Static resx:ResUI.TbSettingsEnableCheckPreReleaseUpdate}" />
|
Text="{x:Static resx:ResUI.TbSettingsEnableCheckPreReleaseUpdate}" />
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
x:Name="togEnableCheckPreReleaseUpdate"
|
x:Name="togEnableCheckPreReleaseUpdate"
|
||||||
Grid.Row="9"
|
|
||||||
Grid.Column="1"
|
|
||||||
Margin="{StaticResource SettingItemMargin}"
|
Margin="{StaticResource SettingItemMargin}"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
x:Name="btnCheckUpdate"
|
x:Name="btnCheckUpdate"
|
||||||
Grid.Row="2"
|
|
||||||
Width="100"
|
Width="100"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
|
|
||||||
Content="{x:Static resx:ResUI.menuCheckUpdate}"
|
Content="{x:Static resx:ResUI.menuCheckUpdate}"
|
||||||
IsCancel="True"
|
IsCancel="True"
|
||||||
IsDefault="True"
|
IsDefault="True"
|
||||||
Style="{StaticResource MaterialDesignFlatButton}" />
|
Style="{StaticResource MaterialDesignFlatButton}" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
Grid.Row="2"
|
|
||||||
Width="100"
|
Width="100"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
|
|
|
@ -71,15 +71,7 @@ namespace v2rayN.Views
|
||||||
this.BindCommand(ViewModel, vm => vm.RebootAsAdminCmd, v => v.menuRebootAsAdmin).DisposeWith(disposables);
|
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.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).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.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue