import { cn } from '@/lib/utils';
import type { WritingStatus } from '../../types/ai-writing';
interface WritingSkeletonCardProps {
status: WritingStatus;
/** 素材收集阶段的实时进度文案(仅 researching 阶段使用) */
researchProgress?: string;
/** 用户自带大纲时为 true:大纲阶段文案显示「整理你的大纲」而非「规划大纲」。 */
organizing?: boolean;
}
// ── 基础骨架元素 ──────────────────────────────────────────────────────────────
function SkeletonLine({ className }: { className?: string }) {
return (
);
}
function ThinkingDots({ color = 'bg-blue-400' }: { color?: string }) {
return (
{[0, 1, 2].map((i) => (
))}
);
}
// ── 素材收集骨架屏 ────────────────────────────────────────────────────────────
function MaterialsSkeleton({ researchProgress }: { researchProgress?: string }) {
return (
{/* 标题行:展示素材收集专家的实时进度 */}
{researchProgress || '素材收集专家搜索中…'}
{/* 关键词标签占位 */}
{[60, 80, 50].map((w, i) => (
))}
{/* 素材卡片占位 */}
{[0, 1, 2, 3].map((i) => (
{/* 标题 */}
{/* 来源 + 时间 + 相关度 */}
{/* 摘要行 */}
))}
);
}
// ── 大纲规划骨架屏 ────────────────────────────────────────────────────────────
function OutlineSkeleton({ organizing }: { organizing?: boolean } = {}) {
return (
{organizing ? '作家整理你的大纲中…' : '作家规划大纲中…'}
{/* 文章标题占位 */}
{/* 章节列表 */}
{[0, 1, 2, 3].map((i) => (
))}
);
}
// ── 正文写作骨架屏 ────────────────────────────────────────────────────────────
function DraftSkeleton() {
return (
作家写作中…
{/* 标题占位 */}
{/* 章节内容 */}
{[0, 1, 2].map((i) => (
))}
);
}
// ── 编辑审核骨架屏 ────────────────────────────────────────────────────────────
function ReviewSkeleton() {
return (
编辑审核中…
{/* 综合评分占位 */}
{/* 分项评分条 */}
{['事实准确度', '逻辑结构', '语言质量'].map((label, i) => (
))}
{/* 意见条目占位 */}
);
}
// ── 按意见修改骨架屏 ──────────────────────────────────────────────────────────
function RevisingSkeleton() {
return (
作家按意见修改中…
{[0, 1, 2].map((i) => (
))}
);
}
// ── 状态映射 ──────────────────────────────────────────────────────────────────
// researching / awaiting_material_confirm 由 WritingSkeletonCard 单独处理(需透传进度文案)
const SKELETON_MAP: Partial> = {
// 实际运行状态
writing_outline: OutlineSkeleton,
writing_draft: DraftSkeleton,
reviewing: ReviewSkeleton,
revising: RevisingSkeleton,
// 过渡等待状态(用户提交后、后端事件到达前的空白期)
awaiting_outline_confirm: OutlineSkeleton, // 过渡到写作
awaiting_draft_confirm: DraftSkeleton, // 提交修改意见或编辑审核后
awaiting_review_confirm: RevisingSkeleton, // 采纳编辑意见后
};
export function WritingSkeletonCard({ status, researchProgress, organizing }: WritingSkeletonCardProps) {
// 素材收集阶段单独渲染,以便透传实时进度文案
if (status === 'analyzing_sample' || status === 'researching' || status === 'awaiting_material_confirm') {
return (
);
}
// 大纲阶段单独渲染,以便透传「整理 / 规划」文案(用户自带大纲走「整理」)
if (status === 'writing_outline' || status === 'awaiting_outline_confirm') {
return (
);
}
const Skeleton = SKELETON_MAP[status];
if (!Skeleton) return null;
return (
);
}