内容目录
The source code has been studied for a long time, and its operating mechanism has been discovered. If the page that BlazorWebView navigates to is not https://0.0.0.0, then it will open the page in a browser outside the client.
// The URLs here are allowed to be opened in the browser
public static readonly Uri[] URLS = new Uri[]
{
new Uri("https://open.feishu.cn")
};
this.webView.BlazorWebViewInitializing += (s, e) =>
{
this.webView.WebView.CoreWebView2InitializationCompleted += (s, e) =>
{
this.webView.UrlLoading += (s, e) =>
{
foreach (var item in URLS)
{
if (e.Url.IsBaseOf(item)|| e.Url.ToString().StartsWith(item.ToString()))
{
// Set loading strategy
e.UrlLoadingStrategy = UrlLoadingStrategy.OpenInWebView;
break;
}
}
};
};
};
Then navigate to open:
WebView.CoreWebView2.Navigate(url)
文章评论