feat(renderer): platform-gated dual renderer backend with isolated QtWebEngine profiles

Windows prefers WebView2, Linux uses QtWebEngine only; pythonnet deps are win32-marked. Each QtWebEngine instance gets its own profile under data/webengine, and Chromium flags are sanitized before QApplication (--no-sandbox accepted only for explicit root/container use).
This commit is contained in:
2026-09-17 16:40:03 +08:00
parent 342e53df02
commit 554be4f92b
6 changed files with 445 additions and 6 deletions
+14 -3
View File
@@ -1,4 +1,4 @@
from PyQt6.QtWebEngineCore import QWebEnginePage, QWebEngineScript
from PyQt6.QtWebEngineCore import QWebEnginePage, QWebEngineScript, QWebEngineProfile
from PyQt6.QtCore import QUrl
from PyQt6.QtGui import QDesktopServices
@@ -10,8 +10,19 @@ class CustomWebPage(QWebEnginePage):
2. 禁用 Ctrl/Meta + 滚轮 及 Ctrl + +/-/0 快捷键的页面缩放
(浏览器式缩放对桌面聊天工具无意义且易误触)。
"""
def __init__(self, parent=None):
super().__init__(parent)
def __init__(self, profile_or_parent=None, parent=None):
# P1-03:兼容两种调用 —— 新式 CustomWebPage(profile, parent) 与旧式 CustomWebPage(parent)。
# profile 缺省 None → QtWebEngine 默认 profilemain_window 传入本实例独立 profile。
if isinstance(profile_or_parent, QWebEngineProfile):
profile, par = profile_or_parent, parent
else:
profile, par = None, profile_or_parent
if parent is not None:
raise TypeError("CustomWebPage(profile, parent) 或 CustomWebPage(parent)")
if profile is not None:
super().__init__(profile, par)
else:
super().__init__(par)
self._inject_zoom_lock()
def _inject_zoom_lock(self):