添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
坏坏的遥控器  ·  使用 Microsoft Edge ...·  2 天前    · 
飞奔的口罩  ·  how to close ...·  2 天前    · 
刚失恋的香蕉  ·  Chrome ...·  昨天    · 
曾深爱过的眼镜  ·  AssemblyName 類別 ...·  1 月前    · 
热心肠的冲锋衣  ·  Failed to activate ...·  9 月前    · 
销魂的水桶  ·  subprocess时报sudo: ...·  1 年前    · 

若要清除 WebView2 应用的用户数据文件夹中的浏览数据并释放空间,请调用清除浏览数据 API 的方法。

清除浏览数据 API 允许以编程方式擦除与 WebView2 用户配置文件关联的 用户数据文件夹中 的数据。 例如,当用户注销时,使用此 API 清除用户数据和历史记录。

可以执行下列操作:

  • 清除所有浏览数据。
  • 清除所选类型的浏览数据。
  • 清除指定时间范围内所选类型的浏览数据。
  • 清除所有浏览数据

    此方法清除数据类型枚举中列出的所有类型的浏览数据,而不管数据创建时间如何。 它清除调用方法的用户配置文件的用户数据文件夹中的数据。

    profile = webView.CoreWebView2.Profile; // Get the current time, the time in which the browsing data will be cleared // until. System.DateTime endTime = DateTime.Now; System.DateTime startTime = DateTime.Now.AddHours(-1); // Offset the current time by one hour to clear the browsing data from the // last hour. CoreWebView2BrowsingDataKinds dataKinds = (CoreWebView2BrowsingDataKinds) (CoreWebView2BrowsingDataKinds.GeneralAutofill | CoreWebView2BrowsingDataKinds.PasswordAutosave); await profile.ClearBrowsingDataAsync(dataKinds, startTime, endTime);
  • CoreWebView2Profile.ClearBrowsingDataAsync (dataKinds、startTime、endTime) 方法
  • CoreWebView2BrowsingDataKinds 枚举
  • wwil::com_ptr<ICoreWebView2> coreWebView2; CHECK_FAILURE(m_controller->get_CoreWebView2(&coreWebView2)); auto webview7 = coreWebView2.try_query<ICoreWebView2_7>(); if (webview7) wil::com_ptr<ICoreWebView2Profile> profile; CHECK_FAILURE(webview7->get_Profile(&profile)); double endTime = (double)std::time(nullptr); double startTime = endTime - 3600; // Get the current time and offset the current time by 3600 seconds to clear // the data from the start time (one hour ago), until the end time (present // time). // This clears the data for the last hour. COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds = (COREWEBVIEW2_BROWSING_DATA_KINDS) (COREWEBVIEW2_BROWSING_DATA_KINDS_GENERAL_AUTOFILL | COREWEBVIEW2_BROWSING_DATA_KINDS_PASSWORD_AUTOSAVE); CHECK_FAILURE(profile->ClearBrowsingDataInTimeRange( dataKinds, startTime, endTime, Callback<ICoreWebView2ClearBrowsingDataCompletedHandler>( [this](HRESULT error) -> HRESULT { return S_OK; .Get()));
  • ICoreWebView2Profile::ClearBrowsingDataInTimeRange (dataKinds、startTime、endTime) 方法
  • COREWEBVIEW2_BROWSING_DATA_KINDS枚举
  • ICoreWebView2ClearBrowsingDataCompletedHandler 接口
  • CoreWebView2.Profile 属性
  • CoreWebView2Profile 类
  • CoreWebView2Profile.ClearBrowsingDataAsync () 方法
  • CoreWebView2Profile.ClearBrowsingDataAsync (dataKinds) 方法
  • CoreWebView2Profile.ClearBrowsingDataAsync (dataKinds、startTime、endTime) 方法
  • CoreWebView2BrowsingDataKinds 枚举
  • ICoreWebView2Profile::ClearBrowsingDataAll () 方法
  • ICoreWebView2Profile::ClearBrowsingData (dataKinds) 方法
  • ICoreWebView2Profile::ClearBrowsingDataInTimeRange (dataKinds、startTime、endTime) 方法
  • COREWEBVIEW2_BROWSING_DATA_KINDS枚举
  • ICoreWebView2ClearBrowsingDataCompletedHandler 接口
  •