修复fs模式错误; 增加window.open的支持
parent
fe56af2292
commit
8822c8effd
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue