fix: move selected session detail to sidebar
This commit is contained in:
@@ -343,13 +343,15 @@ export default function Home() {
|
||||
</header>
|
||||
|
||||
<div className="space-y-8">
|
||||
{!current && (
|
||||
<PromptPanel
|
||||
session={current}
|
||||
session={null}
|
||||
onGenerate={handleGenerate}
|
||||
onUploadProject={handleUploadProject}
|
||||
loading={loading}
|
||||
uploadLoading={uploadLoading}
|
||||
/>
|
||||
)}
|
||||
{current && (
|
||||
<section className="space-y-5">
|
||||
<div className="flex items-end justify-between">
|
||||
|
||||
@@ -2,6 +2,72 @@
|
||||
|
||||
import type { GenSession } from '@/lib/types';
|
||||
|
||||
function modeLabel(mode?: GenSession['inputMode']) {
|
||||
if (mode === 'remix') return '二创';
|
||||
if (mode === 'replicate') return '复刻';
|
||||
if (mode === 'extend') return '补全';
|
||||
return '想法';
|
||||
}
|
||||
|
||||
function imageSourcesForSession(session: GenSession) {
|
||||
const uploaded = session.uploadedImages?.map(image => ({
|
||||
url: image.url,
|
||||
label: image.role === 'subject' ? '主体图' : image.role === 'reference' ? '参考图' : image.accessoryName || image.role,
|
||||
})) ?? [];
|
||||
if (uploaded.length) return uploaded;
|
||||
return session.refImages.map((url, index) => ({ url, label: `参考 ${index + 1}` }));
|
||||
}
|
||||
|
||||
function ActiveSessionDetail({ session }: { session: GenSession }) {
|
||||
const refs = imageSourcesForSession(session);
|
||||
const selectedCount = session.images.filter(image => image.status === 'selected').length;
|
||||
const packCount = session.packs?.length ?? 0;
|
||||
|
||||
return (
|
||||
<div className="rounded-[8px] border border-[#e6f578]/18 bg-black/28 p-4 shadow-[0_18px_50px_-34px_rgba(230,245,120,0.72)]">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="text-[9px] uppercase tracking-[0.18em] text-[#e6f578]/60">Session</span>
|
||||
<span className="rounded-full border border-white/10 bg-white/[0.04] px-2 py-0.5 text-[9px] text-white/42">
|
||||
{modeLabel(session.inputMode)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-3 line-clamp-4 text-[12px] font-medium leading-relaxed text-white/82">
|
||||
{session.characterSpec?.name || session.prompt}
|
||||
</div>
|
||||
<div className="mt-3 grid grid-cols-3 gap-1.5 text-[9px] text-white/44">
|
||||
<div className="rounded-[6px] bg-white/[0.045] px-2 py-1.5">
|
||||
<div>图片</div>
|
||||
<b className="mt-0.5 block text-[11px] text-white/78">{session.images.length}</b>
|
||||
</div>
|
||||
<div className="rounded-[6px] bg-white/[0.045] px-2 py-1.5">
|
||||
<div>选中</div>
|
||||
<b className="mt-0.5 block text-[11px] text-[#e6f578]">{selectedCount}</b>
|
||||
</div>
|
||||
<div className="rounded-[6px] bg-white/[0.045] px-2 py-1.5">
|
||||
<div>包</div>
|
||||
<b className="mt-0.5 block text-[11px] text-white/78">{packCount}</b>
|
||||
</div>
|
||||
</div>
|
||||
{refs.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<div className="mb-1.5 text-[9px] uppercase tracking-[0.14em] text-white/32">Reference</div>
|
||||
<div className="grid grid-cols-4 gap-1.5">
|
||||
{refs.slice(0, 4).map((ref, index) => (
|
||||
<div key={`${ref.url}-${index}`} className="relative aspect-square overflow-hidden rounded-[6px] bg-white ring-1 ring-white/10">
|
||||
<img src={ref.url} alt={ref.label} className="h-full w-full object-contain" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-3 flex items-center justify-between gap-2 text-[9px] text-white/36">
|
||||
<span>{new Date(session.createdAt).toLocaleString('zh-CN', { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })}</span>
|
||||
<span className="font-mono">{session.id.slice(0, 10)}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Sidebar({
|
||||
open,
|
||||
onToggle,
|
||||
@@ -33,8 +99,11 @@ export default function Sidebar({
|
||||
);
|
||||
}
|
||||
|
||||
const activeSession = sessions.find(session => session.id === currentId) ?? null;
|
||||
|
||||
return (
|
||||
<aside className="glass-sidebar w-72 shrink-0 flex flex-col">
|
||||
<aside className="flex shrink-0 items-stretch">
|
||||
<div className="glass-sidebar w-72 shrink-0 flex flex-col">
|
||||
<div className="px-4 pt-5 pb-3 flex items-center gap-3">
|
||||
<div className="w-8 h-8 rounded-[8px] bg-gradient-to-br from-[#e6f578] to-[#d6b36a] flex items-center justify-center shadow-glow-violet">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#081006" strokeWidth="2.5">
|
||||
@@ -82,8 +151,8 @@ export default function Sidebar({
|
||||
const selectedCount = s.images.filter(i => i.status === 'selected').length;
|
||||
const active = currentId === s.id;
|
||||
return (
|
||||
<div key={s.id} className="relative">
|
||||
<button
|
||||
key={s.id}
|
||||
onClick={() => onPick(s.id)}
|
||||
className={`w-full text-left px-3 py-2.5 rounded-[8px] text-xs transition-all ${
|
||||
active
|
||||
@@ -92,7 +161,7 @@ export default function Sidebar({
|
||||
}`}
|
||||
>
|
||||
<div className={`line-clamp-2 font-medium leading-relaxed ${active ? 'text-white' : 'text-white/85'}`}>
|
||||
{s.prompt}
|
||||
{s.characterSpec?.name || s.prompt}
|
||||
</div>
|
||||
<div className={`mt-1.5 flex justify-between items-center text-[10px] ${active ? 'text-white/65' : 'text-white/40'}`}>
|
||||
<span>
|
||||
@@ -108,6 +177,7 @@ export default function Sidebar({
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@@ -115,6 +185,22 @@ export default function Sidebar({
|
||||
<div className="border-t border-white/[0.06] px-5 py-3 text-[10px] text-white/30">
|
||||
本地端口 4560 · 数据 / data
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{activeSession && (
|
||||
<div className="glass-sidebar w-72 shrink-0 border-l border-[#e6f578]/10">
|
||||
<div className="h-full overflow-y-auto px-4 py-5">
|
||||
<div className="mb-3 flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div className="text-[10px] font-semibold uppercase tracking-[0.18em] text-[#e6f578]/70">Detail</div>
|
||||
<div className="mt-1 text-[12px] text-white/45">已选项目</div>
|
||||
</div>
|
||||
<span className="h-2 w-2 rounded-full bg-[#e6f578] shadow-[0_0_18px_rgba(230,245,120,0.75)]" />
|
||||
</div>
|
||||
<ActiveSessionDetail session={activeSession} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user