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); ShowMsg(true, msg);
if (_process != null && !blChanged) if (_process != null && !_process.HasExited && !blChanged)
{ {
MainFormHandler.Instance.ClashConfigReload(fileName); MainFormHandler.Instance.ClashConfigReload(fileName);
} }

View File

@@ -335,11 +335,17 @@ namespace clashN.Handler
public async void ClashSetActiveProxy(string name, string nameNode) public async void ClashSetActiveProxy(string name, string nameNode)
{ {
var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/proxies/{name}"; try
Dictionary<string, string> headers = new Dictionary<string, string>(); {
headers.Add("name", nameNode); var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/proxies/{name}";
await HttpClientHelper.GetInstance().PutAsync(url, headers); 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) public void ClashConfigUpdate(Dictionary<string, string> headers)
@@ -358,13 +364,19 @@ namespace clashN.Handler
}); });
} }
public async void ClashConfigReload( string filePath) public async void ClashConfigReload(string filePath)
{ {
var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/configs"; try
Dictionary<string, string> headers = new Dictionary<string, string>(); {
headers.Add("path", filePath); var url = $"{Global.httpProtocol}{Global.Loopback}:{LazyConfig.Instance.GetConfig().APIPort}/configs";
await HttpClientHelper.GetInstance().PutAsync(url, headers); 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);
}
} }
} }