ituoke/README.md

73 lines
2.7 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.

# iTuoke
手机操控桌面应用:**Wails + Vue3 + TypeScript**(UI) / **Go**(ADB 设备核心) / **Python**(Agent 独立进程)。
## 架构
```text
frontend/ UI:左画面 | 右对话 | 设置 | 日志
main.go 桌面壳入口(窗口 + 注册服务)
internal/device/ ADB 连接 / 视频预览 / 实时触摸控制(Go)
internal/agent/ 对接 Python Agent 的桥
internal/protocol/ 版本化 JSON-RPC 契约
agent/ Python Agent 进程(可后接云端模型)
```
关键改代码位置已在源文件顶部用 `[关键]` / `[入口]` / `[UI · …]` 备注标出。
## 开发
需要 Go 1.26、Node.js 22.18+(测试直接运行 TypeScript)、npm 和 Wails v3。macOS 实时预览还需安装 `scrcpy 5.0.1` 与 `ffmpeg`(当前控制协议对应 scrcpy 5.0.1)。首次运行先安装前端依赖,并同步内置 ADB:
```bash
npm --prefix frontend install
./scripts/sync-platform-tools.sh
```
```bash
# 1) 生成前端绑定(改 Go 导出方法后重跑)
wails3 generate bindings -ts -i ./...
# 2) 跑桌面应用(热重载)
wails3 dev
# 3) 可选:单独起 Python Agent
cd agent && python3 main.py
```
macOS 开发运行会把应用包同步到 `~/Applications/iTuoke.app` 后启动,避免从外置磁盘运行时反复触发「可移除宗卷」文件授权。ADB 使用应用专用的本地后台服务,不复用其他工具的默认服务;配对记录继续保留。
## 内置 ADB(客户无需安装)
```bash
./scripts/sync-platform-tools.sh # 同步 platform-tools 到 third_party/
wails3 build # macOS 打包时自动拷进 .app/Contents/Resources/
```
运行时优先使用应用内置 `adb`,不依赖客户电脑是否安装过 Android SDK。
## 当前能力
- USB / 无线 ADB 设备发现、配对、连接与离线重连。
- scrcpy 视频预览,支持适应窗口及 50%–200% 缩放。
- 预览中点按、长按及连续拖动:按下、移动、松开实时发送到 scrcpy 控制通道。
- 深色、浅色和跟随系统主题,连接配置与缩放偏好持久化。
- 设置与日志页面;Go/Python Agent 对话目前仍为 stub,尚未接入模型。
`frontend/bindings/`、依赖目录、构建产物、录屏和本机配置不提交;前端绑定由上述生成命令或 Wails 构建任务重建。图标、原始图标素材及各平台打包模板保留在仓库。
## 验证
```bash
node --test frontend/tests/*.test.mjs
npm --prefix frontend run build
go test -race ./internal/...
```
可选实机预览检查(设备需已连接到 iTuoke 的专用 ADB 服务):
```bash
ITUOKE_TEST_DEVICE='手机IP:连接端口' go test -race ./internal/device -run TestLocalPhonePreview -v -count=1
```