remove export to server config

pull/3756/head
2dust 2023-04-23 15:06:51 +08:00
parent 4283404f35
commit 7b9c64c5a5
4 changed files with 1 additions and 141 deletions

View File

@ -156,125 +156,6 @@ namespace v2rayN.Handler
}
}
public void Export2ServerConfig(ProfileItem item, Config config)
{
if (item == null)
{
return;
}
if (item.configType is not EConfigType.VMess and not EConfigType.VLESS)
{
UI.Show(ResUI.NonVmessService);
return;
}
SaveFileDialog fileDialog = new()
{
Filter = "Config|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{
return;
}
string fileName = fileDialog.FileName;
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
//Config configCopy = Utils.DeepCopy(config);
//configCopy.index = index;
if (CoreConfigHandler.Export2ServerConfig(item, fileName, out string msg) != 0)
{
UI.Show(msg);
}
else
{
UI.ShowWarning(string.Format(ResUI.SaveServerConfigurationIn, fileName));
}
}
public void BackupGuiNConfig(Config config, bool auto = false)
{
string fileName = $"guiNConfig_{DateTime.Now:yyyy_MM_dd_HH_mm_ss_fff}.json";
if (auto)
{
fileName = Utils.GetBackupPath(fileName);
}
else
{
SaveFileDialog fileDialog = new()
{
FileName = fileName,
Filter = "guiNConfig|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{
return;
}
fileName = fileDialog.FileName;
}
if (Utils.IsNullOrEmpty(fileName))
{
return;
}
var ret = Utils.ToJsonFile(config, fileName);
if (!auto)
{
if (ret == 0)
{
UI.Show(ResUI.OperationSuccess);
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
}
}
}
public bool RestoreGuiNConfig(ref Config config)
{
var fileContent = string.Empty;
OpenFileDialog fileDialog = new();
fileDialog.InitialDirectory = Utils.GetBackupPath("");
fileDialog.Filter = "guiNConfig|*.json|All|*.*";
fileDialog.FilterIndex = 2;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() == true)
{
fileContent = Utils.LoadResource(fileDialog.FileName);
}
else
{
return false;
}
if (Utils.IsNullOrEmpty(fileContent))
{
UI.ShowWarning(ResUI.OperationFailed);
return false;
}
var resConfig = Utils.FromJson<Config>(fileContent);
if (resConfig == null)
{
UI.ShowWarning(ResUI.OperationFailed);
return false;
}
//backup first
BackupGuiNConfig(config, true);
config = resConfig;
LazyConfig.Instance.SetConfig(config);
return true;
}
public void UpdateTask(Config config, Action<bool, string> update)
{
Task.Run(() => UpdateTaskRunSubscription(config, update));

View File

@ -121,7 +121,6 @@ namespace v2rayN.ViewModels
//servers export
public ReactiveCommand<Unit, Unit> Export2ClientConfigCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ServerConfigCmd { get; }
public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; }
public ReactiveCommand<Unit, Unit> Export2SubContentCmd { get; }
@ -418,11 +417,7 @@ namespace v2rayN.ViewModels
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
{
Export2ClientConfig();
}, canEditRemove);
Export2ServerConfigCmd = ReactiveCommand.Create(() =>
{
Export2ServerConfig();
}, canEditRemove);
}, canEditRemove);
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
{
Export2ShareUrl();
@ -1247,17 +1242,6 @@ namespace v2rayN.ViewModels
MainFormHandler.Instance.Export2ClientConfig(item, _config);
}
private void Export2ServerConfig()
{
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
if (item is null)
{
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
return;
}
MainFormHandler.Instance.Export2ServerConfig(item, _config);
}
public void Export2ShareUrl()
{
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)

View File

@ -608,10 +608,6 @@
x:Name="menuExport2ClientConfig"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ClientConfig}" />
<MenuItem
x:Name="menuExport2ServerConfig"
Height="{StaticResource MenuItemHeight}"
Header="{x:Static resx:ResUI.menuExport2ServerConfig}" />
<MenuItem
x:Name="menuExport2ShareUrl"
Height="{StaticResource MenuItemHeight}"

View File

@ -103,7 +103,6 @@ namespace v2rayN.Views
//servers export
this.BindCommand(ViewModel, vm => vm.Export2ClientConfigCmd, v => v.menuExport2ClientConfig).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ServerConfigCmd, v => v.menuExport2ServerConfig).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2ShareUrlCmd, v => v.menuExport2ShareUrl).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.Export2SubContentCmd, v => v.menuExport2SubContent).DisposeWith(disposables);