fix: 修复 QRLogin SDK 二维码不显示的问题

1. 使用 getElementById 获取容器,避免清空容器本身
2. 确保 DOM 渲染完成后再调用 SDK

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-02-26 11:36:46 +08:00
parent d76ee80ecc
commit 79cef9ac91
+13 -9
View File
@@ -90,16 +90,20 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
if (window.QRLogin) {
console.log('✅ Using Feishu QR SDK')
// 使用飞书官方 QR SDK
if (qrContainerRef.current) {
qrContainerRef.current.innerHTML = ''
// 先清空容器内容(保留容器元素本身)
const container = document.getElementById('feishu-qrcode-container')
if (container) {
container.innerHTML = ''
}
qrObjRef.current = window.QRLogin({
id: 'feishu-qrcode-container',
goto: authUrl,
width: '200',
height: '200',
})
// 确保 DOM 已渲染后再调用 SDK
setTimeout(() => {
qrObjRef.current = window.QRLogin({
id: 'feishu-qrcode-container',
goto: authUrl,
width: '200',
height: '200',
})
}, 50)
setStatus('pending')
startPolling(result.data.session_id)