fix: retry mobile QR loading

This commit is contained in:
Rixuan Shao
2026-07-11 21:53:19 +08:00
parent 782cfb66d0
commit 1cf15e8a6b
2 changed files with 9 additions and 2 deletions
@@ -193,6 +193,8 @@ class WebUiSafetyTests(unittest.TestCase):
block_end = script.index('document.querySelectorAll(".login-desktop-save")', block_start) block_end = script.index('document.querySelectorAll(".login-desktop-save")', block_start)
block = script[block_start:block_end] block = script[block_start:block_end]
self.assertLess(block.index("window.open(publicUrl"), block.index('await postForm("/login-desktop/open")')) self.assertLess(block.index("window.open(publicUrl"), block.index('await postForm("/login-desktop/open")'))
self.assertIn("refreshLoginQr(1800)", block)
self.assertIn("retries - 1", script)
def test_schedule_sync_writes_configured_window_to_shared_spool(self): def test_schedule_sync_writes_configured_window_to_shared_spool(self):
with tempfile.TemporaryDirectory() as temp_dir: with tempfile.TemporaryDirectory() as temp_dir:
+7 -2
View File
@@ -383,7 +383,7 @@
} }
}; };
const refreshLoginQr = async (delay = 0) => { const refreshLoginQr = async (delay = 0, retries = 8) => {
if (!qrImage) return; if (!qrImage) return;
window.clearTimeout(qrRefreshTimer); window.clearTimeout(qrRefreshTimer);
qrRefreshTimer = window.setTimeout(async () => { qrRefreshTimer = window.setTimeout(async () => {
@@ -401,7 +401,12 @@
if (previous) URL.revokeObjectURL(previous); if (previous) URL.revokeObjectURL(previous);
if (qrStatus) qrStatus.textContent = "二维码已加载。如果过期,点击刷新。"; if (qrStatus) qrStatus.textContent = "二维码已加载。如果过期,点击刷新。";
} catch { } catch {
if (qrStatus) qrStatus.textContent = "二维码还未准备好,请稍后刷新。"; if (retries > 1) {
if (qrStatus) qrStatus.textContent = "登录页正在加载,继续等待二维码...";
refreshLoginQr(1400, retries - 1);
} else if (qrStatus) {
qrStatus.textContent = "二维码还未准备好,请点击刷新重试。";
}
} }
}, delay); }, delay);
}; };