From fdb030cba0864a30a166b0c8c7647975d1103053 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 28 Feb 2026 10:19:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20H5=20JSSDK=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8=E9=A3=9E=E4=B9=A6=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E6=B3=A8=E5=85=A5=E7=9A=84=20tt=20=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - H5 JSSDK 与 tt 对象冲突,导致警告 - tt 对象由飞书客户端自动注入,无需额外 SDK - 使用 tt.requestAuthCode 进行免登 --- frontend/index.html | 2 -- frontend/src/pages/login/index.tsx | 36 ++++++++---------------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 96e9f3e..ee4fc07 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -7,8 +7,6 @@ 企业工具台 - -
diff --git a/frontend/src/pages/login/index.tsx b/frontend/src/pages/login/index.tsx index 4b0433e..499bc4e 100644 --- a/frontend/src/pages/login/index.tsx +++ b/frontend/src/pages/login/index.tsx @@ -9,9 +9,6 @@ import styles from './login.module.css' declare global { interface Window { tt?: any - h5sdk?: { - ready: (callback: () => void) => void - } } } @@ -82,24 +79,6 @@ export default function Login() { return } - // 如果 h5sdk 存在,使用 h5sdk.ready() 等待 - if (window.h5sdk?.ready) { - let readyCalled = false - const timeoutId = setTimeout(() => { - if (!readyCalled) { - console.error('h5sdk.ready() 超时') - setLoading(false) - } - }, 5000) - - window.h5sdk.ready(() => { - readyCalled = true - clearTimeout(timeoutId) - performFeishuLogin(companyParam) - }) - return - } - // 轮询等待 tt 对象(最多 5 秒) let attempts = 0 const maxAttempts = 50 @@ -143,22 +122,25 @@ export default function Login() { } if (!appId) { + console.error('appId 获取失败') setLoading(false) Toast.show('飞书应用配置错误') return } - // 调用飞书免登(使用 tt.requestAccess) - window.tt.requestAccess({ - appID: appId, - scopeList: [], + console.log('开始免登,appId:', appId) + + // 调用飞书免登 + window.tt.requestAuthCode({ + appId: appId, success: (res: any) => { + console.log('免登成功,code:', res.code) handleFeishuLogin(res.code, companyParam) }, fail: (error: any) => { - console.error('requestAccess 失败:', error) + console.error('免登失败:', error) setLoading(false) - Toast.show('免登失败:' + (error.errMsg || JSON.stringify(error))) + Toast.show('免登失败:' + (error.errMsg || error.errorMessage || JSON.stringify(error))) }, }) } catch (e) {