fix(企业微信服务): 修复未读聊天检测与点击逻辑

调整变量命名以准确反映收集的是聊天行节点而非红点节点
新增两种点击方式的兜底逻辑,提升点击成功率
添加页面跳转验证,避免点击未生效的假成功情况
优化异常处理流程,点击失败时直接返回false
This commit is contained in:
2026-05-11 16:29:11 +08:00
parent 9bfb1a9040
commit 57cf264e44

View File

@@ -636,7 +636,7 @@ object WeworkLoopImpl {
* 检查首页-聊天列表是否有未读红点并点击进入 * 检查首页-聊天列表是否有未读红点并点击进入
*/ */
private fun checkUnreadChatRoom(list: AccessibilityNodeInfo): Boolean { private fun checkUnreadChatRoom(list: AccessibilityNodeInfo): Boolean {
val spotNodeList = arrayListOf<AccessibilityNodeInfo>() val unreadRowNodeList = arrayListOf<AccessibilityNodeInfo>()
for (i in 0 until list.childCount) { for (i in 0 until list.childCount) {
val item = list.getChild(i) val item = list.getChild(i)
if (item != null && Views.RelativeLayout.equals(item.className)) { if (item != null && Views.RelativeLayout.equals(item.className)) {
@@ -647,20 +647,22 @@ object WeworkLoopImpl {
&& spotNode.text != null && spotNode.text != null
&& spotNode.text.toString().replace("+", "").isDigitsOnly() && spotNode.text.toString().replace("+", "").isDigitsOnly()
) { ) {
spotNodeList.add(spotNode) unreadRowNodeList.add(item)
} }
} }
} }
} }
if (spotNodeList.size > 0) { if (unreadRowNodeList.isNotEmpty()) {
LogUtils.i("发现未读消息: " + spotNodeList.size + "") LogUtils.i("发现未读消息: " + unreadRowNodeList.size + "")
log("发现未读消息: " + spotNodeList.size + "") log("发现未读消息: " + unreadRowNodeList.size + "")
if (AccessibilityUtil.performClick(spotNodeList.firstOrNull())) { val firstUnreadRow = unreadRowNodeList.firstOrNull()
//进入聊天页 下一步 getChatMessageList val clicked = AccessibilityUtil.performClick(firstUnreadRow)
} else { || AccessibilityUtil.clickByNode(WeworkController.weworkService, firstUnreadRow)
AccessibilityUtil.clickByNode(WeworkController.weworkService, spotNodeList.firstOrNull()?.parent) if (!clicked) {
return false
} }
return true // 避免“点击红点但未实际进会话”的假成功
return AccessibilityUtil.waitForPageMissing("WwMainActivity", "GlobalSearchActivity", timeout = 2000)
} else { } else {
return false return false
} }