From 8444a2b22fc3f322ff2b2bfe0a8dbf283f5fe7c3 Mon Sep 17 00:00:00 2001 From: hbl917070 Date: Fri, 20 Dec 2024 02:39:37 +0800 Subject: [PATCH] Attempt to fix issue where the application cannot open on some computers --- Tiefsee/WebWindow.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Tiefsee/WebWindow.cs b/Tiefsee/WebWindow.cs index 58f15b4..763755c 100644 --- a/Tiefsee/WebWindow.cs +++ b/Tiefsee/WebWindow.cs @@ -301,16 +301,17 @@ public class AppInfo { /// 取得 CoreWebView2Environment /// public static async Task GetCoreWebView2Environment() { - if (_webView2Environment == null) { - // --disable-web-security 允許跨域請求 - // --disable-features=msWebOOUI,msPdfOOUI 禁止迷你選單 - // --user-agent 覆寫userAgent - // --enable-features=msWebView2EnableDraggableRegions 讓 webview2 支援 css「app-region:drag」 - string webvviewArguments = "--disable-web-security"; - var opts = new CoreWebView2EnvironmentOptions { AdditionalBrowserArguments = webvviewArguments }; - _webView2Environment = await CoreWebView2Environment.CreateAsync(null, AppPath.appData, opts); - } - return _webView2Environment; + // if (_webView2Environment == null) { + // --disable-web-security 允許跨域請求 + // --disable-features=msWebOOUI,msPdfOOUI 禁止迷你選單 + // --user-agent 覆寫userAgent + // --enable-features=msWebView2EnableDraggableRegions 讓 webview2 支援 css「app-region:drag」 + string webvviewArguments = "--disable-web-security " + + "--enable-features=msWebView2EnableDraggableRegions"; + var opts = new CoreWebView2EnvironmentOptions { AdditionalBrowserArguments = webvviewArguments }; + var webView2Environment = await CoreWebView2Environment.CreateAsync(null, AppPath.appData, opts); + // } + return webView2Environment; } /// @@ -375,7 +376,7 @@ public async Task Init() { // 覆寫 userAgent。用於在請求 API 時,辨識身份是否合法 _wv2.CoreWebView2.Settings.UserAgent = _wv2.CoreWebView2.Settings.UserAgent + " " + Program.webvviewUserAgent; // 讓 webview2 支援 css「app - region:drag」 - _wv2.CoreWebView2.Settings.IsNonClientRegionSupportEnabled = true; + // _wv2.CoreWebView2.Settings.IsNonClientRegionSupportEnabled = true; // 觸摸輸入的設備上使用捏合運動在 WebView2 中縮放 Web 內容 // _wv2.CoreWebView2.Settings.IsPinchZoomEnabled = false; // 是否啟用特定於瀏覽器的快速鍵