diff --git a/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py b/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py index 2d3b488..6352c25 100644 --- a/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py +++ b/usr/lib/python3/dist-packages/webengine/gtk3/_webengine.py @@ -96,6 +96,22 @@ class WebEngine(WebKit2.WebView): Inject(self, env).connect(self.called_by_js) + self.connect('create', self.create_new_window) + + + + + def create_new_window(self, webview, nav): + req = nav.get_request() + w, h = self.window.get_size() + win = Gtk.Window() + web = WebEngine(win) + web.set_settings(self.get_settings()) + web.load_request(req) + win.set_default_size(w, h) + win.add(web) + win.show_all() + def set_root(self, root): self.root = root @@ -147,6 +163,7 @@ class WebEngine(WebKit2.WebView): # 退出app case 'quit': + self.window.close() self.emit('quit') # 读取图片, 返回图片像素数据 @@ -221,8 +238,9 @@ class WebEngine(WebKit2.WebView): match(params.get('action')): case 'access': try: - with open(filepath, params.get('mode')) as file: - output = True + file = open(filepath, params.get('mode')) + file.close() + output = True except Exception as err: output = False diff --git a/usr/lib/python3/dist-packages/webengine/gtk3/inject.js b/usr/lib/python3/dist-packages/webengine/gtk3/inject.js index f7196a0..6147341 100644 --- a/usr/lib/python3/dist-packages/webengine/gtk3/inject.js +++ b/usr/lib/python3/dist-packages/webengine/gtk3/inject.js @@ -208,16 +208,14 @@ Object.assign(native, { return handler('fs', { action: 'write', mode, - append: false, filepath, content }) }, - append(filepath, content = '', mode = 'w') { + append(filepath, content = '', mode = 'a+') { return handler('fs', { action: 'write', mode, - append: true, filepath, content })