You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
998 B
33 lines
998 B
1 year ago
|
using Microsoft.Web.WebView2.Core;
|
||
|
using Microsoft.Web.WebView2.Core.DevToolsProtocolExtension;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace BBWYB.Client.Helpers
|
||
|
{
|
||
|
public class CustomWebView2 : Microsoft.Web.WebView2.Wpf.WebView2, IDisposable
|
||
|
{
|
||
|
public CustomWebView2(string folderName = "WebView2UserData")
|
||
|
{
|
||
|
//允许跨域
|
||
|
var op = new CoreWebView2EnvironmentOptions("--disable-web-security")
|
||
|
{
|
||
|
// AreBrowserExtensionsEnabled = true
|
||
|
};
|
||
|
var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: System.IO. Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), folderName)).Result;
|
||
|
EnsureCoreWebView2Async(wb2Setting);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public void DisposeWeb()
|
||
|
{
|
||
|
base.Dispose();
|
||
|
GC.Collect();
|
||
|
}
|
||
|
}
|
||
|
}
|