1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
|
||||
import type { Character, CustomWorldProfile } from '../../types';
|
||||
import { rpgCreationAssetClient } from '../../services/rpg-creation/rpgCreationAssetClient';
|
||||
import {
|
||||
CustomWorldEntityCatalog,
|
||||
type ResultTab,
|
||||
@@ -91,10 +92,19 @@ export function RpgCreationResultView({
|
||||
qualityFindings = [],
|
||||
}: RpgCreationResultViewProps) {
|
||||
const [activeTab, setActiveTab] = useState<ResultTab>('world');
|
||||
const [openingCgGenerating, setOpeningCgGenerating] = useState(false);
|
||||
const [openingCgGenerationError, setOpeningCgGenerationError] = useState<
|
||||
string | null
|
||||
>(null);
|
||||
const latestProfileRef = useRef(profile);
|
||||
const assetDebugEnabled = useMemo(
|
||||
() => shouldEnableRpgCreationAssetDebugPanel(),
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
latestProfileRef.current = profile;
|
||||
}, [profile]);
|
||||
const {
|
||||
closeEditorTarget,
|
||||
createLabel,
|
||||
@@ -133,6 +143,32 @@ export function RpgCreationResultView({
|
||||
}
|
||||
: handleDeleteLandmarks;
|
||||
|
||||
const handleGenerateOpeningCg = async () => {
|
||||
if (readOnly || isGenerating || openingCgGenerating) {
|
||||
return;
|
||||
}
|
||||
|
||||
setOpeningCgGenerating(true);
|
||||
setOpeningCgGenerationError(null);
|
||||
try {
|
||||
const openingCg = await rpgCreationAssetClient.generateOpeningCg({
|
||||
profile: latestProfileRef.current,
|
||||
});
|
||||
onProfileChange({
|
||||
...latestProfileRef.current,
|
||||
openingCg,
|
||||
});
|
||||
} catch (generationError) {
|
||||
setOpeningCgGenerationError(
|
||||
generationError instanceof Error
|
||||
? generationError.message
|
||||
: '生成开局 CG 失败',
|
||||
);
|
||||
} finally {
|
||||
setOpeningCgGenerating(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="platform-remap-surface mx-auto flex h-full min-h-0 w-full flex-col xl:max-w-[min(100%,98rem)] xl:px-1 2xl:max-w-[min(100%,112rem)]">
|
||||
<RpgCreationResultHeader
|
||||
@@ -152,6 +188,14 @@ export function RpgCreationResultView({
|
||||
onProfileChange={onProfileChange}
|
||||
onDeleteStoryNpcs={deleteStoryNpcs}
|
||||
onDeleteLandmarks={deleteLandmarks}
|
||||
openingCgGenerating={openingCgGenerating}
|
||||
openingCgPhaseLabel={
|
||||
openingCgGenerating ? '正在生成开局 CG' : null
|
||||
}
|
||||
openingCgGenerateDisabled={isGenerating}
|
||||
onGenerateOpeningCg={
|
||||
readOnly ? undefined : () => void handleGenerateOpeningCg()
|
||||
}
|
||||
createActionLabel={
|
||||
readOnly || (compactAgentResultMode && !onGenerateEntity)
|
||||
? undefined
|
||||
@@ -227,6 +271,11 @@ export function RpgCreationResultView({
|
||||
{localGenerationError}
|
||||
</div>
|
||||
) : null}
|
||||
{!error && openingCgGenerationError ? (
|
||||
<div className="platform-banner platform-banner--danger mt-3 rounded-2xl text-sm leading-6">
|
||||
{openingCgGenerationError}
|
||||
</div>
|
||||
) : null}
|
||||
{assetDebugEnabled ? (
|
||||
<RpgCreationAssetDebugPanel profile={profile} />
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user