Files
kefu/admin-web/apps/mobile-h5/README.md
T
2026-09-29 15:52:07 +08:00

55 lines
3.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.
# 企微客服助手 · 手机远程控制台(mobile-h5)
给客服本人用的手机 / 平板 H5:用 ZYT 账号登录,查看自己电脑上客服软件的运行状态,远程启动 /
停止自动回复,管理会话黑名单。有 `wecom_rpa.remote/all` 权限的主管可以切换查看其他客服。
- 技术栈:Vue 3 + Vite + Vant 4,hash 路由,按需引入 Vant 样式。
- 布局:手机单栏 + 底部标签栏;宽度 ≥ 768px(平板、电脑浏览器)切成左列表 / 右详情两栏。
- 适配:iOS 安全区(`viewport-fit=cover`)、深色模式(跟随系统)、可"添加到主屏幕"(manifest + 不缓存的 Service Worker)。
- 托管:构建产物由管理端 `wechat_rpa/admin_api.py` 挂在 `/m/`,接口是同源的 `/api/v2/mobile/*`。
## 独立项目
这个目录**不属于** admin-web 的 pnpm workspace(`pnpm-workspace.yaml` 里有 `!apps/mobile-h5`),
依赖和锁文件都在本目录,不会影响 vben 管理端的安装和构建。
```bash
cd admin-web/apps/mobile-h5
pnpm install --ignore-workspace # 走本目录 .npmrc 里的 npmmirror
pnpm dev # http://127.0.0.1:5190/m/ ,/api 代理到 127.0.0.1:8766(MOBILE_API_TARGET 可改)
pnpm test # vitest:时间格式、设备 / 指令状态文案
pnpm build # vue-tsc 类型检查 + vite build → dist/
```
发布时把 `dist/` 放到服务器 `/opt/im-admin/admin-web/apps/mobile-h5/dist/`(见
`deploy/mobile-remote-20260928/`),`deploy/im-admin/Dockerfile` 会把它一起打进镜像。
## 页面
| 路由 | 内容 |
|---|---|
| `#/login` | ZYT 账号密码登录(后台代登 ZYT 终端 8,密码不落地);公网明文 HTTP 下提示改用 HTTPS |
| `#/desktops` | 电脑卡片:在线 / 离线、监听中 / 已停止、企业微信连接、回复通道、待处理数;启动 / 停止自动回复(需确认),下发后每 3 秒查询一次指令结果 |
| `#/conversations` | 会话列表(来自聊天归档,只有名称、类型、最近时间,不含聊天正文)+ 搜索 + 黑名单页签;详情里加入 / 移出黑名单 |
| `#/me` | 当前账号、五项手机端权限是否开通、登录信息、添加到主屏幕说明、退出登录 |
电脑离线(客服软件没开)时只显示"电脑离线",无法远程拉起;电脑上是旧版客服软件(没有命令通道)时显示
"版本过低",按钮不可用。
## 接口(`/api/v2/mobile`,Bearer 令牌)
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | `/auth/login` | `{account, password, client_name}` → `{access_token, expires_at, me}` |
| POST | `/auth/logout` | 同时注销 ZYT 终端 8 会话 |
| GET | `/me` | 账号、权限(control / control_all / blacklist_add / blacklist_remove / root)、会话有效期 |
| GET | `/accounts?q=` | 全部客服电脑概况,仅 `wecom_rpa.remote/all` |
| GET | `/desktops?account_id=` | 名下电脑与实时状态;`account_id` 仅 remote/all 可指定别人 |
| POST | `/desktops/{device_id}/commands?account_id=` | `{type: start_listening \| stop_listening}`,离线 409 `device_offline`,旧版 409 `client_outdated` |
| GET | `/commands/{id}` | 指令状态:pending → delivered → succeeded / failed / expired / superseded |
| GET | `/conversations?q=&scope=all\|blocked&cursor=&limit=` | 会话与黑名单状态 |
| PUT | `/blacklist/{account}/{conversation}?account_id=` | `{name, account_name, reason}`,需 `wecom_rpa.blacklist/add` |
| DELETE | `/blacklist/{account}/{conversation}?account_id=` | 需 `wecom_rpa.blacklist/remove` |
错误体统一是 `{"detail": {"code": "...", "message": "给人看的中文"}}`,401 时前端清掉令牌回登录页。