Rename Manager

This commit is contained in:
2dust
2025-08-17 17:31:55 +08:00
parent 2060ac18fd
commit d5c50ef27c
74 changed files with 383 additions and 383 deletions
@@ -19,7 +19,7 @@ public class AddServer2ViewModel : MyReactiveObject
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -45,25 +45,25 @@ public class AddServer2ViewModel : MyReactiveObject
var remarks = SelectedSource.Remarks;
if (remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
return;
}
if (SelectedSource.Address.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom);
return;
}
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
if (await ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
@@ -74,12 +74,12 @@ public class AddServer2ViewModel : MyReactiveObject
return;
}
var item = await AppHandler.Instance.GetProfileItem(SelectedSource.IndexId);
var item = await AppManager.Instance.GetProfileItem(SelectedSource.IndexId);
item ??= SelectedSource;
item.Address = fileName;
if (await ConfigHandler.AddCustomServer(_config, item, false) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
if (item.IndexId.IsNotEmpty())
{
SelectedSource = JsonUtils.DeepCopy(item);
@@ -88,7 +88,7 @@ public class AddServer2ViewModel : MyReactiveObject
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.FailedImportedCustomServer);
NoticeManager.Instance.Enqueue(ResUI.FailedImportedCustomServer);
}
}
@@ -97,7 +97,7 @@ public class AddServer2ViewModel : MyReactiveObject
var address = SelectedSource.Address;
if (address.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom);
return;
}
@@ -108,7 +108,7 @@ public class AddServer2ViewModel : MyReactiveObject
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration);
NoticeManager.Instance.Enqueue(ResUI.FailedReadConfiguration);
}
await Task.CompletedTask;
}
@@ -16,7 +16,7 @@ public class AddServerViewModel : MyReactiveObject
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -43,32 +43,32 @@ public class AddServerViewModel : MyReactiveObject
{
if (SelectedSource.Remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
return;
}
if (SelectedSource.Address.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress);
NoticeManager.Instance.Enqueue(ResUI.FillServerAddress);
return;
}
var port = SelectedSource.Port.ToString();
if (port.IsNullOrEmpty() || !Utils.IsNumeric(port)
|| SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort)
{
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort);
NoticeManager.Instance.Enqueue(ResUI.FillCorrectServerPort);
return;
}
if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
{
if (SelectedSource.Id.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.FillPassword);
NoticeManager.Instance.Enqueue(ResUI.FillPassword);
return;
}
if (SelectedSource.Security.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectEncryption);
return;
}
}
@@ -76,7 +76,7 @@ public class AddServerViewModel : MyReactiveObject
{
if (SelectedSource.Id.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.FillUUID);
NoticeManager.Instance.Enqueue(ResUI.FillUUID);
return;
}
}
@@ -84,12 +84,12 @@ public class AddServerViewModel : MyReactiveObject
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
}
@@ -22,7 +22,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
public BackupAndRestoreViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -52,14 +52,14 @@ public class BackupAndRestoreViewModel : MyReactiveObject
_config.WebDavItem = SelectedSource;
_ = await ConfigHandler.SaveConfig(_config);
var result = await WebDavHandler.Instance.CheckConnection();
var result = await WebDavManager.Instance.CheckConnection();
if (result)
{
DisplayOperationMsg(ResUI.OperationSuccess);
}
else
{
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
}
}
@@ -70,7 +70,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
var result = await CreateZipFileFromDirectory(fileName);
if (result)
{
var result2 = await WebDavHandler.Instance.PutFile(fileName);
var result2 = await WebDavManager.Instance.PutFile(fileName);
if (result2)
{
DisplayOperationMsg(ResUI.OperationSuccess);
@@ -78,21 +78,21 @@ public class BackupAndRestoreViewModel : MyReactiveObject
}
}
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
}
private async Task RemoteRestore()
{
DisplayOperationMsg();
var fileName = Utils.GetTempPath(Utils.GetGuid());
var result = await WebDavHandler.Instance.GetRawFile(fileName);
var result = await WebDavManager.Instance.GetRawFile(fileName);
if (result)
{
await LocalRestore(fileName);
return;
}
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
}
public async Task<bool> LocalBackup(string fileName)
@@ -105,7 +105,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
}
else
{
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
}
return result;
@@ -158,7 +158,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
}
else
{
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
}
}
@@ -21,7 +21,7 @@ public class CheckUpdateViewModel : MyReactiveObject
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
CheckUpdateCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -26,7 +26,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh;
@@ -58,7 +58,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
private async Task GetClashConnections()
{
var ret = await ClashApiHandler.Instance.GetClashConnectionsAsync();
var ret = await ClashApiManager.Instance.GetClashConnectionsAsync();
if (ret == null)
{
return;
@@ -118,7 +118,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
{
_connectionItems.Clear();
}
await ClashApiHandler.Instance.ClashConnectionClose(id);
await ClashApiManager.Instance.ClashConnectionClose(id);
await GetClashConnections();
}
@@ -43,7 +43,7 @@ public class ClashProxiesViewModel : MyReactiveObject
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -152,13 +152,13 @@ public class ClashProxiesViewModel : MyReactiveObject
{
{ "mode", mode.ToString().ToLower() }
};
await ClashApiHandler.Instance.ClashConfigUpdate(headers);
await ClashApiManager.Instance.ClashConfigUpdate(headers);
}
}
private async Task GetClashProxies(bool refreshUI)
{
var ret = await ClashApiHandler.Instance.GetClashProxiesAsync();
var ret = await ClashApiManager.Instance.GetClashProxiesAsync();
if (ret?.Item1 == null || ret.Item2 == null)
{
return;
@@ -182,7 +182,7 @@ public class ClashProxiesViewModel : MyReactiveObject
var selectedName = SelectedGroup?.Name;
_proxyGroups.Clear();
var proxyGroups = ClashApiHandler.Instance.GetClashProxyGroups();
var proxyGroups = ClashApiManager.Instance.GetClashProxyGroups();
if (proxyGroups != null && proxyGroups.Count > 0)
{
foreach (var it in proxyGroups)
@@ -352,11 +352,11 @@ public class ClashProxiesViewModel : MyReactiveObject
var selectedProxy = TryGetProxy(name);
if (selectedProxy == null || selectedProxy.type != "Selector")
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
return;
}
await ClashApiHandler.Instance.ClashSetActiveProxy(name, nameNode);
await ClashApiManager.Instance.ClashSetActiveProxy(name, nameNode);
selectedProxy.now = nameNode;
var group = _proxyGroups.FirstOrDefault(it => it.Name == SelectedGroup.Name);
@@ -368,12 +368,12 @@ public class ClashProxiesViewModel : MyReactiveObject
SelectedGroup = group2;
}
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
private async Task ProxiesDelayTest(bool blAll = true)
{
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
ClashApiManager.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
{
if (item == null || result.IsNullOrEmpty())
{
@@ -38,7 +38,7 @@ public class DNSSettingViewModel : MyReactiveObject
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync);
@@ -60,7 +60,7 @@ public class DNSSettingViewModel : MyReactiveObject
private async Task Init()
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
var item = _config.SimpleDNSItem;
UseSystemHosts = item.UseSystemHosts;
AddCommonHosts = item.AddCommonHosts;
@@ -76,14 +76,14 @@ public class DNSSettingViewModel : MyReactiveObject
Hosts = item.Hosts;
DirectExpectedIPs = item.DirectExpectedIPs;
var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
RayCustomDNSEnableCompatible = item1.Enabled;
UseSystemHostsCompatible = item1.UseSystemHosts;
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
SBCustomDNSEnableCompatible = item2.Enabled;
DomainStrategy4Freedom2Compatible = item2?.DomainStrategy4Freedom ?? string.Empty;
DomainDNSAddress2Compatible = item2?.DomainDNSAddress ?? string.Empty;
@@ -117,7 +117,7 @@ public class DNSSettingViewModel : MyReactiveObject
{
if (NormalDNSCompatible.Contains('{') || NormalDNSCompatible.Contains('}'))
{
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
@@ -127,7 +127,7 @@ public class DNSSettingViewModel : MyReactiveObject
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
if (obj2 == null)
{
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
@@ -136,12 +136,12 @@ public class DNSSettingViewModel : MyReactiveObject
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
if (obj2 == null)
{
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
item1.Enabled = RayCustomDNSEnableCompatible;
item1.DomainStrategy4Freedom = DomainStrategy4FreedomCompatible;
item1.DomainDNSAddress = DomainDNSAddressCompatible;
@@ -149,7 +149,7 @@ public class DNSSettingViewModel : MyReactiveObject
item1.NormalDNS = NormalDNSCompatible;
await ConfigHandler.SaveDNSItems(_config, item1);
var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
item2.Enabled = SBCustomDNSEnableCompatible;
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
@@ -41,7 +41,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject
public FullConfigTemplateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
{
@@ -53,13 +53,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
private async Task Init()
{
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
EnableFullConfigTemplate4Ray = item?.Enabled ?? false;
FullConfigTemplate4Ray = item?.Config ?? string.Empty;
AddProxyOnly4Ray = item?.AddProxyOnly ?? false;
ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty;
var item2 = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
FullConfigTemplate4Singbox = item2?.Config ?? string.Empty;
FullTunConfigTemplate4Singbox = item2?.TunConfig ?? string.Empty;
@@ -75,13 +75,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
if (!await SaveSingboxConfigAsync())
return;
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_ = _updateView?.Invoke(EViewAction.CloseWindow, null);
}
private async Task<bool> SaveXrayConfigAsync()
{
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
item.Enabled = EnableFullConfigTemplate4Ray;
item.Config = null;
@@ -96,7 +96,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject
private async Task<bool> SaveSingboxConfigAsync()
{
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
item.Enabled = EnableFullConfigTemplate4Singbox;
item.Config = null;
item.TunConfig = null;
@@ -11,7 +11,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject
public GlobalHotkeySettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
_globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys);
@@ -58,7 +58,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
}
@@ -71,7 +71,7 @@ public class MainWindowViewModel : MyReactiveObject
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
#region WhenAnyValue && ReactiveCommand
@@ -178,7 +178,7 @@ public class MainWindowViewModel : MyReactiveObject
{
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
});
RebootAsAdminCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -226,13 +226,13 @@ public class MainWindowViewModel : MyReactiveObject
await ConfigHandler.InitBuiltinRouting(_config);
await ConfigHandler.InitBuiltinDNS(_config);
await ConfigHandler.InitBuiltinFullConfigTemplate(_config);
await ProfileExHandler.Instance.Init();
await CoreHandler.Instance.Init(_config, UpdateHandler);
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
await ProfileExManager.Instance.Init();
await CoreManager.Instance.Init(_config, UpdateHandler);
TaskManager.Instance.RegUpdateTask(_config, UpdateTaskHandler);
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
{
await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler);
await StatisticsManager.Instance.Init(_config, UpdateStatisticsHandler);
}
BlReloadEnabled = true;
@@ -247,16 +247,16 @@ public class MainWindowViewModel : MyReactiveObject
private void UpdateHandler(bool notify, string msg)
{
NoticeHandler.Instance.SendMessage(msg);
NoticeManager.Instance.SendMessage(msg);
if (notify)
{
NoticeHandler.Instance.Enqueue(msg);
NoticeManager.Instance.Enqueue(msg);
}
}
private void UpdateTaskHandler(bool success, string msg)
{
NoticeHandler.Instance.SendMessageEx(msg);
NoticeManager.Instance.SendMessageEx(msg);
if (success)
{
var indexIdOld = _config.IndexId;
@@ -303,10 +303,10 @@ public class MainWindowViewModel : MyReactiveObject
MessageBus.Current.SendMessage("", EMsgCommand.AppExit.ToString());
await ConfigHandler.SaveConfig(_config);
await ProfileExHandler.Instance.SaveTo();
await StatisticsHandler.Instance.SaveTo();
await CoreHandler.Instance.CoreStop();
StatisticsHandler.Instance.Close();
await ProfileExManager.Instance.SaveTo();
await StatisticsManager.Instance.SaveTo();
await CoreManager.Instance.CoreStop();
StatisticsManager.Instance.Close();
Logging.SaveLog("MyAppExitAsync End");
}
@@ -324,7 +324,7 @@ public class MainWindowViewModel : MyReactiveObject
{
if (!Utils.UpgradeAppExists(out var upgradeFileName))
{
NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
NoticeManager.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
Logging.SaveLog("UpgradeApp does not exist");
return;
}
@@ -404,11 +404,11 @@ public class MainWindowViewModel : MyReactiveObject
{
RefreshSubscriptions();
RefreshServers();
NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
NoticeManager.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
@@ -445,7 +445,7 @@ public class MainWindowViewModel : MyReactiveObject
{
if (result.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound);
NoticeManager.Instance.Enqueue(ResUI.NoValidQRcodeFound);
}
else
{
@@ -454,11 +454,11 @@ public class MainWindowViewModel : MyReactiveObject
{
RefreshSubscriptions();
RefreshServers();
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
}
@@ -531,7 +531,7 @@ public class MainWindowViewModel : MyReactiveObject
private async Task ClearServerStatistics()
{
await StatisticsHandler.Instance.ClearAllServerStatistics();
await StatisticsManager.Instance.ClearAllServerStatistics();
RefreshServers();
}
@@ -602,13 +602,13 @@ public class MainWindowViewModel : MyReactiveObject
private async Task LoadCore()
{
var node = await ConfigHandler.GetDefaultServer(_config);
await CoreHandler.Instance.LoadCore(node);
await CoreManager.Instance.LoadCore(node);
}
public async Task CloseCore()
{
await ConfigHandler.SaveConfig(_config);
await CoreHandler.Instance.CoreStop();
await CoreManager.Instance.CoreStop();
}
private async Task AutoHideStartup()
+1 -1
View File
@@ -20,7 +20,7 @@ public class MsgViewModel : MyReactiveObject
public MsgViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
@@ -109,7 +109,7 @@ public class OptionSettingViewModel : MyReactiveObject
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -276,7 +276,7 @@ public class OptionSettingViewModel : MyReactiveObject
if (localPort.ToString().IsNullOrEmpty() || !Utils.IsNumeric(localPort.ToString())
|| localPort <= 0 || localPort >= Global.MaxPort)
{
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
return;
}
var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics
@@ -369,14 +369,14 @@ public class OptionSettingViewModel : MyReactiveObject
if (await ConfigHandler.SaveConfig(_config) == 0)
{
await AutoStartupHandler.UpdateTask(_config);
AppHandler.Instance.Reset();
AppManager.Instance.Reset();
NoticeHandler.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
@@ -100,7 +100,7 @@ public class ProfilesViewModel : MyReactiveObject
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
#region WhenAnyValue && ReactiveCommand
@@ -284,8 +284,8 @@ public class ProfilesViewModel : MyReactiveObject
{
if (result.IndexId.IsNullOrEmpty())
{
NoticeHandler.Instance.SendMessageEx(result.Delay);
NoticeHandler.Instance.Enqueue(result.Delay);
NoticeManager.Instance.SendMessageEx(result.Delay);
NoticeManager.Instance.Enqueue(result.Delay);
return;
}
var item = _profileItems.FirstOrDefault(it => it.IndexId == result.IndexId);
@@ -403,7 +403,7 @@ public class ProfilesViewModel : MyReactiveObject
_subItems.Add(new SubItem { Remarks = ResUI.AllGroupServers });
foreach (var item in await AppHandler.Instance.SubItems())
foreach (var item in await AppManager.Instance.SubItems())
{
_subItems.Add(item);
}
@@ -419,12 +419,12 @@ public class ProfilesViewModel : MyReactiveObject
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
{
var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, filter);
var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, filter);
await ConfigHandler.SetDefaultServer(_config, lstModel);
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? [];
var lstProfileExs = await ProfileExManager.Instance.GetProfileExs();
lstModel = (from t in lstModel
join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b
from t22 in t2b.DefaultIfEmpty()
@@ -474,7 +474,7 @@ public class ProfilesViewModel : MyReactiveObject
{
foreach (var profile in orderProfiles)
{
var item = await AppHandler.Instance.GetProfileItem(profile.IndexId);
var item = await AppManager.Instance.GetProfileItem(profile.IndexId);
if (item is not null)
{
lstSelected.Add(item);
@@ -495,10 +495,10 @@ public class ProfilesViewModel : MyReactiveObject
{
return;
}
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
return;
}
eConfigType = item.ConfigType;
@@ -536,7 +536,7 @@ public class ProfilesViewModel : MyReactiveObject
var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId);
await ConfigHandler.RemoveServers(_config, lstSelected);
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
if (lstSelected.Count == _profileItems.Count)
{
_profileItems.Clear();
@@ -556,7 +556,7 @@ public class ProfilesViewModel : MyReactiveObject
RefreshServers();
Reload();
}
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
}
private async Task CopyServer()
@@ -569,7 +569,7 @@ public class ProfilesViewModel : MyReactiveObject
if (await ConfigHandler.CopyServer(_config, lstSelected) == 0)
{
RefreshServers();
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
}
@@ -592,10 +592,10 @@ public class ProfilesViewModel : MyReactiveObject
{
return;
}
var item = await AppHandler.Instance.GetProfileItem(indexId);
var item = await AppManager.Instance.GetProfileItem(indexId);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
return;
}
@@ -621,10 +621,10 @@ public class ProfilesViewModel : MyReactiveObject
public async Task ShareServerAsync()
{
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
return;
}
var url = FmtHandler.GetShareUri(item);
@@ -647,7 +647,7 @@ public class ProfilesViewModel : MyReactiveObject
var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelected, coreType, multipleLoad);
if (ret.Success != true)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
return;
}
if (ret?.Data?.ToString() == _config.IndexId)
@@ -682,7 +682,7 @@ public class ProfilesViewModel : MyReactiveObject
{
var count = await ConfigHandler.RemoveInvalidServerResult(_config, _config.SubIndexId);
RefreshServers();
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
}
//move server
@@ -700,7 +700,7 @@ public class ProfilesViewModel : MyReactiveObject
}
await ConfigHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id);
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RefreshServers();
SelectedMoveToGroup = null;
@@ -712,7 +712,7 @@ public class ProfilesViewModel : MyReactiveObject
var item = _lstProfile.FirstOrDefault(t => t.IndexId == SelectedProfile.IndexId);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
return;
}
@@ -762,10 +762,10 @@ public class ProfilesViewModel : MyReactiveObject
private async Task Export2ClientConfigAsync(bool blClipboard)
{
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
return;
}
if (blClipboard)
@@ -773,12 +773,12 @@ public class ProfilesViewModel : MyReactiveObject
var result = await CoreConfigHandler.GenerateClientConfig(item, null);
if (result.Success != true)
{
NoticeHandler.Instance.Enqueue(result.Msg);
NoticeManager.Instance.Enqueue(result.Msg);
}
else
{
await _updateView?.Invoke(EViewAction.SetClipboardData, result.Data);
NoticeHandler.Instance.SendMessage(ResUI.OperationSuccess);
NoticeManager.Instance.SendMessage(ResUI.OperationSuccess);
}
}
else
@@ -796,11 +796,11 @@ public class ProfilesViewModel : MyReactiveObject
var result = await CoreConfigHandler.GenerateClientConfig(item, fileName);
if (result.Success != true)
{
NoticeHandler.Instance.Enqueue(result.Msg);
NoticeManager.Instance.Enqueue(result.Msg);
}
else
{
NoticeHandler.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName));
NoticeManager.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName));
}
}
@@ -833,7 +833,7 @@ public class ProfilesViewModel : MyReactiveObject
{
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
}
NoticeHandler.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
NoticeManager.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
}
}
@@ -850,7 +850,7 @@ public class ProfilesViewModel : MyReactiveObject
}
else
{
item = await AppHandler.Instance.GetSubItem(_config.SubIndexId);
item = await AppManager.Instance.GetSubItem(_config.SubIndexId);
if (item is null)
{
return;
@@ -28,7 +28,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -83,7 +83,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
if (!hasRule)
{
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process"));
NoticeManager.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process"));
return;
}
//NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
@@ -37,7 +37,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
var canEditRemove = this.WhenAnyValue(
@@ -151,7 +151,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
{
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
return;
}
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
@@ -174,7 +174,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
{
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
return;
}
@@ -205,7 +205,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
{
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
return;
}
@@ -226,7 +226,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
string remarks = SelectedRouting.Remarks;
if (remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
return;
}
var item = SelectedRouting;
@@ -239,12 +239,12 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
if (await ConfigHandler.SaveRoutingItem(_config, item) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
@@ -266,7 +266,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
if (ret == 0)
{
RefreshRulesItems();
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
}
@@ -281,7 +281,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
if (ret == 0)
{
RefreshRulesItems();
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
}
@@ -290,7 +290,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
var url = SelectedRouting.Url;
if (url.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl);
NoticeManager.Instance.Enqueue(ResUI.MsgNeedUrl);
return;
}
@@ -300,7 +300,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
if (ret == 0)
{
RefreshRulesItems();
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
}
}
@@ -35,7 +35,7 @@ public class RoutingSettingViewModel : MyReactiveObject
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
var canEditRemove = this.WhenAnyValue(
@@ -84,7 +84,7 @@ public class RoutingSettingViewModel : MyReactiveObject
{
_routingItems.Clear();
var routings = await AppHandler.Instance.RoutingItems();
var routings = await AppManager.Instance.RoutingItems();
foreach (var item in routings)
{
var it = new RoutingItemModel()
@@ -109,12 +109,12 @@ public class RoutingSettingViewModel : MyReactiveObject
if (await ConfigHandler.SaveConfig(_config) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
@@ -129,7 +129,7 @@ public class RoutingSettingViewModel : MyReactiveObject
}
else
{
item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id);
item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id);
if (item is null)
{
return;
@@ -146,7 +146,7 @@ public class RoutingSettingViewModel : MyReactiveObject
{
if (SelectedSource is null || SelectedSource.Remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
return;
}
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
@@ -155,7 +155,7 @@ public class RoutingSettingViewModel : MyReactiveObject
}
foreach (var it in SelectedSources ?? [SelectedSource])
{
var item = await AppHandler.Instance.GetRoutingItem(it?.Id);
var item = await AppManager.Instance.GetRoutingItem(it?.Id);
if (item != null)
{
await ConfigHandler.RemoveRoutingItem(item);
@@ -168,10 +168,10 @@ public class RoutingSettingViewModel : MyReactiveObject
public async Task RoutingAdvancedSetDefault()
{
var item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id);
var item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id);
if (item is null)
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
return;
}
@@ -100,7 +100,7 @@ public class StatusBarViewModel : MyReactiveObject
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
SelectedRouting = new();
SelectedServer = new();
RunningServerToolTipText = "-";
@@ -228,7 +228,7 @@ public class StatusBarViewModel : MyReactiveObject
private async Task CopyProxyCmdToClipboard()
{
var cmd = Utils.IsWindows() ? "set" : "export";
var address = $"{Global.Loopback}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}";
var address = $"{Global.Loopback}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}";
var sb = new StringBuilder();
sb.AppendLine($"{cmd} http_proxy={Global.HttpProtocol}{address}");
@@ -283,7 +283,7 @@ public class StatusBarViewModel : MyReactiveObject
private async Task RefreshServersMenu()
{
var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, "");
var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, "");
_servers.Clear();
if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit)
@@ -336,7 +336,7 @@ public class StatusBarViewModel : MyReactiveObject
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
NoticeHandler.Instance.SendMessageEx(msg);
NoticeManager.Instance.SendMessageEx(msg);
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
}
@@ -355,7 +355,7 @@ public class StatusBarViewModel : MyReactiveObject
}
_config.SystemProxyItem.SysProxyType = type;
await ChangeSystemProxyAsync(type, true);
NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}");
NoticeManager.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}");
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
await ConfigHandler.SaveConfig(_config);
@@ -381,7 +381,7 @@ public class StatusBarViewModel : MyReactiveObject
_routingItems.Clear();
BlRouting = true;
var routings = await AppHandler.Instance.RoutingItems();
var routings = await AppManager.Instance.RoutingItems();
foreach (var item in routings)
{
_routingItems.Add(item);
@@ -404,7 +404,7 @@ public class StatusBarViewModel : MyReactiveObject
return;
}
var item = await AppHandler.Instance.GetRoutingItem(SelectedRouting?.Id);
var item = await AppManager.Instance.GetRoutingItem(SelectedRouting?.Id);
if (item is null)
{
return;
@@ -412,7 +412,7 @@ public class StatusBarViewModel : MyReactiveObject
if (await ConfigHandler.SetDefaultRouting(_config, item) == 0)
{
NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting);
NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting);
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
}
@@ -471,11 +471,11 @@ public class StatusBarViewModel : MyReactiveObject
}
else if (Utils.IsLinux())
{
return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty();
return AppManager.Instance.LinuxSudoPwd.IsNotEmpty();
}
else if (Utils.IsOSX())
{
return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty();
return AppManager.Instance.LinuxSudoPwd.IsNotEmpty();
}
return false;
}
@@ -487,10 +487,10 @@ public class StatusBarViewModel : MyReactiveObject
public async Task InboundDisplayStatus()
{
StringBuilder sb = new();
sb.Append($"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}");
sb.Append($"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}");
if (_config.Inbound.First().SecondLocalPortEnabled)
{
sb.Append($",{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}");
sb.Append($",{AppManager.Instance.GetLocalPort(EInboundProtocol.socks2)}");
}
sb.Append(']');
InboundDisplay = $"{ResUI.LabLocal}:{sb}";
@@ -498,8 +498,8 @@ public class StatusBarViewModel : MyReactiveObject
if (_config.Inbound.First().AllowLANConn)
{
var lan = _config.Inbound.First().NewPort4LAN
? $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks3)}]"
: $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}]";
? $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks3)}]"
: $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}]";
InboundLanDisplay = $"{ResUI.LabLAN}:{lan}";
}
else
@@ -13,7 +13,7 @@ public class SubEditViewModel : MyReactiveObject
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
@@ -29,7 +29,7 @@ public class SubEditViewModel : MyReactiveObject
var remarks = SelectedSource.Remarks;
if (remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
return;
}
@@ -39,25 +39,25 @@ public class SubEditViewModel : MyReactiveObject
var uri = Utils.TryUri(url);
if (uri == null)
{
NoticeHandler.Instance.Enqueue(ResUI.InvalidUrlTip);
NoticeManager.Instance.Enqueue(ResUI.InvalidUrlTip);
return;
}
//Do not allow http protocol
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
{
NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol);
NoticeManager.Instance.Enqueue(ResUI.InsecureUrlProtocol);
//return;
}
}
if (await ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
{
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
_updateView?.Invoke(EViewAction.CloseWindow, null);
}
else
{
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
}
}
}
@@ -24,7 +24,7 @@ public class SubSettingViewModel : MyReactiveObject
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
{
_config = AppHandler.Instance.Config;
_config = AppManager.Instance.Config;
_updateView = updateView;
var canEditRemove = this.WhenAnyValue(
@@ -61,7 +61,7 @@ public class SubSettingViewModel : MyReactiveObject
public async Task RefreshSubItems()
{
_subItems.Clear();
_subItems.AddRange(await AppHandler.Instance.SubItems());
_subItems.AddRange(await AppManager.Instance.SubItems());
}
public async Task EditSubAsync(bool blNew)
@@ -73,7 +73,7 @@ public class SubSettingViewModel : MyReactiveObject
}
else
{
item = await AppHandler.Instance.GetSubItem(SelectedSource?.Id);
item = await AppManager.Instance.GetSubItem(SelectedSource?.Id);
if (item is null)
{
return;
@@ -98,7 +98,7 @@ public class SubSettingViewModel : MyReactiveObject
await ConfigHandler.DeleteSubItem(_config, it.Id);
}
await RefreshSubItems();
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
IsModified = true;
}
}