(node: TreeNode)
| 897 | }; |
| 898 | |
| 899 | const handleNodeDoubleClick = async (node: TreeNode) => { |
| 900 | if (node.type === 'file') { |
| 901 | // Handle .ecs scene files |
| 902 | const ext = node.name.split('.').pop()?.toLowerCase(); |
| 903 | if (ext === 'ecs' && onOpenScene) { |
| 904 | onOpenScene(node.path); |
| 905 | return; |
| 906 | } |
| 907 | |
| 908 | // 脚本文件使用配置的编辑器打开 |
| 909 | // Open script files with configured editor |
| 910 | if (ext === 'ts' || ext === 'tsx' || ext === 'js' || ext === 'jsx') { |
| 911 | const settings = SettingsService.getInstance(); |
| 912 | const editorCommand = settings.getScriptEditorCommand(); |
| 913 | |
| 914 | if (editorCommand) { |
| 915 | // 使用项目路径,如果没有则使用文件所在目录 |
| 916 | // Use project path, or file's parent directory if not available |
| 917 | const workingDir = rootPath || node.path.substring(0, node.path.lastIndexOf('\\')) || node.path.substring(0, node.path.lastIndexOf('/')); |
| 918 | try { |
| 919 | await TauriAPI.openWithEditor(workingDir, editorCommand, node.path); |
| 920 | return; |
| 921 | } catch (error) { |
| 922 | console.error('Failed to open with editor:', error); |
| 923 | // 如果失败,回退到系统默认应用 |
| 924 | // Fall back to system default app if failed |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | |
| 929 | if (fileActionRegistry) { |
| 930 | const handled = await fileActionRegistry.handleDoubleClick(node.path); |
| 931 | if (handled) { |
| 932 | return; |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | try { |
| 937 | await TauriAPI.openFileWithSystemApp(node.path); |
| 938 | } catch (error) { |
| 939 | console.error('Failed to open file:', error); |
| 940 | } |
| 941 | } |
| 942 | }; |
| 943 | |
| 944 | const handleContextMenu = (e: React.MouseEvent, node: TreeNode | null) => { |
| 945 | e.preventDefault(); |
no test coverage detected