修复作品架已发布卡片分享入口
为作品架分享按钮补充可见底色与回归测试 将已发布作品卡分享动作接入统一发布分享弹窗 同步玩法链路文档中的作品架分享口径
This commit is contained in:
@@ -12,8 +12,10 @@ import type { WoodenFishWorkSummaryResponse } from '../../../packages/shared/src
|
||||
import type { CustomWorldLibraryEntry } from '../../../packages/shared/src/contracts/runtime';
|
||||
import type { SquareHoleWorkSummary } from '../../../packages/shared/src/contracts/squareHoleWorks';
|
||||
import type { VisualNovelWorkSummary } from '../../../packages/shared/src/contracts/visualNovel';
|
||||
import { resolveSelectionStageFromPath } from '../../routing/appPageRoutes';
|
||||
import type { CreationEntryConfig } from '../../services/creationEntryConfigService';
|
||||
import type { CustomWorldProfile } from '../../types';
|
||||
import type { PublishShareModalPayload } from '../common/publishShareModalModel';
|
||||
import type {
|
||||
PlatformCreationTypeCard,
|
||||
PlatformCreationTypeId,
|
||||
@@ -99,6 +101,7 @@ type CustomWorldCreationHubProps = {
|
||||
item: CreationWorkShelfItem,
|
||||
) => CreationWorkShelfRuntimeState | null;
|
||||
onOpenShelfItem?: (item: CreationWorkShelfItem) => void;
|
||||
onShareWork?: ((payload: PublishShareModalPayload) => void) | null;
|
||||
// 中文注释:底部加号入口可传入后端作品架摘要,用于推导最近使用过的模板。
|
||||
recentWorkItems?: CreationWorkShelfItem[];
|
||||
mode?: 'full' | 'start-only' | 'works-only';
|
||||
@@ -167,6 +170,41 @@ function writeWorkMetricSnapshot(items: CreationWorkShelfItem[]) {
|
||||
}
|
||||
}
|
||||
|
||||
function resolveShelfShareStage(
|
||||
sharePath: string,
|
||||
): PublishShareModalPayload['stage'] | null {
|
||||
let pathname = '';
|
||||
try {
|
||||
pathname = new URL(sharePath, 'https://genarrative.local').pathname;
|
||||
} catch {
|
||||
pathname = sharePath.split(/[?#]/u)[0] ?? '';
|
||||
}
|
||||
|
||||
const stage = resolveSelectionStageFromPath(pathname);
|
||||
return stage === 'platform' ? null : stage;
|
||||
}
|
||||
|
||||
function buildCreationWorkShelfSharePayload(
|
||||
item: CreationWorkShelfItem,
|
||||
): PublishShareModalPayload | null {
|
||||
const publicWorkCode = item.publicWorkCode?.trim();
|
||||
const sharePath = item.sharePath?.trim();
|
||||
if (!publicWorkCode || !sharePath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const stage = resolveShelfShareStage(sharePath);
|
||||
if (!stage) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
publicWorkCode,
|
||||
stage,
|
||||
};
|
||||
}
|
||||
|
||||
/** 渲染底部加号创作入口页与草稿作品架,最近创作复用最近使用过的模板入口。 */
|
||||
export function CustomWorldCreationHub({
|
||||
items,
|
||||
@@ -216,6 +254,7 @@ export function CustomWorldCreationHub({
|
||||
onDeleteVisualNovel = null,
|
||||
getWorkState,
|
||||
onOpenShelfItem,
|
||||
onShareWork = null,
|
||||
recentWorkItems: recentWorkSourceItems,
|
||||
mode = 'full',
|
||||
}: CustomWorldCreationHubProps) {
|
||||
@@ -406,6 +445,17 @@ export function CustomWorldCreationHub({
|
||||
return item.actions.delete ?? null;
|
||||
}
|
||||
|
||||
function buildShareAction(item: CreationWorkShelfItem) {
|
||||
const payload = buildCreationWorkShelfSharePayload(item);
|
||||
if (!payload) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return () => {
|
||||
onShareWork?.(payload);
|
||||
};
|
||||
}
|
||||
|
||||
function buildPointIncentiveAction(item: CreationWorkShelfItem) {
|
||||
return item.actions.claimPointIncentive ?? null;
|
||||
}
|
||||
@@ -481,6 +531,7 @@ export function CustomWorldCreationHub({
|
||||
}}
|
||||
onDelete={buildDeleteAction(item)}
|
||||
deleteBusy={deletingWorkId === item.id}
|
||||
onShare={buildShareAction(item)}
|
||||
onClaimPointIncentive={buildPointIncentiveAction(item)}
|
||||
pointIncentiveBusy={
|
||||
item.source.kind === 'puzzle' &&
|
||||
|
||||
Reference in New Issue
Block a user