@@ -58,6 +58,7 @@ public class WebpagePanel : UserControl
58
58
private FileInfo _activeFileInfo = null ;
59
59
private CoreWebView2Environment _webViewEnvironment ;
60
60
private bool DetectEncoding = false ;
61
+ private static bool firstPreview = true ;
61
62
62
63
public WebpagePanel ( )
63
64
{
@@ -257,19 +258,6 @@ private void CoreWebView2InitializationCompleted(object sender, EventArgs e)
257
258
_webView . CoreWebView2 . FrameNavigationStarting += FrameNavigationStarting ;
258
259
_webView . CoreWebView2 . Settings . AreDefaultScriptDialogsEnabled = false ;
259
260
_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
- ) ;
273
261
274
262
// 3 places to get web app:
275
263
// 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)
281
269
var webAppUrl = SettingHelper . Get < string > ( "WebAppUrl" , null , "QuickLook.Plugin.WebViewPlus" ) ;
282
270
if ( webAppUrl != null )
283
271
{
284
- ProcessHelper . WriteLog ( $ "QuickLook.Plugin.WebViewPlus using app via custom url: { webAppUrl } ") ;
272
+ // ProcessHelper.WriteLog($"QuickLook.Plugin.WebViewPlus using app via custom url: {webAppUrl}");
285
273
uri = new Uri ( webAppUrl ) ;
286
274
}
287
275
else
288
276
{
289
277
// map webviewplus folder to a private virtual hostname
290
278
if ( File . Exists ( Path . Combine ( webAppInConfigFolder , "index.html" ) ) )
291
279
{
292
- ProcessHelper . WriteLog ( "QuickLook.Plugin.WebViewPlus using app from config" ) ;
280
+ // ProcessHelper.WriteLog("QuickLook.Plugin.WebViewPlus using app from config");
293
281
_webView . CoreWebView2 . SetVirtualHostNameToFolderMapping ( "webviewplus.mooflu.com" , webAppInConfigFolder , CoreWebView2HostResourceAccessKind . Allow ) ;
294
282
}
295
283
else if ( File . Exists ( Path . Combine ( webAppInBundledFolder , "index.html" ) ) )
296
284
{
297
- ProcessHelper . WriteLog ( "QuickLook.Plugin.WebViewPlus using app from plugin" ) ;
285
+ // ProcessHelper.WriteLog("QuickLook.Plugin.WebViewPlus using app from plugin");
298
286
_webView . CoreWebView2 . SetVirtualHostNameToFolderMapping ( "webviewplus.mooflu.com" , webAppInBundledFolder , CoreWebView2HostResourceAccessKind . Allow ) ;
299
287
}
300
288
}
@@ -343,6 +331,24 @@ public void UnloadData()
343
331
344
332
public void Dispose ( )
345
333
{
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
+
346
352
_activeFileInfo = null ;
347
353
_sharedBuffer ? . Dispose ( ) ;
348
354
_sharedBuffer = null ;
0 commit comments