Fix ScriptMessageHandler invalidation after RemoveAllUserScripts on Windows. (#13829)

This commit is contained in:
anjis
2026-05-27 22:59:43 +08:00
committed by GitHub
parent 5b071d5013
commit 9c63aee9f8

View File

@@ -242,6 +242,14 @@ void PrinterWebView::SendAPIKey()
)",
m_apikey);
m_browser->RemoveAllUserScripts();
#ifdef _WIN32
// RemoveAllUserScripts causes WebView2 to forget about our script message handler,
// so re-add it here.
m_browser->RemoveScriptMessageHandler("wx");
m_browser->AddScriptMessageHandler("wx");
#endif
#ifdef __linux__
// Re-inject the vue-resize/WebKitGTK workaround that RemoveAllUserScripts just cleared.
inject_vue_resize_workaround(m_browser);