Files
opsxshell/shared/types/session.types.ts
T
Logan.Li b0d0e3a5f3 feat(i18n): add multi-language support (ja/ko/vi/ru/zh-TW) with system auto-detection
- Extend AppLanguage to 7 locales: zh-CN, zh-TW, en, ja, ko, vi, ru
- Auto-detect system language via navigator.languages; fallback to English
- Add BCP47 locale mapping for date formatting and sorting
- Create 50 translation JSON files (5 languages × 10 namespaces, 1137 keys each)
- Update language selector with native language names
- Extend locale key parity test to cover all 7 languages (70 assertions)
- Add VNC/RDP desktop, serial terminal, AI agent, port forwarding, and SFTP features
- Add credential encryption, host metrics, session backup crypto, and zmodem bridge
- Update Rust backend: desktop services, host metrics, SSH/SFTP enhancements
2026-08-12 00:07:48 +08:00

136 lines
3.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Session Types - 统一的会话类型定义
* 在主进程和渲染进程间共享
*/
// 认证方式
export type AuthType = 'password' | 'key' | 'agent'
/** Persisted session protocol. Missing/undefined means SSH (legacy rows). */
export type SessionProtocol = 'ssh' | 'rdp' | 'vnc'
// 代理类型
export type ProxyType = 'none' | 'http' | 'socks5'
// 代理配置
export interface ProxyConfig {
type: ProxyType
host: string
port: number
username?: string
password?: string
}
/** Jump host / bastion credentials (ProxyJump-style) */
export interface JumpHostConfig {
host: string
port?: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
/** Optional proxy used only when reaching the jump host */
proxy?: ProxyConfig
}
// 会话配置 (用于快速连接)
export interface SSHConnectionConfig {
host: string
port: number
username: string
password?: string
privateKey?: string
passphrase?: string
authType?: AuthType
proxy?: ProxyConfig
/** 连接成功后自动发送到 shell 的命令(可含片段变量) */
startupCommand?: string
/** 单跳板(兼容);多跳请用 jumpHosts */
jumpHost?: JumpHostConfig
/** 有序跳板链:第一跳 → … → 最后一跳 → 目标 */
jumpHosts?: JumpHostConfig[]
/** TCP connect and SSH handshake timeout in seconds. */
timeoutSeconds?: number
/** Enable SSH protocol keepalive for this connection. */
keepAlive?: boolean
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链(优先于 jumpSessionId) */
jumpSessionIds?: string[]
}
// 持久化会话
export interface Session {
id: string
name: string
host: string
port: number
username: string
authType: AuthType
/** Defaults to ssh when omitted (legacy sessions). */
protocol?: SessionProtocol
password?: string // 加密存储
/** 私钥路径或 PEM 正文;落盘时由 Rust 加密 */
privateKey?: string
passphrase?: string // 私钥密码(加密存储)
proxy?: ProxyConfig // 代理配置
/** 连接成功后自动执行的启动命令 */
startupCommand?: string
/** 单跳板会话 ID(兼容) */
jumpSessionId?: string
/** 有序跳板会话 ID 链 JSON 持久化 */
jumpSessionIds?: string[]
/** 内联单跳板(兼容) */
jumpHost?: JumpHostConfig
/** 内联多跳板链 */
jumpHosts?: JumpHostConfig[]
/** RDP domain (optional). */
domain?: string
/** RDP security mode. */
security?: 'nla' | 'tls' | 'rdp' | 'auto'
/** Desktop resolution hint (RDP/VNC). */
width?: number
height?: number
/**
* Detected or manual remote OS / distro icon id
* (ubuntu, debian, windows, vnc, linux, …).
*/
distro?: string
/** Human-readable OS from PRETTY_NAME (e.g. Ubuntu 24.04.4 LTS). */
osPrettyName?: string
group?: string
tags?: string[]
createdAt?: number
updatedAt?: number
}
// 会话创建请求
export interface SessionCreateRequest {
name: string
host: string
port: number
username: string
authType: AuthType
protocol?: SessionProtocol
password?: string
privateKey?: string
passphrase?: string
proxy?: ProxyConfig
startupCommand?: string
jumpSessionId?: string
jumpSessionIds?: string[]
jumpHost?: JumpHostConfig
jumpHosts?: JumpHostConfig[]
domain?: string
security?: 'nla' | 'tls' | 'rdp' | 'auto'
width?: number
height?: number
distro?: string
group?: string
tags?: string[]
}
// 会话更新请求
export type SessionUpdateRequest = Partial<Omit<Session, 'id' | 'createdAt' | 'updatedAt'>>