增加shell操作

master
yutent 2023-09-12 18:55:32 +08:00
parent b398551deb
commit ece744aafe
2 changed files with 27 additions and 1 deletions

View File

@ -3,7 +3,8 @@
# @date 2023/08/08 14:07:26 # @date 2023/08/08 14:07:26
import gi, os, sys, json, shutil, hashlib, random import gi, os, sys, json
import webbrowser, shutil, hashlib, random
gi.require_version('Gtk', '3.0') gi.require_version('Gtk', '3.0')
gi.require_version("WebKit2", "4.1") gi.require_version("WebKit2", "4.1")
@ -288,6 +289,25 @@ class WebEngine(WebKit2.WebView):
return (_error, output) return (_error, output)
def _shell_handler(self, params = {}):
_error = None
output = None
path = params.get('path')
match(params.get('action')):
case 'openExternal':
webbrowser.open(params.get('url'))
case 'showItemInFolder':
os.system(f"xdg-open '{path}'")
case 'openPath':
os.system(f"xdg-open '{path}'")
case 'trashItem':
pass
def _fs_handler(self, params = {}): def _fs_handler(self, params = {}):
_error = None _error = None

View File

@ -241,6 +241,12 @@
return native.env.LANG return native.env.LANG
} }
}, },
shell: {
openExternal(url) {},
showItemInFolder(path) {},
openPath(path) {},
trashItem(path) {}
},
fs: { fs: {
access(filepath, mode = 'r') { access(filepath, mode = 'r') {
return handler('fs', { action: 'access', mode, filepath }) return handler('fs', { action: 'access', mode, filepath })