Integrate unfinished server-rs refactor worklists

This commit is contained in:
2026-04-30 13:39:06 +08:00
parent 62934b0809
commit 7ab0933f6d
676 changed files with 24487 additions and 21531 deletions

View File

@@ -56,9 +56,9 @@ import {
} from '../../services/big-fish-creation';
import { listBigFishGallery } from '../../services/big-fish-gallery';
import {
advanceLocalBigFishRuntimeRun,
recordBigFishPlay,
startLocalBigFishRuntimeRun,
startBigFishRun as startBigFishRuntimeRun,
submitBigFishInput as submitBigFishRuntimeInput,
} from '../../services/big-fish-runtime';
import {
deleteBigFishWork,
@@ -456,6 +456,7 @@ export function PlatformEntryFlowShellImpl({
>(null);
const [bigFishRuntimeSessionSource, setBigFishRuntimeSessionSource] =
useState<BigFishRuntimeSessionSource>(null);
const bigFishInputInFlightRef = useRef(false);
const [isBigFishLoadingLibrary, setIsBigFishLoadingLibrary] = useState(false);
const [bigFishGenerationState, setBigFishGenerationState] =
useState<MiniGameDraftGenerationState | null>(null);
@@ -1182,7 +1183,7 @@ export function PlatformEntryFlowShellImpl({
}
}, [bigFishRun, bigFishSession, selectionStage, setSelectionStage]);
const startBigFishRun = useCallback(() => {
const startBigFishRun = useCallback(async () => {
if (!bigFishSession) {
return;
}
@@ -1191,16 +1192,25 @@ export function PlatformEntryFlowShellImpl({
setBigFishError(null);
setBigFishRuntimeShare(null);
setBigFishRuntimeWork(null);
setBigFishRuntimeStartedAt(Date.now());
setBigFishRuntimeSessionSource('draft');
setBigFishRun(startLocalBigFishRuntimeRun({ session: bigFishSession }));
setSelectionStage('big-fish-runtime');
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishRuntimeStartedAt(null);
setBigFishRun(null);
try {
const { run } = await startBigFishRuntimeRun(sessionId);
setBigFishRuntimeStartedAt(Date.now());
setBigFishRuntimeSessionSource('draft');
setBigFishRun(run);
setSelectionStage('big-fish-runtime');
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩失败。'),
);
});
void refreshBigFishShelf();
} catch (error) {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼玩失败。'),
resolveBigFishErrorMessage(error, '启动大鱼吃小鱼玩失败。'),
);
});
void refreshBigFishShelf();
}
}, [
bigFishSession,
refreshBigFishShelf,
@@ -1208,7 +1218,7 @@ export function PlatformEntryFlowShellImpl({
setSelectionStage,
]);
const restartBigFishRun = useCallback(() => {
const restartBigFishRun = useCallback(async () => {
if (!bigFishSession && !bigFishRun) {
return;
}
@@ -1222,23 +1232,26 @@ export function PlatformEntryFlowShellImpl({
if (bigFishSession) {
setBigFishRuntimeShare(null);
}
setBigFishRuntimeStartedAt(Date.now());
setBigFishRuntimeSessionSource(bigFishSession ? 'draft' : 'work');
setBigFishRun(
startLocalBigFishRuntimeRun({
session: bigFishSession,
work: bigFishRuntimeWork,
}),
);
setSelectionStage('big-fish-runtime');
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishRuntimeStartedAt(null);
setBigFishRun(null);
try {
const { run } = await startBigFishRuntimeRun(sessionId);
setBigFishRuntimeStartedAt(Date.now());
setBigFishRuntimeSessionSource(bigFishSession ? 'draft' : 'work');
setBigFishRun(run);
setSelectionStage('big-fish-runtime');
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩失败。'),
);
});
} catch (error) {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼玩失败。'),
resolveBigFishErrorMessage(error, '启动大鱼吃小鱼玩失败。'),
);
});
}
}, [
bigFishRun,
bigFishRuntimeWork,
bigFishSession,
resolveBigFishErrorMessage,
setSelectionStage,
@@ -1327,18 +1340,31 @@ export function PlatformEntryFlowShellImpl({
);
const submitBigFishInput = useCallback(
(payload: SubmitBigFishInputRequest) => {
if (!bigFishRun || bigFishRun.status !== 'running') {
async (payload: SubmitBigFishInputRequest) => {
if (
!bigFishRun ||
bigFishRun.status !== 'running' ||
bigFishInputInFlightRef.current
) {
return;
}
setBigFishRun((currentRun) =>
currentRun
? advanceLocalBigFishRuntimeRun(currentRun, payload)
: currentRun,
);
bigFishInputInFlightRef.current = true;
try {
const { run } = await submitBigFishRuntimeInput(
bigFishRun.runId,
payload,
);
setBigFishRun(run);
} catch (error) {
setBigFishError(
resolveBigFishErrorMessage(error, '同步大鱼吃小鱼输入失败。'),
);
} finally {
bigFishInputInFlightRef.current = false;
}
},
[bigFishRun],
[bigFishRun, resolveBigFishErrorMessage, setBigFishError],
);
const reportBigFishObservedPlayTime = useCallback(() => {
@@ -1793,7 +1819,7 @@ export function PlatformEntryFlowShellImpl({
);
const startBigFishRunFromWork = useCallback(
(item: BigFishWorkSummary) => {
async (item: BigFishWorkSummary) => {
const sessionId = item.sourceSessionId?.trim();
if (!sessionId) {
setBigFishError('当前作品缺少会话信息,暂时无法进入玩法。');
@@ -1808,18 +1834,27 @@ export function PlatformEntryFlowShellImpl({
title: item.title,
publicWorkCode,
});
setBigFishRuntimeStartedAt(Date.now());
setBigFishRuntimeStartedAt(null);
setBigFishRuntimeSessionSource('work');
setBigFishRun(startLocalBigFishRuntimeRun({ work: item }));
setSelectionStage('big-fish-runtime');
pushAppHistoryPath(
buildPublicWorkStagePath('big-fish-runtime', publicWorkCode),
);
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩失败。'),
setBigFishRun(null);
try {
const { run } = await startBigFishRuntimeRun(sessionId);
setBigFishRuntimeStartedAt(Date.now());
setBigFishRun(run);
setSelectionStage('big-fish-runtime');
pushAppHistoryPath(
buildPublicWorkStagePath('big-fish-runtime', publicWorkCode),
);
});
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩失败。'),
);
});
} catch (error) {
setBigFishError(
resolveBigFishErrorMessage(error, '启动大鱼吃小鱼玩法失败。'),
);
}
},
[bigFishFlow, resolveBigFishErrorMessage, setSelectionStage],
);
@@ -2018,10 +2053,10 @@ export function PlatformEntryFlowShellImpl({
(entry) => entry.sourceSessionId === sessionId,
);
if (matchedEntry) {
startBigFishRunFromWork(matchedEntry);
void startBigFishRunFromWork(matchedEntry);
return;
}
startBigFishRunFromWork({
void startBigFishRunFromWork({
workId: `big-fish:${sessionId}`,
sourceSessionId: sessionId,
ownerUserId: work.ownerUserId ?? '',