收紧生成任务轮询与资产读取路径
空生成任务列表不再保持四秒轮询 读取资源字节优先通过read-url直连OSS 保留read-bytes作为OSS读取失败兜底 更新资产导出与项目记忆文档口径
This commit is contained in:
@@ -544,7 +544,10 @@ import type {
|
||||
} from './platformEntryTypes';
|
||||
import { PlatformEntryWorldDetailView } from './PlatformEntryWorldDetailView';
|
||||
import { PlatformErrorDialog } from './PlatformErrorDialog';
|
||||
import { buildExternalGenerationQueueStatus } from './platformExternalGenerationQueueStatusModel';
|
||||
import {
|
||||
buildExternalGenerationQueueStatus,
|
||||
shouldUseFastExternalGenerationTaskPolling,
|
||||
} from './platformExternalGenerationQueueStatusModel';
|
||||
import { resolvePlatformGenerationProgressTickDecision } from './platformGenerationProgressTickModel';
|
||||
import {
|
||||
sendPlatformHostDraftNotificationToHost,
|
||||
@@ -707,6 +710,7 @@ type PuzzleBackgroundCompileTask = {
|
||||
generationState: MiniGameDraftGenerationState;
|
||||
error: string | null;
|
||||
};
|
||||
const EXTERNAL_GENERATION_TASK_FAST_POLL_INTERVAL_MS = 4_000;
|
||||
|
||||
function isUnacknowledgedExternalGenerationTerminalTask(
|
||||
task: ExternalGenerationTaskRecord,
|
||||
@@ -4967,6 +4971,15 @@ export function PlatformEntryFlowShellImpl({
|
||||
woodenFishGenerationState,
|
||||
);
|
||||
const isHostNetworkOnline = useHostNetworkOnline();
|
||||
const shouldFastPollKnownExternalGenerationTask =
|
||||
puzzleOperation?.queueState?.status === 'queued' ||
|
||||
puzzleOperation?.queueState?.status === 'running' ||
|
||||
jumpHopQueueState?.status === 'queued' ||
|
||||
jumpHopQueueState?.status === 'running' ||
|
||||
puzzleClearQueueState?.status === 'queued' ||
|
||||
puzzleClearQueueState?.status === 'running' ||
|
||||
woodenFishQueueState?.status === 'queued' ||
|
||||
woodenFishQueueState?.status === 'running';
|
||||
const shouldPollExternalGenerationTasks =
|
||||
platformBootstrap.canReadProtectedData && Boolean(authUi?.user?.id);
|
||||
const externalGenerationQueueOwnerKey =
|
||||
@@ -4991,6 +5004,21 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
let disposed = false;
|
||||
let controller: AbortController | null = null;
|
||||
let timerId: number | null = null;
|
||||
|
||||
const scheduleNextRefresh = (delayMs: number) => {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
if (timerId != null) {
|
||||
window.clearTimeout(timerId);
|
||||
timerId = null;
|
||||
}
|
||||
if (delayMs <= 0) {
|
||||
return;
|
||||
}
|
||||
timerId = window.setTimeout(refreshTaskList, delayMs);
|
||||
};
|
||||
|
||||
const refreshTaskList = () => {
|
||||
controller?.abort();
|
||||
@@ -5010,6 +5038,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
),
|
||||
);
|
||||
setExternalGenerationTaskOverview(response.overview);
|
||||
scheduleNextRefresh(
|
||||
shouldFastPollKnownExternalGenerationTask ||
|
||||
shouldUseFastExternalGenerationTaskPolling(
|
||||
buildExternalGenerationQueueStatus(
|
||||
response.overview,
|
||||
null,
|
||||
response.tasks,
|
||||
),
|
||||
)
|
||||
? EXTERNAL_GENERATION_TASK_FAST_POLL_INTERVAL_MS
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -5021,16 +5061,28 @@ export function PlatformEntryFlowShellImpl({
|
||||
};
|
||||
|
||||
refreshTaskList();
|
||||
const intervalId = window.setInterval(refreshTaskList, 4000);
|
||||
const handleResume = () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
return;
|
||||
}
|
||||
refreshTaskList();
|
||||
};
|
||||
window.addEventListener('focus', handleResume);
|
||||
document.addEventListener('visibilitychange', handleResume);
|
||||
|
||||
return () => {
|
||||
disposed = true;
|
||||
controller?.abort();
|
||||
window.clearInterval(intervalId);
|
||||
if (timerId != null) {
|
||||
window.clearTimeout(timerId);
|
||||
}
|
||||
window.removeEventListener('focus', handleResume);
|
||||
document.removeEventListener('visibilitychange', handleResume);
|
||||
};
|
||||
}, [
|
||||
externalGenerationQueueOwnerKey,
|
||||
isHostNetworkOnline,
|
||||
shouldFastPollKnownExternalGenerationTask,
|
||||
shouldPollExternalGenerationTasks,
|
||||
]);
|
||||
const activeExternalGenerationJobState = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user