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();
        }
    }
}