refactor: 收口创作恢复URL模型
This commit is contained in:
36
src/components/platform-entry/platformPuzzleIdentityModel.ts
Normal file
36
src/components/platform-entry/platformPuzzleIdentityModel.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user