feat(ui): 强化 AI 工作中动效——构思占位/流式进度条/波动三点/转圈

- 动效基元:ai-dot 波动(三点竖跳)、ai-stream 不确定进度条、ai-breathe 呼吸微光(均带 reduced-motion 回退)
- ThinkingIndicator 升级为明显波动;新增 Spinner / StreamingBar / GenerationSkeleton 原子件;Button 加 loading 态
- 写作台:首 token 前正文区『AI 正在构思本章…』占位(补最大缺口,不再空白像卡死)+ 流式顶部进度条
- 整章重写流式进度条;续写/润色忙碌骨架 + 触发键转圈;生成器/角色/世界观改用 Button loading
This commit is contained in:
Yaojia Wang
2026-07-12 19:32:18 +02:00
parent 9bc0e1f2e6
commit 1afeb2cdb5
16 changed files with 227 additions and 28 deletions

View File

@@ -6,6 +6,7 @@ import { AppShell } from "@/components/AppShell";
import { Drawer } from "@/components/Drawer";
import { useToast } from "@/components/Toast";
import { StatusNote } from "@/components/ui/StatusNote";
import { StreamingBar } from "@/components/ui/StreamingBar";
import type { ProjectResponse } from "@/lib/api/types";
import { friendlyError } from "@/lib/errors/messages";
import { useAutosave } from "@/lib/autosave/useAutosave";
@@ -90,6 +91,8 @@ export function Workbench({
const toast = useToast();
const autosave = useAutosave(project.id, chapterNo, initialText);
const stream = useDraftStream();
// 构思中 = 流式已开始但首 token 未到(正文区覆盖构思占位);有字后即为在吐字。
const isThinking = stream.isStreaming && stream.state.text.length === 0;
const lastStreamText = useRef("");
const canRefine = selection !== null && selection.text.trim().length > 0;
const chapterTriggerRef = useRef<HTMLButtonElement>(null);
@@ -382,6 +385,10 @@ export function Workbench({
onClose={() => setRewriteOpen(false)}
/>
) : null}
{/* 写本章流式期间:编辑区顶部常挂一条不确定进度条,明确「进行中」(生成结束卸载)。 */}
{stream.isStreaming ? (
<StreamingBar label="AI 正在写本章" className="shrink-0" />
) : null}
<div ref={editorScrollRef} className="flex-1 overflow-auto px-6 py-8">
{chapters.length === 0 ? (
<StatusNote variant="info" className="mb-4">
@@ -392,6 +399,7 @@ export function Workbench({
value={text}
onChange={onEditorChange}
streaming={stream.isStreaming}
isThinking={isThinking}
onSelectionChange={setSelection}
/>
</div>