ai写作
This commit is contained in:
1 parent
cc8703577d
commit
10d7190ea4
12 files changed
+643
-43
No files matched your search
@@ -0,0 +1,156 @@
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { WritingStatus } from '../../types/ai-writing';
|
||||
|
||||
interface WritingSkeletonCardProps {
|
||||
status: WritingStatus;
|
||||
}
|
||||
|
||||
function SkeletonLine({ className }: { className?: string }) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'h-3 rounded-md bg-muted animate-pulse',
|
||||
className,
|
||||
)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function ThinkingDots() {
|
||||
return (
|
||||
<span className="inline-flex gap-1 items-center">
|
||||
<span className="size-1.5 rounded-full bg-current animate-bounce [animation-delay:0ms]" />
|
||||
<span className="size-1.5 rounded-full bg-current animate-bounce [animation-delay:150ms]" />
|
||||
<span className="size-1.5 rounded-full bg-current animate-bounce [animation-delay:300ms]" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function MaterialsSkeleton() {
|
||||
return (
|
||||
<div className="space-y-3 p-4">
|
||||
<div className="flex items-center gap-2 text-xs text-blue-500 font-medium">
|
||||
<ThinkingDots />
|
||||
<span>素材收集专家搜索中…</span>
|
||||
</div>
|
||||
{[0.85, 0.6, 0.7].map((_, i) => (
|
||||
<div key={i} className="rounded-lg border p-3 space-y-2">
|
||||
<SkeletonLine className="w-3/4" />
|
||||
<SkeletonLine className="w-1/3 h-2" />
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-5/6 h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function OutlineSkeleton() {
|
||||
return (
|
||||
<div className="space-y-3 p-4">
|
||||
<div className="flex items-center gap-2 text-xs text-purple-500 font-medium">
|
||||
<ThinkingDots />
|
||||
<span>作家规划大纲中…</span>
|
||||
</div>
|
||||
{/* 文章标题占位 */}
|
||||
<SkeletonLine className="w-1/2 h-4" />
|
||||
{/* 章节 */}
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div key={i} className="pl-3 border-l-2 border-muted space-y-1.5">
|
||||
<SkeletonLine className="w-2/5 h-3" />
|
||||
<SkeletonLine className="w-3/5 h-2" />
|
||||
<SkeletonLine className="w-1/2 h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DraftSkeleton() {
|
||||
return (
|
||||
<div className="space-y-4 p-4">
|
||||
<div className="flex items-center gap-2 text-xs text-purple-500 font-medium">
|
||||
<ThinkingDots />
|
||||
<span>作家写作中…</span>
|
||||
</div>
|
||||
{/* 文章标题 */}
|
||||
<SkeletonLine className="w-2/5 h-5 mx-auto" />
|
||||
{/* 3 个章节 */}
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<SkeletonLine className="w-1/4 h-3.5" />
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-4/5 h-2" />
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-3/4 h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ReviewSkeleton() {
|
||||
return (
|
||||
<div className="space-y-3 p-4">
|
||||
<div className="flex items-center gap-2 text-xs text-orange-500 font-medium">
|
||||
<ThinkingDots />
|
||||
<span>编辑审核中…</span>
|
||||
</div>
|
||||
{/* 分数条 */}
|
||||
{['事实准确度', '逻辑结构', '语言质量'].map((label) => (
|
||||
<div key={label} className="space-y-1">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-xs text-muted-foreground">{label}</span>
|
||||
<SkeletonLine className="w-8 h-3" />
|
||||
</div>
|
||||
<div className="h-1.5 rounded-full bg-muted overflow-hidden">
|
||||
<div className="h-full w-2/3 rounded-full bg-muted-foreground/30 animate-pulse" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{/* 问题列表占位 */}
|
||||
<div className="space-y-2 pt-2">
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-5/6 h-2" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function RevisingSkeletonInner() {
|
||||
return (
|
||||
<div className="space-y-4 p-4">
|
||||
<div className="flex items-center gap-2 text-xs text-purple-500 font-medium">
|
||||
<ThinkingDots />
|
||||
<span>作家按意见修改中…</span>
|
||||
</div>
|
||||
<SkeletonLine className="w-2/5 h-5 mx-auto" />
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<SkeletonLine className="w-1/4 h-3.5" />
|
||||
<SkeletonLine className="w-full h-2" />
|
||||
<SkeletonLine className="w-4/5 h-2" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const SKELETON_MAP: Partial<Record<WritingStatus, React.FC>> = {
|
||||
researching: MaterialsSkeleton,
|
||||
writing_outline: OutlineSkeleton,
|
||||
writing_draft: DraftSkeleton,
|
||||
reviewing: ReviewSkeleton,
|
||||
revising: RevisingSkeletonInner,
|
||||
};
|
||||
|
||||
export function WritingSkeletonCard({ status }: WritingSkeletonCardProps) {
|
||||
const Skeleton = SKELETON_MAP[status];
|
||||
if (!Skeleton) return null;
|
||||
return (
|
||||
<div className="rounded-xl border bg-card shadow-sm overflow-hidden">
|
||||
<Skeleton />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user