From e31cf88eab79a112b34b19acadbabcb234a67e9b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 19:28:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E4=B8=8E=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E7=9B=B8=E5=90=8C=E7=9A=84=20tt=20=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=88=B7=E6=96=B0=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - 登录页可以飞书免登,但审批详情页不能 - 原因:登录页有刷新机制等待 tt 对象注入,审批详情页没有 修复: - approval/detail.tsx - 添加与登录页相同的刷新逻辑 - 在飞书中但 tt 对象不存在时,自动刷新页面(最多3次) - 每次刷新后重新检测 tt 对象是否已注入 工作流程: 1. 用户点击飞书消息按钮 2. 打开审批详情页 3. 检测到在飞书中但 tt 对象不存在 4. 自动刷新页面(最多3次) 5. tt 对象注入成功后自动免登 6. 免登成功后加载审批详情 相关文件: - frontend/src/pages/approval/detail.tsx Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/approval/detail.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/pages/approval/detail.tsx b/frontend/src/pages/approval/detail.tsx index 1fd4052..d980342 100644 --- a/frontend/src/pages/approval/detail.tsx +++ b/frontend/src/pages/approval/detail.tsx @@ -214,9 +214,25 @@ export default function ApprovalDetail() { const ua = navigator.userAgent const isInFeishu = ua.includes('Lark') || ua.includes('feishu') || ua.includes('lark') + const currentUrl = window.location.href + const urlParams = new URLSearchParams(window.location.search) + console.log('📱 飞书环境检测:', { isInFeishu, ua: ua.substring(0, 100) }) console.log('🔧 tt 对象:', window.tt) + // 关键:在飞书中但 tt 对象不存在时,刷新页面等待注入(与登录页相同的逻辑) + if (isInFeishu && !window.tt) { + const reloadCount = parseInt(urlParams.get('reload') || '0') + if (reloadCount < 3) { + console.log(`⚠️ 在飞书中但 tt 对象不存在,第 ${reloadCount + 1} 次刷新页面`) + const newUrl = currentUrl.split('?')[0] + '?' + urlParams.toString().replace(/reload=\d+/g, '').replace(/^&+/, '') + window.location.href = newUrl + (newUrl.includes('?') ? '&' : '?') + `reload=${reloadCount + 1}` + return + } else { + console.log('❌ 多次刷新后 tt 对象仍不存在,跳转登录页') + } + } + if (isInFeishu && window.tt && !tryingFeishuLogin) { console.log('🚀 开始飞书免登...') setTryingFeishuLogin(true)