Private
Public Access
1
0

新增:SFTP直连+连接池+autoConnect+文件服务器端口自动回退

- SFTP模块:连接/断开/文件CRUD/系统信息采集/base64二进制写入
- 连接池:多服务器同时在线,瞬间切换profile
- autoConnect:启动时自动连接所有非本地服务器
- 端口自动回退:listenWithFallback消除TOCTOU,解决端口冲突崩溃
- 文件服务器URL集中管理:file-server.ts消除8+处硬编码端口
- Sidebar设置面板:添加服务器/自动连接/自动刷新开关
- 修复:validateFilePath越界panic、正则预编译
- 修复:注释准确性(RemoveAll/端口8073/动态端口文档)
This commit is contained in:
2026-05-04 15:33:19 +08:00
parent 6eaaa56eb6
commit 6bee55b96f
41 changed files with 2620 additions and 458 deletions

View File

@@ -55,6 +55,10 @@ export function CreateFile(path: string): $CancellablePromise<filesystem$0.FileO
});
}
export function DeleteConnectionProfile(id: number): $CancellablePromise<void> {
return $Call.ByID(2675016907, id);
}
/**
* DeletePath 删除文件或目录
*/
@@ -198,6 +202,12 @@ export function GetFileServerURL(): $CancellablePromise<string> {
return $Call.ByID(4117667287);
}
export function GetLocalSystemInfo(): $CancellablePromise<{ [_ in string]?: any }> {
return $Call.ByID(2203542363).then(($result: any) => {
return $$createType0($result);
});
}
/**
* GetMemoryInfo 获取内存信息
*/
@@ -279,6 +289,12 @@ export function ListZipContents(zipPath: string): $CancellablePromise<{ [_ in st
});
}
export function LoadConnectionProfiles(): $CancellablePromise<{ [_ in string]?: any }[]> {
return $Call.ByID(454364767).then(($result: any) => {
return $$createType3($result);
});
}
/**
* OpenPath 使用系统默认程序打开文件或目录
*/
@@ -341,6 +357,12 @@ export function SaveBase64File(req: $models.SaveBase64FileRequest): $Cancellable
return $Call.ByID(1355120553, req);
}
export function SaveConnectionProfile(req: $models.SaveProfileRequest): $CancellablePromise<{ [_ in string]?: any }> {
return $Call.ByID(3622685069, req).then(($result: any) => {
return $$createType0($result);
});
}
/**
* SelectPDFSaveDirectory 选择PDF保存目录
*/
@@ -371,6 +393,120 @@ export function SetWindowTitleBarColor(color: number, isDark: boolean): $Cancell
return $Call.ByID(1570627619, color, isDark);
}
/**
* SftpConnect 建立 SFTP 连接,返回连接标识符 connID
*/
export function SftpConnect(req: $models.SftpConnectRequest): $CancellablePromise<string> {
return $Call.ByID(2742828454, req);
}
/**
* SftpCreateDir SFTP 创建目录
*/
export function SftpCreateDir(connID: string, dirPath: string): $CancellablePromise<filesystem$0.FileOperationResult | null> {
return $Call.ByID(586600875, connID, dirPath).then(($result: any) => {
return $$createType2($result);
});
}
/**
* SftpCreateFile SFTP 创建文件
*/
export function SftpCreateFile(connID: string, filePath: string): $CancellablePromise<filesystem$0.FileOperationResult | null> {
return $Call.ByID(623026146, connID, filePath).then(($result: any) => {
return $$createType2($result);
});
}
/**
* SftpDeletePath SFTP 删除文件或目录
*/
export function SftpDeletePath(connID: string, filePath: string): $CancellablePromise<filesystem$0.FileOperationResult | null> {
return $Call.ByID(1833619836, connID, filePath).then(($result: any) => {
return $$createType2($result);
});
}
/**
* SftpDisconnect 断开 SFTP 连接
*/
export function SftpDisconnect(connID: string): $CancellablePromise<void> {
return $Call.ByID(597628874, connID);
}
/**
* SftpDownloadToTemp 下载远程文件到本地临时目录(用于预览)
*/
export function SftpDownloadToTemp(connID: string, remotePath: string): $CancellablePromise<string> {
return $Call.ByID(1159267603, connID, remotePath);
}
/**
* SftpGetCommonPaths 获取 SFTP 远程主机常用路径
*/
export function SftpGetCommonPaths(connID: string): $CancellablePromise<{ [_ in string]?: string }> {
return $Call.ByID(2874386183, connID).then(($result: any) => {
return $$createType4($result);
});
}
/**
* SftpGetFileInfo SFTP 获取文件信息
*/
export function SftpGetFileInfo(connID: string, filePath: string): $CancellablePromise<{ [_ in string]?: any }> {
return $Call.ByID(1959840482, connID, filePath).then(($result: any) => {
return $$createType0($result);
});
}
/**
* SftpGetSystemInfo 获取 SFTP 远程主机系统信息CPU/内存/磁盘)
*/
export function SftpGetSystemInfo(connID: string): $CancellablePromise<{ [_ in string]?: any }> {
return $Call.ByID(1950143653, connID).then(($result: any) => {
return $$createType0($result);
});
}
/**
* SftpListDir SFTP 列出目录
*/
export function SftpListDir(connID: string, dirPath: string): $CancellablePromise<{ [_ in string]?: any }[]> {
return $Call.ByID(2061863855, connID, dirPath).then(($result: any) => {
return $$createType3($result);
});
}
/**
* SftpReadFile SFTP 读取文件内容
*/
export function SftpReadFile(connID: string, filePath: string): $CancellablePromise<string> {
return $Call.ByID(3068590994, connID, filePath);
}
/**
* SftpRenamePath SFTP 重命名文件或目录
*/
export function SftpRenamePath(req: $models.SftpRenamePathRequest): $CancellablePromise<filesystem$0.FileOperationResult | null> {
return $Call.ByID(183173937, req).then(($result: any) => {
return $$createType2($result);
});
}
/**
* SftpWriteBase64File SFTP 写入 base64 编码的二进制文件(粘贴图片等)
*/
export function SftpWriteBase64File(sessionID: string, filePath: string, base64Content: string): $CancellablePromise<void> {
return $Call.ByID(139141998, sessionID, filePath, base64Content);
}
/**
* SftpWriteFile SFTP 写入文件
*/
export function SftpWriteFile(req: $models.SftpWriteFileRequest): $CancellablePromise<void> {
return $Call.ByID(2401472593, req);
}
/**
* VerifyUpdateFile 验证更新文件哈希值
*/

View File

@@ -10,5 +10,9 @@ export {
RenamePathRequest,
SaveAppConfigRequest,
SaveBase64FileRequest,
SaveProfileRequest,
SftpConnectRequest,
SftpRenamePathRequest,
SftpWriteFileRequest,
WriteFileRequest
} from "./models.js";

View File

@@ -109,6 +109,171 @@ export class SaveBase64FileRequest {
}
}
export class SaveProfileRequest {
"id": number | null;
"name": string;
"host": string;
"port": number;
"username": string;
"password": string;
"key_path": string;
"type": string;
"token": string;
"last_connected": number | null;
/** Creates a new SaveProfileRequest instance. */
constructor($$source: Partial<SaveProfileRequest> = {}) {
if (!("id" in $$source)) {
this["id"] = null;
}
if (!("name" in $$source)) {
this["name"] = "";
}
if (!("host" in $$source)) {
this["host"] = "";
}
if (!("port" in $$source)) {
this["port"] = 0;
}
if (!("username" in $$source)) {
this["username"] = "";
}
if (!("password" in $$source)) {
this["password"] = "";
}
if (!("key_path" in $$source)) {
this["key_path"] = "";
}
if (!("type" in $$source)) {
this["type"] = "";
}
if (!("token" in $$source)) {
this["token"] = "";
}
if (!("last_connected" in $$source)) {
this["last_connected"] = null;
}
Object.assign(this, $$source);
}
/**
* Creates a new SaveProfileRequest instance from a string or object.
*/
static createFrom($$source: any = {}): SaveProfileRequest {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new SaveProfileRequest($$parsedSource as Partial<SaveProfileRequest>);
}
}
/**
* SftpConnectRequest SFTP 连接请求
*/
export class SftpConnectRequest {
"host": string;
"port": number;
"username": string;
"password": string;
"key_path": string;
"key_passphrase": string;
/** Creates a new SftpConnectRequest instance. */
constructor($$source: Partial<SftpConnectRequest> = {}) {
if (!("host" in $$source)) {
this["host"] = "";
}
if (!("port" in $$source)) {
this["port"] = 0;
}
if (!("username" in $$source)) {
this["username"] = "";
}
if (!("password" in $$source)) {
this["password"] = "";
}
if (!("key_path" in $$source)) {
this["key_path"] = "";
}
if (!("key_passphrase" in $$source)) {
this["key_passphrase"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new SftpConnectRequest instance from a string or object.
*/
static createFrom($$source: any = {}): SftpConnectRequest {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new SftpConnectRequest($$parsedSource as Partial<SftpConnectRequest>);
}
}
/**
* SftpRenamePathRequest SFTP 重命名请求
*/
export class SftpRenamePathRequest {
"session_id": string;
"old_path": string;
"new_path": string;
/** Creates a new SftpRenamePathRequest instance. */
constructor($$source: Partial<SftpRenamePathRequest> = {}) {
if (!("session_id" in $$source)) {
this["session_id"] = "";
}
if (!("old_path" in $$source)) {
this["old_path"] = "";
}
if (!("new_path" in $$source)) {
this["new_path"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new SftpRenamePathRequest instance from a string or object.
*/
static createFrom($$source: any = {}): SftpRenamePathRequest {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new SftpRenamePathRequest($$parsedSource as Partial<SftpRenamePathRequest>);
}
}
/**
* SftpWriteFileRequest SFTP 写入请求
*/
export class SftpWriteFileRequest {
"session_id": string;
"path": string;
"content": string;
/** Creates a new SftpWriteFileRequest instance. */
constructor($$source: Partial<SftpWriteFileRequest> = {}) {
if (!("session_id" in $$source)) {
this["session_id"] = "";
}
if (!("path" in $$source)) {
this["path"] = "";
}
if (!("content" in $$source)) {
this["content"] = "";
}
Object.assign(this, $$source);
}
/**
* Creates a new SftpWriteFileRequest instance from a string or object.
*/
static createFrom($$source: any = {}): SftpWriteFileRequest {
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
return new SftpWriteFileRequest($$parsedSource as Partial<SftpWriteFileRequest>);
}
}
/**
* WriteFileRequest 写入文件请求结构体
*/