From 79cef9ac912cb79f4ab51ee6282b13e4ff2cbafc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 11:36:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20QRLogin=20SDK=20?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 使用 getElementById 获取容器,避免清空容器本身 2. 确保 DOM 渲染完成后再调用 SDK Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/login/QRCodeLogin.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/login/QRCodeLogin.tsx b/frontend/src/pages/login/QRCodeLogin.tsx index 164b4e6..4f47e19 100644 --- a/frontend/src/pages/login/QRCodeLogin.tsx +++ b/frontend/src/pages/login/QRCodeLogin.tsx @@ -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)