fix recommend runtime auth isolation

This commit is contained in:
2026-05-09 16:08:40 +08:00
parent 9ca66715a4
commit 80a4183b45
14 changed files with 292 additions and 25 deletions

View File

@@ -382,6 +382,11 @@ const AGENT_RESULT_STRUCTURAL_BLOCKER_CODES = new Set([
'publish_missing_main_chapter',
'publish_missing_first_act',
]);
const RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS = {
skipRefresh: true,
notifyAuthStateChange: false,
clearAuthOnUnauthorized: false,
};
function getPlatformPublicGalleryEntryTime(entry: PlatformPublicGalleryCard) {
const rawTime = entry.publishedAt ?? entry.updatedAt;
@@ -3495,13 +3500,23 @@ export function PlatformEntryFlowShellImpl({
? visualNovelWork
: null;
if (!workDetail) {
const response = await getVisualNovelWorkDetail(targetProfileId);
const response = await getVisualNovelWorkDetail(
targetProfileId,
options.embedded ? RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS : {},
);
workDetail = response.work;
}
const { run } = await startVisualNovelRun(targetProfileId, {
const startRunPayload = {
profileId: targetProfileId,
mode: 'play',
});
mode: 'play' as const,
};
const { run } = options.embedded
? await startVisualNovelRun(
targetProfileId,
startRunPayload,
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: await startVisualNovelRun(targetProfileId, startRunPayload);
setVisualNovelWork(workDetail);
setVisualNovelRun(run);
setVisualNovelRuntimeReturnStage(returnStage);
@@ -4004,10 +4019,16 @@ export function PlatformEntryFlowShellImpl({
try {
const item =
detailItem ?? (await getPuzzleGalleryDetail(profileId)).item;
const { run } = await startPuzzleRun({
const startRunPayload = {
profileId: item.profileId,
levelId: levelId ?? null,
});
};
const { run } = options.embedded
? await startPuzzleRun(
startRunPayload,
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: await startPuzzleRun(startRunPayload);
setSelectedPuzzleDetail(item);
setPuzzleRun(run);
setPuzzleRuntimeReturnStage(returnStage);
@@ -4057,7 +4078,12 @@ export function PlatformEntryFlowShellImpl({
setMatch3DError(null);
try {
const { run } = await startMatch3DRun(profile.profileId);
const { run } = options.embedded
? await startMatch3DRun(
profile.profileId,
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: await startMatch3DRun(profile.profileId);
setMatch3DRun(run);
setMatch3DRuntimeReturnStage(returnStage);
if (!options.embedded) {
@@ -4110,7 +4136,12 @@ export function PlatformEntryFlowShellImpl({
setSquareHoleError(null);
try {
const { run } = await startSquareHoleRun(profile.profileId);
const { run } = options.embedded
? await startSquareHoleRun(
profile.profileId,
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: await startSquareHoleRun(profile.profileId);
setSquareHoleRun(run);
setSquareHoleRuntimeReturnStage(returnStage);
if (!options.embedded) {
@@ -4279,12 +4310,21 @@ export function PlatformEntryFlowShellImpl({
const elapsedMs = Math.max(1_000, Date.now() - bigFishRuntimeStartedAt);
setBigFishRuntimeStartedAt(null);
void recordBigFishPlay(sessionId, { elapsedMs }).catch((error) => {
const reportPromise =
activeRecommendRuntimeKind === 'big-fish'
? recordBigFishPlay(
sessionId,
{ elapsedMs },
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: recordBigFishPlay(sessionId, { elapsedMs });
void reportPromise.catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩时长失败。'),
);
});
}, [
activeRecommendRuntimeKind,
bigFishRun?.sessionId,
bigFishRuntimeStartedAt,
resolveBigFishErrorMessage,
@@ -5844,7 +5884,12 @@ export function PlatformEntryFlowShellImpl({
setBigFishRuntimeReturnStage(returnStage);
setBigFishRun(null);
try {
const { run } = await startBigFishRuntimeRun(sessionId);
const { run } = options.embedded
? await startBigFishRuntimeRun(
sessionId,
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: await startBigFishRuntimeRun(sessionId);
setBigFishRuntimeStartedAt(Date.now());
setBigFishRun(run);
if (!options.embedded) {
@@ -5853,7 +5898,14 @@ export function PlatformEntryFlowShellImpl({
buildPublicWorkStagePath('big-fish-runtime', publicWorkCode),
);
}
void recordBigFishPlay(sessionId, { elapsedMs: 0 }).catch((error) => {
const recordPlayPromise = options.embedded
? recordBigFishPlay(
sessionId,
{ elapsedMs: 0 },
RECOMMEND_RUNTIME_BACKGROUND_AUTH_OPTIONS,
)
: recordBigFishPlay(sessionId, { elapsedMs: 0 });
void recordPlayPromise.catch((error) => {
setBigFishError(
resolveBigFishErrorMessage(error, '记录大鱼吃小鱼游玩失败。'),
);
@@ -6410,6 +6462,7 @@ export function PlatformEntryFlowShellImpl({
if (
selectionStage !== 'platform' ||
platformBootstrap.platformTab !== 'home' ||
!platformBootstrap.canReadProtectedData ||
platformBootstrap.isLoadingPlatform
) {
return;
@@ -6439,6 +6492,7 @@ export function PlatformEntryFlowShellImpl({
}, [
activeRecommendEntryKey,
isStartingRecommendEntry,
platformBootstrap.canReadProtectedData,
platformBootstrap.isLoadingPlatform,
platformBootstrap.platformTab,
recommendRuntimeEntries,