From 787a687238317251eed84f456505b1c878ffe41e Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Tue, 3 Nov 2026 21:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E6=A0=8F=E9=82=A3=E9=A2=97=E8=83=B6?= =?UTF-8?q?=E5=9B=8A=E6=94=B9=E6=88=90=E5=85=A8=E7=AB=99=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E7=9A=84=E3=80=8C=E9=A1=B9=E7=9B=AE=E6=A6=82=E5=86=B5=E3=80=8D?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=EF=BC=9A=E7=82=B9=E5=BC=80=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E6=8A=BD=E5=B1=89=EF=BC=8C=E9=A1=B9=E7=9B=AE=E5=B1=82=E5=8F=AA?= =?UTF-8?q?=E5=9C=A8=E8=BF=99=E4=B8=80=E5=A4=84=E8=AF=B4=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 症状(2026-11 第十一轮 · 用户第 2 条原话「上面那个项目总览、展开、归档(删除)和顶部 系统 Header 的项目总览应该整合到一处(要不保留最顶部作为入口,点击展开侧面的面板,把 项目概况、操作按钮都放到那个对应的面板中)」):同一条项目身份在一屏里说了三遍——顶栏 流程控制台(名称·状态·进度·当前节点)、工作台外壳那条面包屑工具条(项目名 + 镜头/合格/ 任务/成本 + 展开概况 + 删除项目)、概览页页头(归档项目);而它点下去是「跳流程概览」, 既不是看项目详情也不是做项目操作,语义含混。另外控制台以前只在 `wide` 才渲染, 900~991 与手机档整块消失,窄屏根本够不到归档与删除。 做法:①新增 `app/layout/ProjectBriefDrawer.tsx`(约 207 行)= 项目层唯一载体。 `Drawer` 宽 `min(620px, calc(100vw - 32px))`,标题是项目名、副标题「状态 · 流程 83% · 720p / 16:9」;正文自上而下:`ErrorText` → 「项目身份」Panel(`Info` 回显画幅/分辨率/ 题材/时长/默认模型/创建时间/简介)→ `StatGrid cols={2}` 四张指标(镜头合格、时长、 任务、成本)→ 「流程进度」Panel(`WorkflowBar compact`,容器自适应网格)→ 「项目环节」 Panel 七行 `.nex-brief-row`(图标 + 序号 + 站名 + 右端汇总状态 Tag,当前站标「当前」) → footer「返回项目总览(text, mr-auto)| 归档/取消归档 | 删除项目(全站唯一一颗 primary + danger,点第一次变「确认删除」并在正文里出一条 danger Notice 说明会连带清除 分镜、任务与素材)」。数据一律读 `stores/project.ts` 那份 6 秒轮询,抽屉不发第二个请求; 认「加载成功的那份数据自己的 id」而不是路由号,项目 404 时不会残留上一个项目。 列数跟着视口降档(`Grid.useBreakpoint()`:sm 以下 `Info` 收单列、简介那条 span 同步降), 否则 `Descriptions` 会报「Sum of column span in a line not match column」。 ②`app/App.tsx` 把开合状态记在外壳(`briefOpen`),抽屉挂在 `MediaLightbox` 旁边而不是 任何路由里——它是跨七站的常驻面板,离开某一站不该关掉。 ③`PipelineConsole` 从 `NavLink` 改成 kit 的 ` ) } diff --git a/frontend/src/app/layout/ProjectBriefDrawer.tsx b/frontend/src/app/layout/ProjectBriefDrawer.tsx new file mode 100644 index 0000000..7c7e3af --- /dev/null +++ b/frontend/src/app/layout/ProjectBriefDrawer.tsx @@ -0,0 +1,207 @@ +/** + * 「项目概况」抽屉:项目身份 + 指标 + 流程 + 七站跳转 + 项目级操作,全部收在一处。 + * + * 症状(2026-11 第十一轮 · 用户第 2 条原话「项目总览、展开、归档(删除)和顶部系统 + * Header 的项目总览应该整合到一处…点击展开侧面的面板,把项目概况、操作按钮都放到 + * 那个对应的面板中」「要进一步把各级的信息归拢并提供交互的层次清晰」): + * 项目身份在**同一屏说了三遍**——顶栏那颗胶囊(名称·状态·进度·当前节点)、 + * 外壳那条面包屑工具条(项目名 + 镜头/合格/任务/成本 + 展开概况 + 删除项目)、 + * 概览页的「流程概览」页头(归档项目);而 4 张指标卡 + 12 节点流程条坐在正文上方, + * 每个环节页都要先滚过这两屏才看到自己真正的内容。层级也是乱的: + * 「项目级」的操作(归档 / 删除)出现在「页面级」的位置上。 + * 做法:四级层次各归各位—— + * ① 顶栏控制台 = 唯一的项目身份入口(点击展开本抽屉,不再跳页); + * ② 本抽屉 = 项目层(身份回显 / 指标 / 流程 / 七站跳转 / 归档 / 删除); + * ③ NodeHead = 环节层页头(每站一张带底纹的卡,见 components/ui/Page.tsx); + * ④ Panel = 内容层。于是工作台外壳可以一行可见块都不渲染(见 pages/ProjectDetail.tsx)。 + * 为什么用右侧抽屉而不是弹窗:这是「随时查一眼项目全局」的辅助面板, + * 遮罩之下正文还在原地,关掉就回到刚才那一站,不需要重新载入。 + * 数据一律读 useProjectStore(外壳每 6 秒轮询),这里不发第二个请求。 + */ +import { useState } from 'react' +import { useLocation, useNavigate } from 'react-router-dom' +import { Flex, Grid } from 'antd' +import * as api from '../../api/client' +import { fmtMoney, fmtTime, pct, statusLabel } from '../../lib/format' +import { moduleState } from '../../lib/pipeline' +import { + Button, Drawer, ErrorText, Info, Loading, Notice, PageStack, Panel, + Stat, StatGrid, Status, Tag, Value, type TagTone +} from '../../components/ui' +import { WorkflowBar } from '../../components/media/WorkflowBar' +import { + IconChart, IconClose, IconDelete, IconFolder, IconBolt, IconClock, + IconProjects, IconSync, IconTracks +} from '../../components/icons' +import { pathOf, projectModules, type NavItem } from './nav' +import { refresh, useProjectStore } from '../../stores/project' +import { notify } from '../../stores/notice' + +/** 环节汇总状态 → 标签(口径与 lib/pipeline 的节点状态一致,只是从 12 个节点折成 7 站) */ +const MODULE_TAG: Record = { + done: { label: '已完成', tone: 'ok' }, + active: { label: '进行中', tone: 'accent' }, + failed: { label: '需处理', tone: 'bad' }, + pending: { label: '待处理', tone: 'default' } +} + +/** 环节项 → 路由最后一段(NODE_MODULE 的取值口径就是它) */ +const slugOf = (m: NavItem): string => pathOf(m, '0').split('/').pop() || '' + +export function ProjectBriefDrawer({ open, onClose, projectId }: { + open: boolean + onClose: () => void + projectId: string +}) { + const navigate = useNavigate() + const location = useLocation() + /* 抽屉宽度是 min(620, 100vw-32):手机上是 398,回显表两列会把「分辨率 / 帧率」 + 这种标签挤到折行,所以列数跟着视口降档。antd Descriptions 要求每行的 span 之和 + 等于 column,简介那条通栏的 span 也必须跟着算——写死 span:2 在单列下会报 + 「Sum of column span in a line not match column」。 */ + const twoCol = !!Grid.useBreakpoint().sm + const [busy, setBusy] = useState(false) + const [confirming, setConfirming] = useState(false) + const [error, setError] = useState('') + const project = useProjectStore((s) => s.project) + const workflow = useProjectStore((s) => s.workflow) + const stats = useProjectStore((s) => s.stats) + /* 认「加载成功的那份数据自己的 id」,不认路由号:项目 404 时 store 里还留着上一个 */ + const proj = projectId && project?.id === Number(projectId) ? project : null + const st = stats || {} + const isArchived = proj?.status === 'archived' + const curSlug = slugOf(projectModules.find((m) => pathOf(m, projectId) === location.pathname) || projectModules[0]) + + function go(to: string) { + onClose() + navigate(to) + } + + async function run(fn: () => Promise) { + setBusy(true) + setError('') + try { await fn() } catch (exc: any) { setError(exc?.message || String(exc)) } finally { setBusy(false) } + } + + const setArchived = (on: boolean) => run(async () => { + await api.patch(`/api/projects/${projectId}`, { status: on ? 'archived' : 'draft' }) + notify(on ? '项目已归档,不再自动推进流程' : '已取消归档,流程状态按镜头真实进度重算') + await refresh() + }) + + const removeProject = () => run(async () => { + await api.del(`/api/projects/${projectId}`, { purge_files: true }) + navigate('/') + }) + + const taskHint = Object.entries(st.task_status || {}).map(([k, v]) => `${statusLabel(k)} ${v}`).join(' · ') + const nextStep = workflow.find((s: any) => s.state === 'active' || s.state === 'failed') + + return ( + + + + {confirming && ( + + )} + + }> + {!proj + ? 正在载入项目概况… + : ( + + {error} + + }> + + + + + } label="镜头(合格/总数)" + value={<>{st.shots_approved || 0}/ {st.shots || 0}} + hint={`驳回 ${st.shots_rejected || 0} · 合格进度 ${pct(st.progress_ratio)}`} /> + } label="时长(计划/已生成)" + value={<>{(st.planned_duration || 0).toFixed(1)}s/ {(st.generated_duration || 0).toFixed(1)}s} + hint={taskHint || '暂无任务'} /> + } label="任务(活跃/总数)" + value={<>{st.tasks_active || 0}/ {st.tasks || 0}} + hint={taskHint || '暂无任务'} /> + } label="成本 / 成片" + value={fmtMoney(st.cost?.total_cost, st.cost?.currency)} + hint={`${(st.exports || []).length} 个导出记录`} /> + + + 下一步:{nextStep.label} : 全部 {workflow.length} 个节点已完成}> + + + + + + {projectModules.map((m, i) => { + const slug = slugOf(m) + const tag = MODULE_TAG[moduleState(workflow, slug)] || MODULE_TAG.pending + const isCur = slug === curSlug + return ( + + ) + })} + + + + {confirming && ( + setConfirming(false)}> + 删除《{proj.name}》会同时清除分镜、任务与已生成素材,且不可恢复。 + + )} + + )} + + ) +} + +/** 轨道百分比:与顶栏控制台同一个算法(已完成节点 / 全部节点),不用后端的镜头合格率 */ +function pctDone(nodes: any[]): string { + const total = nodes.length + if (!total) return '流程未生成' + return `${Math.round((nodes.filter((n: any) => n.state === 'done').length / total) * 100)}%` +} + +export default ProjectBriefDrawer