refactor: 收口平台阶段失权判定
This commit is contained in:
@@ -532,6 +532,7 @@ import {
|
||||
buildPuzzleResultProfileId,
|
||||
buildPuzzleResultWorkId,
|
||||
} from './platformPuzzleIdentityModel';
|
||||
import { resolveSelectionStageAfterProtectedDataLoss } from './platformSelectionStageModel';
|
||||
import { PlatformTaskCompletionDialog } from './PlatformTaskCompletionDialog';
|
||||
import { PlatformWorkDetailView } from './PlatformWorkDetailView';
|
||||
import { usePlatformCreationAgentFlowController } from './usePlatformCreationAgentFlowController';
|
||||
@@ -6657,24 +6658,10 @@ export function PlatformEntryFlowShellImpl({
|
||||
persistRpgAgentUiState(null, null);
|
||||
resetAutoSaveTrackingToIdle();
|
||||
|
||||
if (
|
||||
selectionStage !== 'platform' &&
|
||||
selectionStage !== 'work-detail' &&
|
||||
selectionStage !== 'detail' &&
|
||||
selectionStage !== 'agent-workspace' &&
|
||||
selectionStage !== 'big-fish-agent-workspace' &&
|
||||
selectionStage !== 'match3d-agent-workspace' &&
|
||||
selectionStage !== 'square-hole-agent-workspace' &&
|
||||
selectionStage !== 'jump-hop-workspace' &&
|
||||
selectionStage !== 'wooden-fish-workspace' &&
|
||||
selectionStage !== 'puzzle-agent-workspace' &&
|
||||
selectionStage !== 'bark-battle-workspace' &&
|
||||
selectionStage !== 'visual-novel-agent-workspace' &&
|
||||
selectionStage !== 'baby-object-match-workspace' &&
|
||||
selectionStage !== 'creative-agent-workspace' &&
|
||||
selectionStage !== 'puzzle-gallery-detail'
|
||||
) {
|
||||
setSelectionStage('platform');
|
||||
const nextSelectionStage =
|
||||
resolveSelectionStageAfterProtectedDataLoss(selectionStage);
|
||||
if (nextSelectionStage !== selectionStage) {
|
||||
setSelectionStage(nextSelectionStage);
|
||||
}
|
||||
}, [
|
||||
authUi?.user,
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import type { SelectionStage } from './platformEntryTypes';
|
||||
import { resolveSelectionStageAfterProtectedDataLoss } from './platformSelectionStageModel';
|
||||
|
||||
describe('platformSelectionStageModel', () => {
|
||||
test('keeps public and workspace stages after protected data loss', () => {
|
||||
const stableStages: SelectionStage[] = [
|
||||
'platform',
|
||||
'work-detail',
|
||||
'detail',
|
||||
'agent-workspace',
|
||||
'big-fish-agent-workspace',
|
||||
'match3d-agent-workspace',
|
||||
'square-hole-agent-workspace',
|
||||
'jump-hop-workspace',
|
||||
'wooden-fish-workspace',
|
||||
'puzzle-agent-workspace',
|
||||
'bark-battle-workspace',
|
||||
'visual-novel-agent-workspace',
|
||||
'baby-object-match-workspace',
|
||||
'creative-agent-workspace',
|
||||
'puzzle-gallery-detail',
|
||||
];
|
||||
|
||||
stableStages.forEach((stage) => {
|
||||
expect(resolveSelectionStageAfterProtectedDataLoss(stage)).toBe(stage);
|
||||
});
|
||||
});
|
||||
|
||||
test('resets private result, generating, runtime and profile stages to platform', () => {
|
||||
const resetStages: SelectionStage[] = [
|
||||
'profile-feedback',
|
||||
'big-fish-generating',
|
||||
'big-fish-result',
|
||||
'big-fish-runtime',
|
||||
'match3d-generating',
|
||||
'match3d-result',
|
||||
'match3d-runtime',
|
||||
'square-hole-generating',
|
||||
'square-hole-result',
|
||||
'square-hole-runtime',
|
||||
'jump-hop-generating',
|
||||
'jump-hop-result',
|
||||
'jump-hop-runtime',
|
||||
'jump-hop-gallery-detail',
|
||||
'wooden-fish-generating',
|
||||
'wooden-fish-result',
|
||||
'wooden-fish-runtime',
|
||||
'visual-novel-generating',
|
||||
'visual-novel-result',
|
||||
'visual-novel-gallery-detail',
|
||||
'visual-novel-runtime',
|
||||
'baby-object-match-generating',
|
||||
'baby-object-match-result',
|
||||
'baby-object-match-runtime',
|
||||
'baby-love-drawing-runtime',
|
||||
'puzzle-generating',
|
||||
'puzzle-onboarding',
|
||||
'puzzle-result',
|
||||
'puzzle-runtime',
|
||||
'custom-world-generating',
|
||||
'custom-world-result',
|
||||
'bark-battle-generating',
|
||||
'bark-battle-result',
|
||||
'bark-battle-runtime',
|
||||
];
|
||||
|
||||
resetStages.forEach((stage) => {
|
||||
expect(resolveSelectionStageAfterProtectedDataLoss(stage)).toBe(
|
||||
'platform',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
59
src/components/platform-entry/platformSelectionStageModel.ts
Normal file
59
src/components/platform-entry/platformSelectionStageModel.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import type { SelectionStage } from './platformEntryTypes';
|
||||
|
||||
const PROTECTED_DATA_LOSS_STABLE_STAGE_BY_STAGE = {
|
||||
platform: true,
|
||||
'profile-feedback': false,
|
||||
'work-detail': true,
|
||||
detail: true,
|
||||
'agent-workspace': true,
|
||||
'big-fish-agent-workspace': true,
|
||||
'big-fish-generating': false,
|
||||
'big-fish-result': false,
|
||||
'big-fish-runtime': false,
|
||||
'match3d-agent-workspace': true,
|
||||
'match3d-generating': false,
|
||||
'match3d-result': false,
|
||||
'match3d-runtime': false,
|
||||
'square-hole-agent-workspace': true,
|
||||
'square-hole-generating': false,
|
||||
'square-hole-result': false,
|
||||
'square-hole-runtime': false,
|
||||
'jump-hop-workspace': true,
|
||||
'jump-hop-generating': false,
|
||||
'jump-hop-result': false,
|
||||
'jump-hop-runtime': false,
|
||||
'jump-hop-gallery-detail': false,
|
||||
'bark-battle-workspace': true,
|
||||
'bark-battle-generating': false,
|
||||
'bark-battle-result': false,
|
||||
'bark-battle-runtime': false,
|
||||
'wooden-fish-workspace': true,
|
||||
'wooden-fish-generating': false,
|
||||
'wooden-fish-result': false,
|
||||
'wooden-fish-runtime': false,
|
||||
'creative-agent-workspace': true,
|
||||
'visual-novel-agent-workspace': true,
|
||||
'visual-novel-generating': false,
|
||||
'visual-novel-result': false,
|
||||
'visual-novel-gallery-detail': false,
|
||||
'visual-novel-runtime': false,
|
||||
'baby-object-match-workspace': true,
|
||||
'baby-object-match-generating': false,
|
||||
'baby-object-match-result': false,
|
||||
'baby-object-match-runtime': false,
|
||||
'baby-love-drawing-runtime': false,
|
||||
'puzzle-agent-workspace': true,
|
||||
'puzzle-generating': false,
|
||||
'puzzle-onboarding': false,
|
||||
'puzzle-result': false,
|
||||
'puzzle-gallery-detail': true,
|
||||
'puzzle-runtime': false,
|
||||
'custom-world-generating': false,
|
||||
'custom-world-result': false,
|
||||
} as const satisfies Record<SelectionStage, boolean>;
|
||||
|
||||
export function resolveSelectionStageAfterProtectedDataLoss(
|
||||
stage: SelectionStage,
|
||||
): SelectionStage {
|
||||
return PROTECTED_DATA_LOSS_STABLE_STAGE_BY_STAGE[stage] ? stage : 'platform';
|
||||
}
|
||||
Reference in New Issue
Block a user