修复fs模式错误; 增加window.open的支持
parent
fe56af2292
commit
8822c8effd
|
@ -96,6 +96,22 @@ class WebEngine(WebKit2.WebView):
|
||||||
|
|
||||||
Inject(self, env).connect(self.called_by_js)
|
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):
|
def set_root(self, root):
|
||||||
self.root = root
|
self.root = root
|
||||||
|
@ -147,6 +163,7 @@ class WebEngine(WebKit2.WebView):
|
||||||
|
|
||||||
# 退出app
|
# 退出app
|
||||||
case 'quit':
|
case 'quit':
|
||||||
|
self.window.close()
|
||||||
self.emit('quit')
|
self.emit('quit')
|
||||||
|
|
||||||
# 读取图片, 返回图片像素数据
|
# 读取图片, 返回图片像素数据
|
||||||
|
@ -221,8 +238,9 @@ class WebEngine(WebKit2.WebView):
|
||||||
match(params.get('action')):
|
match(params.get('action')):
|
||||||
case 'access':
|
case 'access':
|
||||||
try:
|
try:
|
||||||
with open(filepath, params.get('mode')) as file:
|
file = open(filepath, params.get('mode'))
|
||||||
output = True
|
file.close()
|
||||||
|
output = True
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
output = False
|
output = False
|
||||||
|
|
||||||
|
|
|
@ -208,16 +208,14 @@ Object.assign(native, {
|
||||||
return handler('fs', {
|
return handler('fs', {
|
||||||
action: 'write',
|
action: 'write',
|
||||||
mode,
|
mode,
|
||||||
append: false,
|
|
||||||
filepath,
|
filepath,
|
||||||
content
|
content
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
append(filepath, content = '', mode = 'w') {
|
append(filepath, content = '', mode = 'a+') {
|
||||||
return handler('fs', {
|
return handler('fs', {
|
||||||
action: 'write',
|
action: 'write',
|
||||||
mode,
|
mode,
|
||||||
append: true,
|
|
||||||
filepath,
|
filepath,
|
||||||
content
|
content
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue