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

主要更新:
- 后端添加可执行文件检测逻辑,支持脚本、二进制文件和权限检测
- 文件列表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

@@ -104,8 +104,18 @@ wss.on("connection", (ws: WebSocket) => {
credentialId?: number;
userId?: string;
};
initialPath?: string;
executeCommand?: string;
}) {
const { cols, rows, hostConfig } = data;
const { cols, rows, hostConfig, initialPath, executeCommand } = data;
sshLogger.debug("Terminal connection data received", {
operation: "terminal_connect_data",
hasInitialPath: !!initialPath,
initialPath,
hasExecuteCommand: !!executeCommand,
executeCommand
});
const {
id,
ip,
@@ -302,6 +312,34 @@ wss.on("connection", (ws: WebSocket) => {
setupPingInterval();
// Change to initial path if specified
if (initialPath && initialPath.trim() !== "") {
sshLogger.debug(`Changing to initial path: ${initialPath}`, {
operation: "ssh_initial_path",
hostId: id,
path: initialPath,
});
// Send cd command to change directory
const cdCommand = `cd "${initialPath.replace(/"/g, '\\"')}" && pwd\n`;
stream.write(cdCommand);
}
// Execute command if specified
if (executeCommand && executeCommand.trim() !== "") {
sshLogger.debug(`Executing command: ${executeCommand}`, {
operation: "ssh_execute_command",
hostId: id,
command: executeCommand,
});
// Wait a moment for the cd command to complete, then execute the command
setTimeout(() => {
const command = `${executeCommand}\n`;
stream.write(command);
}, 500);
}
ws.send(
JSON.stringify({ type: "connected", message: "SSH connected" }),
);