功能修复:打开实例文件夹时异常报错

This commit is contained in:
li-xiaochen 2025-02-23 20:28:31 +08:00
parent c94d6d5494
commit f5011e0051
2 changed files with 8 additions and 2 deletions

View file

@ -43,7 +43,6 @@ command_list = {
"pip_tools_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} pip-tools --no-warn-script-location", "pip_tools_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} pip-tools --no-warn-script-location",
"pip_sync": lambda: f"..\\python\\Scripts\\pip-sync -i {mirror_list[config.conf.mirror]} requirements.txt", "pip_sync": lambda: f"..\\python\\Scripts\\pip-sync -i {mirror_list[config.conf.mirror]} requirements.txt",
"webview": lambda instance_path="": f'..\\python\\pythonw -X utf8 webview_ui.py "{instance_path}"', "webview": lambda instance_path="": f'..\\python\\pythonw -X utf8 webview_ui.py "{instance_path}"',
"open_folder": lambda folder_path: f"explorer {folder_path}",
} }
@ -252,3 +251,10 @@ class Api:
def migrate_instances_config(self): def migrate_instances_config(self):
"""迁移多开配置""" """迁移多开配置"""
return manager.migrate_instances_config() return manager.migrate_instances_config()
def open_folder(self, path):
if not os.path.exists(path):
custom_event(LogType.error, f"路径不存在:{path}")
else:
os.startfile(path)
custom_event(LogType.info, f"成功打开文件夹:{path}")

View file

@ -62,7 +62,7 @@ function end_update_instance_name() {
update_instance_name_index.value = null update_instance_name_index.value = null
} }
function open_folder(path) { function open_folder(path) {
pywebview.api.run('open_folder', null, { folder_path: path }) pywebview.api.open_folder(path)
} }
function start_instance(instance) { function start_instance(instance) {
pywebview.api.run('webview', 'mower-ng', { pywebview.api.run('webview', 'mower-ng', {