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)