js注入改为开始时注入, 窗口增加hide和show 2个回调

master
yutent 2023-09-13 14:04:51 +08:00
parent ece744aafe
commit 3062354338
2 changed files with 6 additions and 2 deletions

View File

@ -17,7 +17,7 @@ class Inject:
code = open(self.abspath('./inject.js'), 'r').read()
frame = WebKit2.UserContentInjectedFrames.ALL_FRAMES
time = WebKit2.UserScriptInjectionTime.END
time = WebKit2.UserScriptInjectionTime.START
code = code.replace("'{{env}}'", json.dumps(env))
code = code.replace("{{uuid}}", webview.uuid)

View File

@ -96,7 +96,11 @@ class WebEngine(WebKit2.WebView):
# 允许前端 widnow.close() 关闭窗口
self.connect('close', self.close_window)
win.connect("destroy", self.remove_from_opener) # 通过外部关闭窗口时从父级中移除
# 通过外部关闭窗口时从父级中移除
win.connect("destroy", self.remove_from_opener)
win.connect('hide', lambda w: self.call_js('hide'))
win.connect('show', lambda w: self.call_js('show'))
def remove_from_opener(self, win = None):