feat(loading): support typewriter story teaser during first scene generation

This commit is contained in:
DESKTOP-I1T6TF3\Q
2026-06-04 14:40:35 +08:00
parent e04c51e875
commit 4e4e06ec8a
4 changed files with 99 additions and 6 deletions
+22
View File
@@ -402,6 +402,7 @@ function PlayInner() {
const [error, setError] = useState<string | null>(null);
const [presentation, setPresentation] = useState(false);
const [lastExitLabel, setLastExitLabel] = useState<string | null>(null);
const [teaserText, setTeaserText] = useState<string | null>(null);
const startedRef = useRef(false);
const poolRef = useRef<Map<string, PrefetchEntry>>(new Map());
@@ -694,6 +695,25 @@ function PlayInner() {
return;
}
if (livePayload) {
fetch("/api/teaser", {
method: "POST",
headers: {
"Content-Type": "application/json",
...getByoHeaders(),
},
body: JSON.stringify({ worldSetting: livePayload.worldSetting }),
})
.then(async (r) => {
if (!r.ok) return;
const data = await r.json();
if (data.teaser) {
setTeaserText(data.teaser);
}
})
.catch(() => {});
}
type PrebakedFirstAct = StartResponse & {
worldSetting: string;
styleGuide: string;
@@ -1155,6 +1175,7 @@ function PlayInner() {
onAdvance={onAdvance}
onSelectChoice={onSelectChoice}
fullViewport
teaserText={teaserText}
/>
</div>
);
@@ -1194,6 +1215,7 @@ function PlayInner() {
onBackgroundClick={onBackgroundClick}
onAdvance={onAdvance}
onSelectChoice={onSelectChoice}
teaserText={teaserText}
aboveCanvas={
<button
type="button"