refactor: 收口创作恢复URL模型

This commit is contained in:
2026-06-03 20:46:39 +08:00
parent fe2f8a66e6
commit 30ead590e2
9 changed files with 569 additions and 218 deletions

View File

@@ -0,0 +1,36 @@
/** 收口拼图草稿在 session/profile/work 之间的稳定身份互推规则。 */
export function buildPuzzleResultProfileId(
sessionId: string | null | undefined,
) {
const stableSuffix = resolvePuzzleSessionStableSuffix(sessionId);
return stableSuffix ? `puzzle-profile-${stableSuffix}` : null;
}
export function buildPuzzleResultWorkId(sessionId: string | null | undefined) {
const stableSuffix = resolvePuzzleSessionStableSuffix(sessionId);
return stableSuffix ? `puzzle-work-${stableSuffix}` : null;
}
export function buildPuzzleSessionIdFromProfileId(
profileId: string | null | undefined,
) {
const normalizedProfileId = profileId?.trim();
if (!normalizedProfileId?.startsWith('puzzle-profile-')) {
return null;
}
const stableSuffix = normalizedProfileId.slice('puzzle-profile-'.length);
return stableSuffix ? `puzzle-session-${stableSuffix}` : null;
}
function resolvePuzzleSessionStableSuffix(
sessionId: string | null | undefined,
) {
const normalizedSessionId = sessionId?.trim();
if (!normalizedSessionId) {
return null;
}
return normalizedSessionId.startsWith('puzzle-session-')
? normalizedSessionId.slice('puzzle-session-'.length)
: normalizedSessionId;
}