mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 11:59:13 +00:00
Optimization and improvement
This commit is contained in:
parent
0377e7ce19
commit
e96a4818c4
5 changed files with 9 additions and 9 deletions
|
@ -11,6 +11,9 @@ namespace ServiceLib.ViewModels;
|
|||
|
||||
public class StatusBarViewModel : MyReactiveObject
|
||||
{
|
||||
private static readonly Lazy<StatusBarViewModel> _instance = new(() => new(null));
|
||||
public static StatusBarViewModel Instance => _instance.Value;
|
||||
|
||||
#region ObservableCollection
|
||||
|
||||
public IObservableCollection<RoutingItem> RoutingItems { get; } = new ObservableCollectionExtended<RoutingItem>();
|
||||
|
|
|
@ -16,9 +16,7 @@ public partial class App : Application
|
|||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
|
||||
|
||||
var ViewModel = new StatusBarViewModel(null);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||
DataContext = ViewModel;
|
||||
DataContext = StatusBarViewModel.Instance;
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace v2rayN.Desktop.Views;
|
|||
public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
{
|
||||
private static Config _config;
|
||||
private WindowNotificationManager? _manager;
|
||||
private readonly WindowNotificationManager? _manager;
|
||||
private CheckUpdateView? _checkUpdateView;
|
||||
private BackupAndRestoreView? _backupAndRestoreView;
|
||||
private bool _blCloseByUser = false;
|
||||
|
|
|
@ -6,7 +6,6 @@ using Avalonia.ReactiveUI;
|
|||
using Avalonia.Threading;
|
||||
using DialogHostAvalonia;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
using v2rayN.Desktop.Common;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
|
@ -20,9 +19,8 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
|||
InitializeComponent();
|
||||
|
||||
_config = AppManager.Instance.Config;
|
||||
//ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
||||
//Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||
ViewModel = Locator.Current.GetService<StatusBarViewModel>();
|
||||
|
||||
ViewModel = StatusBarViewModel.Instance;
|
||||
ViewModel?.InitUpdateView(UpdateViewHandler);
|
||||
|
||||
txtRunningServerDisplay.Tapped += TxtRunningServerDisplay_Tapped;
|
||||
|
|
|
@ -15,7 +15,8 @@ public partial class StatusBarView
|
|||
{
|
||||
InitializeComponent();
|
||||
_config = AppManager.Instance.Config;
|
||||
ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
||||
ViewModel = StatusBarViewModel.Instance;
|
||||
ViewModel?.InitUpdateView(UpdateViewHandler);
|
||||
|
||||
menuExit.Click += menuExit_Click;
|
||||
txtRunningServerDisplay.PreviewMouseDown += txtRunningInfoDisplay_MouseDoubleClick;
|
||||
|
|
Loading…
Reference in a new issue