Rename LazyConfig to AppHandler
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Splat;
|
||||
using v2rayN.Desktop.ViewModels;
|
||||
using v2rayN.Desktop.Views;
|
||||
|
||||
@@ -10,11 +9,14 @@ namespace v2rayN.Desktop;
|
||||
public partial class App : Application
|
||||
{
|
||||
//public static EventWaitHandle ProgramStarted;
|
||||
private static Config _config;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
Init();
|
||||
if (!AppHandler.Instance.InitApp())
|
||||
{
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
@@ -49,30 +51,7 @@ public partial class App : Application
|
||||
// return;
|
||||
//}
|
||||
|
||||
Logging.Setup();
|
||||
Logging.LoggingEnabled(_config.guiItem.enableLog);
|
||||
Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
||||
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
||||
Logging.ClearLogs();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (ConfigHandler.LoadConfig(ref _config) != 0)
|
||||
{
|
||||
//Logging.SaveLog($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}<7D><><EFBFBD><EFBFBD>GUI<55><49><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>쳣,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>");
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
LazyConfig.Instance.SetConfig(_config);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(), typeof(NoticeHandler));
|
||||
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);
|
||||
|
||||
//Under Win10
|
||||
if (Utils.IsWindows() && Environment.OSVersion.Version.Major < 10)
|
||||
{
|
||||
Environment.SetEnvironmentVariable("DOTNET_EnableWriteXorExecute", "0", EnvironmentVariableTarget.User);
|
||||
}
|
||||
AppHandler.Instance.InitComponents();
|
||||
}
|
||||
|
||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace v2rayN.Desktop.Handler
|
||||
|
||||
try
|
||||
{
|
||||
int port = LazyConfig.Instance.GetLocalPort(EInboundProtocol.http);
|
||||
int portSocks = LazyConfig.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
int portPac = LazyConfig.Instance.GetLocalPort(EInboundProtocol.pac);
|
||||
int port = AppHandler.Instance.GetLocalPort(EInboundProtocol.http);
|
||||
int portSocks = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
int portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
|
||||
if (port <= 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace v2rayN.Desktop.ViewModels
|
||||
|
||||
public AppViewModel()
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace v2rayN.Desktop.ViewModels
|
||||
|
||||
public ThemeSettingViewModel()
|
||||
{
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
BindingUI();
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace v2rayN.Desktop.Views
|
||||
|
||||
case EConfigType.Shadowsocks:
|
||||
gridSs.IsVisible = true;
|
||||
LazyConfig.Instance.GetShadowsocksSecurities(profileItem).ForEach(it =>
|
||||
AppHandler.Instance.GetShadowsocksSecurities(profileItem).ForEach(it =>
|
||||
{
|
||||
cmbSecurity3.Items.Add(it);
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace v2rayN.Desktop.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
btnCancel.Click += (s, e) => this.Close();
|
||||
ViewModel = new DNSSettingViewModel(UpdateViewHandler);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace v2rayN.Desktop.Views
|
||||
InitializeComponent();
|
||||
|
||||
btnCancel.Click += (s, e) => this.Close();
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
//_config.globalHotkeys ??= new List<KeyEventItem>();
|
||||
|
||||
//txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace v2rayN.Desktop.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.BottomRight };
|
||||
|
||||
//ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace v2rayN.Desktop.Views
|
||||
InitializeComponent();
|
||||
|
||||
btnCancel.Click += (s, e) => this.Close();
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
// var lstFonts = GetFonts(Utils.GetFontsPath());
|
||||
|
||||
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace v2rayN.Desktop.Views
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
_window = window;
|
||||
|
||||
menuSelectAll.Click += menuSelectAll_Click;
|
||||
|
||||
Reference in New Issue
Block a user