mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-14 16:35:00 +03:00
Centralize shared configuration state
Introduce a synchronized ConfigState and make ConfigTextManager static. Update configuration access across desktop and WebAPI, and add an AddServer overload using the current configuration.
This commit is contained in:
@@ -79,7 +79,7 @@ public static class ConnectionHandler
|
||||
|
||||
public static async Task<int> GetRealPingTime(HttpClient client, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var url = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
|
||||
var url = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl;
|
||||
var responseTime = -1;
|
||||
try
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public static class ConnectionHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = ConfigTextManager.Instance.Config.SpeedTestItem.IPAPIUrl;
|
||||
var url = ConfigTextManager.Config.SpeedTestItem.IPAPIUrl;
|
||||
if (url.IsNullOrEmpty())
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -9,7 +9,7 @@ public static class CoreConfigHandler
|
||||
|
||||
public static async Task<RetResult> GenerateClientConfig(CoreConfigContext context, string? fileName)
|
||||
{
|
||||
var config = ConfigTextManager.Instance.Config;
|
||||
var config = ConfigTextManager.Config;
|
||||
var result = new RetResult();
|
||||
var node = context.Node;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public static class ProxySettingLinux
|
||||
|
||||
private static async Task ExecCmd(List<string> args)
|
||||
{
|
||||
var customSystemProxyScriptPath = ConfigTextManager.Instance.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
||||
var customSystemProxyScriptPath = ConfigTextManager.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
||||
var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath))
|
||||
? customSystemProxyScriptPath
|
||||
: await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetLinuxShellFileName), false);
|
||||
|
||||
@@ -24,7 +24,7 @@ public static class ProxySettingOSX
|
||||
|
||||
private static async Task ExecCmd(List<string> args)
|
||||
{
|
||||
var customSystemProxyScriptPath = ConfigTextManager.Instance.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
||||
var customSystemProxyScriptPath = ConfigTextManager.Config.SystemProxyItem?.CustomSystemProxyScriptPath;
|
||||
var fileName = (customSystemProxyScriptPath.IsNotEmpty() && File.Exists(customSystemProxyScriptPath))
|
||||
? customSystemProxyScriptPath
|
||||
: await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
|
||||
|
||||
@@ -67,7 +67,7 @@ public sealed class AppManager
|
||||
}
|
||||
|
||||
Logging.Setup();
|
||||
_config = ConfigTextManager.Instance.Init();
|
||||
_config = ConfigTextManager.Init();
|
||||
if (_config == null)
|
||||
{
|
||||
return false;
|
||||
@@ -127,7 +127,7 @@ public sealed class AppManager
|
||||
AppEvents.AppExitRequested.Publish();
|
||||
await Task.Delay(50); //Wait for AppExitRequested to be processed
|
||||
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
await StatisticsManager.Instance.SaveTo();
|
||||
await CoreManager.Instance.CoreStop();
|
||||
|
||||
@@ -82,7 +82,7 @@ public sealed class ClashApiManager
|
||||
private async Task<int> TestProxyDelay(string name)
|
||||
{
|
||||
var url = $"{ApiUrl}/proxies/{Utils.UrlEncode(name)}/delay?timeout=10000&url=" +
|
||||
Utils.UrlEncode(ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl);
|
||||
Utils.UrlEncode(ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl);
|
||||
return await SendTestRequest(url);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public sealed class ClashApiManager
|
||||
{
|
||||
var url =
|
||||
$"{ApiUrl}/providers/proxies/{Utils.UrlEncode(providerName)}/{Utils.UrlEncode(name)}/healthcheck?timeout=10000&url=" +
|
||||
Utils.UrlEncode(ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl);
|
||||
Utils.UrlEncode(ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl);
|
||||
return await SendTestRequest(url);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,25 @@ public static class ConfigDbManager
|
||||
{
|
||||
private static readonly string _tag = "ConfigDbManager";
|
||||
|
||||
private static Config CurrentConfig => ConfigState.Instance.Current;
|
||||
|
||||
private static async Task<int> SaveConfig()
|
||||
{
|
||||
return await ConfigTextManager.Instance.SaveConfig();
|
||||
return await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
|
||||
#region Server
|
||||
|
||||
/// <summary>
|
||||
/// Add a server profile to the current configuration from ConfigState.
|
||||
/// </summary>
|
||||
/// <param name="profileItem">Server profile to add</param>
|
||||
/// <returns>Result of the operation (0 if successful, -1 if failed)</returns>
|
||||
public static Task<int> AddServer(ProfileItem profileItem)
|
||||
{
|
||||
return AddServer(CurrentConfig, profileItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a server profile to the configuration
|
||||
/// Dispatches the request to the appropriate method based on the config type
|
||||
@@ -2997,7 +3009,7 @@ public static class ConfigDbManager
|
||||
private static async Task<int> MigrateProfileExtraV2ToV3Sub(List<ProfileItem> batch)
|
||||
{
|
||||
var updateProfileItems = new List<ProfileItem>();
|
||||
var config = ConfigTextManager.Instance.Config;
|
||||
var config = ConfigTextManager.Config;
|
||||
|
||||
foreach (var item in batch)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace ServiceLib.Manager.Data;
|
||||
|
||||
public sealed class ConfigState
|
||||
{
|
||||
private static readonly Lazy<ConfigState> _instance = new(() => new());
|
||||
private readonly Lock _lock = new();
|
||||
private Config? _current;
|
||||
|
||||
public static ConfigState Instance => _instance.Value;
|
||||
|
||||
public Config Current
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _current ??= new Config();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInitialized
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _current is not null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrent(Config config)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(config);
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
_current = config;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,27 @@
|
||||
namespace ServiceLib.Manager.Data;
|
||||
|
||||
public class ConfigTextManager
|
||||
public static class ConfigTextManager
|
||||
{
|
||||
private static readonly Lazy<ConfigTextManager> _instance = new(() => new());
|
||||
public static ConfigTextManager Instance => _instance.Value;
|
||||
|
||||
private static readonly string _configRes = Global.ConfigFileName;
|
||||
private static readonly string _tag = "ConfigTextManager";
|
||||
|
||||
public Config Config { get; private set; }
|
||||
public static Config Config
|
||||
{
|
||||
get => ConfigState.Instance.Current;
|
||||
private set => ConfigState.Instance.SetCurrent(value);
|
||||
}
|
||||
|
||||
#region Init
|
||||
|
||||
public Config? Init()
|
||||
public static Config? Init()
|
||||
{
|
||||
Config = LoadConfig();
|
||||
var config = LoadConfig();
|
||||
if (config == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Config = config;
|
||||
return Config;
|
||||
}
|
||||
|
||||
@@ -25,7 +32,7 @@ public class ConfigTextManager
|
||||
/// Initialize default values for missing configuration sections
|
||||
/// </summary>
|
||||
/// <returns>Config object containing application settings or null if there's an error</returns>
|
||||
private Config? LoadConfig()
|
||||
private static Config? LoadConfig()
|
||||
{
|
||||
Config? config = null;
|
||||
var result = EmbedUtils.LoadResource(Utils.GetConfigPath(_configRes));
|
||||
@@ -228,7 +235,7 @@ public class ConfigTextManager
|
||||
/// </summary>
|
||||
/// <param name="_config">Configuration object to be saved</param>
|
||||
/// <returns>0 if successful, -1 if failed</returns>
|
||||
public async Task<int> SaveConfig()
|
||||
public static async Task<int> SaveConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -259,7 +266,7 @@ public class ConfigTextManager
|
||||
|
||||
#region UIItem
|
||||
|
||||
public WindowSizeItem? GetWindowSizeItem(string typeName)
|
||||
public static WindowSizeItem? GetWindowSizeItem(string typeName)
|
||||
{
|
||||
var sizeItem = Config?.UiItem?.WindowSizeItem?.FirstOrDefault(t => t.TypeName == typeName);
|
||||
if (sizeItem == null || sizeItem.Width <= 0 || sizeItem.Height <= 0)
|
||||
@@ -270,7 +277,7 @@ public class ConfigTextManager
|
||||
return sizeItem;
|
||||
}
|
||||
|
||||
public int SaveWindowSizeItem(string typeName, double width, double height)
|
||||
public static int SaveWindowSizeItem(string typeName, double width, double height)
|
||||
{
|
||||
var sizeItem = Config?.UiItem?.WindowSizeItem?.FirstOrDefault(t => t.TypeName == typeName);
|
||||
if (sizeItem == null)
|
||||
@@ -285,7 +292,7 @@ public class ConfigTextManager
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int SaveMainGirdHeight(double height1, double height2)
|
||||
public static int SaveMainGirdHeight(double height1, double height2)
|
||||
{
|
||||
var uiItem = Config.UiItem ?? new();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PacManager
|
||||
|
||||
private async Task<byte[]> InitText(int httpPort)
|
||||
{
|
||||
var customSystemProxyPacPath = ConfigTextManager.Instance.Config.SystemProxyItem.CustomSystemProxyPacPath;
|
||||
var customSystemProxyPacPath = ConfigTextManager.Config.SystemProxyItem.CustomSystemProxyPacPath;
|
||||
var fileName = customSystemProxyPacPath.IsNotEmpty() && File.Exists(customSystemProxyPacPath)
|
||||
? customSystemProxyPacPath
|
||||
: Path.Combine(Utils.GetConfigPath(), "pac.txt");
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TaskManager
|
||||
|
||||
try
|
||||
{
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -16,7 +16,7 @@ public sealed class WebDavManager
|
||||
|
||||
public WebDavManager()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
}
|
||||
|
||||
private async Task<bool> GetClient()
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class CoreConfigV2rayService
|
||||
subjectSelector = [baseTagName],
|
||||
pingConfig = new()
|
||||
{
|
||||
destination = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||
destination = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||
interval = "5m",
|
||||
timeout = "30s",
|
||||
sampling = 2,
|
||||
@@ -68,7 +68,7 @@ public partial class CoreConfigV2rayService
|
||||
_coreConfig.observatory = new Observatory4Ray
|
||||
{
|
||||
subjectSelector = [baseTagName],
|
||||
probeUrl = ConfigTextManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||
probeUrl = ConfigTextManager.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||
probeInterval = "3m",
|
||||
enableConcurrency = true,
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ public partial class AddGroupServerViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public AddGroupServerViewModel(ProfileItem profileItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
x => x.SelectedChild,
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public AddServer2ViewModel(ProfileItem profileItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -319,7 +319,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public AddServerViewModel(ProfileItem profileItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
FetchCertCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ public partial class BackupAndRestoreViewModel : MyReactiveObject
|
||||
|
||||
public BackupAndRestoreViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
@@ -46,7 +46,7 @@ public partial class BackupAndRestoreViewModel : MyReactiveObject
|
||||
{
|
||||
DisplayOperationMsg();
|
||||
_config.WebDavItem = SelectedSource;
|
||||
_ = await ConfigTextManager.Instance.SaveConfig();
|
||||
_ = await ConfigTextManager.SaveConfig();
|
||||
|
||||
var result = await WebDavManager.Instance.CheckConnection();
|
||||
if (result)
|
||||
|
||||
@@ -19,7 +19,7 @@ public partial class CheckUpdateViewModel : MyReactiveObject
|
||||
|
||||
public CheckUpdateViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
CheckUpdateCmd = ReactiveCommand.CreateFromTask(CheckUpdate);
|
||||
CheckUpdateCmd.ThrownExceptions.Subscribe(ex =>
|
||||
@@ -126,7 +126,7 @@ public partial class CheckUpdateViewModel : MyReactiveObject
|
||||
.Select(t => t.CoreTypeForStorage)
|
||||
.ToList();
|
||||
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
|
||||
private async Task CheckOnly()
|
||||
|
||||
@@ -4,7 +4,7 @@ public partial class ClashConnectionsViewModel : MyReactiveObject
|
||||
{
|
||||
public ClashConnectionsViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
|
||||
@@ -7,7 +7,7 @@ public partial class ClashProxiesViewModel : MyReactiveObject
|
||||
|
||||
public ClashProxiesViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public DNSSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync);
|
||||
|
||||
ImportDefConfig4V2rayCompatibleCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
@@ -82,7 +82,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
private async Task Init()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
var item = _config.SimpleDNSItem;
|
||||
UseSystemHosts = item.UseSystemHosts ?? false;
|
||||
AddCommonHosts = item.AddCommonHosts ?? false;
|
||||
@@ -217,7 +217,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
|
||||
item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible));
|
||||
await ConfigDbManager.SaveDNSItems(_config, item2);
|
||||
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
RequestClose?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public FullConfigTemplateViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await SaveSettingAsync();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public GlobalHotkeySettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
_globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable
|
||||
{
|
||||
_config.GlobalHotkeys = _globalHotkeys;
|
||||
|
||||
if (await ConfigTextManager.Instance.SaveConfig() == 0)
|
||||
if (await ConfigTextManager.SaveConfig() == 0)
|
||||
{
|
||||
RequestClose?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public partial class MainWindowViewModel : MyReactiveObject
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
BlIsWindows = Utils.IsWindows();
|
||||
MainGirdOrientation = _config.UiItem.MainGirdOrientation;
|
||||
|
||||
@@ -795,7 +795,7 @@ public partial class MainWindowViewModel : MyReactiveObject
|
||||
await StatusBarViewModel.RefreshRoutingsMenu();
|
||||
});
|
||||
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
using var downloadService = await DownloadService.CreateDownloadServiceWithCheck();
|
||||
await new UpdateService(downloadService, _config, UpdateTaskHandler).UpdateGeoFileAll();
|
||||
await Reload();
|
||||
|
||||
@@ -16,7 +16,7 @@ public partial class MsgViewModel : MyReactiveObject
|
||||
|
||||
public MsgViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
|
||||
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public partial class OptionSettingViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public OptionSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
BlIsWindows = Utils.IsWindows();
|
||||
BlIsLinux = Utils.IsLinux();
|
||||
BlIsIsMacOS = Utils.IsMacOS();
|
||||
@@ -407,7 +407,7 @@ public partial class OptionSettingViewModel : MyReactiveObject, ICloseable
|
||||
//coreType
|
||||
await SaveCoreType();
|
||||
|
||||
if (await ConfigTextManager.Instance.SaveConfig() == 0)
|
||||
if (await ConfigTextManager.SaveConfig() == 0)
|
||||
{
|
||||
await AutoStartupHandler.UpdateTask(_config);
|
||||
AppManager.Instance.Reset();
|
||||
|
||||
@@ -51,7 +51,7 @@ public partial class ProfilesSelectViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public ProfilesSelectViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
_subIndexId = _config.SubIndexId ?? string.Empty;
|
||||
|
||||
#region WhenAnyValue && ReactiveCommand
|
||||
|
||||
@@ -96,7 +96,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
||||
|
||||
public ProfilesViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
#region WhenAnyValue && ReactiveCommand
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public partial class RoutingRuleDetailsViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public RoutingRuleDetailsViewModel(RulesItem rulesItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
SelectProfileCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public RoutingRuleSettingViewModel(RoutingItem routingItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
x => x.SelectedSource,
|
||||
|
||||
@@ -32,7 +32,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
||||
|
||||
public RoutingSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
x => x.SelectedSource,
|
||||
@@ -113,7 +113,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.RoutingBasicItem.DomainStrategy = DomainStrategy;
|
||||
_config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox;
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
|
||||
#endregion Refresh Save
|
||||
|
||||
@@ -107,7 +107,7 @@ public partial class StatusBarViewModel : MyReactiveObject
|
||||
|
||||
public StatusBarViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
SelectedRouting = new();
|
||||
SelectedServer = new();
|
||||
RunningServerToolTipText = GetRunningServerToolTipText("-");
|
||||
@@ -373,7 +373,7 @@ public partial class StatusBarViewModel : MyReactiveObject
|
||||
NoticeManager.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType}");
|
||||
|
||||
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
|
||||
public async Task ChangeSystemProxyAsync(ESysProxyType type, bool blChange)
|
||||
@@ -459,7 +459,7 @@ public partial class StatusBarViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
ReloadRequested.Publish();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class SubEditViewModel : MyReactiveObject, ICloseable
|
||||
|
||||
public SubEditViewModel(SubItem subItem)
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
SelectPrevProfileCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ public partial class SubSettingViewModel : MyReactiveObject
|
||||
|
||||
public SubSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
x => x.SelectedSource,
|
||||
|
||||
@@ -65,7 +65,7 @@ public partial class App : Application
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock)
|
||||
if (!ConfigTextManager.Config.UiItem.MacOSShowInDock)
|
||||
{
|
||||
MacAppUtils.SetActivationPolicyAccessory();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public partial class App : Application
|
||||
|
||||
private static void RestoreMacOSAccessoryPolicyAfterMiniaturize(MainWindow mainWindow)
|
||||
{
|
||||
if (ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock)
|
||||
if (ConfigTextManager.Config.UiItem.MacOSShowInDock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public partial class App : Application
|
||||
|
||||
private static void RestoreMacOSAccessoryPolicy(MainWindow mainWindow)
|
||||
{
|
||||
if (ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock || MacAppUtils.IsWindowMiniaturized(mainWindow))
|
||||
if (ConfigTextManager.Config.UiItem.MacOSShowInDock || MacAppUtils.IsWindowMiniaturized(mainWindow))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||
{
|
||||
try
|
||||
{
|
||||
var sizeItem = ConfigTextManager.Instance.GetWindowSizeItem(GetType().Name);
|
||||
var sizeItem = ConfigTextManager.GetWindowSizeItem(GetType().Name);
|
||||
if (sizeItem is null)
|
||||
{
|
||||
return;
|
||||
@@ -55,7 +55,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||
base.OnClosed(e);
|
||||
try
|
||||
{
|
||||
ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ internal class Program
|
||||
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
var showInDock = Design.IsDesignMode || ConfigTextManager.Instance.Config.UiItem.MacOSShowInDock;
|
||||
var showInDock = Design.IsDesignMode || ConfigTextManager.Config.UiItem.MacOSShowInDock;
|
||||
builder = builder.With(new MacOSPlatformOptions { ShowInDock = showInDock });
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
|
||||
public ThemeSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
BindingUI();
|
||||
RestoreUI();
|
||||
@@ -43,7 +43,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentTheme = CurrentTheme;
|
||||
ModifyTheme();
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||
ModifyFontSize();
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
Loaded += Window_Loaded;
|
||||
btnCancel.Click += (s, e) => Close();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
Loaded += Window_Loaded;
|
||||
btnCancel.Click += (_, _) => Close();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
|
||||
|
||||
KeyDown += MainWindow_KeyDown;
|
||||
@@ -396,15 +396,15 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
|
||||
if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
|
||||
{
|
||||
ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth);
|
||||
ConfigTextManager.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth);
|
||||
}
|
||||
else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
|
||||
{
|
||||
ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.RowDefinitions[0].ActualHeight, gridMain.RowDefinitions[2].ActualHeight);
|
||||
ConfigTextManager.SaveMainGirdHeight(gridMain.RowDefinitions[0].ActualHeight, gridMain.RowDefinitions[2].ActualHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||
|
||||
Loaded += Window_Loaded;
|
||||
btnCancel.Click += (s, e) => Close();
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged;
|
||||
btnBrowseCustomSystemProxyPacPath.Click += BtnBrowseCustomSystemProxyPacPath_Click;
|
||||
|
||||
@@ -15,7 +15,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
menuSelectAll.Click += menuSelectAll_Click;
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
|
||||
@@ -11,7 +11,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
txtRunningServerDisplay.Tapped += TxtRunningServerDisplay_Tapped;
|
||||
txtRunningInfoDisplay.Tapped += TxtRunningServerDisplay_Tapped;
|
||||
|
||||
@@ -36,7 +36,7 @@ public sealed partial class V2rayRuntime
|
||||
Config.WebDavItem.Password = input.Password;
|
||||
}
|
||||
Config.WebDavItem.DirName = input.DirName?.Trim();
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
return OperationView.Ok(ApiMessageKeys.WebDavSettingsSaved);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public sealed partial class V2rayRuntime
|
||||
{
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
await StatisticsManager.Instance.SaveTo();
|
||||
});
|
||||
@@ -211,7 +211,7 @@ public sealed partial class V2rayRuntime
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
await StatisticsManager.Instance.SaveTo();
|
||||
StatisticsManager.Instance.Close();
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()), cancellationToken);
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()), cancellationToken);
|
||||
await SQLiteHelper.Instance.DisposeDbConnectionAsync();
|
||||
databaseClosed = true;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public sealed partial class V2rayRuntime
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.ToList();
|
||||
Config.CheckUpdateItem.UpdateViaProxy = input.UseProxy;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
|
||||
return OperationView.Ok(ApiMessageKeys.CoreUpdateSettingsSaved);
|
||||
|
||||
@@ -39,7 +39,7 @@ public sealed partial class V2rayRuntime
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
Config.SubIndexId = subscriptionId ?? string.Empty;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
_events.Publish("profiles-changed", new { subscriptionId = Config.SubIndexId });
|
||||
return OperationView.Ok(ApiMessageKeys.CommonCompleted, new { subscriptionId = Config.SubIndexId });
|
||||
@@ -63,7 +63,7 @@ public sealed partial class V2rayRuntime
|
||||
var imported = await ConfigDbManager.AddBatchServers(Config, request.Content, groupId, request.IsSubscription);
|
||||
if (imported > 0)
|
||||
{
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
}
|
||||
return imported;
|
||||
});
|
||||
@@ -270,7 +270,7 @@ public sealed partial class V2rayRuntime
|
||||
if (removesCurrent)
|
||||
{
|
||||
_ = await ConfigDbManager.GetDefaultServer(Config);
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public sealed partial class V2rayRuntime
|
||||
await using var operation = await _operations.EnterOperationAsync(token);
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
}, operation.Token);
|
||||
}, cancellationToken);
|
||||
|
||||
@@ -252,7 +252,7 @@ public sealed partial class V2rayRuntime
|
||||
}
|
||||
Config.RoutingBasicItem.DomainStrategy = input.DomainStrategy!;
|
||||
Config.RoutingBasicItem.DomainStrategy4Singbox = input.DomainStrategy4Singbox!;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
@@ -260,7 +260,7 @@ public sealed partial class V2rayRuntime
|
||||
RestoreConfigValues(Config, oldConfig);
|
||||
try
|
||||
{
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()));
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()));
|
||||
}
|
||||
catch (Exception rollbackException)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ public sealed partial class V2rayRuntime
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
ApplyInboundSettings(Config.Inbound[0], input);
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
|
||||
return await CompleteCoreAffectingChangeAsync("inbound", fingerprint != GetCoreConfigurationFingerprint(), applyContext);
|
||||
@@ -375,7 +375,7 @@ public sealed partial class V2rayRuntime
|
||||
Config.Fragment4RayItem.Lengths = fragmentLengths.ToList();
|
||||
Config.Fragment4RayItem.Delays = fragmentDelays.ToList();
|
||||
Config.Fragment4RayItem.MaxSplit = input.FragmentMaxSplit;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
|
||||
return await CompleteCoreAffectingChangeAsync("core", fingerprint != GetCoreConfigurationFingerprint(), applyContext);
|
||||
@@ -402,7 +402,7 @@ public sealed partial class V2rayRuntime
|
||||
Config.ConstItem.SrsSourceUrl = input.SrsSourceUrl;
|
||||
Config.ConstItem.RouteRulesTemplateSourceUrl = input.RouteRulesTemplateSourceUrl;
|
||||
Config.ConstItem.SubConvertUrl = input.SubConvertUrl;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
|
||||
if (statisticsChanged)
|
||||
@@ -435,7 +435,7 @@ public sealed partial class V2rayRuntime
|
||||
Config.SpeedTestItem.MixedConcurrencyCount = Math.Max(input.MixedConcurrencyCount, Global.SpeedTestConcurrencyCountMin);
|
||||
Config.SpeedTestItem.IPAPIUrl = input.IPAPIUrl;
|
||||
Config.SpeedTestItem.UdpTestTarget = input.UdpTestTarget;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
_events.Publish("settings-changed", new { section = "speedtest", restartRequired = false });
|
||||
return OperationView.Ok(ApiMessageKeys.SpeedTestSettingsSaved);
|
||||
@@ -467,7 +467,7 @@ public sealed partial class V2rayRuntime
|
||||
item.CoreType = mapping.CoreType;
|
||||
}
|
||||
}
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
return await CompleteCoreAffectingChangeAsync("core-types", fingerprint != GetCoreConfigurationFingerprint(), applyContext);
|
||||
}
|
||||
@@ -503,7 +503,7 @@ public sealed partial class V2rayRuntime
|
||||
{
|
||||
Config.RoutingBasicItem.DomainStrategy = input.DomainStrategy!;
|
||||
Config.RoutingBasicItem.DomainStrategy4Singbox = input.DomainStrategy4Singbox!;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
return await CompleteCoreAffectingChangeAsync("routing", fingerprint != GetCoreConfigurationFingerprint(), applyContext);
|
||||
}
|
||||
@@ -522,7 +522,7 @@ public sealed partial class V2rayRuntime
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
Config.SimpleDNSItem = input;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
return await CompleteCoreAffectingChangeAsync("dns", fingerprint != GetCoreConfigurationFingerprint(), applyContext);
|
||||
}
|
||||
@@ -743,7 +743,7 @@ public sealed partial class V2rayRuntime
|
||||
else
|
||||
{
|
||||
Config.RoutingBasicItem.RoutingIndexId = string.Empty;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
}
|
||||
}
|
||||
return (Removed: true, AffectsCore: item.IsActive);
|
||||
@@ -1234,7 +1234,7 @@ public sealed partial class V2rayRuntime
|
||||
}
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
token.ThrowIfCancellationRequested();
|
||||
}, token),
|
||||
() => RestoreRegionalPresetSnapshotAsync(applyContext));
|
||||
@@ -1349,7 +1349,7 @@ public sealed partial class V2rayRuntime
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
RestoreConfigValues(Config, context.OldConfig);
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
|
||||
await SQLiteHelper.Instance.DeleteAllAsync<RoutingItem>();
|
||||
if (context.OldRoutingItems.Length > 0
|
||||
@@ -1625,7 +1625,7 @@ public sealed partial class V2rayRuntime
|
||||
try
|
||||
{
|
||||
RestoreConfigValues(Config, context.OldConfig);
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()));
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()));
|
||||
configRestored = true;
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed partial class V2rayRuntime(
|
||||
private bool _restoring;
|
||||
private int _restoreAndRestartRequested;
|
||||
|
||||
private Config Config => ConfigTextManager.Instance.Config;
|
||||
private Config Config => ConfigTextManager.Config;
|
||||
private CoreRuntimeSnapshot CurrentCoreRuntime => Volatile.Read(ref _coreRuntime);
|
||||
public bool RestoreAndRestartRequested => Volatile.Read(ref _restoreAndRestartRequested) != 0;
|
||||
|
||||
@@ -245,7 +245,7 @@ public sealed partial class V2rayRuntime(
|
||||
{
|
||||
Config.Inbound[0].AllowLANConn = allowProxyFromLan;
|
||||
}
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
await ConfigDbManager.InitBuiltinDNS(Config);
|
||||
await BuiltinDnsProfileBootstrap.EnsureAsync(
|
||||
@@ -269,7 +269,7 @@ public sealed partial class V2rayRuntime(
|
||||
}
|
||||
var selectedProfileId = Config.IndexId;
|
||||
var defaultProfile = await ConfigDbManager.GetDefaultServer(Config);
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()));
|
||||
await _mutations.RunAsync(() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()));
|
||||
await ProfileExManager.Instance.Init();
|
||||
await CertPemManager.Instance.Init(Config);
|
||||
// The Web frontend owns its runtime and rejects generated launch contexts that enable TUN.
|
||||
@@ -392,7 +392,7 @@ public sealed partial class V2rayRuntime(
|
||||
steps.Add(new("configuration save", async deadline =>
|
||||
{
|
||||
await _mutations.RunAsync(
|
||||
() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig()),
|
||||
() => EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig()),
|
||||
deadline.Token);
|
||||
return true;
|
||||
}));
|
||||
@@ -503,7 +503,7 @@ public sealed partial class V2rayRuntime(
|
||||
if (removesCurrentProfile)
|
||||
{
|
||||
_ = await ConfigDbManager.GetDefaultServer(Config);
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -552,7 +552,7 @@ public sealed partial class V2rayRuntime(
|
||||
await handler.UpdateProcess(id);
|
||||
|
||||
operation.Token.ThrowIfCancellationRequested();
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
await UpdateSubscriptionTimestampLockedAsync(id);
|
||||
}, operation.Token);
|
||||
_events.Publish("profiles-changed", new { subscriptionId = id });
|
||||
@@ -780,7 +780,7 @@ public sealed partial class V2rayRuntime(
|
||||
await _mutations.RunAsync(async () =>
|
||||
{
|
||||
Config.IndexId = profile.IndexId;
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -792,7 +792,7 @@ public sealed partial class V2rayRuntime(
|
||||
var selected = await ConfigDbManager.GetDefaultServer(Config);
|
||||
if (selected is not null)
|
||||
{
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.Instance.SaveConfig());
|
||||
await EnsureConfigSaveSucceededAsync(() => ConfigTextManager.SaveConfig());
|
||||
}
|
||||
return selected;
|
||||
});
|
||||
|
||||
@@ -11,7 +11,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||
{
|
||||
try
|
||||
{
|
||||
var sizeItem = ConfigTextManager.Instance.GetWindowSizeItem(GetType().Name);
|
||||
var sizeItem = ConfigTextManager.GetWindowSizeItem(GetType().Name);
|
||||
if (sizeItem == null)
|
||||
{
|
||||
return;
|
||||
@@ -32,7 +32,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||
|
||||
try
|
||||
{
|
||||
ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class MaterialDesignFonts
|
||||
{
|
||||
try
|
||||
{
|
||||
var fontFamily = ConfigTextManager.Instance.Config.UiItem.CurrentFontFamily;
|
||||
var fontFamily = ConfigTextManager.Config.UiItem.CurrentFontFamily;
|
||||
if (fontFamily.IsNotEmpty())
|
||||
{
|
||||
var fontPath = Utils.GetFontsPath();
|
||||
|
||||
@@ -22,7 +22,7 @@ public sealed partial class HotkeyManager
|
||||
private void Init()
|
||||
{
|
||||
_hotkeyTriggerDic.Clear();
|
||||
foreach (var item in ConfigTextManager.Instance.Config.GlobalHotkeys)
|
||||
foreach (var item in ConfigTextManager.Config.GlobalHotkeys)
|
||||
{
|
||||
if (item.KeyCode != null && (Key)item.KeyCode != Key.None)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
|
||||
public ThemeSettingViewModel()
|
||||
{
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
RegisterSystemColorSet(_config, ModifyTheme);
|
||||
|
||||
@@ -64,7 +64,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentTheme = CurrentTheme;
|
||||
ModifyTheme();
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.ColorPrimaryName = SelectedSwatch?.Name;
|
||||
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||
ModifyFontSize();
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ public partial class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
await ConfigTextManager.Instance.SaveConfig();
|
||||
await ConfigTextManager.SaveConfig();
|
||||
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ public partial class AddGroupServerWindow
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void InitializeData(ProfileItem profileItem)
|
||||
|
||||
@@ -38,7 +38,7 @@ public partial class AddServer2Window
|
||||
interaction.SetOutput(fileName);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void InitializeData(ProfileItem profileItem)
|
||||
|
||||
@@ -204,7 +204,7 @@ public partial class AddServerWindow
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void InitializeData(ProfileItem profileItem)
|
||||
|
||||
@@ -14,7 +14,7 @@ public partial class ClashConnectionsView
|
||||
public ClashConnectionsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class DNSSettingWindow
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
cmbDirectDNSStrategy.ItemsSource = Global.DomainStrategy;
|
||||
cmbRemoteDNSStrategy.ItemsSource = Global.DomainStrategy;
|
||||
@@ -72,7 +72,7 @@ public partial class DNSSettingWindow
|
||||
this.OneWayBind(ViewModel, vm => vm.IsSimpleDNSEnabled, v => v.gridBasicDNSSettings.IsEnabled).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.IsSimpleDNSEnabled, v => v.gridAdvancedDNSSettings.IsEnabled).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -8,7 +8,7 @@ public partial class FullConfigTemplateWindow
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
@@ -25,7 +25,7 @@ public partial class FullConfigTemplateWindow
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void linkFullConfigTemplateDoc_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -21,7 +21,7 @@ public partial class GlobalHotkeySettingWindow
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
BindingData();
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public partial class MainWindow
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
||||
|
||||
App.Current.SessionEnding += Current_SessionEnding;
|
||||
@@ -345,15 +345,15 @@ public partial class MainWindow
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
ConfigTextManager.Instance.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
ConfigTextManager.SaveWindowSizeItem(GetType().Name, Width, Height);
|
||||
|
||||
if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
|
||||
{
|
||||
ConfigTextManager.Instance.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth);
|
||||
ConfigTextManager.SaveMainGirdHeight(gridMain.ColumnDefinitions[0].ActualWidth, gridMain.ColumnDefinitions[2].ActualWidth);
|
||||
}
|
||||
else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
|
||||
{
|
||||
ConfigTextManager.Instance.SaveMainGirdHeight(gridMain1.RowDefinitions[0].ActualHeight, gridMain1.RowDefinitions[2].ActualHeight);
|
||||
ConfigTextManager.SaveMainGirdHeight(gridMain1.RowDefinitions[0].ActualHeight, gridMain1.RowDefinitions[2].ActualHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class OptionSettingWindow
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
clbdestOverride.SelectionChanged += ClbdestOverride_SelectionChanged;
|
||||
btnBrowseCustomSystemProxyPacPath.Click += BtnBrowseCustomSystemProxyPacPath_Click;
|
||||
@@ -149,7 +149,7 @@ public partial class OptionSettingWindow
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private async Task InitSettingFont()
|
||||
|
||||
@@ -39,7 +39,7 @@ public partial class ProfilesSelectWindow
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void AllowMultiSelect(bool allow)
|
||||
|
||||
@@ -17,7 +17,7 @@ public partial class ProfilesView
|
||||
InitializeComponent();
|
||||
lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40;
|
||||
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
|
||||
|
||||
@@ -37,7 +37,7 @@ public partial class RoutingRuleDetailsWindow
|
||||
this.BindCommand(ViewModel, vm => vm.SelectProfileCmd, v => v.btnSelectProfile).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void InitializeData(RulesItem rulesItem)
|
||||
|
||||
@@ -76,7 +76,7 @@ public partial class RoutingRuleSettingWindow
|
||||
interaction.SetOutput(fileName);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -37,7 +37,7 @@ public partial class RoutingSettingWindow
|
||||
interaction.SetOutput(result);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
|
||||
@@ -9,7 +9,7 @@ public partial class StatusBarView
|
||||
public StatusBarView()
|
||||
{
|
||||
InitializeComponent();
|
||||
_config = ConfigTextManager.Instance.Config;
|
||||
_config = ConfigTextManager.Config;
|
||||
|
||||
menuExit.Click += menuExit_Click;
|
||||
txtRunningServerDisplay.PreviewMouseDown += txtRunningInfoDisplay_MouseDoubleClick;
|
||||
|
||||
@@ -35,7 +35,7 @@ public partial class SubEditWindow
|
||||
this.BindCommand(ViewModel, vm => vm.SelectNextProfileCmd, v => v.btnSelectNextProfile).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -47,7 +47,7 @@ public partial class SubSettingWindow
|
||||
interaction.SetOutput(RxVoid.Default);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Instance.Config.UiItem.CurrentTheme);
|
||||
WindowsUtils.SetDarkBorder(this, ConfigTextManager.Config.UiItem.CurrentTheme);
|
||||
}
|
||||
|
||||
private async Task ShareSub(string url)
|
||||
|
||||
Reference in New Issue
Block a user