迁移页面骨架原语(PageHead/Layout/Stack)+ 登录、我的账号、项目工作台

main
mula.liu 2026-11-01 16:52:45 +08:00
parent 93abe0ce7b
commit b8734c9adc
8 changed files with 528 additions and 14 deletions

View File

@ -1,4 +1,4 @@
import { useEffect, useState, type InputHTMLAttributes } from 'react'
import { useEffect, useState, type InputHTMLAttributes, type Ref } from 'react'
import { cn } from '../../lib/cn'
import * as api from '../../api/client'
import { EyeIcon } from './EyeIcon'
@ -27,6 +27,8 @@ export type SecretInputProps = {
/** 取回明文的接口;不传就只做本地密文/明文切换 */
revealUrl?: string
className?: string
/** React 19:ref 是普通 prop,跟着 rest 落到原生 input 上 */
ref?: Ref<HTMLInputElement>
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'id' | 'placeholder' | 'disabled' | 'className'>
export function SecretInput({

View File

@ -0,0 +1,88 @@
/**
* 页面级骨架(旧全局样式里的 header / .row / .between / .error / .sub)。
*
* 这些不是"组件"那么重,但 13 个页面每一页都要用;写成一处的意义和
* UI规范第二章一样:同一层级的东西在所有页面上量出来必须是同一个数。
* 页面里再出现 <header className="flex justify-between…"> 就算抄回去了一遍。
*/
import type { ReactNode } from 'react'
import { cn } from '../../lib/cn'
/** 站内文字链配色(.link):<Link> 没有组件形态,用这个类名常量保持一致 */
export const LINK_CLS = 'text-success text-caption no-underline hover:underline'
/**
* 页头(旧 <header>):左边「状态行 + 大标题」,右边整组动作。
* 窄屏按旧站规则改成纵向堆叠,动作按钮拉满一行——两三个小按钮排在
* 25px 标题右边,在 430px 屏上会挤成一团中文碎渣。
*/
export function PageHead({ title, meta, eyebrow, actions, className }: {
title?: ReactNode; meta?: ReactNode; eyebrow?: ReactNode; actions?: ReactNode; className?: string
}) {
return (
<header className={cn('flex flex-wrap items-center justify-between gap-3 mb-[25px] min-w-0 max-nav:items-start', className)}>
<div className="min-w-0">
{meta && <Row className="max-nav:w-full max-nav:[&>button]:flex-1">{meta}</Row>}
{eyebrow && <div className="text-tiny tracking-[1.6px] text-muted font-bold">{eyebrow}</div>}
{title && <h1>{title}</h1>}
</div>
{actions && <Row className="max-nav:w-full max-nav:[&>button]:flex-1 [--ctl-h:var(--ctl-h-md)]">{actions}</Row>}
</header>
)
}
/** 通用横排(.row):窄屏自动折行,同行控件等高由 --ctl-h 保证 */
export function Row({ children, className, tight }: { children?: ReactNode; className?: string; tight?: boolean }) {
return (
<div className={cn('flex flex-wrap items-center gap-[9px] min-w-0', tight && '[--ctl-h:var(--ctl-h-md)]', className)}>
{children}
</div>
)
}
/** 两端对齐(.between):左说明右动作,窄屏折行后仍然左对齐 */
export function Between({ children, className, tight }: { children?: ReactNode; className?: string; tight?: boolean }) {
return (
<div className={cn('flex flex-wrap items-center justify-between gap-3 min-w-0', tight && '[--ctl-h:var(--ctl-h-md)]', className)}>
{children}
</div>
)
}
/** 行内错误回显(.error):10px 红字,紧贴它说明的那个控件,不占提示条的位置 */
export function ErrorText({ children, className }: { children?: ReactNode; className?: string }) {
if (!children) return null
return <span className={cn('block text-danger text-tiny [overflow-wrap:anywhere] mt-1', className)}>{children}</span>
}
/** 分节线(.sub):同一面板里两个话题之间用它,不要再塞一个 h3 */
export function Sub({ children, className }: { children?: ReactNode; className?: string }) {
return <div className={cn('border-t border-line mt-[22px] pt-[18px] min-w-0', className)}>{children}</div>
}
/**
* 两栏正文(.layout):主栏吃掉剩余宽度,侧栏最窄 300px。
* ≤1100 收成单列——断点写在组件里,页面不许再为自己写 @media。
*/
export function Layout({ children, className }: { children?: ReactNode; className?: string }) {
return (
<div className={cn('grid min-w-0 items-start gap-4 grid-cols-[minmax(0,1.5fr)_minmax(300px,0.8fr)] '
+ '[&>*]:min-w-0 max-mid2:grid-cols-1', className)}>
{children}
</div>
)
}
/**
* 一栏内的面板堆叠(.right)。
* ≤1100 时 <Layout> 已经折成单列,这一层临时并排两列把宽度用掉;
* ≤900 再叠回来(max-* 变体按断点从宽到窄排进样式表,后者自然覆盖前者)。
*/
export function Stack({ children, className }: { children?: ReactNode; className?: string }) {
return (
<div className={cn('flex min-w-0 flex-col gap-[15px] [&>*]:min-w-0 '
+ 'max-mid2:grid max-mid2:grid-cols-2 max-mid2:gap-4 max-nav:flex max-nav:gap-[15px]', className)}>
{children}
</div>
)
}

View File

@ -12,14 +12,22 @@ export function Panel({ children, className, style, pad = true }: {
)
}
/** 面板头:标题 + 右侧动作。窄列必须允许换行,否则筛选控件会把面板内容顶出边界。 */
export function PanelHead({ title, sub, right, className }: {
title?: ReactNode; sub?: ReactNode; right?: ReactNode; className?: string
/**
* 面板头:眉标 + 标题 + 右侧动作。
*
* 旧站 25 处面板头全都是 <small class="eyebrow"> + <h2>,标题走的是全局 h2(17px);
* 第一版迁移手写成 14px 的 h3,整站面板标题比正文重不了多少,扫视时找不到锚点。
* 窄列必须允许换行(旧站第二十章补的 .panel-head{flex-wrap:wrap}):两列栅格下
* 每列只有 ~400px,筛选控件的最小宽度就超过整列,不换行会把内容压到相邻面板上。
*/
export function PanelHead({ title, eyebrow, sub, right, className }: {
title?: ReactNode; eyebrow?: ReactNode; sub?: ReactNode; right?: ReactNode; className?: string
}) {
return (
<div className={cn('flex justify-between items-center gap-3 flex-wrap mb-[18px] min-w-0 [&>*]:min-w-0', className)}>
<div className="min-w-0">
{title && <h3 className="m-0 text-title font-bold">{title}</h3>}
{eyebrow && <Eyebrow>{eyebrow}</Eyebrow>}
{title && <h2 className="mt-[5px] mb-0 text-h2 font-bold">{title}</h2>}
{sub && <p className="mt-[5px] mb-0 text-caption text-dim leading-[1.6]">{sub}</p>}
</div>
{right && <div className="flex items-center gap-2 flex-wrap min-w-0">{right}</div>}

View File

@ -1,6 +1,7 @@
export * from './Button'
export * from './Status'
export * from './Panel'
export * from './Page'
export * from './Controls'
export * from './Table'
export * from './Overlay'

View File

@ -2,3 +2,4 @@ export * from './use-async'
export * from './use-polling'
export * from './use-outside-click'
export * from './use-local-storage'
export * from './use-auto-refresh'

View File

@ -1,4 +1,182 @@
/** 待迁移:我的账号(占位,见 .local/vue-ref/src/views/Account.vue) */
/**
* 我的账号:基本资料、改密、登录设备。
*
* 会话列表每 45 秒自己刷新(旧站是渲染不出界面的 <AutoRefresh/>,现在是 useAutoRefresh)。
* 只要资料改过没保存、或三个改密框里有字,就跳过刷新——把用户刚敲的内容冲掉,
* 是这种「顺手挂着轮询」的页面最容易犯的错。
*/
import { useEffect, useState } from 'react'
import { useSearchParams } from 'react-router-dom'
import * as api from '../api/client'
import { fmtAgo, fmtTime } from '../lib/format'
import { useAutoRefresh } from '../hooks/use-auto-refresh'
import { SecretInput } from '../components/forms'
import {
Actions, Button, CardRow, Empty, ErrorText, Field, FormRow, Layout, Notice, PageHead, Panel, PanelHead, Stack, Tag
} from '../components/ui'
import { login, roleLabel, setUser, useAuthStore } from '../stores/auth'
const RULES_HINT = '至少 8 位,且不能只有一类字符(字母 / 数字 / 符号至少两种)'
export default function Account() {
return <div className="p-[26px] text-center text-faint text-body">我的账号 迁移中…</div>
const [params] = useSearchParams()
const auth = useAuthStore()
const [busy, setBusy] = useState('')
const [error, setError] = useState('')
const [notice, setNotice] = useState('')
const [sessions, setSessions] = useState<any[]>([])
const [profile, setProfile] = useState({ display_name: '', email: '' })
const [savedSnapshot, setSavedSnapshot] = useState('')
const [pwd, setPwd] = useState({ current_password: '', new_password: '', confirm: '' })
const mustChange = params.get('must') === '1' || !!auth.user?.must_change_password
/** 资料改过没保存 / 改密框里有字 → 暂停轮询,别把用户刚敲的内容冲掉 */
const formTouched = savedSnapshot !== JSON.stringify(profile)
|| Boolean(pwd.current_password || pwd.new_password || pwd.confirm)
const role = roleLabel(auth.user?.role || '')
const isAdmin = auth.user?.role === 'admin'
async function load(silent = true) {
if (!silent) setError('')
try {
const data = await api.get('/api/auth/me')
const user = data.user || auth.user
setUser(user)
const next = { display_name: user?.display_name || '', email: user?.email || '' }
setProfile(next)
setSessions(data.sessions || [])
setSavedSnapshot(JSON.stringify(next))
} catch (exc: any) {
setError(exc?.message || String(exc))
}
}
useEffect(() => { void load(false) }, [])
async function saveProfile() {
setBusy('保存资料'); setError(''); setNotice('')
try {
setUser(await api.patch('/api/auth/me', { ...profile }))
setNotice('资料已更新。')
} catch (exc: any) { setError(exc?.message || String(exc)) }
finally { setBusy('') }
}
async function changePassword() {
setError(''); setNotice('')
if (!pwd.current_password || !pwd.new_password) { setError('请填写当前密码与新密码'); return }
if (pwd.new_password !== pwd.confirm) { setError('两次输入的新密码不一致'); return }
setBusy('修改密码')
try {
const data = await api.post('/api/auth/password', {
current_password: pwd.current_password, new_password: pwd.new_password
})
setUser(data.user || null)
setPwd({ current_password: '', new_password: '', confirm: '' })
setNotice(`密码已更新,其它 ${data.revoked_sessions ?? 0} 个登录会话已注销。`)
await load()
} catch (exc: any) { setError(exc?.message || String(exc)) }
finally { setBusy('') }
}
/** 首次登录的种子账号:改完密码就地重新签一次会话,确保 Cookie 属性是最新的 */
async function relogin() {
if (!auth.user?.username || !pwd.new_password) return
try { await login(auth.user.username, pwd.new_password) } catch { /* 已经改完,重签失败不拦人 */ }
}
async function revoke(row: any) {
setBusy('注销会话'); setError('')
try {
await api.del(`/api/auth/sessions/${row.id}`)
setSessions((list) => list.filter((item) => item.id !== row.id))
setNotice(`已注销「${row.label}」的登录会话。`)
} catch (exc: any) { setError(exc?.message || String(exc)) }
finally { setBusy('') }
}
useAutoRefresh(() => void load(), 45000, !!busy, !!busy || formTouched)
return (
<div className="min-w-0">
<PageHead eyebrow="MY ACCOUNT" title="我的账号"
actions={<Tag tone={isAdmin ? 'info' : 'default'}>{role}</Tag>} />
{mustChange && <Notice>这个账号还在使用初始密码,请先修改密码再开始制作。</Notice>}
<Notice onClose={() => setNotice('')}>{notice}</Notice>
<ErrorText className="mb-[14px] text-caption">{error}</ErrorText>
<Layout>
<Stack>
<Panel>
<PanelHead eyebrow="PROFILE" title="基本资料" />
<FormRow>
<Field label="登录名"><input value={auth.user?.username || ''} disabled /></Field>
<Field label="显示名">
<input value={profile.display_name} maxLength={80} placeholder="同事看到的名字"
onChange={(e) => setProfile((p) => ({ ...p, display_name: e.target.value }))} />
</Field>
<Field label="邮箱">
<input value={profile.email} maxLength={160} placeholder="用于通知,可留空"
onChange={(e) => setProfile((p) => ({ ...p, email: e.target.value }))} />
</Field>
<Field label="角色"><input value={role + '(由管理员分配)'} disabled /></Field>
</FormRow>
<Actions>
<Button variant="primary" disabled={!!busy} onClick={saveProfile}>保存资料</Button>
</Actions>
</Panel>
<Panel>
<PanelHead eyebrow="PASSWORD" title="修改密码" />
<FormRow>
<Field label="当前密码">
<SecretInput value={pwd.current_password} autocomplete="current-password" placeholder="输入当前密码"
onChange={(v) => setPwd((p) => ({ ...p, current_password: v }))} />
</Field>
<Field label="新密码">
<SecretInput value={pwd.new_password} title={RULES_HINT} autocomplete="new-password"
placeholder="至少 8 位,建议混合字母与数字"
onChange={(v) => setPwd((p) => ({ ...p, new_password: v }))} />
</Field>
<Field label="确认新密码">
<SecretInput value={pwd.confirm} autocomplete="new-password" placeholder="再输入一次新密码"
onChange={(v) => setPwd((p) => ({ ...p, confirm: v }))}
onKeyUp={(e) => { if (e.key === 'Enter') void changePassword() }} />
</Field>
</FormRow>
<Actions>
<Button variant="primary" disabled={!!busy} title="改密后其它设备的会话会自动注销,本机保留。"
onClick={changePassword}>
修改密码
</Button>
<Button variant="outline" disabled={!!busy || !pwd.new_password || pwd.new_password !== pwd.confirm}
onClick={relogin}>
用新密码重新登录本机
</Button>
</Actions>
</Panel>
</Stack>
<Stack>
<Panel>
<PanelHead eyebrow="SESSIONS" title="登录设备" />
{!sessions.length
? <Empty>只有一个当前会话,没有其它设备在线。</Empty>
: (
<div className="flex flex-col">
{sessions.map((row) => (
<CardRow key={row.id} title={row.current ? '当前会话' : row.label}
right={row.current
? <Tag>使用中</Tag>
: <Button variant="outline" size="sm" disabled={!!busy} onClick={() => revoke(row)}>注销</Button>}>
<p>{row.ip || '未知 IP'} · 活跃于 {fmtAgo(row.last_seen_at)} · {fmtTime(row.expires_at)} 过期</p>
</CardRow>
))}
</div>
)}
</Panel>
</Stack>
</Layout>
</div>
)
}

View File

@ -1,4 +1,107 @@
/** 待迁移:登录(占位,见 .local/vue-ref/src/views/Login.vue) */
/**
* 登录页(chromeless:不套顶栏/侧栏,也不拉需要鉴权的系统状态)。
*
* 账号决定你能做什么:管理员管模型与账号,制作可以跑生产,观摩只读——
* 这句话放在标题的 title 里,登录前不需要读一整段说明。
*/
import { useEffect, useRef, useState, type FormEvent } from 'react'
import { useNavigate, useSearchParams } from 'react-router-dom'
import { SecretInput } from '../components/forms'
import { Button } from '../components/ui'
import { login, useAuthStore } from '../stores/auth'
import { setTheme, useAppliedTheme } from '../stores/theme'
export default function Login() {
return <div className="p-[26px] text-center text-faint text-body">登录 迁移中…</div>
const navigate = useNavigate()
const [params] = useSearchParams()
const { offline, error: connError, hint, user } = useAuthStore()
const isLight = useAppliedTheme() === 'light'
const [form, setForm] = useState({ username: '', password: '' })
const [busy, setBusy] = useState(false)
const [error, setError] = useState('')
const userRef = useRef<HTMLInputElement | null>(null)
const passRef = useRef<HTMLInputElement | null>(null)
useEffect(() => {
/* 首次部署时库里只有一个种子账号,后端会把用户名带下来,省得用户猜 */
setForm((f) => (f.username || !hint ? f : { ...f, username: hint }))
userRef.current?.focus()
}, [hint])
async function submit(event?: FormEvent) {
event?.preventDefault()
if (busy) return
if (!form.username.trim() || !form.password) {
setError('请输入用户名和密码')
return
}
setBusy(true)
setError('')
try {
const data = await login(form.username, form.password)
const next = String(params.get('next') || '').trim()
if (data?.user?.must_change_password) {
await navigate({ pathname: '/account', search: '?must=1' }, { replace: true })
return
}
/* 只接受站内相对路径,//evil.com 这种会被当成外域跳走 */
await navigate(next && next.startsWith('/') && !next.startsWith('//') ? next : '/', { replace: true })
} catch (exc: any) {
setError(exc?.message || String(exc))
setForm((f) => ({ ...f, password: '' }))
passRef.current?.focus()
} finally {
setBusy(false)
}
}
return (
<div className="grid min-h-screen place-items-center bg-[radial-gradient(900px_420px_at_50%_-8%,var(--c-accent-tint2),transparent_70%),var(--c-bg-app)] p-6">
<button type="button" onClick={() => setTheme(isLight ? 'dark' : 'light')}
aria-label={'切换明暗主题,当前为' + (isLight ? '浅色' : '深色')}
className="fixed right-5 top-[18px] inline-flex h-(--ctl-h-md) items-center rounded-[8px] border border-line bg-sunken px-[11px] text-caption text-ink-2">
{isLight ? '☀ 浅色' : '☾ 深色'}
</button>
<form className="w-[min(392px,100%)] rounded-float border border-line bg-panel px-6 pb-[22px] pt-[26px] shadow-[0_24px_60px_var(--c-shade-3)]" onSubmit={submit}>
<div className="flex items-center gap-2.5 pb-[18px] text-caption font-bold tracking-[1px] text-ink-2">
<b aria-hidden="true" className="grid h-[37px] w-[37px] place-items-center rounded-[11px] bg-accent-fill text-[22px] text-on-accent">N</b>
<span>长视频编导平台
<small className="mt-[5px] block text-tiny font-normal text-faint">NEX ANIMATION STUDIO</small>
</span>
</div>
<h1 className="mb-[18px] mt-0 text-h2 font-bold" title="账号决定你能做什么:管理员管模型与账号,制作可以跑生产,观摩只读。">登录以继续</h1>
{params.get('loggedOut') === '1' && (
<p className="mb-1 rounded-[8px] border border-line bg-info-tint px-[10px] py-[9px] text-caption text-info">已退出登录。</p>
)}
{offline && (
<p className="mb-1 rounded-[8px] border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">后端连接不上:{connError || '请确认服务已启动'}</p>
)}
{error && (
<p className="mb-1 rounded-[8px] border border-danger-line bg-danger-tint px-[10px] py-[9px] text-caption text-danger">{error}</p>
)}
<label className="mb-[10px] flex flex-col gap-[5px] text-caption">
<span className="text-muted">用户名</span>
<input ref={userRef} value={form.username} autoComplete="username" spellCheck={false}
placeholder={'如 ' + (user?.username || 'admin')}
onChange={(e) => setForm((f) => ({ ...f, username: e.target.value }))} />
</label>
<label className="mb-[10px] flex flex-col gap-[5px] text-caption">
<span className="text-muted">密码</span>
<SecretInput id="login-pass" ref={passRef} value={form.password} autocomplete="current-password"
placeholder="输入密码后点右侧图标可查看"
onChange={(next) => setForm((f) => ({ ...f, password: next }))}
onKeyUp={(e) => { if (e.key === 'Enter') void submit() }} />
</label>
<Button type="submit" variant="primary" size="lg" disabled={busy} className="mt-4 w-full">
{busy ? '正在验证…' : '登录'}
</Button>
<p className="mt-[14px] mb-0 text-center text-[10.5px] text-faint">忘记密码请联系平台管理员在「用户管理」里重置。</p>
</form>
</div>
)
}

View File

@ -1,11 +1,144 @@
/* 待迁移:项目工作台(占位,见 .local/vue-ref/src/views/ProjectDetail.vue) */
import { Outlet } from 'react-router-dom'
/**
* 项目工作台外壳:标题行 + 可折叠「项目概况」+ 各业务页签(<Outlet/>)。
*
* GL-1:项目概况(4 张指标卡 + 12 节点流程条)在桌面端同样要能收起。
* 以前只有 ≤900px 才折叠,正文被顶出首屏 ≈470px,每个页签都要先滚一屏废话。
* 折叠状态记在 project.ts(useBriefStore):分镜工作台也要能收起这块概况,
* 两处按钮共用同一份偏好,不会各说各话。
*/
import { useEffect, useState } from 'react'
import { Link, Outlet, useNavigate, useParams } from 'react-router-dom'
import * as api from '../api/client'
import { allNodesDone, stageNote } from '../lib/pipeline'
import { fmtMoney, pct, statusLabel } from '../lib/format'
import { cn } from '../lib/cn'
import {
Button, Empty, ErrorText, Loading, Notice, Panel, PanelHead, Stat, StatGrid, Status, Tag, Value
} from '../components/ui'
import { WorkflowBar } from '../components/media/WorkflowBar'
import { loadProject, startPolling, stopPolling, useBriefStore, useProjectStore } from '../stores/project'
export default function ProjectDetail() {
const { id: idParam } = useParams()
const id = Number(idParam)
const navigate = useNavigate()
const [error, setError] = useState('')
const [confirming, setConfirming] = useState(false)
const summaryOpen = useBriefStore((s) => s.open)
const setSummaryOpen = useBriefStore((s) => s.set)
const { project, workflow, stats, loading, error: storeError } = useProjectStore()
const nextStep = workflow.find((s: any) => s.state === 'active' || s.state === 'failed')
/** 流程走完的项目不再报「当前节点:导出完整视频」,否则和旁边的「已交付」自相矛盾 */
const flowDone = allNodesDone(workflow)
const flowNote = stageNote(project, workflow)
const taskHint = Object.entries<any>(stats?.task_status || {}).map(([k, v]) => `${statusLabel(k)} ${v}`).join(' · ')
/* 切项目:重新拉一次详情,并让轮询跟着新 id 走(卸载时一定停掉,
否则离开工作台后每 6 秒还在请求上一个项目) */
useEffect(() => {
if (!Number.isFinite(id)) return
setError('')
setConfirming(false)
void loadProject(id, false)
startPolling(id)
return stopPolling
}, [id])
async function removeProject() {
try {
await api.del(`/api/projects/${id}`, { purge_files: true })
navigate('/')
} catch (exc: any) {
setError(exc?.message || String(exc))
}
}
if (loading && !project) return <Loading>正在载入项目…</Loading>
if (!project) {
return (
<Empty>
未找到项目 #{id},可能已被删除。{' '}
<Link to="/" className="text-success text-caption no-underline hover:underline">返回项目总览</Link>
</Empty>
)
}
const st = stats || {}
return (
<div>
项目工作台迁移中…
<Outlet />
<div className="min-w-0">
<header className="mb-[25px] flex flex-wrap items-center justify-between gap-3 min-w-0 max-nav:items-start">
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-[9px] min-w-0 max-nav:w-full">
<Link to="/" className="text-success text-caption no-underline hover:underline">← 项目总览</Link>
<Status value={project.status} />
{flowDone
? <Tag tone="ok">{flowNote}</Tag>
: <Tag tone="info">当前节点:{flowNote || project.stage_label}</Tag>}
</div>
<h1>{project.name}</h1>
</div>
{/* 项目状态由 project.ts 每 6 秒轮询,页面无需再单独刷新 */}
<div className="flex flex-wrap items-center gap-[9px] [--ctl-h:var(--ctl-h-md)] max-nav:w-full max-nav:[&>button]:flex-1">
<Button variant="del" size="lg" title="删除整个项目:分镜、任务与已生成素材一起清除"
onClick={() => setConfirming((v) => !v)}>
⌫ 删除项目
</Button>
</div>
</header>
<ErrorText className="mb-3">{error || storeError}</ErrorText>
{confirming && (
<Notice danger onClose={() => setConfirming(false)}>
<div className="flex flex-wrap items-center justify-between gap-3 w-full min-w-0">
<span className="min-w-0">删除《{project.name}》会同时清除分镜、任务与已生成素材,确认?</span>
<div className="flex flex-wrap items-center gap-[9px] [--ctl-h:var(--ctl-h-md)]">
<Button variant="outline" size="sm" onClick={() => setConfirming(false)}>取消</Button>
<Button variant="del" size="lg" danger onClick={removeProject}>确认删除</Button>
</div>
</div>
</Notice>
)}
{/* 折叠条在所有断点都可用:收起后这一行本身就是紧凑摘要,正文直接顶到首屏 */}
<button aria-expanded={summaryOpen} onClick={() => setSummaryOpen(!summaryOpen)}
className="mb-[14px] flex w-full items-center gap-2 rounded-tile border border-line-strong bg-panel px-3 py-[10px] text-left text-ink-2 hover:border-accent-line hover:bg-card">
<span className="flex-none text-[11px] font-bold">项目概况</span>
<small className="min-w-0 flex-1 truncate text-muted text-tiny">
{statusLabel(project.status)} · 镜头 {st.shots_approved || 0}/{st.shots || 0} · 合格 {pct(st.progress_ratio)}
{' '}· 任务 {st.tasks_active || 0}/{st.tasks || 0} · 成本 {fmtMoney(st.cost?.total_cost, st.cost?.currency)}
</small>
<b className="flex-none whitespace-nowrap text-accent text-tiny">
{summaryOpen ? '收起概况 ⌃' : '展开概况 ⌄'}
</b>
</button>
<div className={cn('min-w-0', summaryOpen ? 'mb-[18px]' : 'hidden')}>
<StatGrid cols={4}>
<Stat label="镜头(合格/总数)"
value={<>{st.shots_approved || 0}<span className="text-title text-faint"> / {st.shots || 0}</span></>}
hint={`${statusLabel('failed')} ${st.shots_failed || 0} · ${st.shots_rejected || 0} 驳回`} />
<Stat label="时长(计划/已生成)"
value={<><span className="text-lg">{(st.planned_duration || 0).toFixed(1)}s</span>
<span className="text-ui text-faint"> / {(st.generated_duration || 0).toFixed(1)}s</span></>}
hint={`镜头合格进度 ${pct(st.progress_ratio)}`} />
<Stat label="任务(活跃/总数)"
value={<>{st.tasks_active || 0}<span className="text-title text-faint"> / {st.tasks || 0}</span></>}
hint={taskHint || '暂无任务'} />
<Stat label="成本 / 成片" value={<span className="text-lg">{fmtMoney(st.cost?.total_cost, st.cost?.currency)}</span>}
hint={`${(st.exports || []).length} 个导出记录`} />
</StatGrid>
<Panel className="mb-[18px]">
<PanelHead eyebrow="PIPELINE · 12 节点业务流程" title="流程进度"
right={nextStep ? <Value>下一步:{nextStep.label} — {nextStep.detail}</Value> : undefined} />
<WorkflowBar workflow={workflow} />
</Panel>
</div>
<div className="min-w-0"><Outlet /></div>
</div>
)
}