auto-save 2026-05-18 23:28 (+1, ~6)

This commit is contained in:
2026-05-18 23:28:34 +08:00
parent 446e012450
commit 52a5b77681
7 changed files with 309 additions and 119 deletions

View File

@@ -11,6 +11,7 @@ export default function Home() {
const [current, setCurrent] = useState<GenSession | null>(null);
const [loading, setLoading] = useState(false);
const [provider, setProvider] = useState<string>('?');
const [sidebarOpen, setSidebarOpen] = useState(true);
const refreshSessions = useCallback(async () => {
const r = await fetch('/api/sessions');
@@ -60,36 +61,51 @@ export default function Home() {
}
return (
<div className="flex h-screen">
<div className="flex h-screen bg-[#FAFAFA]">
<Sidebar
open={sidebarOpen}
onToggle={() => setSidebarOpen(v => !v)}
sessions={sessions}
currentId={current?.id ?? null}
onPick={id => setCurrent(sessions.find(s => s.id === id) ?? null)}
onNew={() => setCurrent(null)}
/>
<main className="flex-1 overflow-y-auto">
<header className="px-8 py-6 border-b border-white/10 flex items-center justify-between">
<div>
<h1 className="text-xl font-bold">AI </h1>
<p className="text-xs text-white/40 mt-1"> </p>
</div>
<div className="text-xs text-white/40">
provider: <span className={provider === 'poe' ? 'text-accent' : 'text-yellow-400'}>{provider}</span>
{provider === 'mock' && <span className="ml-2 text-yellow-400/80">( POE_API_KEY)</span>}
</div>
</header>
<div className="mx-auto max-w-[1180px] px-10 py-10">
<header className="flex items-start justify-between mb-10">
<div>
<h1 className="text-[26px] font-semibold tracking-tight text-zinc-900 leading-tight">
AI
</h1>
<p className="text-sm text-zinc-500 mt-1.5">
</p>
</div>
<div className="flex items-center gap-2 pt-1">
<span className={provider === 'poe' ? 'chip chip-live' : 'chip chip-mock'}>
<span className={`w-1.5 h-1.5 rounded-full ${provider === 'poe' ? 'bg-emerald-500' : 'bg-amber-500'}`} />
{provider === 'poe' ? 'Poe · 实时生图' : provider === 'mock' ? 'Mock · 占位图' : provider}
</span>
</div>
</header>
<div className="p-8 space-y-6 max-w-6xl">
<PromptPanel onGenerate={handleGenerate} loading={loading} />
{current && (
<section className="card p-6 space-y-4">
<div className="flex items-center justify-between">
<h2 className="text-sm text-white/60"> · {new Date(current.createdAt).toLocaleString('zh-CN')}</h2>
<code className="text-xs text-white/30">{current.id}</code>
</div>
<ResultGrid images={current.images} onAction={handleAction} />
</section>
)}
<div className="space-y-8">
<PromptPanel onGenerate={handleGenerate} loading={loading} />
{current && (
<section className="space-y-4">
<div className="flex items-end justify-between">
<div>
<h2 className="text-sm font-medium text-zinc-900"></h2>
<p className="text-xs text-zinc-500 mt-0.5">
{new Date(current.createdAt).toLocaleString('zh-CN')}
</p>
</div>
<code className="text-[11px] text-zinc-400 font-mono">{current.id}</code>
</div>
<ResultGrid images={current.images} onAction={handleAction} />
</section>
)}
</div>
</div>
</main>
</div>