fix: 添加与登录页相同的 tt 对象刷新机制
问题: - 登录页可以飞书免登,但审批详情页不能 - 原因:登录页有刷新机制等待 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user