From 6a0c116bd425db7870e2eb2f2fe97382e434cdf1 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 10 Jan 2021 17:18:43 +0100 Subject: [PATCH] Fix WebView2 data path --- QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs | 3 --- .../QuickLook.Plugin.HtmlViewer/WebpagePanel.cs | 8 +++++++- QuickLook/App.xaml.cs | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs index bdd3482..ade50d1 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/Plugin.cs @@ -19,7 +19,6 @@ using System.IO; using System.Linq; using System.Windows; using System.Windows.Threading; -using Microsoft.Web.WebView2.Wpf; using QuickLook.Common.Plugin; namespace QuickLook.Plugin.HtmlViewer @@ -35,8 +34,6 @@ namespace QuickLook.Plugin.HtmlViewer public void Init() { - if (Helper.IsWebView2Available()) - new WebView2().EnsureCoreWebView2Async(); } public bool CanHandle(string path) diff --git a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebpagePanel.cs b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebpagePanel.cs index f98b2bc..fd3c82b 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebpagePanel.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.HtmlViewer/WebpagePanel.cs @@ -39,7 +39,13 @@ namespace QuickLook.Plugin.HtmlViewer } else { - _webView = new WebView2(); + _webView = new WebView2 + { + CreationProperties = new CoreWebView2CreationProperties + { + UserDataFolder = Path.Combine(App.LocalDataPath, @"WebView2_Data\\") + } + }; _webView.NavigationStarting += NavigationStarting_CancelNavigation; Content = _webView; } diff --git a/QuickLook/App.xaml.cs b/QuickLook/App.xaml.cs index fe8ca87..b31a9ee 100644 --- a/QuickLook/App.xaml.cs +++ b/QuickLook/App.xaml.cs @@ -32,6 +32,7 @@ namespace QuickLook /// public partial class App : Application { + public static readonly string LocalDataPath = SettingHelper.LocalDataPath; public static readonly string UserPluginPath = Path.Combine(SettingHelper.LocalDataPath, "QuickLook.Plugin\\"); public static readonly string AppFullPath = Assembly.GetExecutingAssembly().Location; public static readonly string AppPath = Path.GetDirectoryName(AppFullPath);