feat: 监控页按名称排序 + 按钮改「看屏 / 打开设备端 Agent」;设备名匹配补 USB 设备
用户反馈的三件事:
1) **监控页设备排序**改成按**名称**(A01/A02/…),没名字的排最后按地址。
之前是 adb 返回的顺序,看着像按 IP 排,同型号多台时对不上号。
排序放在 `/api/status`(后端),大屏页一并受益。
2) **操作按钮改名 + 换实现**:
- 「截图」→「**看屏**」(行为不变,就是查看设备实时画面)
- 「定位」→「**打开设备端 Agent**」:改成让设备上的 Agent 弹身份大字页
(名称/IP/平台地址),替代原来"推 HTML 让设备浏览器打开定位页"那套
(那套要设备装浏览器、页面还依赖设备能访问平台,backlog A1/A2 一直没修)
* 新接口 `POST /api/agent/show-info {serial, close?}`;没装 Agent 时明确报出来
* **先点亮屏幕 + 解除锁屏再拉起** —— 设备息屏时 am start 会把大字页开在锁屏后面,
人看到的还是一片黑(实测踩过)
* 平台地址取操作者当前访问地址;若是 localhost 则换成本机局域网地址
(设备上显示 127.0.0.1 毫无意义)
3) **安装应用的选择设备界面仍显示裸序列号**:USB 设备在 adb 里的 serial 就是
`ro.serialno`,等于池里那条网络记录的**指纹** —— 之前只按 serial 匹配,插着 USB
时会冒出一个没名字的 `s8o7nrt8pbzhfadq`。现在按 serial 或指纹任一命中都取名称,
三处(剪贴板注入 / 安装弹窗 / 安装进度表)统一。
顺带修掉几个自己踩出来的坑:
- `device_pool.list_configured()` 返回的是 **serial 字符串列表**,我当成字典用了
(`.get("serial")` 抛异常被 except 吞掉 → 名字全空)→ 改用 `list_devices()`
- `web/device_agent_api.py` 用了 `PERM_DEVICES` 但没导入 → 服务直接起不来(502)
- Agent 自检里的版本号是写死的常量(升到 1.4 还显示 1.0)→ 改成读包信息
- `doc/API.md` 章节编号(插了一节没把后面整体下移,出现两个 §16)
验证:安装弹窗里 USB 那台现在显示「A07」(指纹匹配);监控页按钮为
「看屏 / 打开设备端 Agent」;对装/未装 Agent 的设备分别得到大字页 / 明确报错;
大字页实测显示 A07 + 192.168.20.250:18050 + Agent v1.4。
This commit is contained in:
+7
-3
@@ -277,12 +277,16 @@ class ApkManager:
|
||||
|
||||
# 设备名(平台给设备起的名字,如 A08)—— 进度表里显示这个而不是型号:
|
||||
# 8 台同型号时型号根本区分不了,名字才行
|
||||
pool_names = {}
|
||||
pool_names, fp_names = {}, {}
|
||||
try:
|
||||
from core import device_pool
|
||||
for d in device_pool.list_configured(enabled_only=False):
|
||||
# list_devices() 返回字典(含 name/fingerprint)
|
||||
for d in device_pool.list_devices():
|
||||
if d.get("serial"):
|
||||
pool_names[d["serial"]] = d.get("name") or ""
|
||||
# USB 设备的 adb serial == ro.serialno == 池里那条记录的指纹
|
||||
if d.get("fingerprint"):
|
||||
fp_names[d["fingerprint"]] = d.get("name") or ""
|
||||
except Exception as e:
|
||||
_log.warning(f"读取设备名失败(进度表将显示地址): {e}")
|
||||
|
||||
@@ -290,7 +294,7 @@ class ApkManager:
|
||||
items = {}
|
||||
for s in serials:
|
||||
items[s] = {
|
||||
"name": pool_names.get(s) or s,
|
||||
"name": pool_names.get(s) or fp_names.get(s) or s,
|
||||
"status": "pending",
|
||||
"msg": "",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user