Optimization and improvement, using event subscribers

This commit is contained in:
2dust
2025-09-24 10:57:06 +08:00
parent e96a4818c4
commit 671678724b
10 changed files with 95 additions and 97 deletions

View File

@@ -1,8 +1,7 @@
using System.Reactive;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Splat;
using v2rayN.Desktop.Common;
using v2rayN.Desktop.Views;
namespace v2rayN.Desktop;
@@ -55,16 +54,8 @@ public partial class App : Application
{
if (desktop.MainWindow != null)
{
var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
if (clipboardData.IsNullOrEmpty())
{
return;
}
var service = Locator.Current.GetService<MainWindowViewModel>();
if (service != null)
{
_ = service.AddServerViaClipboardAsync(clipboardData);
}
AppEvents.AddServerViaClipboardRequested.OnNext(Unit.Default);
await Task.Delay(1000);
}
}
}