feat: v0.3.0 版本 - SSH终端、SFTP、端口转发功能实现
核心功能: - SSH终端: 密码/密钥认证、XTerm.js终端、多主题配色、IP高亮 - SFTP管理: 双栏文件管理、上传下载、传输队列 - 端口转发: 本地/远程转发、SOCKS5动态代理、规则管理 架构改进: - 拆分大型组件 (SFTPView/TabBar/Sidebar) - 添加统一日志和错误处理 - 修复React严格模式下的终端黑屏问题 UI更新: - 新增端口转发视图 - 更新UI预览文档 - 左侧栏右键菜单支持SFTP快捷打开
This commit is contained in:
1 parent
cf1c054381
commit
484d850abd
105 files changed
+25330
-64
No files matched your search
@@ -0,0 +1,89 @@
|
||||
// 浏览器环境中模拟 electron API
|
||||
if (typeof window !== 'undefined' && !window.electronAPI) {
|
||||
window.electronAPI = {
|
||||
// SSH 相关
|
||||
sshConnect: async (config) => ({
|
||||
success: true,
|
||||
connectionId: 'mock-' + Date.now()
|
||||
}),
|
||||
sshDisconnect: async () => ({ success: true }),
|
||||
sshExec: async () => ({ success: true, result: '' }),
|
||||
sshCreateShell: async () => ({
|
||||
success: true,
|
||||
shellId: 'shell-' + Date.now()
|
||||
}),
|
||||
sshShellWrite: async () => ({ success: true }),
|
||||
sshShellResize: async () => ({ success: true }),
|
||||
|
||||
// 会话管理
|
||||
sessionGetAll: async () => ({
|
||||
success: true,
|
||||
sessions: [
|
||||
{ id: '1', name: '本地开发服务器', host: '192.168.1.100', port: 22, username: 'root', authType: 'password' },
|
||||
{ id: '2', name: '阿里云生产', host: '47.100.1.1', port: 22, username: 'admin', authType: 'key' },
|
||||
{ id: '3', name: '腾讯云测试', host: '119.29.1.1', port: 2222, username: 'ubuntu', authType: 'password' },
|
||||
]
|
||||
}),
|
||||
sessionGetById: async (id) => ({
|
||||
success: true,
|
||||
session: {
|
||||
id,
|
||||
name: '测试服务器',
|
||||
host: '192.168.1.100',
|
||||
port: 22,
|
||||
username: 'root',
|
||||
authType: 'password'
|
||||
}
|
||||
}),
|
||||
sessionCreate: async (session) => ({
|
||||
success: true,
|
||||
session: { ...session, id: 'new-' + Date.now() }
|
||||
}),
|
||||
sessionUpdate: async (id, updates) => ({
|
||||
success: true,
|
||||
session: { id, ...updates }
|
||||
}),
|
||||
sessionDelete: async () => ({ success: true }),
|
||||
|
||||
// SFTP
|
||||
sftpConnect: async () => ({
|
||||
success: true,
|
||||
sftpId: 'sftp-' + Date.now()
|
||||
}),
|
||||
sftpListDirectory: async () => ({
|
||||
success: true,
|
||||
files: [
|
||||
{ filename: 'documents', longname: 'drwxr-xr-x', attrs: { mode: 16877, size: 4096 } },
|
||||
{ filename: 'file.txt', longname: '-rw-r--r--', attrs: { mode: 33188, size: 1024 } },
|
||||
]
|
||||
}),
|
||||
sftpUpload: async () => ({ success: true }),
|
||||
sftpDownload: async () => ({ success: true }),
|
||||
|
||||
// 端口转发
|
||||
sshForwardLocal: async () => ({ success: true, boundPort: 1080 }),
|
||||
sshForwardRemote: async () => ({ success: true }),
|
||||
sshForwardDynamic: async () => ({ success: true, boundPort: 1080 }),
|
||||
|
||||
// 设置
|
||||
settingsGet: async () => ({ success: true, value: null }),
|
||||
settingsSet: async () => ({ success: true }),
|
||||
|
||||
// 对话框
|
||||
showSaveDialog: async () => ({ canceled: false, filePath: '/mock/path' }),
|
||||
showOpenDialog: async () => ({ canceled: false, filePaths: ['/mock/path'] }),
|
||||
|
||||
// 应用信息
|
||||
getVersion: async () => '1.0.0',
|
||||
|
||||
// 事件监听
|
||||
onMenuNewSession: () => {},
|
||||
onMenuQuickConnect: () => {},
|
||||
onMenuImportSessions: () => {},
|
||||
onMenuExportSessions: () => {},
|
||||
onShellData: () => {},
|
||||
onSFTPProgress: () => {},
|
||||
removeAllListeners: () => {},
|
||||
};
|
||||
console.log('[Mock] electronAPI loaded for browser preview');
|
||||
}
|
||||
Reference in new issue
Block a user