修复:自动回收失效隧道占用并限制首次连接等待时间

This commit is contained in:
2026-10-23 17:47:29 +08:00
parent 3519dd0891
commit 8684ce1a4d
8 changed files with 216 additions and 13 deletions
+3 -2
View File
@@ -45,6 +45,7 @@ export const CachedWorkspacePages = forwardRef<WorkspaceNavigation, {
if (revisions.current && state.dataRevision !== revisions.current.dataRevision) setRefreshKey(value => value + 1);
revisions.current = state;
setError('');
setReady(true);
return true;
} catch (value) {
if (alive.current && generation.current === epoch && !onUnauthorized(value)) setError(value instanceof Error ? value.message : '页面状态校验失败,请重试');
@@ -84,7 +85,7 @@ export const CachedWorkspacePages = forwardRef<WorkspaceNavigation, {
} }));
useEffect(() => {
alive.current = true;
void validate().then(ok => { if (ok) setReady(true); });
void validate();
const invalidate = () => setRefreshKey(value => value + 1);
window.addEventListener(WORKSPACE_INVALIDATED, invalidate);
return () => { alive.current = false; generation.current++; validation.current = null; window.removeEventListener(WORKSPACE_INVALIDATED, invalidate); };
@@ -95,7 +96,7 @@ export const CachedWorkspacePages = forwardRef<WorkspaceNavigation, {
const frame = requestAnimationFrame(() => window.scrollTo(0, entries.current.get(page)?.scroll || 0));
return () => cancelAnimationFrame(frame);
}, [page, ready, activeEntryKey]);
const connectionNotice = error && <Alert type="warning" showIcon message="页面状态暂未更新" description={error} action={<Button onClick={() => { void validate().then(ok => { if (ok) setReady(true); }); }}>重新连接</Button>} />;
const connectionNotice = error && <Alert type="warning" showIcon message="页面状态暂未更新" description={error} action={<Button onClick={() => { void validate(); }}>重新连接</Button>} />;
if (!ready) return connectionNotice || <div className="loading-panel"><Spin />正在打开工作台…</div>;
return <>{connectionNotice}{Array.from(entries.current.entries()).filter(([name]) => retained(name) || name === page).map(([name, entry]) => {
const active = name === page;