mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
open default browser for update log content link
This commit is contained in:
@@ -5,7 +5,9 @@ using Microsoft.UI.Windowing;
|
|||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.Web.WebView2.Core;
|
using Microsoft.Web.WebView2.Core;
|
||||||
using Snap.Hutao.Core.Graphics;
|
using Snap.Hutao.Core.Graphics;
|
||||||
|
using System.Diagnostics;
|
||||||
using Windows.Graphics;
|
using Windows.Graphics;
|
||||||
|
using Windows.System;
|
||||||
|
|
||||||
namespace Snap.Hutao.UI.Xaml.View.Window.WebView2;
|
namespace Snap.Hutao.UI.Xaml.View.Window.WebView2;
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ internal sealed class UpdateLogContentProvider : IWebView2ContentProvider
|
|||||||
public ValueTask InitializeAsync(IServiceProvider serviceProvider, CancellationToken token)
|
public ValueTask InitializeAsync(IServiceProvider serviceProvider, CancellationToken token)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(CoreWebView2);
|
ArgumentNullException.ThrowIfNull(CoreWebView2);
|
||||||
|
CoreWebView2.NewWindowRequested += OnNewWindowRequested;
|
||||||
CoreWebView2.Navigate("https://hut.ao/statements/latest.html");
|
CoreWebView2.Navigate("https://hut.ao/statements/latest.html");
|
||||||
return ValueTask.CompletedTask;
|
return ValueTask.CompletedTask;
|
||||||
}
|
}
|
||||||
@@ -70,5 +73,15 @@ internal sealed class UpdateLogContentProvider : IWebView2ContentProvider
|
|||||||
|
|
||||||
public void Unload()
|
public void Unload()
|
||||||
{
|
{
|
||||||
|
if (CoreWebView2 is not null)
|
||||||
|
{
|
||||||
|
CoreWebView2.NewWindowRequested -= OnNewWindowRequested;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNewWindowRequested(object? sender, CoreWebView2NewWindowRequestedEventArgs e)
|
||||||
|
{
|
||||||
|
e.Handled = true;
|
||||||
|
_ = Launcher.LaunchUriAsync(e.Uri.ToUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user