diff --git a/openless-all/app/src/App.tsx b/openless-all/app/src/App.tsx index 1aa7cea6..b1baac39 100644 --- a/openless-all/app/src/App.tsx +++ b/openless-all/app/src/App.tsx @@ -57,15 +57,28 @@ export function App({ isCapsule, isQa }: AppProps) { let cancelled = false; if (os === 'win') { + // 超时保护:50 次 × 200ms = 10s。hotkey hook 永远 starting(被反作弊 / EDR + // / UAC 拦)时不让 UI 死锁灰屏,过 10s 强 setGate('ready') 让用户进 + // Permissions 页看 hotkey_status.lastError 处理。详见 issue #163。 + const POLL_INTERVAL_MS = 200; + const POLL_MAX_ATTEMPTS = 50; const pollHotkeyStatus = async () => { - while (!cancelled) { + let attempts = 0; + while (!cancelled && attempts < POLL_MAX_ATTEMPTS) { + attempts += 1; const status = await getHotkeyStatus(); if (cancelled) return; if (status.state !== 'starting') { setGate('ready'); return; } - await new Promise(resolve => window.setTimeout(resolve, 200)); + await new Promise(resolve => window.setTimeout(resolve, POLL_INTERVAL_MS)); + } + if (!cancelled) { + console.warn( + `[startup] hotkey gate timed out after ${POLL_MAX_ATTEMPTS * POLL_INTERVAL_MS}ms; forcing ready so user can reach Permissions page` + ); + setGate('ready'); } }; void pollHotkeyStatus().catch(error => {