This commit is contained in:
恍兮惚兮 2024-07-21 01:09:30 +08:00
parent ce3808b948
commit 010579f20b
2 changed files with 9 additions and 9 deletions

View File

@ -1014,7 +1014,7 @@ class WebivewWidget(abstractwebview):
webview_native_handle_kind_t.WEBVIEW_NATIVE_HANDLE_KIND_UI_WIDGET webview_native_handle_kind_t.WEBVIEW_NATIVE_HANDLE_KIND_UI_WIDGET
) )
def __init__(self, parent=None, debug=True) -> None: def __init__(self, parent=None, debug=True, usedarklight=True) -> None:
super().__init__(parent) super().__init__(parent)
declare_library_path( declare_library_path(
os.path.abspath( os.path.abspath(
@ -1036,13 +1036,13 @@ class WebivewWidget(abstractwebview):
self.keepref = [zoomfunc] self.keepref = [zoomfunc]
self.webview.bind("__on_load", self._on_load) self.webview.bind("__on_load", self._on_load)
self.webview.init("""window.__on_load(window.location.href)""") self.webview.init("""window.__on_load(window.location.href)""")
if usedarklight:
self.__darkstate = None self.__darkstate = None
t = QTimer(self) t = QTimer(self)
t.setInterval(100) t.setInterval(100)
t.timeout.connect(self.__darkstatechecker) t.timeout.connect(self.__darkstatechecker)
t.timeout.emit() t.timeout.emit()
t.start() t.start()
def __darkstatechecker(self): def __darkstatechecker(self):
dl = globalconfig["darklight2"] dl = globalconfig["darklight2"]

View File

@ -46,7 +46,7 @@ class TextBrowser(QWidget, dataget):
self.webivewwidget.on_load.connect(self.__loadextra) self.webivewwidget.on_load.connect(self.__loadextra)
else: else:
# webview2当会执行alert之类的弹窗js时若qt窗口不可视会卡住 # webview2当会执行alert之类的弹窗js时若qt窗口不可视会卡住
self.webivewwidget = WebivewWidget(self) self.webivewwidget = WebivewWidget(self, usedarklight=False)
# webview2无法接收qt事件。 # webview2无法接收qt事件。
webviewhwnd = self.webivewwidget.get_hwnd() webviewhwnd = self.webivewwidget.get_hwnd()