mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-20 06:02:23 +00:00
refine code
This commit is contained in:
parent
46c887537e
commit
219f544a43
3 changed files with 22 additions and 28 deletions
|
@ -441,7 +441,7 @@ namespace v2rayN.Forms
|
||||||
await v2rayHandler.LoadV2ray(config);
|
await v2rayHandler.LoadV2ray(config);
|
||||||
Global.reloadV2ray = false;
|
Global.reloadV2ray = false;
|
||||||
ChangePACButtonStatus(config.listenerType);
|
ChangePACButtonStatus(config.listenerType);
|
||||||
//ConfigHandler.SaveConfig(ref config, false); // ChangePACButtonStatus does it.
|
//ConfigHandler.SaveConfigToFile(ref config, false); // ChangePACButtonStatus does it.
|
||||||
statistics?.SaveToFile();
|
statistics?.SaveToFile();
|
||||||
|
|
||||||
this.Invoke((MethodInvoker)(delegate
|
this.Invoke((MethodInvoker)(delegate
|
||||||
|
@ -459,7 +459,7 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
List<Task> tasks = new List<Task>
|
List<Task> tasks = new List<Task>
|
||||||
{
|
{
|
||||||
Task.Run(() => ConfigHandler.SaveConfig(ref config)),
|
Task.Run(() => ConfigHandler.SaveConfigToFile(ref config)),
|
||||||
Task.Run(() => HttpProxyHandle.CloseHttpAgent(config)),
|
Task.Run(() => HttpProxyHandle.CloseHttpAgent(config)),
|
||||||
Task.Run(() => v2rayHandler.V2rayStop()),
|
Task.Run(() => v2rayHandler.V2rayStop()),
|
||||||
Task.Run(() => PACServerHandle.Stop()),
|
Task.Run(() => PACServerHandle.Stop()),
|
||||||
|
@ -1255,7 +1255,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.reloadV2ray = false;
|
Global.reloadV2ray = false;
|
||||||
ConfigHandler.SaveConfig(ref config);
|
ConfigHandler.SaveConfigToFile(ref config);
|
||||||
|
|
||||||
this.Invoke((MethodInvoker)(delegate
|
this.Invoke((MethodInvoker)(delegate
|
||||||
{
|
{
|
||||||
|
@ -1689,13 +1689,13 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
ColumnHeader c = lvServers.Columns[e.ColumnIndex];
|
ColumnHeader c = lvServers.Columns[e.ColumnIndex];
|
||||||
ConfigHandler.AddformMainLvColWidth(ref config, c.Name, c.Width);
|
ConfigHandler.AddformMainLvColWidth(ref config, c.Name, c.Width);
|
||||||
Task.Run(() => ConfigHandler.SaveConfig(ref config));
|
Task.Run(() => ConfigHandler.SaveConfigToFile(ref config));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_ResizeEnd(object sender, EventArgs e)
|
private void MainForm_ResizeEnd(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
config.uiItem.mainSize = new Size(this.Width, this.Height);
|
config.uiItem.mainSize = new Size(this.Width, this.Height);
|
||||||
Task.Run(() => ConfigHandler.SaveConfig(ref config));
|
Task.Run(() => ConfigHandler.SaveConfigToFile(ref config));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void lvServers_ColumnReordered(object sender, ColumnReorderedEventArgs e)
|
private async void lvServers_ColumnReordered(object sender, ColumnReorderedEventArgs e)
|
||||||
|
@ -1705,7 +1705,7 @@ namespace v2rayN.Forms
|
||||||
orderby col.DisplayIndex
|
orderby col.DisplayIndex
|
||||||
select col.Name).ToList();
|
select col.Name).ToList();
|
||||||
config.uiItem.mainLvColLayout = names;
|
config.uiItem.mainLvColLayout = names;
|
||||||
_ = Task.Run(() => ConfigHandler.SaveConfig(ref config));
|
_ = Task.Run(() => ConfigHandler.SaveConfigToFile(ref config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ namespace v2rayN.Forms
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.SaveConfig(ref config) == 0)
|
if (ConfigHandler.SaveConfigToFile(ref config) == 0)
|
||||||
{
|
{
|
||||||
this.DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ namespace v2rayN.Handler
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
config.vmess.Insert(index + 1, vmessItem); // 插入到下一项
|
config.vmess.Insert(index + 1, vmessItem); // 插入到下一项
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -328,26 +328,20 @@ namespace v2rayN.Handler
|
||||||
config.index = index;
|
config.index = index;
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存参数
|
/// 保存设置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config"></param>
|
/// <param name="config"></param>
|
||||||
/// <returns></returns>
|
public static int SaveConfigToFile(ref Config config)
|
||||||
public static int SaveConfig(ref Config config)
|
|
||||||
{
|
{
|
||||||
return ToJsonFile(config);
|
return Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||||
}
|
}
|
||||||
|
public static int SaveConfigToFile(Config config)
|
||||||
/// <summary>
|
|
||||||
/// 存储文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
private static int ToJsonFile(Config config)
|
|
||||||
{
|
{
|
||||||
return Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
return Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||||
}
|
}
|
||||||
|
@ -533,7 +527,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -572,7 +566,7 @@ namespace v2rayN.Handler
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -593,7 +587,7 @@ namespace v2rayN.Handler
|
||||||
Global.reloadV2ray = true;
|
Global.reloadV2ray = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -634,7 +628,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -673,7 +667,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -854,7 +848,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -878,7 +872,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToJsonFile(config);
|
SaveConfigToFile(config);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue