-
Notifications
You must be signed in to change notification settings - Fork 0
Data Models
Wenkang Zhu edited this page Aug 10, 2026
·
3 revisions
所有模型 JSON 序列化 camelCase,时间戳为 Unix 毫秒。前后端类型一一对应(Rust serde ↔ TS types)。
{
id: string; // UUID
name: string; // 展示名
host: string; // 主机地址
port: number; // SSH 端口
username: string;
authType: 'Password' | 'PrivateKey';
passwordRef: string | null; // 安全存储引用键,非明文
privateKeyPath: string | null;
passphraseRef: string | null; // 私钥口令引用键
remark: string | null;
}
SaveHostRequest为前端提交形态:额外含password/passphrase明文字段,仅存在于请求中,后端落盘前清除。host.rs模型带#[serde(alias = "auth_type")]等 legacy 兼容。
{
sessionId: string;
hostId: string;
host: string;
port: number;
username: string;
status: 'Connecting' | 'Connected' | 'AuthFailed' | 'Disconnected' | 'Timeout' | 'Error';
createdAt: number; // 毫秒时间戳
}{
sessionId: string;
timestamp: number; // 采集时间
cpuUsage: number; // 0.0 ~ 100.0(/proc/stat 增量计算)
memoryUsage: number; // 0.0 ~ 100.0
diskUsage: number; // 0.0 ~ 100.0(根分区)
diskAvailableBytes: number; // 根分区剩余容量
diskTotalBytes: number; // 根分区总容量
}{
taskId: string;
taskType: string;
sessionId: string | null;
status: 'Pending' | 'Running' | 'Done' | 'Failed';
createdAt: number;
}{
taskId: string; // UUID v4
sessionId: string;
transferType: 'Upload' | 'Download';
remotePath: string;
localPath: string;
fileName: string; // 从路径提取,用于 UI
totalBytes: number;
transferredBytes: number;
speedBps: number;
status: 'Pending' | 'Running' | 'Done' | 'Failed' | 'Cancelled';
errorMessage: string | null; // Failed 时记录原因
createdAt: number;
}{
name: string; // 不含路径
path: string; // 完整绝对路径
isDir: boolean;
size: number; // bytes,目录为 0
modifiedAt: number; // 毫秒时间戳
permissions: string; // 如 "rwxr-xr-x"
}见 API.md:SessionStatusEvent、ConnectionProgressEvent、TerminalDataEvent、SftpProgressEvent、SftpTaskStatusEvent、TaskStatusEvent。
- Rust 侧统一
#[serde(rename_all = "camelCase")] - 旧字段兼容:
#[serde(alias = "snake_case")](host.rs 的 auth_type / password_ref / private_key_path / passphrase_ref) - 校验(proptest 属性测试):毫秒时间戳必须
>= 1_000_000_000_000(2001-09-09);百分比字段0.0~100.0;端口1~65535