Files
Rtty/desktop/README.md

56 lines
1.6 KiB
Markdown
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.

# Rtty Desktop (桌面端)
Rtty 的 Flutter Windows 桌面终端客户端。连接 `rtty-server`Rust 后端),消费
服务端下发的**原始 ANSI 二进制帧**,通过 `xterm`Dart 版 xterm.js做工业级
ANSI 渲染,保证对 vim / htop / tmux 等全屏软件 100% 兼容。
## 架构
```
rtty-server (Rust)
│ WebSocket (ws://host:8080/ws)
│ • JSON 控制帧 (ready / snapshot / control / error)
│ • 二进制帧 = 原始 ANSI 字节流 (PC 端渲染)
rtty-desktop (Flutter / Windows)
• RttyClient —— WebSocket 连接管理 + 协议解析
• Terminal —— xterm 终端网格 / ANSI 解析
• ConnectionBar —— 顶部连接控制条
```
## 运行
```bash
# 1. 先启动 Rust 服务端(仓库根目录)
cd .. && cargo run
# 2. 启动桌面端
cd desktop
flutter run -d windows
```
## 构建
```bash
flutter build windows --release
# 产物build/windows/x64/runner/Release/rtty_desktop.exe
```
## 测试
```bash
# Widget 测试(无需服务端)
flutter test test/widget_test.dart
# 端到端集成测试(需先启动 Rust 服务端)
flutter test test/e2e_ws_test.dart
```
## 协议要点
- 连接 `ws://host:port/ws`(可选 `?session=<id>` 复用会话)。
- 服务端 `ready` 帧携带会话 ID 与初始尺寸,驱动 xterm 网格。
- PTY 输出以二进制帧下发,桌面端直接喂给 xterm 渲染。
- 键盘输入与终端回写经 `{"type":"input","data":...}` 发回服务端写入 PTY。
- 窗口尺寸变化时发送 `{"type":"resize","cols":..,"rows":..}` 同步网格。