@@ -58,6 +58,7 @@ public class WebpagePanel : UserControl
5858 private FileInfo _activeFileInfo = null ;
5959 private CoreWebView2Environment _webViewEnvironment ;
6060 private bool DetectEncoding = false ;
61+ private static bool firstPreview = true ;
6162
6263 public WebpagePanel ( )
6364 {
@@ -257,19 +258,6 @@ private void CoreWebView2InitializationCompleted(object sender, EventArgs e)
257258 _webView . CoreWebView2 . FrameNavigationStarting += FrameNavigationStarting ;
258259 _webView . CoreWebView2 . Settings . AreDefaultScriptDialogsEnabled = false ;
259260 _webView . CoreWebView2 . Settings . AreHostObjectsAllowed = false ;
260- _webView . CoreWebView2 . Profile . ClearBrowsingDataAsync (
261- CoreWebView2BrowsingDataKinds . FileSystems |
262- CoreWebView2BrowsingDataKinds . IndexedDb |
263- // keep local storage
264- CoreWebView2BrowsingDataKinds . WebSql |
265- CoreWebView2BrowsingDataKinds . CacheStorage |
266- CoreWebView2BrowsingDataKinds . Cookies |
267- CoreWebView2BrowsingDataKinds . DiskCache |
268- CoreWebView2BrowsingDataKinds . DownloadHistory |
269- CoreWebView2BrowsingDataKinds . GeneralAutofill |
270- CoreWebView2BrowsingDataKinds . PasswordAutosave |
271- CoreWebView2BrowsingDataKinds . Settings
272- ) ;
273261
274262 // 3 places to get web app:
275263 // 1. a url via WebAppUrl (e.g. locally hosted vite dev version of app)
@@ -281,20 +269,20 @@ private void CoreWebView2InitializationCompleted(object sender, EventArgs e)
281269 var webAppUrl = SettingHelper . Get < string > ( "WebAppUrl" , null , "QuickLook.Plugin.WebViewPlus" ) ;
282270 if ( webAppUrl != null )
283271 {
284- ProcessHelper . WriteLog ( $ "QuickLook.Plugin.WebViewPlus using app via custom url: { webAppUrl } ") ;
272+ // ProcessHelper.WriteLog($"QuickLook.Plugin.WebViewPlus using app via custom url: {webAppUrl}");
285273 uri = new Uri ( webAppUrl ) ;
286274 }
287275 else
288276 {
289277 // map webviewplus folder to a private virtual hostname
290278 if ( File . Exists ( Path . Combine ( webAppInConfigFolder , "index.html" ) ) )
291279 {
292- ProcessHelper . WriteLog ( "QuickLook.Plugin.WebViewPlus using app from config" ) ;
280+ // ProcessHelper.WriteLog("QuickLook.Plugin.WebViewPlus using app from config");
293281 _webView . CoreWebView2 . SetVirtualHostNameToFolderMapping ( "webviewplus.mooflu.com" , webAppInConfigFolder , CoreWebView2HostResourceAccessKind . Allow ) ;
294282 }
295283 else if ( File . Exists ( Path . Combine ( webAppInBundledFolder , "index.html" ) ) )
296284 {
297- ProcessHelper . WriteLog ( "QuickLook.Plugin.WebViewPlus using app from plugin" ) ;
285+ // ProcessHelper.WriteLog("QuickLook.Plugin.WebViewPlus using app from plugin");
298286 _webView . CoreWebView2 . SetVirtualHostNameToFolderMapping ( "webviewplus.mooflu.com" , webAppInBundledFolder , CoreWebView2HostResourceAccessKind . Allow ) ;
299287 }
300288 }
@@ -343,6 +331,24 @@ public void UnloadData()
343331
344332 public void Dispose ( )
345333 {
334+ if ( firstPreview )
335+ {
336+ firstPreview = false ;
337+ _webView . CoreWebView2 . Profile . ClearBrowsingDataAsync (
338+ CoreWebView2BrowsingDataKinds . FileSystems |
339+ CoreWebView2BrowsingDataKinds . IndexedDb |
340+ // keep local storage
341+ CoreWebView2BrowsingDataKinds . WebSql |
342+ CoreWebView2BrowsingDataKinds . CacheStorage |
343+ CoreWebView2BrowsingDataKinds . Cookies |
344+ CoreWebView2BrowsingDataKinds . DiskCache |
345+ CoreWebView2BrowsingDataKinds . DownloadHistory |
346+ CoreWebView2BrowsingDataKinds . GeneralAutofill |
347+ CoreWebView2BrowsingDataKinds . PasswordAutosave |
348+ CoreWebView2BrowsingDataKinds . Settings
349+ ) ;
350+ }
351+
346352 _activeFileInfo = null ;
347353 _sharedBuffer ? . Dispose ( ) ;
348354 _sharedBuffer = null ;
0 commit comments