From 6f7ac6c40b26c3cbdaceb67b3796c51100717673 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 28 Feb 2026 10:25:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E6=96=B0=E6=B7=BB=E5=8A=A0=20H?= =?UTF-8?q?5=20JSSDK=20=E5=B9=B6=E4=BD=BF=E7=94=A8=20h5sdk.ready()=20?= =?UTF-8?q?=E7=AD=89=E5=BE=85=20tt=20=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - H5 JSSDK 是飞书网页应用免登必需的 - 使用 h5sdk.ready() 确保 tt 对象被注入后再调用 API --- frontend/index.html | 2 ++ frontend/src/pages/login/index.tsx | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/frontend/index.html b/frontend/index.html index ee4fc07..96e9f3e 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -7,6 +7,8 @@ 企业工具台 + +
diff --git a/frontend/src/pages/login/index.tsx b/frontend/src/pages/login/index.tsx index 499bc4e..8fad2de 100644 --- a/frontend/src/pages/login/index.tsx +++ b/frontend/src/pages/login/index.tsx @@ -9,6 +9,9 @@ import styles from './login.module.css' declare global { interface Window { tt?: any + h5sdk?: { + ready: (callback: () => void) => void + } } } @@ -73,6 +76,20 @@ export default function Login() { // 飞书内免登 const attemptFeishuAutoLogin = async (companyParam?: string) => { + // 如果 h5sdk 存在,使用 h5sdk.ready() 等待环境就绪 + if (window.h5sdk?.ready) { + window.h5sdk.ready(() => { + console.log('h5sdk ready, tt对象:', !!window.tt) + if (window.tt) { + performFeishuLogin(companyParam) + } else { + console.error('h5sdk ready 后 tt 对象仍不存在') + setLoading(false) + } + }) + return + } + // 如果 tt 对象已存在,直接使用 if (window.tt) { performFeishuLogin(companyParam)