合入最新 master
合并 origin/master 并保留平台入口运行态与推荐链路语义 修正合并后基于 tab 语义变化的前端断言
This commit is contained in:
@@ -317,6 +317,7 @@ import {
|
||||
submitRpgProfileFeedback,
|
||||
} from '../../services/rpg-entry/rpgProfileClient';
|
||||
import { requestRpgRuntimeJson } from '../../services/rpg-runtime/rpgRuntimeRequest';
|
||||
import { type RuntimeGuestRequestOptions } from '../../services/runtimeGuestAuth';
|
||||
import { squareHoleCreationClient } from '../../services/square-hole-creation';
|
||||
import {
|
||||
dropSquareHoleShape,
|
||||
@@ -377,11 +378,15 @@ import {
|
||||
type CreationWorkShelfItem,
|
||||
isPersistedBarkBattleDraftGenerating,
|
||||
} from '../custom-world-home/creationWorkShelf';
|
||||
import { selectAdjacentPlatformRecommendEntry } from '../rpg-entry/rpgEntryPublicGalleryViewModel';
|
||||
import {
|
||||
buildPlatformRecommendFeedEntries,
|
||||
selectAdjacentPlatformRecommendEntry,
|
||||
} from '../rpg-entry/rpgEntryPublicGalleryViewModel';
|
||||
import {
|
||||
isBigFishGalleryEntry,
|
||||
isEdutainmentGalleryEntry,
|
||||
isJumpHopGalleryEntry,
|
||||
isPuzzleClearGalleryEntry,
|
||||
isPuzzleGalleryEntry,
|
||||
mapPuzzleClearWorkToPlatformGalleryCard,
|
||||
type PlatformPublicGalleryCard,
|
||||
@@ -495,7 +500,6 @@ import {
|
||||
import {
|
||||
canExposePublicWork,
|
||||
EDUTAINMENT_HIDDEN_MESSAGE,
|
||||
filterGeneralPublicWorks,
|
||||
} from './platformEdutainmentVisibility';
|
||||
import {
|
||||
PlatformDraftGenerationPointNoticeDialog,
|
||||
@@ -1496,6 +1500,8 @@ export function PlatformEntryFlowShellImpl({
|
||||
useState<MiniGameDraftGenerationState | null>(null);
|
||||
const [jumpHopError, setJumpHopError] = useState<string | null>(null);
|
||||
const [isJumpHopBusy, setIsJumpHopBusy] = useState(false);
|
||||
const [barkBattleRuntimeRequestOptions, setBarkBattleRuntimeRequestOptions] =
|
||||
useState<RuntimeGuestRequestOptions | null>(null);
|
||||
const [puzzleClearSession, setPuzzleClearSession] =
|
||||
useState<PuzzleClearSessionSnapshotResponse | null>(null);
|
||||
const [puzzleClearRun, setPuzzleClearRun] = useState<
|
||||
@@ -1599,6 +1605,34 @@ export function PlatformEntryFlowShellImpl({
|
||||
useState<PuzzleRuntimeReturnStage>('puzzle-gallery-detail');
|
||||
const [puzzleRuntimeAuthMode, setPuzzleRuntimeAuthMode] =
|
||||
useState<PuzzleRuntimeAuthMode>('default');
|
||||
const buildRecommendRuntimeRequestOptions = useCallback(
|
||||
async (
|
||||
input: {
|
||||
kind?: RecommendRuntimeKind;
|
||||
embedded?: boolean;
|
||||
forcePublicRuntime?: boolean;
|
||||
} = {},
|
||||
) => {
|
||||
const shouldUseRuntimeOptions = Boolean(
|
||||
input.forcePublicRuntime ||
|
||||
input.embedded ||
|
||||
(input.kind && activeRecommendRuntimeKind === input.kind),
|
||||
);
|
||||
|
||||
return shouldUseRuntimeOptions
|
||||
? buildRecommendRuntimeAuthOptions(authUi, true)
|
||||
: {};
|
||||
},
|
||||
[activeRecommendRuntimeKind, authUi],
|
||||
);
|
||||
const buildPuzzleRuntimeRequestOptions = useCallback(
|
||||
() =>
|
||||
buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle',
|
||||
forcePublicRuntime: puzzleRuntimeAuthMode === 'isolated',
|
||||
}),
|
||||
[buildRecommendRuntimeRequestOptions, puzzleRuntimeAuthMode],
|
||||
);
|
||||
const [isPuzzleLeaderboardBusy, setIsPuzzleLeaderboardBusy] = useState(false);
|
||||
const submittedPuzzleLeaderboardKeysRef = useRef(new Set<string>());
|
||||
const puzzleStartInFlightKeyRef = useRef<string | null>(null);
|
||||
@@ -1734,6 +1768,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
const entries = creationEntryConfig?.creationTypes ?? [];
|
||||
return new Map(entries.map((entry) => [entry.id, entry]));
|
||||
}, [creationEntryConfig]);
|
||||
const publicWorkInteractions = useMemo(
|
||||
() => creationEntryConfig?.publicWorkInteractions ?? [],
|
||||
[creationEntryConfig],
|
||||
);
|
||||
const getUnifiedSpec = useCallback(
|
||||
(playId: UnifiedCreationPlayId) =>
|
||||
getUnifiedCreationSpec(playId, unifiedCreationConfigById.get(playId)),
|
||||
@@ -2938,10 +2976,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
} = publicGalleryFeeds;
|
||||
const recommendRuntimeEntries = useMemo(
|
||||
() =>
|
||||
buildPlatformRecommendedEntries({
|
||||
featuredEntries: filterGeneralPublicWorks(featuredGalleryEntries),
|
||||
latestEntries: filterGeneralPublicWorks(latestGalleryEntries),
|
||||
}),
|
||||
buildPlatformRecommendFeedEntries(
|
||||
featuredGalleryEntries,
|
||||
latestGalleryEntries,
|
||||
),
|
||||
[featuredGalleryEntries, latestGalleryEntries],
|
||||
);
|
||||
|
||||
@@ -6994,15 +7032,17 @@ export function PlatformEntryFlowShellImpl({
|
||||
profileId: targetProfileId,
|
||||
mode: 'play' as const,
|
||||
};
|
||||
const runtimeGuestOptions =
|
||||
options.embedded || workDetail.summary.publishStatus === 'draft'
|
||||
? await buildRecommendRuntimeAuthOptions(authUi, true)
|
||||
: {};
|
||||
const runtimeRequestOptions = await buildRecommendRuntimeRequestOptions(
|
||||
{
|
||||
kind: 'visual-novel',
|
||||
embedded: options.embedded,
|
||||
},
|
||||
);
|
||||
const { run } = options.embedded
|
||||
? await startVisualNovelRun(
|
||||
targetProfileId,
|
||||
startRunPayload,
|
||||
runtimeGuestOptions,
|
||||
runtimeRequestOptions,
|
||||
)
|
||||
: await startVisualNovelRun(targetProfileId, startRunPayload);
|
||||
setVisualNovelWork(workDetail);
|
||||
@@ -7028,7 +7068,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
},
|
||||
[
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
resolvePuzzleErrorMessage,
|
||||
setIsVisualNovelBusy,
|
||||
setSelectionStage,
|
||||
@@ -7050,14 +7090,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
setVisualNovelError(null);
|
||||
setIsVisualNovelBusy(true);
|
||||
try {
|
||||
const runtimeGuestOptions =
|
||||
activeRecommendRuntimeKind === 'visual-novel'
|
||||
? await buildRecommendRuntimeAuthOptions(authUi, true)
|
||||
: {};
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'visual-novel',
|
||||
});
|
||||
const nextRun = await streamVisualNovelRuntimeAction(
|
||||
visualNovelRun.runId,
|
||||
payload,
|
||||
runtimeGuestOptions,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setVisualNovelRun(nextRun);
|
||||
} catch (error) {
|
||||
@@ -7069,8 +7109,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
},
|
||||
[
|
||||
activeRecommendRuntimeKind,
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
isVisualNovelBusy,
|
||||
resolvePuzzleErrorMessage,
|
||||
setIsVisualNovelBusy,
|
||||
@@ -7519,22 +7558,15 @@ export function PlatformEntryFlowShellImpl({
|
||||
setJumpHopError(null);
|
||||
setJumpHopRuntimeReturnStage(options.returnStage ?? 'work-detail');
|
||||
try {
|
||||
const runtimeGuestOptions =
|
||||
options.embedded || shouldUseRecommendRuntimeGuestAuth(authUi)
|
||||
? await buildRecommendRuntimeAuthOptions(authUi, true)
|
||||
: RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS;
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'jump-hop',
|
||||
embedded: options.embedded,
|
||||
forcePublicRuntime: shouldUseRecommendRuntimeGuestAuth(authUi),
|
||||
});
|
||||
setJumpHopRuntimeRequestOptions(
|
||||
runtimeGuestOptions.runtimeGuestToken?.trim()
|
||||
? {
|
||||
runtimeGuestToken: runtimeGuestOptions.runtimeGuestToken,
|
||||
authImpact: runtimeGuestOptions.authImpact,
|
||||
skipAuth: runtimeGuestOptions.skipAuth,
|
||||
skipRefresh: runtimeGuestOptions.skipRefresh,
|
||||
notifyAuthStateChange:
|
||||
runtimeGuestOptions.notifyAuthStateChange,
|
||||
clearAuthOnUnauthorized:
|
||||
runtimeGuestOptions.clearAuthOnUnauthorized,
|
||||
}
|
||||
Object.keys(runtimeRequestOptions).length > 0
|
||||
? runtimeRequestOptions
|
||||
: null,
|
||||
);
|
||||
const [detail, runResponse] = await Promise.all([
|
||||
@@ -7544,7 +7576,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
.getWorkDetail(normalizedProfileId)
|
||||
.catch(() => null),
|
||||
jumpHopClient.startRun(normalizedProfileId, {
|
||||
...runtimeGuestOptions,
|
||||
...runtimeRequestOptions,
|
||||
runtimeMode: 'published',
|
||||
}),
|
||||
]);
|
||||
@@ -7571,7 +7603,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsJumpHopBusy(false);
|
||||
}
|
||||
},
|
||||
[authUi, setSelectionStage],
|
||||
[authUi, buildRecommendRuntimeRequestOptions, setSelectionStage],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -8012,15 +8044,16 @@ export function PlatformEntryFlowShellImpl({
|
||||
setPuzzleClearError(null);
|
||||
setPuzzleClearRuntimeReturnStage(options.returnStage ?? 'work-detail');
|
||||
try {
|
||||
const runtimeGuestOptions = await buildRecommendRuntimeAuthOptions(
|
||||
authUi,
|
||||
options.embedded,
|
||||
);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle-clear',
|
||||
embedded: options.embedded,
|
||||
});
|
||||
const [detail, runResponse] = await Promise.all([
|
||||
puzzleClearClient
|
||||
.getRuntimeWorkDetail(normalizedProfileId)
|
||||
.catch(() => null),
|
||||
puzzleClearClient.startRun(normalizedProfileId, runtimeGuestOptions),
|
||||
puzzleClearClient.startRun(normalizedProfileId, runtimeRequestOptions),
|
||||
]);
|
||||
if (detail?.item) {
|
||||
setPuzzleClearWork(detail.item);
|
||||
@@ -8045,7 +8078,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsPuzzleClearBusy(false);
|
||||
}
|
||||
},
|
||||
[authUi, setSelectionStage],
|
||||
[buildRecommendRuntimeRequestOptions, setSelectionStage],
|
||||
);
|
||||
|
||||
const retryPuzzleClearLevelRun = useCallback(async () => {
|
||||
@@ -8070,7 +8103,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsPuzzleClearBusy(true);
|
||||
setPuzzleClearError(null);
|
||||
try {
|
||||
const response = await puzzleClearClient.retryLevel(runId);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle-clear',
|
||||
});
|
||||
const response = await puzzleClearClient.retryLevel(
|
||||
runId,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setPuzzleClearRun(response.run);
|
||||
} catch (error) {
|
||||
setPuzzleClearError(
|
||||
@@ -8082,6 +8122,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}, [
|
||||
puzzleClearRun,
|
||||
puzzleClearWork,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
setSelectionStage,
|
||||
startPuzzleClearTestRunFromProfile,
|
||||
]);
|
||||
@@ -8107,7 +8148,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsPuzzleClearBusy(true);
|
||||
setPuzzleClearError(null);
|
||||
try {
|
||||
const response = await puzzleClearClient.advanceNextLevel(runId);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle-clear',
|
||||
});
|
||||
const response = await puzzleClearClient.advanceNextLevel(
|
||||
runId,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setPuzzleClearRun(response.run);
|
||||
} catch (error) {
|
||||
setPuzzleClearError(
|
||||
@@ -8116,7 +8164,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
} finally {
|
||||
setIsPuzzleClearBusy(false);
|
||||
}
|
||||
}, [puzzleClearRun, puzzleClearWork, setSelectionStage]);
|
||||
}, [
|
||||
puzzleClearRun,
|
||||
puzzleClearWork,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
setSelectionStage,
|
||||
]);
|
||||
|
||||
const markPuzzleClearLevelTimeUp = useCallback(async () => {
|
||||
const runId = puzzleClearRun?.runId;
|
||||
@@ -8130,14 +8183,21 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await puzzleClearClient.markTimeUp(runId);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle-clear',
|
||||
});
|
||||
const response = await puzzleClearClient.markTimeUp(
|
||||
runId,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setPuzzleClearRun(response.run);
|
||||
} catch (error) {
|
||||
setPuzzleClearError(
|
||||
resolveRpgCreationErrorMessage(error, '同步拼消消倒计时失败。'),
|
||||
);
|
||||
}
|
||||
}, [puzzleClearRun]);
|
||||
}, [puzzleClearRun, buildRecommendRuntimeRequestOptions]);
|
||||
|
||||
const swapPuzzleClearCardsInRun = useCallback(
|
||||
async (payload: {
|
||||
@@ -8156,7 +8216,15 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await puzzleClearClient.swapCards(runId, payload);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'puzzle-clear',
|
||||
});
|
||||
const response = await puzzleClearClient.swapCards(
|
||||
runId,
|
||||
payload,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setPuzzleClearRun(response.run);
|
||||
} catch (error) {
|
||||
setPuzzleClearError(
|
||||
@@ -8164,7 +8232,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
);
|
||||
}
|
||||
},
|
||||
[puzzleClearRun],
|
||||
[puzzleClearRun, buildRecommendRuntimeRequestOptions],
|
||||
);
|
||||
|
||||
const compileWoodenFishSession = useCallback(
|
||||
@@ -8516,16 +8584,17 @@ export function PlatformEntryFlowShellImpl({
|
||||
setWoodenFishError(null);
|
||||
setWoodenFishRuntimeReturnStage(options.returnStage ?? 'work-detail');
|
||||
try {
|
||||
const runtimeGuestOptions = await buildRecommendRuntimeAuthOptions(
|
||||
authUi,
|
||||
options.embedded,
|
||||
);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'wooden-fish',
|
||||
embedded: options.embedded,
|
||||
});
|
||||
const [detail, runResponse] = await Promise.all([
|
||||
woodenFishClient.getWorkDetail(normalizedProfileId).catch(() => null),
|
||||
options.embedded
|
||||
? woodenFishClient.startRun(
|
||||
normalizedProfileId,
|
||||
runtimeGuestOptions,
|
||||
runtimeRequestOptions,
|
||||
)
|
||||
: woodenFishClient.startRun(normalizedProfileId),
|
||||
]);
|
||||
@@ -8552,7 +8621,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsWoodenFishBusy(false);
|
||||
}
|
||||
},
|
||||
[authUi, setSelectionStage],
|
||||
[buildRecommendRuntimeRequestOptions, setSelectionStage],
|
||||
);
|
||||
|
||||
const checkpointWoodenFishRuntimeRun = useCallback(
|
||||
@@ -8564,10 +8633,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
if (!runId) {
|
||||
return;
|
||||
}
|
||||
const response = await woodenFishClient.checkpointRun(runId, payload);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'wooden-fish',
|
||||
});
|
||||
const response = await woodenFishClient.checkpointRun(
|
||||
runId,
|
||||
payload,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setWoodenFishRun(response.run);
|
||||
},
|
||||
[woodenFishRun?.runId],
|
||||
[buildRecommendRuntimeRequestOptions, woodenFishRun?.runId],
|
||||
);
|
||||
|
||||
const executePuzzleAction = puzzleFlow.executeAction;
|
||||
@@ -9038,9 +9115,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
try {
|
||||
let runtimeProfile: Match3DWorkProfile | Match3DWorkSummary = profile;
|
||||
const canReadProtectedMatch3DDetail =
|
||||
!options.embedded || !shouldUseRecommendRuntimeGuestAuth(authUi);
|
||||
if (
|
||||
!hasMatch3DRuntimeAsset(profile.generatedItemAssets) ||
|
||||
!hasMatch3DRuntimeBackgroundAsset(profile)
|
||||
canReadProtectedMatch3DDetail &&
|
||||
(!hasMatch3DRuntimeAsset(profile.generatedItemAssets) ||
|
||||
!hasMatch3DRuntimeBackgroundAsset(profile))
|
||||
) {
|
||||
try {
|
||||
const { item } = await getMatch3DWorkDetail(profile.profileId);
|
||||
@@ -9066,12 +9146,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
runtimeProfile.generatedBackgroundAsset,
|
||||
{ expireSeconds: 300 },
|
||||
);
|
||||
const runtimeGuestOptions =
|
||||
options.authMode === 'isolated'
|
||||
? RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS
|
||||
: await buildRecommendRuntimeAuthOptions(authUi, options.embedded);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'match3d',
|
||||
embedded: options.embedded,
|
||||
forcePublicRuntime: options.authMode === 'isolated',
|
||||
});
|
||||
const runtimeOptions = {
|
||||
...runtimeGuestOptions,
|
||||
...runtimeRequestOptions,
|
||||
...(typeof options.itemTypeCountOverride === 'number'
|
||||
? { itemTypeCountOverride: options.itemTypeCountOverride }
|
||||
: {}),
|
||||
@@ -9120,6 +9202,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
[
|
||||
isMatch3DBusy,
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
match3dFlow,
|
||||
resolveMatch3DErrorMessage,
|
||||
resolveMatch3DRuntimeAdapter,
|
||||
@@ -9143,12 +9226,13 @@ export function PlatformEntryFlowShellImpl({
|
||||
setSquareHoleError(null);
|
||||
|
||||
try {
|
||||
const runtimeGuestOptions = await buildRecommendRuntimeAuthOptions(
|
||||
authUi,
|
||||
options.embedded,
|
||||
);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'square-hole',
|
||||
embedded: options.embedded,
|
||||
});
|
||||
const { run } = options.embedded
|
||||
? await startSquareHoleRun(profile.profileId, runtimeGuestOptions)
|
||||
? await startSquareHoleRun(profile.profileId, runtimeRequestOptions)
|
||||
: await startSquareHoleRun(profile.profileId);
|
||||
setSquareHoleRun(run);
|
||||
setSquareHoleRuntimeReturnStage(returnStage);
|
||||
@@ -9180,7 +9264,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
},
|
||||
[
|
||||
isSquareHoleBusy,
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
resolveSquareHoleErrorMessage,
|
||||
setSelectionStage,
|
||||
setSquareHoleError,
|
||||
@@ -9298,14 +9382,14 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
bigFishInputInFlightRef.current = true;
|
||||
try {
|
||||
const runtimeGuestOptions =
|
||||
activeRecommendRuntimeKind === 'big-fish'
|
||||
? await buildRecommendRuntimeAuthOptions(authUi, true)
|
||||
: {};
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'big-fish',
|
||||
});
|
||||
const { run } = await submitBigFishRuntimeInput(
|
||||
bigFishRun.runId,
|
||||
payload,
|
||||
runtimeGuestOptions,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setBigFishRun(run);
|
||||
} catch (error) {
|
||||
@@ -9317,8 +9401,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
},
|
||||
[
|
||||
activeRecommendRuntimeKind,
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
bigFishRun,
|
||||
resolveBigFishErrorMessage,
|
||||
setBigFishError,
|
||||
@@ -9333,21 +9416,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
const elapsedMs = Math.max(1_000, Date.now() - bigFishRuntimeStartedAt);
|
||||
setBigFishRuntimeStartedAt(null);
|
||||
const reportPromise =
|
||||
activeRecommendRuntimeKind === 'big-fish'
|
||||
? buildRecommendRuntimeAuthOptions(authUi, true).then(
|
||||
(runtimeAuthOptions) =>
|
||||
recordBigFishPlay(sessionId, { elapsedMs }, runtimeAuthOptions),
|
||||
)
|
||||
: recordBigFishPlay(sessionId, { elapsedMs });
|
||||
const reportPromise = buildRecommendRuntimeRequestOptions({
|
||||
kind: 'big-fish',
|
||||
}).then((runtimeRequestOptions) =>
|
||||
recordBigFishPlay(sessionId, { elapsedMs }, runtimeRequestOptions),
|
||||
);
|
||||
void reportPromise.catch((error) => {
|
||||
setBigFishError(
|
||||
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩时长失败。'),
|
||||
);
|
||||
});
|
||||
}, [
|
||||
activeRecommendRuntimeKind,
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
bigFishRun?.sessionId,
|
||||
bigFishRuntimeStartedAt,
|
||||
resolveBigFishErrorMessage,
|
||||
@@ -9665,14 +9745,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
profileId: currentLevel.profileId,
|
||||
levelId: resolvePuzzleRestartLevelId(currentRun, detailItem),
|
||||
};
|
||||
const runtimeGuestOptions =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? await buildRecommendRuntimeGuestOptions()
|
||||
: {};
|
||||
const { run } =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? await startPuzzleRun(startRunPayload, runtimeGuestOptions)
|
||||
: await startPuzzleRun(startRunPayload);
|
||||
const runtimeRequestOptions = await buildPuzzleRuntimeRequestOptions();
|
||||
const { run } = await startPuzzleRun(
|
||||
startRunPayload,
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setSelectedPuzzleDetail(detailItem);
|
||||
puzzleRunRef.current = run;
|
||||
setPuzzleRun(run);
|
||||
@@ -9686,7 +9763,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}, [
|
||||
isPuzzleBusy,
|
||||
puzzleRun,
|
||||
puzzleRuntimeAuthMode,
|
||||
buildPuzzleRuntimeRequestOptions,
|
||||
resolvePuzzleErrorMessage,
|
||||
selectedPuzzleDetail,
|
||||
setIsPuzzleBusy,
|
||||
@@ -9798,16 +9875,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
const submitLeaderboardPromise =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? buildRecommendRuntimeGuestOptions().then((runtimeGuestOptions) =>
|
||||
submitPuzzleLeaderboard(
|
||||
puzzleRun.runId,
|
||||
payload,
|
||||
runtimeGuestOptions,
|
||||
),
|
||||
)
|
||||
: submitPuzzleLeaderboard(puzzleRun.runId, payload);
|
||||
const submitLeaderboardPromise = buildPuzzleRuntimeRequestOptions().then(
|
||||
(runtimeRequestOptions) =>
|
||||
submitPuzzleLeaderboard(puzzleRun.runId, payload, runtimeRequestOptions),
|
||||
);
|
||||
|
||||
void submitLeaderboardPromise
|
||||
.then(({ run }) => {
|
||||
@@ -9831,7 +9902,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
authUi?.user?.displayName,
|
||||
platformBootstrap,
|
||||
puzzleRun,
|
||||
puzzleRuntimeAuthMode,
|
||||
buildPuzzleRuntimeRequestOptions,
|
||||
resolvePuzzleErrorMessage,
|
||||
setPuzzleError,
|
||||
]);
|
||||
@@ -9861,10 +9932,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
const runtimeGuestOptions =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? await buildRecommendRuntimeGuestOptions()
|
||||
: {};
|
||||
const runtimeRequestOptions = await buildPuzzleRuntimeRequestOptions();
|
||||
const targetProfileId = _target?.profileId?.trim() ?? '';
|
||||
if (puzzleRun.nextLevelMode === 'similarWorks' && targetProfileId) {
|
||||
const itemPromise =
|
||||
@@ -9873,18 +9941,13 @@ export function PlatformEntryFlowShellImpl({
|
||||
: getPuzzleGalleryDetail(targetProfileId).then(
|
||||
(response) => response.item,
|
||||
);
|
||||
const advancePromise =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? advancePuzzleNextLevel(
|
||||
puzzleRun.runId,
|
||||
{
|
||||
targetProfileId,
|
||||
},
|
||||
runtimeGuestOptions,
|
||||
)
|
||||
: advancePuzzleNextLevel(puzzleRun.runId, {
|
||||
targetProfileId,
|
||||
});
|
||||
const advancePromise = advancePuzzleNextLevel(
|
||||
puzzleRun.runId,
|
||||
{
|
||||
targetProfileId,
|
||||
},
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
const [{ run }, item] = await Promise.all([
|
||||
advancePromise,
|
||||
itemPromise,
|
||||
@@ -9901,14 +9964,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
return;
|
||||
}
|
||||
|
||||
const { run } =
|
||||
puzzleRuntimeAuthMode === 'isolated'
|
||||
? await advancePuzzleNextLevel(
|
||||
puzzleRun.runId,
|
||||
{},
|
||||
runtimeGuestOptions,
|
||||
)
|
||||
: await advancePuzzleNextLevel(puzzleRun.runId, {});
|
||||
const { run } = await advancePuzzleNextLevel(
|
||||
puzzleRun.runId,
|
||||
{},
|
||||
runtimeRequestOptions,
|
||||
);
|
||||
setPuzzleRun(run);
|
||||
} catch (error) {
|
||||
setPuzzleError(resolvePuzzleErrorMessage(error, '准备下一关失败。'));
|
||||
@@ -9921,7 +9981,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
isPuzzleBusy,
|
||||
isPuzzleLeaderboardBusy,
|
||||
puzzleRun,
|
||||
puzzleRuntimeAuthMode,
|
||||
buildPuzzleRuntimeRequestOptions,
|
||||
resolvePuzzleErrorMessage,
|
||||
selectedPuzzleDetail,
|
||||
setIsPuzzleBusy,
|
||||
@@ -10696,7 +10756,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsPublicWorkDetailBusy(true);
|
||||
setPublicWorkDetailError(null);
|
||||
|
||||
const intent = resolvePlatformPublicWorkLikeIntent(entry);
|
||||
const intent = resolvePlatformPublicWorkLikeIntent(
|
||||
entry,
|
||||
publicWorkInteractions,
|
||||
);
|
||||
|
||||
if (intent.type === 'like-big-fish') {
|
||||
void likeBigFishGalleryWork(intent.profileId)
|
||||
@@ -10806,6 +10869,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
[
|
||||
isPublicWorkDetailBusy,
|
||||
platformBootstrap,
|
||||
publicWorkInteractions,
|
||||
resolveBigFishErrorMessage,
|
||||
resolvePuzzleErrorMessage,
|
||||
runProtectedAction,
|
||||
@@ -12452,12 +12516,13 @@ export function PlatformEntryFlowShellImpl({
|
||||
setBigFishRuntimeReturnStage(returnStage);
|
||||
setBigFishRun(null);
|
||||
try {
|
||||
const runtimeGuestOptions = await buildRecommendRuntimeAuthOptions(
|
||||
authUi,
|
||||
options.embedded,
|
||||
);
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'big-fish',
|
||||
embedded: options.embedded,
|
||||
});
|
||||
const { run } = options.embedded
|
||||
? await startBigFishRuntimeRun(sessionId, runtimeGuestOptions)
|
||||
? await startBigFishRuntimeRun(sessionId, runtimeRequestOptions)
|
||||
: await startBigFishRuntimeRun(sessionId);
|
||||
setBigFishRuntimeStartedAt(Date.now());
|
||||
setBigFishRun(run);
|
||||
@@ -12468,7 +12533,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
);
|
||||
}
|
||||
const recordPlayPromise = options.embedded
|
||||
? recordBigFishPlay(sessionId, { elapsedMs: 0 }, runtimeGuestOptions)
|
||||
? recordBigFishPlay(sessionId, { elapsedMs: 0 }, runtimeRequestOptions)
|
||||
: recordBigFishPlay(sessionId, { elapsedMs: 0 });
|
||||
void recordPlayPromise.catch((error) => {
|
||||
setBigFishError(
|
||||
@@ -12484,7 +12549,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
}
|
||||
},
|
||||
[
|
||||
authUi,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
bigFishFlow,
|
||||
resolveBigFishErrorMessage,
|
||||
setBigFishError,
|
||||
@@ -12511,12 +12576,18 @@ export function PlatformEntryFlowShellImpl({
|
||||
);
|
||||
setBarkBattleRuntimeReturnStage(returnStage);
|
||||
try {
|
||||
const runtimeGuestOptions = await buildRecommendRuntimeAuthOptions(
|
||||
authUi,
|
||||
options.embedded,
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({
|
||||
kind: 'bark-battle',
|
||||
embedded: options.embedded,
|
||||
});
|
||||
setBarkBattleRuntimeRequestOptions(
|
||||
Object.keys(runtimeRequestOptions).length > 0
|
||||
? runtimeRequestOptions
|
||||
: null,
|
||||
);
|
||||
const runResponse = options.embedded
|
||||
? await startBarkBattleRun(item.workId, {}, runtimeGuestOptions)
|
||||
? await startBarkBattleRun(item.workId, {}, runtimeRequestOptions)
|
||||
: await startBarkBattleRun(item.workId);
|
||||
void runResponse;
|
||||
selectionStageRef.current = 'bark-battle-runtime';
|
||||
@@ -12537,7 +12608,11 @@ export function PlatformEntryFlowShellImpl({
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[authUi, resolveBarkBattleErrorMessage, setSelectionStage],
|
||||
[
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
resolveBarkBattleErrorMessage,
|
||||
setSelectionStage,
|
||||
],
|
||||
);
|
||||
|
||||
const startSelectedPublicWork = useCallback(() => {
|
||||
@@ -12991,10 +13066,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
match3dFlow.setIsBusy(true);
|
||||
setMatch3DError(null);
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.restartRun(match3dRun.runId)
|
||||
void buildRecommendRuntimeRequestOptions({ kind: 'match3d' })
|
||||
.then((runtimeRequestOptions) =>
|
||||
resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
).restartRun(match3dRun.runId, runtimeRequestOptions),
|
||||
)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
})
|
||||
@@ -13008,24 +13085,28 @@ export function PlatformEntryFlowShellImpl({
|
||||
});
|
||||
}}
|
||||
onOptimisticRunChange={setMatch3DRun}
|
||||
onClickItem={(payload) => {
|
||||
onClickItem={async (payload) => {
|
||||
const runId = payload.runId ?? match3dRun?.runId;
|
||||
if (!runId) {
|
||||
return Promise.reject(new Error('抓大鹅运行态缺少 runId。'));
|
||||
}
|
||||
const runtimeRequestOptions =
|
||||
await buildRecommendRuntimeRequestOptions({ kind: 'match3d' });
|
||||
return resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
).clickItem(runId, payload);
|
||||
).clickItem(runId, payload, runtimeRequestOptions);
|
||||
}}
|
||||
onTimeExpired={() => {
|
||||
if (!match3dRun?.runId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
)
|
||||
.finishTimeUp(match3dRun.runId)
|
||||
void buildRecommendRuntimeRequestOptions({ kind: 'match3d' })
|
||||
.then((runtimeRequestOptions) =>
|
||||
resolveMatch3DRuntimeAdapter(
|
||||
activeMatch3DRuntimeProfile?.profileId,
|
||||
).finishTimeUp(match3dRun.runId, runtimeRequestOptions),
|
||||
)
|
||||
.then(({ run }) => {
|
||||
setMatch3DRun(run);
|
||||
})
|
||||
@@ -13159,9 +13240,17 @@ export function PlatformEntryFlowShellImpl({
|
||||
squareHoleRun?.runId &&
|
||||
squareHoleRun.status.toLowerCase() === 'running'
|
||||
) {
|
||||
void stopSquareHoleRun(squareHoleRun.runId).catch(
|
||||
() => undefined,
|
||||
);
|
||||
void buildRecommendRuntimeRequestOptions({
|
||||
kind: 'square-hole',
|
||||
})
|
||||
.then((runtimeRequestOptions) =>
|
||||
stopSquareHoleRun(
|
||||
squareHoleRun.runId,
|
||||
undefined,
|
||||
runtimeRequestOptions,
|
||||
),
|
||||
)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
setActiveRecommendRuntimeKind(null);
|
||||
}}
|
||||
@@ -13172,7 +13261,12 @@ export function PlatformEntryFlowShellImpl({
|
||||
|
||||
squareHoleFlow.setIsBusy(true);
|
||||
setSquareHoleError(null);
|
||||
void restartSquareHoleRun(squareHoleRun.runId)
|
||||
void buildRecommendRuntimeRequestOptions({
|
||||
kind: 'square-hole',
|
||||
})
|
||||
.then((runtimeRequestOptions) =>
|
||||
restartSquareHoleRun(squareHoleRun.runId, runtimeRequestOptions),
|
||||
)
|
||||
.then(({ run }) => {
|
||||
setSquareHoleRun(run);
|
||||
})
|
||||
@@ -13194,14 +13288,26 @@ export function PlatformEntryFlowShellImpl({
|
||||
if (!runId) {
|
||||
return Promise.reject(new Error('方洞挑战运行态缺少 runId。'));
|
||||
}
|
||||
return dropSquareHoleShape(runId, payload);
|
||||
return buildRecommendRuntimeRequestOptions({
|
||||
kind: 'square-hole',
|
||||
}).then((runtimeRequestOptions) =>
|
||||
dropSquareHoleShape(runId, payload, runtimeRequestOptions),
|
||||
);
|
||||
}}
|
||||
onTimeExpired={() => {
|
||||
if (!squareHoleRun?.runId) {
|
||||
return;
|
||||
}
|
||||
|
||||
void finishSquareHoleTimeUp(squareHoleRun.runId)
|
||||
void buildRecommendRuntimeRequestOptions({
|
||||
kind: 'square-hole',
|
||||
})
|
||||
.then((runtimeRequestOptions) =>
|
||||
finishSquareHoleTimeUp(
|
||||
squareHoleRun.runId,
|
||||
runtimeRequestOptions,
|
||||
),
|
||||
)
|
||||
.then(({ run }) => {
|
||||
setSquareHoleRun(run);
|
||||
})
|
||||
@@ -13246,6 +13352,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
workId={barkBattlePublishedConfig.workId}
|
||||
publishedConfig={barkBattlePublishedConfig}
|
||||
runtimeMode="published"
|
||||
runtimeRequestOptions={barkBattleRuntimeRequestOptions ?? undefined}
|
||||
onExit={() => {
|
||||
setActiveRecommendRuntimeKind(null);
|
||||
}}
|
||||
@@ -13276,7 +13383,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
activeRecommendEntryKey,
|
||||
activeRecommendRuntimeKind,
|
||||
barkBattlePublishedConfig,
|
||||
barkBattleRuntimeRequestOptions,
|
||||
babyObjectMatchDraft,
|
||||
buildRecommendRuntimeRequestOptions,
|
||||
bigFishError,
|
||||
bigFishRun,
|
||||
bigFishRuntimeShare,
|
||||
@@ -13313,6 +13422,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
recommendRuntimeEntries,
|
||||
remodelCurrentPuzzleRuntimeWork,
|
||||
resolveMatch3DErrorMessage,
|
||||
resolveMatch3DRuntimeAdapter,
|
||||
resolveSquareHoleErrorMessage,
|
||||
reportBigFishObservedPlayTime,
|
||||
restartBigFishRun,
|
||||
@@ -13442,7 +13552,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
setIsPublicWorkDetailBusy(true);
|
||||
setPublicWorkDetailError(null);
|
||||
|
||||
const intent = resolvePlatformPublicWorkRemixIntent(entry);
|
||||
const intent = resolvePlatformPublicWorkRemixIntent(
|
||||
entry,
|
||||
publicWorkInteractions,
|
||||
);
|
||||
|
||||
if (intent.type === 'remix-big-fish') {
|
||||
void remixBigFishGalleryWork(intent.profileId)
|
||||
@@ -13517,6 +13630,7 @@ export function PlatformEntryFlowShellImpl({
|
||||
isPublicWorkDetailBusy,
|
||||
platformBootstrap,
|
||||
puzzleFlow,
|
||||
publicWorkInteractions,
|
||||
resetRecommendRuntimeSelection,
|
||||
resolveBigFishErrorMessage,
|
||||
resolvePuzzleErrorMessage,
|
||||
@@ -16702,6 +16816,9 @@ export function PlatformEntryFlowShellImpl({
|
||||
workId={barkBattlePublishedConfig.workId}
|
||||
publishedConfig={barkBattlePublishedConfig}
|
||||
runtimeMode={barkBattleRuntimeMode}
|
||||
runtimeRequestOptions={
|
||||
barkBattleRuntimeRequestOptions ?? undefined
|
||||
}
|
||||
onExit={() => {
|
||||
if (
|
||||
barkBattleRuntimeReturnStage === 'bark-battle-result' &&
|
||||
|
||||
@@ -899,6 +899,23 @@ test('platform public work detail flow resolves like intent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('platform public work detail flow respects configured like disable', () => {
|
||||
expect(
|
||||
resolvePlatformPublicWorkLikeIntent(buildTypedEntry('puzzle'), [
|
||||
{
|
||||
sourceType: 'puzzle',
|
||||
likeEnabled: false,
|
||||
remixEnabled: true,
|
||||
likeDisabledMessage: '拼图点赞维护中。',
|
||||
remixDisabledMessage: '拼图改造维护中。',
|
||||
},
|
||||
]),
|
||||
).toEqual({
|
||||
type: 'unsupported',
|
||||
errorMessage: '拼图点赞维护中。',
|
||||
});
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves remix intent', () => {
|
||||
expect(
|
||||
resolvePlatformPublicWorkRemixIntent(buildTypedEntry('big-fish')),
|
||||
@@ -969,13 +986,31 @@ test('platform public work detail flow resolves remix intent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('platform public work detail flow respects configured remix disable', () => {
|
||||
expect(
|
||||
resolvePlatformPublicWorkRemixIntent(buildRpgEntry(), [
|
||||
{
|
||||
sourceType: 'custom-world',
|
||||
likeEnabled: true,
|
||||
remixEnabled: false,
|
||||
likeDisabledMessage: 'RPG 点赞维护中。',
|
||||
remixDisabledMessage: 'RPG 改造维护中。',
|
||||
},
|
||||
]),
|
||||
).toEqual({
|
||||
type: 'unsupported',
|
||||
errorMessage: 'RPG 改造维护中。',
|
||||
});
|
||||
});
|
||||
|
||||
test('platform public work detail flow resolves edit intent for draft-backed works', () => {
|
||||
const bigFishEntry = buildTypedEntry('big-fish');
|
||||
expect(resolvePlatformPublicWorkEditIntent(bigFishEntry, buildEditIntentDeps()))
|
||||
.toEqual({
|
||||
type: 'edit-big-fish',
|
||||
work: mapPublicWorkDetailToBigFishWork(bigFishEntry),
|
||||
});
|
||||
expect(
|
||||
resolvePlatformPublicWorkEditIntent(bigFishEntry, buildEditIntentDeps()),
|
||||
).toEqual({
|
||||
type: 'edit-big-fish',
|
||||
work: mapPublicWorkDetailToBigFishWork(bigFishEntry),
|
||||
});
|
||||
|
||||
const selectedPuzzleDetail = buildPuzzleWork({
|
||||
profileId: 'puzzle-profile',
|
||||
@@ -1153,7 +1188,10 @@ test('platform public work detail flow resolves edit intent for unsupported and
|
||||
|
||||
const edutainmentEntry = buildTypedEntry('edutainment');
|
||||
expect(
|
||||
resolvePlatformPublicWorkEditIntent(edutainmentEntry, buildEditIntentDeps()),
|
||||
resolvePlatformPublicWorkEditIntent(
|
||||
edutainmentEntry,
|
||||
buildEditIntentDeps(),
|
||||
),
|
||||
).toEqual({
|
||||
type: 'resolve-edutainment-draft',
|
||||
entry: edutainmentEntry,
|
||||
|
||||
@@ -97,6 +97,14 @@ export type PlatformPublicWorkDetailOpenStrategy =
|
||||
|
||||
export type PlatformPublicWorkActionMode = 'edit' | 'remix';
|
||||
|
||||
export type PlatformPublicWorkInteractionConfig = {
|
||||
sourceType: string;
|
||||
likeEnabled: boolean;
|
||||
remixEnabled: boolean;
|
||||
likeDisabledMessage: string;
|
||||
remixDisabledMessage: string;
|
||||
};
|
||||
|
||||
export type PlatformPublicWorkLikeIntent =
|
||||
| {
|
||||
type: 'like-big-fish';
|
||||
@@ -678,9 +686,55 @@ export function resolvePlatformPublicWorkActionMode(
|
||||
: 'remix';
|
||||
}
|
||||
|
||||
export function getPlatformPublicWorkInteractionSourceType(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
) {
|
||||
return 'sourceType' in entry ? entry.sourceType : 'custom-world';
|
||||
}
|
||||
|
||||
function resolveConfiguredPublicWorkInteractionBlock(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
configs: readonly PlatformPublicWorkInteractionConfig[] | null | undefined,
|
||||
action: 'like' | 'remix',
|
||||
): PlatformPublicWorkLikeIntent | PlatformPublicWorkRemixIntent | null {
|
||||
const sourceType = getPlatformPublicWorkInteractionSourceType(entry);
|
||||
const config = configs?.find((item) => item.sourceType === sourceType);
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (action === 'like' && !config.likeEnabled) {
|
||||
return {
|
||||
type: 'unsupported',
|
||||
errorMessage:
|
||||
config.likeDisabledMessage.trim() || '该作品类型暂不支持点赞。',
|
||||
};
|
||||
}
|
||||
|
||||
if (action === 'remix' && !config.remixEnabled) {
|
||||
return {
|
||||
type: 'unsupported',
|
||||
errorMessage:
|
||||
config.remixDisabledMessage.trim() || '该作品类型暂不支持改造。',
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolvePlatformPublicWorkLikeIntent(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
configs?: readonly PlatformPublicWorkInteractionConfig[] | null,
|
||||
): PlatformPublicWorkLikeIntent {
|
||||
const configuredBlock = resolveConfiguredPublicWorkInteractionBlock(
|
||||
entry,
|
||||
configs,
|
||||
'like',
|
||||
);
|
||||
if (configuredBlock) {
|
||||
return configuredBlock as PlatformPublicWorkLikeIntent;
|
||||
}
|
||||
|
||||
if (isBigFishGalleryEntry(entry)) {
|
||||
return {
|
||||
type: 'like-big-fish',
|
||||
@@ -760,7 +814,17 @@ export function resolvePlatformPublicWorkLikeIntent(
|
||||
|
||||
export function resolvePlatformPublicWorkRemixIntent(
|
||||
entry: PlatformPublicGalleryCard,
|
||||
configs?: readonly PlatformPublicWorkInteractionConfig[] | null,
|
||||
): PlatformPublicWorkRemixIntent {
|
||||
const configuredBlock = resolveConfiguredPublicWorkInteractionBlock(
|
||||
entry,
|
||||
configs,
|
||||
'remix',
|
||||
);
|
||||
if (configuredBlock) {
|
||||
return configuredBlock as PlatformPublicWorkRemixIntent;
|
||||
}
|
||||
|
||||
if (isBigFishGalleryEntry(entry)) {
|
||||
return {
|
||||
type: 'remix-big-fish',
|
||||
@@ -933,8 +997,9 @@ export function resolvePlatformPublicWorkEditIntent(
|
||||
|
||||
if (isVisualNovelGalleryEntry(entry)) {
|
||||
const work =
|
||||
deps.visualNovelWorks?.find((item) => item.profileId === entry.profileId) ??
|
||||
null;
|
||||
deps.visualNovelWorks?.find(
|
||||
(item) => item.profileId === entry.profileId,
|
||||
) ?? null;
|
||||
if (!work) {
|
||||
return {
|
||||
type: 'blocked',
|
||||
|
||||
Reference in New Issue
Block a user