refine code
This commit is contained in:
@@ -441,7 +441,7 @@ namespace v2rayN.Forms
|
||||
await v2rayHandler.LoadV2ray(config);
|
||||
Global.reloadV2ray = false;
|
||||
ChangePACButtonStatus(config.listenerType);
|
||||
//ConfigHandler.SaveConfig(ref config, false); // ChangePACButtonStatus does it.
|
||||
//ConfigHandler.SaveConfigToFile(ref config, false); // ChangePACButtonStatus does it.
|
||||
statistics?.SaveToFile();
|
||||
|
||||
this.Invoke((MethodInvoker)(delegate
|
||||
@@ -459,7 +459,7 @@ namespace v2rayN.Forms
|
||||
{
|
||||
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(() => v2rayHandler.V2rayStop()),
|
||||
Task.Run(() => PACServerHandle.Stop()),
|
||||
@@ -1255,7 +1255,7 @@ namespace v2rayN.Forms
|
||||
}
|
||||
|
||||
Global.reloadV2ray = false;
|
||||
ConfigHandler.SaveConfig(ref config);
|
||||
ConfigHandler.SaveConfigToFile(ref config);
|
||||
|
||||
this.Invoke((MethodInvoker)(delegate
|
||||
{
|
||||
@@ -1689,13 +1689,13 @@ namespace v2rayN.Forms
|
||||
{
|
||||
ColumnHeader c = lvServers.Columns[e.ColumnIndex];
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@@ -1705,7 +1705,7 @@ namespace v2rayN.Forms
|
||||
orderby col.DisplayIndex
|
||||
select col.Name).ToList();
|
||||
config.uiItem.mainLvColLayout = names;
|
||||
_ = Task.Run(() => ConfigHandler.SaveConfig(ref config));
|
||||
_ = Task.Run(() => ConfigHandler.SaveConfigToFile(ref config));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ namespace v2rayN.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref config) == 0)
|
||||
if (ConfigHandler.SaveConfigToFile(ref config) == 0)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ namespace v2rayN.Handler
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ namespace v2rayN.Handler
|
||||
|
||||
config.vmess.Insert(index + 1, vmessItem); // 插入到下一项
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -328,26 +328,20 @@ namespace v2rayN.Handler
|
||||
config.index = index;
|
||||
Global.reloadV2ray = true;
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存参数
|
||||
/// 保存设置文件
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveConfig(ref Config config)
|
||||
public static int SaveConfigToFile(ref Config config)
|
||||
{
|
||||
return ToJsonFile(config);
|
||||
return Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储文件
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
private static int ToJsonFile(Config config)
|
||||
public static int SaveConfigToFile(Config config)
|
||||
{
|
||||
return Utils.ToJsonFile(config, Utils.GetPath(configRes));
|
||||
}
|
||||
@@ -533,7 +527,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
Global.reloadV2ray = true;
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -572,7 +566,7 @@ namespace v2rayN.Handler
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -593,7 +587,7 @@ namespace v2rayN.Handler
|
||||
Global.reloadV2ray = true;
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -634,7 +628,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -673,7 +667,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -854,7 +848,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -878,7 +872,7 @@ namespace v2rayN.Handler
|
||||
}
|
||||
}
|
||||
|
||||
ToJsonFile(config);
|
||||
SaveConfigToFile(config);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user