Refactor NoticeHandler

This commit is contained in:
2dust
2024-10-07 10:59:13 +08:00
parent d5c6a42a9a
commit 4ccc7aa92d
37 changed files with 115 additions and 150 deletions

View File

@@ -17,7 +17,6 @@ namespace v2rayN.Desktop.ViewModels
public AppViewModel()
{
_config = AppHandler.Instance.Config;
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
{

View File

@@ -3,7 +3,6 @@ using Avalonia.Controls;
using Avalonia.Styling;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Splat;
using System.Reactive.Linq;
namespace v2rayN.Desktop.ViewModels
@@ -22,7 +21,6 @@ namespace v2rayN.Desktop.ViewModels
public ThemeSettingViewModel()
{
_config = AppHandler.Instance.Config;
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
BindingUI();
RestoreUI();
@@ -75,7 +73,7 @@ namespace v2rayN.Desktop.ViewModels
_config.uiItem.currentLanguage = CurrentLanguage;
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
ConfigHandler.SaveConfig(_config);
_noticeHandler?.Enqueue(ResUI.NeedRebootTips);
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
}
});
}

View File

@@ -2,7 +2,6 @@
using Avalonia.Interactivity;
using Avalonia.ReactiveUI;
using ReactiveUI;
using Splat;
using System.Reactive.Disposables;
using v2rayN.Desktop.Common;
@@ -10,7 +9,6 @@ namespace v2rayN.Desktop.Views
{
public partial class BackupAndRestoreView : ReactiveUserControl<BackupAndRestoreViewModel>
{
private NoticeHandler? _noticeHandler;
private Window _window;
public BackupAndRestoreView(Window window)
@@ -23,7 +21,6 @@ namespace v2rayN.Desktop.Views
ViewModel = new BackupAndRestoreViewModel(UpdateViewHandler);
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables);

View File

@@ -49,7 +49,7 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables);
});
});
}
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View File

@@ -79,7 +79,6 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);

View File

@@ -196,7 +196,7 @@ namespace v2rayN.Desktop.Views
else
{
ViewModel?.EditServerAsync(EConfigType.Custom);
}
}
}
private void LstProfiles_LoadingRow(object? sender, DataGridRowEventArgs e)
@@ -313,6 +313,7 @@ namespace v2rayN.Desktop.Views
ViewModel?.RefreshServers();
}
}
private void MenuStorageUI_Click(object? sender, RoutedEventArgs e)
{
StorageUI();

View File

@@ -12,7 +12,7 @@ namespace v2rayN.Desktop.Views
txtContent.Text = url;
imgQrcode.Source = GetQRCode(url);
// btnCancel.Click += (s, e) => this.Close();
// btnCancel.Click += (s, e) => this.Close();
}
private Bitmap? GetQRCode(string? url)