fix: 修正飞书 SDK 全局变量名为 QRLogin
SDK 的全局变量是 window.QRLogin 而不是 window.QR Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import styles from './QRCodeLogin.module.css'
|
||||
// 声明飞书 QR SDK 类型
|
||||
declare global {
|
||||
interface Window {
|
||||
QR?: (config: {
|
||||
QRLogin?: (config: {
|
||||
id: string
|
||||
goto: string
|
||||
width?: string
|
||||
@@ -63,13 +63,13 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100))
|
||||
|
||||
// 检查飞书 QR SDK 是否已加载
|
||||
if (!window.QR) {
|
||||
if (!window.QRLogin) {
|
||||
console.warn('⚠️ Feishu QR SDK not loaded, trying to wait...')
|
||||
// 再等待一段时间
|
||||
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', {
|
||||
@@ -87,14 +87,14 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
|
||||
sessionIdRef.current = result.data.session_id
|
||||
|
||||
// 检查飞书 QR SDK 是否已加载(在 index.html 中引入)
|
||||
if (window.QR) {
|
||||
if (window.QRLogin) {
|
||||
console.log('✅ Using Feishu QR SDK')
|
||||
// 使用飞书官方 QR SDK
|
||||
if (qrContainerRef.current) {
|
||||
qrContainerRef.current.innerHTML = ''
|
||||
}
|
||||
|
||||
qrObjRef.current = window.QR({
|
||||
qrObjRef.current = window.QRLogin({
|
||||
id: 'feishu-qrcode-container',
|
||||
goto: authUrl,
|
||||
width: '200',
|
||||
|
||||
Reference in New Issue
Block a user