backend/目录)cd /Users/wuzilong/work/00code/Tolan/frontend
npm install
创建 .env.local 文件:
# 如果后端在本地运行
VITE_WS_URL=ws://localhost:8000/ws/realtime
# 如果后端使用HTTPS
VITE_WS_URL=wss://localhost:8443/ws/realtime
如果不配置,默认使用 ws://localhost:8000/ws/realtime
npm run dev
应用将在 http://localhost:5173 启动
等待初始化
开始对话
接收回复
继续对话
症状: 显示"连接中..."但一直无法连接
解决方案:
# 检查后端是否运行
curl http://localhost:8000/docs
症状: 点击录音按钮没有反应
解决方案:
症状: 收到回复但没有声音
解决方案:
症状: 响应时间超过1秒
解决方案:
应用会在控制台输出性能指标:
端到端延迟: 285ms
收到音频数据: 2048 bytes
音频播放状态: playing
目标延迟: < 300ms
# 安装依赖
npm install
# 启动开发服务器(热更新)
npm run dev
# 生产构建
npm run build
# 预览生产构建
npm run preview
# 代码检查
npm run lint
frontend/
├── src/
│ ├── components/ # React组件
│ ├── stores/ # 状态管理
│ ├── utils/ # 工具模块
│ ├── config.ts # 配置
│ └── main.tsx # 入口
├── public/ # 静态资源
└── package.json
遇到问题?
祝您使用愉快!🎉