This commit is contained in:
熊玮 2024-11-15 15:01:03 +08:00
parent c0ad2ca12a
commit e3e26b2b6c

View File

@ -1,4 +1,5 @@
using Avalonia.Controls; using System;
using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Avalonia.Platform; using Avalonia.Platform;
using detect.gui.Services; using detect.gui.Services;
@ -26,19 +27,20 @@ public partial class WebBrowserWindow : Window
Topmost = true; Topmost = true;
CanResize = false; CanResize = false;
Opened += (sender, args) => }
{
var service = Locator.Current.GetService<DeviceClientService>();
if (WebView != null)
{
WebView.RegisterJavascriptObject("DeviceClientService", service);
}
else
{
Log.Warning("WebView is null!");
}
}; protected override void OnOpened(EventArgs e)
{
base.OnOpened(e);
var service = Locator.Current.GetService<DeviceClientService>();
if (WebView != null)
{
WebView.RegisterJavascriptObject("DeviceClientService", service);
}
else
{
Log.Warning("WebView is null!");
}
} }
private void InitializeComponent() private void InitializeComponent()