This commit is contained in:
2dust
2022-08-30 16:16:39 +08:00
parent 388352e783
commit ee7d55e324
2 changed files with 24 additions and 12 deletions

View File

@@ -56,7 +56,7 @@ namespace clashN.Handler
{
ShowMsg(true, msg);
if (_process != null && !blChanged)
if (_process != null && !_process.HasExited && !blChanged)
{
MainFormHandler.Instance.ClashConfigReload(fileName);
}

View File

@@ -334,12 +334,18 @@ namespace clashN.Handler
}
public async void ClashSetActiveProxy(string name, string nameNode)
{
try
{
var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/proxies/{name}";
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("name", nameNode);
await HttpClientHelper.GetInstance().PutAsync(url, headers);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
public void ClashConfigUpdate(Dictionary<string, string> headers)
@@ -359,12 +365,18 @@ namespace clashN.Handler
}
public async void ClashConfigReload(string filePath)
{
try
{
var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/configs";
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("path", filePath);
await HttpClientHelper.GetInstance().PutAsync(url, headers);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
}