Code optimization, function asynchrony

This commit is contained in:
2dust
2024-10-21 09:45:33 +08:00
parent 394b657fc9
commit a866017b4c
21 changed files with 518 additions and 514 deletions
@@ -26,13 +26,13 @@ namespace ServiceLib.ViewModels
_updateView = updateView;
var item = AppHandler.Instance.GetDNSItem(ECoreType.Xray);
var item = AppHandler.Instance.GetDNSItem(ECoreType.Xray).Result;
useSystemHosts = item.useSystemHosts;
domainStrategy4Freedom = item?.domainStrategy4Freedom ?? string.Empty;
domainDNSAddress = item?.domainDNSAddress ?? string.Empty;
normalDNS = item?.normalDNS ?? string.Empty;
var item2 = AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
var item2 = AppHandler.Instance.GetDNSItem(ECoreType.sing_box).Result;
domainStrategy4Freedom2 = item2?.domainStrategy4Freedom ?? string.Empty;
domainDNSAddress2 = item2?.domainDNSAddress ?? string.Empty;
normalDNS2 = item2?.normalDNS ?? string.Empty;
@@ -91,19 +91,19 @@ namespace ServiceLib.ViewModels
}
}
var item = AppHandler.Instance.GetDNSItem(ECoreType.Xray);
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
item.domainStrategy4Freedom = domainStrategy4Freedom;
item.domainDNSAddress = domainDNSAddress;
item.useSystemHosts = useSystemHosts;
item.normalDNS = normalDNS;
ConfigHandler.SaveDNSItems(_config, item);
await ConfigHandler.SaveDNSItems(_config, item);
var item2 = AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
item2.domainStrategy4Freedom = domainStrategy4Freedom2;
item2.domainDNSAddress = domainDNSAddress2;
item2.normalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(normalDNS2));
item2.tunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ;
ConfigHandler.SaveDNSItems(_config, item2);
await ConfigHandler.SaveDNSItems(_config, item2);
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);