17662916cd
将统一创作契约泥点消耗改为数字字段并由前端格式化展示 将后台契约编辑从 JSON 文本改为结构化卡片与弹窗表单 隐藏玩法阶段等内部标识并按玩法默认映射自动带出 更新创作入口文档、团队记忆和回归测试
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import type { PlatformCreationTypeId } from '../../packages/shared/src/contracts/playTypes';
|
|
import { requestJson } from './apiClient';
|
|
|
|
export const DEFAULT_UNIFIED_CREATION_MUD_POINT_COST = 10;
|
|
|
|
/** 后端下发的单个创作类型入口配置,前端只据此展示和分流。 */
|
|
export type CreationEntryTypeConfig = {
|
|
id: PlatformCreationTypeId;
|
|
title: string;
|
|
subtitle: string;
|
|
badge: string;
|
|
imageSrc: string;
|
|
visible: boolean;
|
|
open: boolean;
|
|
sortOrder: number;
|
|
categoryId: string;
|
|
categoryLabel: string;
|
|
categorySortOrder: number;
|
|
updatedAtMicros: number;
|
|
unifiedCreationSpec?: UnifiedCreationSpec | null;
|
|
};
|
|
|
|
/** 统一创作工作台字段契约,用于表单型玩法的最小输入描述。 */
|
|
export type UnifiedCreationField = {
|
|
id: string;
|
|
kind: 'text' | 'select' | 'image' | 'audio';
|
|
label: string;
|
|
required: boolean;
|
|
};
|
|
|
|
/** 统一创作工作台契约,把入口类型映射到工作台、生成页和结果页阶段。 */
|
|
export type UnifiedCreationSpec = {
|
|
playId: PlatformCreationTypeId;
|
|
title: string;
|
|
mudPointCost?: number | null;
|
|
workspaceStage: string;
|
|
generationStage: string;
|
|
resultStage: string;
|
|
fields: UnifiedCreationField[];
|
|
};
|
|
|
|
/** 创作入口公告位配置,HTML 模式仅用于沙箱预览,结构化字段保留旧数据兼容。 */
|
|
export type CreationEntryEventBannerConfig = {
|
|
title: string;
|
|
description: string;
|
|
coverImageSrc: string;
|
|
prizePoolMudPoints: number;
|
|
startsAtText: string;
|
|
endsAtText: string;
|
|
renderMode?: 'structured' | 'html';
|
|
htmlCode?: string | null;
|
|
};
|
|
|
|
/** 创作入口页完整配置;前端只展示后端事实源,不内置入口默认值。 */
|
|
export type CreationEntryConfig = {
|
|
startCard: {
|
|
title: string;
|
|
description: string;
|
|
idleBadge: string;
|
|
busyBadge: string;
|
|
};
|
|
typeModal: {
|
|
title: string;
|
|
description: string;
|
|
};
|
|
/** 旧单条公告位兼容字段,新代码优先读取 eventBanners。 */
|
|
eventBanner: CreationEntryEventBannerConfig;
|
|
/** 底部加号创作入口页的多公告轮播配置。 */
|
|
eventBanners?: CreationEntryEventBannerConfig[];
|
|
creationTypes: CreationEntryTypeConfig[];
|
|
};
|
|
|
|
/** 拉取底部加号创作入口配置;所有入口和公告都以后端事实源为准。 */
|
|
export async function fetchCreationEntryConfig(): Promise<CreationEntryConfig> {
|
|
return requestJson<CreationEntryConfig>(
|
|
'/api/creation-entry/config',
|
|
{ method: 'GET' },
|
|
'读取创作入口配置失败',
|
|
);
|
|
}
|