From e2160aa59f323790565498b1f2262a79c99c1fd6 Mon Sep 17 00:00:00 2001 From: tanjianbin <632190820@qq.com> Date: Fri, 27 Mar 2026 17:38:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A5=BD=E5=8F=8B=E5=90=8E=E8=8E=B7=E5=8F=96=E8=AF=A6?= =?UTF-8?q?=E7=BB=86=E4=BF=A1=E6=81=AF=E7=9A=84=E5=86=97=E4=BD=99=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除 `getFriendDetailInfo` 方法及相关调用,因为添加好友成功后不再需要立即进入详情页抓取信息。这简化了添加好友的流程,避免了不必要的页面跳转和潜在的稳定性问题。 --- .../worktool/service/WeworkLoopImpl.kt | 66 ------------------- 1 file changed, 66 deletions(-) diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt index 26e9495..ff4d6fe 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt @@ -455,12 +455,6 @@ object WeworkLoopImpl { if (textNode?.text?.toString() == "添加请求已过期,添加失败") { LogUtils.d("添加好友失败") } else { - // 获取完整的好友信息 - val friendInfo = getFriendDetailInfo(friendName) - val weworkMessageBean = WeworkMessageBean() - weworkMessageBean.type = WeworkMessageBean.GET_FRIEND_INFO - weworkMessageBean.friend = friendInfo - WeworkController.weworkService.webSocketManager.send(weworkMessageBean) nameList.add(friendName) } //回到上一页 @@ -476,66 +470,6 @@ object WeworkLoopImpl { return nameList } - /** - * 获取好友详细信息 - * 通过好友后进入详情页抓取完整信息 - */ - private fun getFriendDetailInfo(friendName: String): WeworkMessageBean.Friend { - val friend = WeworkMessageBean.Friend().apply { - name = friendName - newFriend = true - } - try { - // 点击发消息进入聊天页面 - val sendMsgNode = AccessibilityUtil.findOneByText(getRoot(), "发消息", exact = true) - if (sendMsgNode != null) { - AccessibilityUtil.performClick(sendMsgNode) - sleep(Constant.CHANGE_PAGE_INTERVAL) - } - - // 进入好友详情页 - if (WeworkRoomUtil.intoFriendDetail()) { - sleep(Constant.CHANGE_PAGE_INTERVAL) - // 解析详情页信息 - val listView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ListView) - if (listView != null) { - // 遍历列表获取各字段信息 - for (i in 0 until listView.childCount) { - val item = listView.getChild(i) ?: continue - val textViews = AccessibilityUtil.findAllOnceByClazz(item, Views.TextView) - if (textViews.size >= 2) { - val label = textViews[0].text?.toString() ?: "" - val value = textViews[1].text?.toString() ?: "" - when { - label.contains("微信号") || label.contains("微信ID") -> friend.wechatId = value - label.contains("手机") -> friend.phone = value - label.contains("企业") -> friend.corpName = value - label.contains("部门") -> friend.department = value - label.contains("职位") || label.contains("职务") -> friend.position = value - label.contains("邮箱") -> friend.email = value - label.contains("备注") -> friend.markName = value - } - LogUtils.d("好友详情 - $label: $value") - } - } - } - // 尝试获取头像(如果有) - val avatarView = AccessibilityUtil.findOneByClazz(getRoot(), Views.ImageView) - if (avatarView != null) { - // 头像通常没有直接URL,这里留空或可通过其他方式获取 - // friend.avatarUrl = "" - } - // 返回聊天页面 - backPress() - sleep(Constant.POP_WINDOW_INTERVAL) - } - } catch (e: Exception) { - LogUtils.e("获取好友详情失败: ${e.message}") - } - LogUtils.d("好友信息: $friend") - return friend - } - /** * 获取单聊联系人详细信息 */