Files
makelore/src/pages/ImageCanvas/DesignHistoryRail.tsx
2026-09-07 15:36:48 +08:00

63 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Images } from 'lucide-react';
import { cn } from '@/lib/utils';
import type { DesignWorkspace } from '../../../shared/image-workspace';
import { DesignPlanHistory } from './DesignPlanHistory';
export function DesignHistoryRail({ workspace }: { workspace: DesignWorkspace | null }) {
const taskCount = workspace?.tasks.length ?? 0;
const resultCount = workspace?.assets.filter((asset) => asset.generationTaskId).length ?? 0;
const platform = window.electron?.platform;
return (
<aside
data-testid="image-workspace-history-rail"
aria-label="历史作品"
className="flex h-full min-h-0 w-[320px] shrink-0 flex-col border-l border-border/70 bg-background font-sans xl:w-[340px]"
>
<header
data-testid="image-workspace-history-header"
className={cn(
'flex h-16 shrink-0 items-center border-b border-border/70 px-4',
platform === 'darwin' && 'pr-[116px]',
platform === 'win32' && 'items-end pb-1.5 pr-[156px]',
)}
>
<div className="min-w-0">
<div className="flex items-center gap-2">
<Images className="h-4 w-4 shrink-0 text-brand" aria-hidden="true" />
<h2 className="truncate text-sm font-semibold text-foreground"></h2>
</div>
<p className={cn(
'mt-1 truncate text-[11px] tabular-nums text-muted-foreground',
platform === 'win32' && 'hidden',
)}>
{taskCount > 0 ? `${taskCount} 次制作 · ${resultCount} 个结果` : '当前设计项目的制作记录'}
</p>
</div>
</header>
<div data-testid="image-workspace-history-scroll" className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-3">
{!workspace ? (
<div className="rounded-2xl border border-dashed border-border/80 bg-surface-subtle/35 px-4 py-7 text-center">
<Images className="mx-auto h-5 w-5 text-muted-foreground" aria-hidden="true" />
<p className="mt-3 text-xs font-semibold text-foreground"></p>
<p className="mt-1 text-[11px] leading-5 text-muted-foreground">
</p>
</div>
) : taskCount === 0 ? (
<div className="rounded-2xl border border-dashed border-border/80 bg-surface-subtle/35 px-4 py-7 text-center">
<Images className="mx-auto h-5 w-5 text-muted-foreground" aria-hidden="true" />
<p className="mt-3 text-xs font-semibold text-foreground"></p>
<p className="mt-1 text-[11px] leading-5 text-muted-foreground">
</p>
</div>
) : (
<DesignPlanHistory workspace={workspace} />
)}
</div>
</aside>
);
}