实现可执行文件检测和运行功能:支持终端集成和右键菜单操作

主要更新:
- 后端添加可执行文件检测逻辑,支持脚本、二进制文件和权限检测
- 文件列表API返回executable字段标识可执行文件
- 右键菜单新增"打开终端"和"运行"功能
- 终端组件支持初始路径和自动执行命令
- 创建TerminalWindow组件提供完整窗口体验
- 运行功能通过终端执行,支持实时输出和交互

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZcR
2025-09-17 01:17:00 +08:00
parent e0e4e69159
commit f70a2102db
7 changed files with 428 additions and 6 deletions

View File

@@ -0,0 +1,99 @@
import React from 'react';
import { DraggableWindow } from './DraggableWindow';
import { Terminal } from '../../Terminal/Terminal';
import { useWindowManager } from './WindowManager';
interface SSHHost {
id: number;
name: string;
ip: string;
port: number;
username: string;
password?: string;
key?: string;
keyPassword?: string;
authType: 'password' | 'key';
credentialId?: number;
userId?: number;
}
interface TerminalWindowProps {
windowId: string;
hostConfig: SSHHost;
initialPath?: string;
initialX?: number;
initialY?: number;
executeCommand?: string;
}
export function TerminalWindow({
windowId,
hostConfig,
initialPath,
initialX = 200,
initialY = 150,
executeCommand
}: TerminalWindowProps) {
console.log('TerminalWindow props:', {
windowId,
initialPath,
executeCommand,
hasExecuteCommand: !!executeCommand
});
const { closeWindow, minimizeWindow, maximizeWindow, focusWindow, windows } = useWindowManager();
// 获取当前窗口状态
const currentWindow = windows.find(w => w.id === windowId);
if (!currentWindow) {
console.warn(`Window with id ${windowId} not found`);
return null;
}
const handleClose = () => {
closeWindow(windowId);
};
const handleMinimize = () => {
minimizeWindow(windowId);
};
const handleMaximize = () => {
maximizeWindow(windowId);
};
const handleFocus = () => {
focusWindow(windowId);
};
const terminalTitle = executeCommand
? `运行 - ${hostConfig.name}:${executeCommand}`
: initialPath
? `终端 - ${hostConfig.name}:${initialPath}`
: `终端 - ${hostConfig.name}`;
return (
<DraggableWindow
title={terminalTitle}
initialX={initialX}
initialY={initialY}
initialWidth={800}
initialHeight={500}
minWidth={600}
minHeight={400}
onClose={handleClose}
onMinimize={handleMinimize}
onMaximize={handleMaximize}
onFocus={handleFocus}
isMaximized={currentWindow.isMaximized}
zIndex={currentWindow.zIndex}
>
<Terminal
hostConfig={hostConfig}
isVisible={!currentWindow.isMinimized}
initialPath={initialPath}
executeCommand={executeCommand}
onClose={handleClose}
/>
</DraggableWindow>
);
}