import type { ReactNode } from 'react'; import type { CustomWorldCreatorIntent, CustomWorldGenerationMode, } from '../types'; import { PlatformActionButton } from './common/PlatformActionButton'; import { PlatformModalCloseButton } from './common/PlatformModalCloseButton'; import { PlatformProgressBar } from './common/PlatformProgressBar'; import { PlatformStatusMessage } from './common/PlatformStatusMessage'; import { PlatformSubpanel } from './common/PlatformSubpanel'; import { PlatformSelectField, PlatformTextField, } from './common/PlatformTextField'; type BaseModalProps = { isOpen: boolean; title: string; onClose: () => void; children: ReactNode; footer?: ReactNode; }; function SelectionModal({ isOpen, title, onClose, children, footer = null, }: BaseModalProps) { if (!isOpen) return null; return (
{title}
{children}
{footer ? (
{footer}
) : null}
); } export function CharacterDraftModal(props: { isOpen: boolean; characterLabel: string; draftName: string; draftBackstory: string; onNameChange: (value: string) => void; onBackstoryChange: (value: string) => void; onClose: () => void; onConfirm: () => void; error?: string | null; }) { const { isOpen, characterLabel, draftName, draftBackstory, onNameChange, onBackstoryChange, onClose, onConfirm, error = null, } = props; return ( 取消 确认进入 )} >
当前角色:{characterLabel} {error ? ( {error} ) : null}
); } type CustomWorldCreatorModalProps = { isOpen: boolean; onClose: () => void; onSubmit: () => void; isGenerating: boolean; progress: number; progressLabel: string; error?: string | null; } & ( | { draft: string; onDraftChange: (value: string) => void; creatorIntent?: never; onCreatorIntentChange?: never; generationMode?: never; onGenerationModeChange?: never; } | { draft?: never; onDraftChange?: never; creatorIntent: CustomWorldCreatorIntent; onCreatorIntentChange: (value: CustomWorldCreatorIntent) => void; generationMode: CustomWorldGenerationMode; onGenerationModeChange: (value: CustomWorldGenerationMode) => void; } ); function hasCreatorIntentProps( props: CustomWorldCreatorModalProps, ): props is Extract< CustomWorldCreatorModalProps, { creatorIntent: CustomWorldCreatorIntent } > { return 'creatorIntent' in props; } export function CustomWorldCreatorModal(props: CustomWorldCreatorModalProps) { const { isOpen, onClose, onSubmit, isGenerating, progress, progressLabel, error = null, } = props; const draftText = hasCreatorIntentProps(props) ? props.creatorIntent.rawSettingText : props.draft; const updateDraftText = (value: string) => { if (hasCreatorIntentProps(props)) { props.onCreatorIntentChange({ ...props.creatorIntent, rawSettingText: value, }); return; } props.onDraftChange(value); }; return ( 取消 {isGenerating ? '生成中...' : '开始生成'} )} >
{hasCreatorIntentProps(props) ? ( ) : null}
用几句话描述世界观、核心矛盾、时代气质和你想体验的叙事方向。系统会据此生成可游玩的自定义世界。
updateDraftText(event.target.value)} rows={8} placeholder="例:一个被潮雾与失落列岛切碎的边境世界,旧盟约、沉船秘术与灯塔守望者纠缠在一起……" surface="editorDark" tone="sky" size="md" density="roomy" className="rounded-2xl leading-7" /> {isGenerating ? (
{progressLabel} {Math.max(0, Math.min(100, Math.round(progress)))}%
) : null} {error ? ( {error} ) : null}
); }