fix: 修正飞书 SDK 全局变量名为 QRLogin

SDK 的全局变量是 window.QRLogin 而不是 window.QR

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-26 11:30:35 +08:00
parent 983f58ee98
commit d76ee80ecc
+5 -5
View File
@@ -7,7 +7,7 @@ import styles from './QRCodeLogin.module.css'
// 声明飞书 QR SDK 类型 // 声明飞书 QR SDK 类型
declare global { declare global {
interface Window { interface Window {
QR?: (config: { QRLogin?: (config: {
id: string id: string
goto: string goto: string
width?: string width?: string
@@ -63,13 +63,13 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
await new Promise(resolve => setTimeout(resolve, 100)) await new Promise(resolve => setTimeout(resolve, 100))
// 检查飞书 QR SDK 是否已加载 // 检查飞书 QR SDK 是否已加载
if (!window.QR) { if (!window.QRLogin) {
console.warn('⚠️ Feishu QR SDK not loaded, trying to wait...') console.warn('⚠️ Feishu QR SDK not loaded, trying to wait...')
// 再等待一段时间 // 再等待一段时间
await new Promise(resolve => setTimeout(resolve, 500)) await new Promise(resolve => setTimeout(resolve, 500))
} }
console.log('🔍 window.QR:', !!window.QR) console.log('🔍 window.QRLogin:', !!window.QRLogin)
// 生成登录会话 // 生成登录会话
const response = await fetch('/api/v1/auth/qrcode-login', { const response = await fetch('/api/v1/auth/qrcode-login', {
@@ -87,14 +87,14 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
sessionIdRef.current = result.data.session_id sessionIdRef.current = result.data.session_id
// 检查飞书 QR SDK 是否已加载(在 index.html 中引入) // 检查飞书 QR SDK 是否已加载(在 index.html 中引入)
if (window.QR) { if (window.QRLogin) {
console.log('✅ Using Feishu QR SDK') console.log('✅ Using Feishu QR SDK')
// 使用飞书官方 QR SDK // 使用飞书官方 QR SDK
if (qrContainerRef.current) { if (qrContainerRef.current) {
qrContainerRef.current.innerHTML = '' qrContainerRef.current.innerHTML = ''
} }
qrObjRef.current = window.QR({ qrObjRef.current = window.QRLogin({
id: 'feishu-qrcode-container', id: 'feishu-qrcode-container',
goto: authUrl, goto: authUrl,
width: '200', width: '200',