fix: 修复 QRLogin SDK 二维码不显示的问题
1. 使用 getElementById 获取容器,避免清空容器本身 2. 确保 DOM 渲染完成后再调用 SDK Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,16 +90,20 @@ export default function QRCodeLogin({ visible, onClose }: QRCodeLoginProps) {
|
|||||||
if (window.QRLogin) {
|
if (window.QRLogin) {
|
||||||
console.log('✅ Using Feishu QR SDK')
|
console.log('✅ Using Feishu QR SDK')
|
||||||
// 使用飞书官方 QR SDK
|
// 使用飞书官方 QR SDK
|
||||||
if (qrContainerRef.current) {
|
// 先清空容器内容(保留容器元素本身)
|
||||||
qrContainerRef.current.innerHTML = ''
|
const container = document.getElementById('feishu-qrcode-container')
|
||||||
|
if (container) {
|
||||||
|
container.innerHTML = ''
|
||||||
}
|
}
|
||||||
|
// 确保 DOM 已渲染后再调用 SDK
|
||||||
qrObjRef.current = window.QRLogin({
|
setTimeout(() => {
|
||||||
id: 'feishu-qrcode-container',
|
qrObjRef.current = window.QRLogin({
|
||||||
goto: authUrl,
|
id: 'feishu-qrcode-container',
|
||||||
width: '200',
|
goto: authUrl,
|
||||||
height: '200',
|
width: '200',
|
||||||
})
|
height: '200',
|
||||||
|
})
|
||||||
|
}, 50)
|
||||||
|
|
||||||
setStatus('pending')
|
setStatus('pending')
|
||||||
startPolling(result.data.session_id)
|
startPolling(result.data.session_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user