迁移项目总览:新建项目表单 + 资源库母版勾选 + 项目列表(窄屏卡片);修正表头右对齐被子选择器压掉
parent
8b9f8ebaa5
commit
f382b0113e
|
|
@ -140,14 +140,16 @@ export function Chip({ active, children, onClick, className, title, disabled, as
|
|||
return <button type="button" title={title} disabled={disabled} onClick={onClick} className={classes}>{children}</button>
|
||||
}
|
||||
|
||||
/** 选中态胶囊 + 移除叉(多选回显) */
|
||||
export function TagChip({ children, onRemove, className }: { children: ReactNode; onRemove?: () => void; className?: string }) {
|
||||
/** 选中态胶囊 + 移除叉(多选回显);removeTitle 解释叉掉之后会发生什么 */
|
||||
export function TagChip({ children, onRemove, className, removeTitle }: {
|
||||
children: ReactNode; onRemove?: () => void; className?: string; removeTitle?: string
|
||||
}) {
|
||||
return (
|
||||
<span className={cn('inline-flex items-center justify-center gap-[5px] h-(--ctl-h-md) px-[9px] text-tiny rounded-pill '
|
||||
+ 'border bg-accent-fill border-accent-fill text-on-accent font-bold whitespace-nowrap shrink-0', className)}>
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button type="button" onClick={onRemove} aria-label="移除"
|
||||
<button type="button" onClick={onRemove} title={removeTitle} aria-label="移除"
|
||||
className="grid place-items-center w-[17px] h-[17px] ml-[5px] p-0 flex-none border-0 rounded-full bg-[color-mix(in_srgb,var(--c-on-accent)_20%,transparent)] text-inherit text-[12px] leading-none hover:bg-danger hover:text-danger-ink">×</button>
|
||||
)}
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ export function Table({ children, className, minWidth = 720, pickable }: {
|
|||
className={cn('w-full border-collapse text-label min-w-0',
|
||||
'[&_th]:text-left [&_th]:text-tiny [&_th]:tracking-[.8px] [&_th]:text-faint [&_th]:font-bold [&_th]:px-2 [&_th]:py-[7px]',
|
||||
'[&_th]:border-b [&_th]:border-line [&_th]:whitespace-nowrap [&_th]:bg-shell [&_th]:sticky [&_th]:top-0 [&_th]:z-[1]',
|
||||
/* 数字列的 <th className={cellRight}> 之前是失效的:上面那条 [&_th]:text-left 带一个
|
||||
元素选择器,特异性 (0,1,1) 高于 .text-right 的 (0,1,0),表头全部退回左对齐。
|
||||
这里把两种对齐写回同一层特异性关系,表头和它下面的数字列才对得上。 */
|
||||
'[&_th.text-right]:text-right [&_th.text-center]:text-center',
|
||||
'[&_td]:px-2 [&_td]:py-[9px] [&_td]:border-b [&_td]:border-line-soft [&_td]:align-middle',
|
||||
'[&_tbody_tr:hover>td]:bg-panel',
|
||||
/* 整行是热区的表(账号列表、模型列表):指针形状说明「点这一行有用」 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,703 @@
|
|||
/** 待迁移:项目总览(占位,见 .local/vue-ref/src/views/Dashboard.vue) */
|
||||
export default function Dashboard() {
|
||||
return <div className="p-[26px] text-center text-faint text-body">项目总览 迁移中…</div>
|
||||
/**
|
||||
* 项目总览(流程第 ① 步的家)
|
||||
*
|
||||
* 这一页承担三件事:新建项目(含直接从资源库带母版)、看所有项目的进度、
|
||||
* 看全局动态。进度和动态都是 20 秒自刷的只读视图——平台在后台跑,
|
||||
* 页面不该要求用户点「刷新」才知道镜头跑完了没有。
|
||||
*/
|
||||
import { useEffect, useMemo, useRef, useState, type FormEvent } from 'react'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import { cn } from '../lib/cn'
|
||||
import * as api from '../api/client'
|
||||
import {
|
||||
EVENT_LEVELS, eventLabel, eventLevelKey, fmtAgo, fmtMoney, fmtTime, opt, pct, statusLabel
|
||||
} from '../lib/format'
|
||||
import { fromAsset, isAudio, isImage } from '../lib/media'
|
||||
import { stageNote } from '../lib/pipeline'
|
||||
import { useAutoRefresh } from '../hooks'
|
||||
import { Select } from '../components/forms'
|
||||
import { MediaThumb } from '../components/media/MediaThumb'
|
||||
import { WorkflowBar } from '../components/media/WorkflowBar'
|
||||
import {
|
||||
Actions, Button, buttonCls, Chip, ChipBar, Ctlbar, Divider, Empty, ErrorText, Eyebrow, Field,
|
||||
FieldBlock, FormRow, Grid, LINK_CLS, Loading, LogBox, LogRow, MONO, MUTED, PageHead, Panel,
|
||||
PanelHead, ProgressBar, Row, SectionTitle, Stat, StatGrid, Status, TabStack, Table, TableBox,
|
||||
Tag, TagChip, Value, cellRight, cellWrap
|
||||
} from '../components/ui'
|
||||
import {
|
||||
capabilityHint, capsOf, defaultFor, deliveryResolutions, fpsChoices, isMock, loadModels,
|
||||
modelsOf, parseRef, refOf, resolutionChoices, useRegistry
|
||||
} from '../stores/models'
|
||||
import { useSystemStore } from '../stores/system'
|
||||
import { notify } from '../stores/notice'
|
||||
|
||||
/** 新建项目表单:字段名与后端 POST /api/projects 一致,提交时直接展开 */
|
||||
type NewProjectForm = {
|
||||
name: string
|
||||
description: string
|
||||
genre: string
|
||||
target_duration: number
|
||||
aspect_ratio: string
|
||||
resolution: string
|
||||
fps: number
|
||||
style_guide: string
|
||||
global_negative_prompt: string
|
||||
default_provider: string
|
||||
default_model: string
|
||||
default_transition: string
|
||||
}
|
||||
const EMPTY_FORM: NewProjectForm = {
|
||||
name: '', description: '', genre: '', target_duration: 120, aspect_ratio: '16:9',
|
||||
resolution: '720p', fps: 24, style_guide: '', global_negative_prompt: '',
|
||||
default_provider: '', default_model: '', default_transition: 'cut'
|
||||
}
|
||||
|
||||
/** 「制作中」的口径:还没走到 delivered 的所有在制状态,与后端 stats 无关 */
|
||||
const ACTIVE_STATUSES = ['generating', 'reviewing', 'composing', 'storyboard', 'binding']
|
||||
|
||||
/** 新建项目时可勾选的资源库分类 */
|
||||
type LibType = 'human' | 'scene' | 'voice'
|
||||
const LIB_TYPES: { value: LibType; label: string }[] = [
|
||||
{ value: 'human', label: '人物' }, { value: 'scene', label: '场景' }, { value: 'voice', label: '声线' }
|
||||
]
|
||||
/** 表格里不许折行的列(数字、状态、动作),长文本列另用 cellWrap */
|
||||
const NOWRAP = 'whitespace-nowrap'
|
||||
/** 没有封面时的占位格:有镜头却没画面 ≠ 没导入分镜,两种情况图标要说清楚 */
|
||||
const COVER_NONE = 'grid h-[41px] w-[72px] place-items-center rounded-[6px] border border-dashed '
|
||||
+ 'border-line-strong bg-panel text-muted text-[14px]'
|
||||
|
||||
const coverOf = (row: any) => (row?.assets || []).find((m: any) => isImage(m.url, m.kind, m.mime)) || null
|
||||
const audioOfRow = (row: any) => (row?.assets || []).find((m: any) => isAudio(m.url, m.kind, m.mime)) || null
|
||||
const libKey = (row: any) => `${row.owner_type}:${row.asset_id ?? row.id}`
|
||||
const subLabel = (row: any) => row.owner_type === 'human'
|
||||
? [row.role, row.default_voice_name && `声线:${row.default_voice_name}`].filter(Boolean).join(' · ')
|
||||
: (row.owner_type === 'scene' ? (row.time_of_day || row.lighting || row.description || '')
|
||||
: [row.gender, row.language, row.provider].filter(Boolean).join(' · '))
|
||||
|
||||
export default function Dashboard() {
|
||||
const navigate = useNavigate()
|
||||
const meta = useSystemStore((s) => s.meta)
|
||||
// 订阅注册表:档位 / 帧率 / 能力告警都要等 /api/providers 回来才会重算
|
||||
useRegistry((s) => s.rows)
|
||||
|
||||
const [projects, setProjects] = useState<any[]>([])
|
||||
const [events, setEvents] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [keyword, setKeyword] = useState('')
|
||||
const [statusFilter, setStatusFilter] = useState('')
|
||||
const [creating, setCreating] = useState(false)
|
||||
/** 全局动态过滤(DB-4):级别 + 关键字,只看异常时不必在 40 条流水里翻 */
|
||||
const [eventLevel, setEventLevel] = useState('')
|
||||
const [eventKeyword, setEventKeyword] = useState('')
|
||||
const [form, setFormState] = useState<NewProjectForm>(EMPTY_FORM)
|
||||
const setForm = (patch: Partial<NewProjectForm>) => setFormState((cur) => ({ ...cur, ...patch }))
|
||||
|
||||
const [libOpen, setLibOpen] = useState(false)
|
||||
const [libType, setLibType] = useState<LibType>('human')
|
||||
const [libQuery, setLibQuery] = useState('')
|
||||
const [libRows, setLibRows] = useState<Record<LibType, any[]>>({ human: [], scene: [], voice: [] })
|
||||
const [libLoading, setLibLoading] = useState(false)
|
||||
const [libError, setLibError] = useState('')
|
||||
/** 选中项保存完整行:切到别的分类后,已选人物还要能显示名字与缩略图 */
|
||||
const [picked, setPicked] = useState<Record<string, any>>({})
|
||||
const libLoaded = useRef<Record<LibType, boolean>>({ human: false, scene: false, voice: false })
|
||||
const libBusy = useRef(false)
|
||||
|
||||
const statuses: string[] = (meta?.project_statuses as string[]) || []
|
||||
/** 视频模型决定可用档位:新建时就按注册表给默认值,不再让用户手填 provider 字符串 */
|
||||
const videoModels = modelsOf('video')
|
||||
const videoOptions = videoModels.map((row) => ({
|
||||
value: refOf(row),
|
||||
label: `${row.display_name || `${row.provider} · ${row.model}`}`
|
||||
+ `${row.available ? '' : '(未就绪)'}${isMock(row) ? '(演练通道)' : ''}`
|
||||
}))
|
||||
const videoRef = form.default_provider ? `${form.default_provider}|${form.default_model}` : ''
|
||||
const applyVideoRef = (next: string) => {
|
||||
const [provider, model] = parseRef(next)
|
||||
setFormState((prev) => {
|
||||
const caps = capsOf(provider, model)
|
||||
const patch: NewProjectForm = { ...prev, default_provider: provider, default_model: model }
|
||||
if (caps.fps > 0) patch.fps = caps.fps
|
||||
// 档位不在模型能力里才回落,且只回落到「原生能出」的最高档:
|
||||
// 放大交付档(1080p)是合法选项,不能一换模型就被静默踢回 720p。
|
||||
const deliverable = deliveryResolutions(provider, model)
|
||||
if (deliverable.length && !deliverable.includes(prev.resolution)) {
|
||||
const native = caps.resolutions.length ? caps.resolutions : deliverable
|
||||
patch.resolution = native[native.length - 1]
|
||||
}
|
||||
return patch
|
||||
})
|
||||
}
|
||||
|
||||
/* 新建项目必须落到注册表里真实存在的模型:留空虽然会被后端回落成平台默认,
|
||||
但表单按空 provider 查能力时会报「注册表里还没有这个模型」,用户以为保存后必然派发失败。
|
||||
这里直接预置平台默认模型(优先真实通道,演练环境才回落 mock),少一个选项也少一次误判。 */
|
||||
const preferredVideoModel = defaultFor('video', false) || defaultFor('video')
|
||||
useEffect(() => {
|
||||
if (!preferredVideoModel) return
|
||||
setFormState((prev) => {
|
||||
if (prev.default_provider) return prev
|
||||
const [provider, model] = parseRef(refOf(preferredVideoModel))
|
||||
const caps = capsOf(provider, model)
|
||||
return {
|
||||
...prev, default_provider: provider, default_model: model,
|
||||
fps: caps.fps > 0 ? caps.fps : prev.fps
|
||||
}
|
||||
})
|
||||
}, [preferredVideoModel])
|
||||
|
||||
const videoCaps = capsOf(form.default_provider, form.default_model || null)
|
||||
const resOptions = resolutionChoices(form.default_provider, form.default_model || null)
|
||||
const fpsOptions = fpsChoices(form.default_provider, form.default_model || null)
|
||||
.map((f) => ({ value: f, label: `${f} fps` }))
|
||||
const modelWarnings = capabilityHint(
|
||||
form.default_provider, form.default_model || null, form.resolution, form.fps, form.aspect_ratio)
|
||||
const durationRule = !videoCaps.minDuration && !videoCaps.maxDuration
|
||||
? '模型未声明单镜时长区间'
|
||||
: `总时长按镜头累加;单镜需在 ${videoCaps.minDuration}–${videoCaps.maxDuration} 秒内`
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
const q = keyword.trim().toLowerCase()
|
||||
return projects.filter((p) => {
|
||||
if (statusFilter && p.status !== statusFilter) return false
|
||||
if (!q) return true
|
||||
return `${p.name} ${p.description} ${p.genre}`.toLowerCase().includes(q)
|
||||
})
|
||||
}, [projects, keyword, statusFilter])
|
||||
|
||||
const shownEvents = useMemo(() => {
|
||||
const needle = eventKeyword.trim().toLowerCase()
|
||||
return events.filter((e: any) => {
|
||||
if (eventLevel && eventLevelKey(e.level) !== eventLevel) return false
|
||||
if (!needle) return true
|
||||
return `${e.message || ''} ${e.action || ''} ${eventLabel(e.action)}`.toLowerCase().includes(needle)
|
||||
})
|
||||
}, [events, eventLevel, eventKeyword])
|
||||
const levelCounts = useMemo(() => {
|
||||
const counts: Record<string, number> = {}
|
||||
for (const e of events) {
|
||||
const key = eventLevelKey(e.level)
|
||||
counts[key] = (counts[key] || 0) + 1
|
||||
}
|
||||
return counts
|
||||
}, [events])
|
||||
|
||||
const totals = {
|
||||
all: projects.length,
|
||||
active: projects.filter((p) => ACTIVE_STATUSES.includes(p.status)).length,
|
||||
delivered: projects.filter((p) => p.status === 'delivered').length,
|
||||
cost: projects.reduce((sum, p) => sum + Number(p.stats?.cost?.total_cost || 0), 0),
|
||||
// 币种来自成本台账本身(/api/meta 里没有 currency 这个字段)
|
||||
currency: projects.find((p) => p.stats?.cost?.currency)?.stats?.cost?.currency || 'CNY'
|
||||
}
|
||||
|
||||
const libShown = useMemo(() => {
|
||||
const needle = libQuery.trim().toLowerCase()
|
||||
return (libRows[libType] || []).filter((row: any) => {
|
||||
if (!needle) return true
|
||||
const media = (row.assets || []).map((m: any) => m.kind).join(' ')
|
||||
return `${row.name} ${row.code || ''} ${(row.tags || []).join(' ')} ${media}`
|
||||
.toLowerCase().includes(needle)
|
||||
})
|
||||
}, [libRows, libType, libQuery])
|
||||
const pickedRows = Object.values(picked)
|
||||
const pickedByType = useMemo(() => {
|
||||
const grouped: Record<string, any[]> = { human: [], scene: [], voice: [] }
|
||||
for (const row of pickedRows) (grouped[row.owner_type] ||= []).push(row)
|
||||
return grouped
|
||||
}, [picked])
|
||||
|
||||
async function loadLibrary(kind: LibType, force = false) {
|
||||
if (libBusy.current || (libLoaded.current[kind] && !force)) return
|
||||
libBusy.current = true
|
||||
setLibLoading(true)
|
||||
setLibError('')
|
||||
try {
|
||||
const data = await api.get('/api/platform/assets',
|
||||
{ owner_type: kind, status: 'active', sort: 'updated', page_size: 0 })
|
||||
setLibRows((cur) => ({ ...cur, [kind]: data.items || [] }))
|
||||
libLoaded.current = { ...libLoaded.current, [kind]: true }
|
||||
} catch (exc: any) {
|
||||
setLibError(exc.message)
|
||||
} finally {
|
||||
libBusy.current = false
|
||||
setLibLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
function toggleLibrary() {
|
||||
const next = !libOpen
|
||||
setLibOpen(next)
|
||||
if (next) void loadLibrary(libType)
|
||||
}
|
||||
|
||||
function pickType(kind: LibType) {
|
||||
setLibType(kind)
|
||||
void loadLibrary(kind)
|
||||
}
|
||||
|
||||
function togglePick(row: any) {
|
||||
const key = libKey(row)
|
||||
setPicked((cur) => {
|
||||
const next = { ...cur }
|
||||
if (next[key]) delete next[key]
|
||||
// 只留引入必需的字段:整行里塞着 base64、workflow config 之类的东西没必要跟着走
|
||||
else next[key] = {
|
||||
owner_type: row.owner_type, asset_id: row.id, name: row.name,
|
||||
type_label: row.type_label, role: row.role, gender: row.gender
|
||||
}
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
function resetLibrary() {
|
||||
setPicked({})
|
||||
setLibOpen(false)
|
||||
setLibQuery('')
|
||||
}
|
||||
|
||||
async function load() {
|
||||
setError('')
|
||||
loadModels()
|
||||
try {
|
||||
const [list, evs] = await Promise.all([
|
||||
api.get('/api/projects', { status: statusFilter, q: keyword }),
|
||||
api.get('/api/events', { limit: 40 })
|
||||
])
|
||||
setProjects(list.projects || [])
|
||||
setEvents(evs.events || [])
|
||||
} catch (exc: any) {
|
||||
setError(exc.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
/* load 每帧都是新函数(要读当前筛选词),钩子与定时器统一走 ref,
|
||||
否则把它的身份塞进依赖数组,等于每敲一个字就立刻回源一次。 */
|
||||
const loadRef = useRef(load)
|
||||
loadRef.current = load
|
||||
|
||||
async function submit(e: FormEvent) {
|
||||
e.preventDefault()
|
||||
if (!form.name.trim()) { setError('请填写项目名称'); return }
|
||||
if (videoCaps.known && videoCaps.mock) {
|
||||
setError('当前选的是 mock 演练通道,正式项目请选择真实视频模型')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const assets = pickedRows.map((row: any) => ({ owner_type: row.owner_type, asset_id: row.asset_id }))
|
||||
const created = await api.post('/api/projects', { ...form, platform_assets: assets })
|
||||
const failures: any[] = created?.import_failures || []
|
||||
const imported: any[] = created?.imported_assets || []
|
||||
setCreating(false)
|
||||
resetLibrary()
|
||||
if (failures.length) {
|
||||
notify(`已引入 ${imported.length} 个资源,${failures.length} 个失败:`
|
||||
+ failures.slice(0, 2).map((f: any) => f.detail).join(';')
|
||||
+ (failures.length > 2 ? ' …' : ''))
|
||||
} else if (imported.length) {
|
||||
notify(`已引入资源库母版 ${imported.length} 个,可直接绑定到镜头`)
|
||||
}
|
||||
await navigate(`/projects/${created.id}/overview`)
|
||||
} catch (exc: any) {
|
||||
setError(exc.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function removeProject(p: any) {
|
||||
if (!window.confirm(`确认删除项目《${p.name}》?该操作不可恢复。`)) return
|
||||
try {
|
||||
await api.del(`/api/projects/${p.id}`, { purge_files: true })
|
||||
await load()
|
||||
} catch (exc: any) { setError(exc.message) }
|
||||
}
|
||||
|
||||
/* 规范 §4 / R6:筛选即时生效,不放「筛选」按钮(与「队列自动刷新不加按钮」同源)。
|
||||
输入停顿 300ms 再回源,避免每敲一个字打一次接口;首帧由 onMounted 那次 load 负责。 */
|
||||
const firstRender = useRef(true)
|
||||
useEffect(() => {
|
||||
if (firstRender.current) { firstRender.current = false; return }
|
||||
const timer = window.setTimeout(() => void loadRef.current(), 300)
|
||||
return () => window.clearTimeout(timer)
|
||||
}, [keyword, statusFilter])
|
||||
|
||||
useEffect(() => { void loadRef.current() }, [])
|
||||
useAutoRefresh(() => void load(), 20000, false, creating)
|
||||
|
||||
return (
|
||||
<TabStack>
|
||||
<PageHead eyebrow="01 / PROJECTS" title="项目总览" className="mb-0"
|
||||
actions={<Button variant="primary" onClick={() => setCreating((v) => !v)}>
|
||||
{creating ? '收起' : '+ 新建长视频项目'}
|
||||
</Button>} />
|
||||
|
||||
<ErrorText>{error}</ErrorText>
|
||||
|
||||
{creating && (
|
||||
<form onSubmit={submit} className="min-w-0">
|
||||
<Panel>
|
||||
<h3 className="mb-3" title="流程第 ① 步:创建视频项目">新建长视频项目</h3>
|
||||
|
||||
<FormRow>
|
||||
<Field label="项目名称" required>
|
||||
<input value={form.name} placeholder="例如:星海纪元 · 第一集"
|
||||
onChange={(e) => setForm({ name: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="题材">
|
||||
<input value={form.genre} placeholder="科幻 / 悬疑 / 都市"
|
||||
onChange={(e) => setForm({ genre: e.target.value })} />
|
||||
</Field>
|
||||
<Field label="目标总时长(秒)">
|
||||
<input type="number" min={1} value={form.target_duration} title={durationRule}
|
||||
onChange={(e) => setForm({ target_duration: Number(e.target.value) })} />
|
||||
</Field>
|
||||
<Field label="默认转场">
|
||||
<Select value={form.default_transition} options={meta?.options?.transition || []}
|
||||
onChange={(v) => setForm({ default_transition: v })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
|
||||
<FormRow>
|
||||
<Field label="默认视频模型">
|
||||
<Select value={videoRef} options={videoOptions} onChange={applyVideoRef}
|
||||
title={`生成模式 ${videoCaps.modes.map((m) => opt('mode', m)).join(' / ') || '未声明'};后续可在项目设置里改`} />
|
||||
</Field>
|
||||
<Field label="画幅">
|
||||
<Select value={form.aspect_ratio} options={meta?.options?.aspect_ratio || []}
|
||||
onChange={(v) => setForm({ aspect_ratio: v })} />
|
||||
</Field>
|
||||
<Field label="分辨率">
|
||||
<Select value={form.resolution} options={resOptions}
|
||||
onChange={(v) => setForm({ resolution: v })} />
|
||||
</Field>
|
||||
<Field label="帧率">
|
||||
<Select value={form.fps} options={fpsOptions}
|
||||
onChange={(v) => setForm({ fps: Number(v) })} />
|
||||
</Field>
|
||||
<Field label="全局负面提示词">
|
||||
<input value={form.global_negative_prompt} placeholder="文字水印,画面抖动,肢体畸变"
|
||||
onChange={(e) => setForm({ global_negative_prompt: e.target.value })} />
|
||||
</Field>
|
||||
</FormRow>
|
||||
|
||||
<FormRow cols={2}>
|
||||
<FieldBlock label="项目简介">
|
||||
<textarea rows={2} value={form.description}
|
||||
onChange={(e) => setForm({ description: e.target.value })} />
|
||||
</FieldBlock>
|
||||
<FieldBlock label="全局风格指南(拼接到每个镜头提示词)">
|
||||
<textarea rows={2} value={form.style_guide} placeholder="赛博朋克国风,冷色调,电影质感"
|
||||
onChange={(e) => setForm({ style_guide: e.target.value })} />
|
||||
</FieldBlock>
|
||||
</FormRow>
|
||||
|
||||
<LibraryPicker open={libOpen} type={libType} onType={pickType}
|
||||
query={libQuery} onQuery={setLibQuery} rows={libShown}
|
||||
loading={libLoading} error={libError} picked={picked}
|
||||
pickedByType={pickedByType}
|
||||
onToggle={toggleLibrary} onPick={togglePick}
|
||||
onRefresh={() => void loadLibrary(libType, true)} />
|
||||
|
||||
<ChipBar>
|
||||
<Chip as="span">可用档位 {videoCaps.resolutions.join(' / ') || '未声明'}</Chip>
|
||||
<Chip as="span">帧率 {videoCaps.fps || '未声明'}fps</Chip>
|
||||
<Chip as="span">单镜 {videoCaps.minDuration || '?'}–{videoCaps.maxDuration || '?'} 秒</Chip>
|
||||
<Chip as="span">参考图上限 {videoCaps.maxReferenceImages || '未声明'}</Chip>
|
||||
</ChipBar>
|
||||
{modelWarnings.map((w, i) => <ErrorText key={`w${i}`} className="mb-1">{w}</ErrorText>)}
|
||||
|
||||
<Actions>
|
||||
<Button variant="primary" type="submit">创建并进入项目</Button>
|
||||
<Button variant="outline" type="button" onClick={() => setCreating(false)}>取消</Button>
|
||||
</Actions>
|
||||
</Panel>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<StatGrid cols={4}>
|
||||
<Stat label="项目总数" value={totals.all} />
|
||||
<Stat label="制作中" value={totals.active} />
|
||||
<Stat label="已交付" value={totals.delivered} />
|
||||
<Stat label="累计成本" value={fmtMoney(totals.cost, totals.currency)} />
|
||||
</StatGrid>
|
||||
|
||||
<Panel>
|
||||
<PanelHead eyebrow="PIPELINE" title="项目列表" right={
|
||||
<Ctlbar className="mb-0 w-full">
|
||||
<Field label="搜索" width="grow">
|
||||
<input value={keyword} aria-label="搜索项目" placeholder="名称 / 简介 / 题材"
|
||||
onChange={(e) => setKeyword(e.target.value)} />
|
||||
</Field>
|
||||
<Field label="状态" width="narrow">
|
||||
<Select size="sm" value={statusFilter} ariaLabel="项目状态筛选" onChange={setStatusFilter}
|
||||
options={[{ value: '', label: '全部状态' },
|
||||
...statuses.map((st) => ({ value: st, label: statusLabel(st) }))]} />
|
||||
</Field>
|
||||
</Ctlbar>
|
||||
} />
|
||||
|
||||
{loading ? <Loading>正在读取项目…</Loading>
|
||||
: !filtered.length ? <Empty>还没有项目。点击右上角「新建长视频项目」开始。</Empty>
|
||||
: (
|
||||
<>
|
||||
<TableBox maxHeight={false} className="max-narrow:hidden">
|
||||
<Table minWidth={940}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>项目</th><th>状态</th><th>流程节点</th>
|
||||
<th className={cellRight}>镜头</th><th className={cellRight}>进度</th>
|
||||
<th className={cellRight}>时长</th><th className={cellRight}>成本</th>
|
||||
<th className={cellRight}>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filtered.map((p) => (
|
||||
<tr key={p.id}>
|
||||
<td className={cellWrap}>
|
||||
<div className="flex min-w-0 items-center gap-[10px]">
|
||||
<div className="w-[72px] flex-none">
|
||||
{p.cover_url
|
||||
? <MediaThumb src={p.cover_url} size="xs" width="72px" radius={6} title={`${p.name} 首帧`} />
|
||||
: <span className={COVER_NONE}
|
||||
title={p.shot_count ? '已有镜头,但还没有生成任何画面' : '还没有导入分镜'}>
|
||||
{p.shot_count ? '▷' : '+'}
|
||||
</span>}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<Link to={`/projects/${p.id}/overview`} className={LINK_CLS}><b>{p.name}</b></Link>
|
||||
<div className={MUTED}>{p.aspect_ratio} · {p.resolution} · {p.fps}fps
|
||||
{p.genre ? ` · ${p.genre}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td className={NOWRAP}><Status value={p.status} /></td>
|
||||
<td className={cellWrap}>{stageNote(p)}</td>
|
||||
<td className={cn(cellRight, NOWRAP)}>{p.stats?.shots || 0}
|
||||
<span className={MUTED}> / 合格 {p.stats?.shots_approved || 0}</span>
|
||||
</td>
|
||||
<td className={cn(cellRight, NOWRAP, 'min-w-[96px]')}>
|
||||
<ProgressBar className="mb-[3px] w-full" value={Math.round((p.stats?.progress_ratio || 0) * 100)} />
|
||||
<small className={MUTED}>{pct(p.stats?.progress_ratio)}</small>
|
||||
</td>
|
||||
<td className={cn(cellRight, NOWRAP, MONO)}>{(p.stats?.planned_duration || 0).toFixed(0)}s</td>
|
||||
<td className={cn(cellRight, NOWRAP, MONO)}>{fmtMoney(p.stats?.cost?.total_cost)}</td>
|
||||
<td className={cn(cellRight, NOWRAP)}>
|
||||
<Row className="justify-end">
|
||||
<Link to={`/projects/${p.id}/overview`} className={LINK_CLS}>进入 →</Link>
|
||||
<Button variant="del" title="删除这个项目" onClick={() => void removeProject(p)}>删除</Button>
|
||||
</Row>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</Table>
|
||||
</TableBox>
|
||||
|
||||
{/* 窄屏换成卡片:940px 的表在手机上只能横向拖,进度和成本永远看不见 */}
|
||||
<div className="hidden min-w-0 gap-[9px] max-narrow:grid">
|
||||
{filtered.map((p) => <ProjectCard key={`card-${p.id}`} p={p} onRemove={removeProject} />)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</Panel>
|
||||
|
||||
<Grid cols={2} gap={16} oneAt="mid2">
|
||||
<Panel>
|
||||
<PanelHead eyebrow="STAGE FLOW" title={
|
||||
<span title="平台按 12 个节点推进:创建项目 → 导入分镜 → 绑定资产 → 生成任务清单 → 检查素材 → 队列调度 → 调用模型 → 保存产物 → 质量检查 → 人工审核 → 时间线合成 → 导出成片。被驳回的镜头会回到「修改提示词 → 重新生成」。">
|
||||
流程节点
|
||||
</span>
|
||||
} />
|
||||
<Divider className="mt-0" />
|
||||
<SectionTitle className="mt-0">示例项目流程
|
||||
<Value>{filtered[0]?.name || '暂无项目'}</Value>
|
||||
</SectionTitle>
|
||||
{filtered[0]?.workflow
|
||||
? <WorkflowBar workflow={filtered[0].workflow} compact />
|
||||
: <Empty className="py-4 text-caption">创建项目后可在这里看到实时节点进度。</Empty>}
|
||||
</Panel>
|
||||
|
||||
<Panel>
|
||||
<PanelHead eyebrow="EVENTS" title="全局动态" />
|
||||
<ChipBar>
|
||||
{EVENT_LEVELS.map((lv) => (
|
||||
<Chip key={lv.value || 'all'} active={eventLevel === lv.value} onClick={() => setEventLevel(lv.value)}>
|
||||
{lv.label}
|
||||
{lv.value && levelCounts[lv.value]
|
||||
? <em className="text-accent not-italic"> {levelCounts[lv.value]}</em> : null}
|
||||
</Chip>
|
||||
))}
|
||||
<Field label="搜索" width="grow" className="max-w-[260px]">
|
||||
<input value={eventKeyword} aria-label="搜索事件" placeholder="事件内容 / 动作"
|
||||
onChange={(e) => setEventKeyword(e.target.value)} />
|
||||
</Field>
|
||||
</ChipBar>
|
||||
<LogBox>
|
||||
{shownEvents.map((e: any) => (
|
||||
<LogRow key={e.id} level={eventLevelKey(e.level)}
|
||||
time={<span title={fmtTime(e.created_at)}>{fmtAgo(e.created_at)}</span>}
|
||||
who={<span className={MONO} title={e.action}>{eventLabel(e.action)}</span>}>
|
||||
{e.message}
|
||||
{e.project_id ? <span className={MUTED}> · 项目#{e.project_id}</span> : null}
|
||||
</LogRow>
|
||||
))}
|
||||
{!events.length && <div className={cn(MUTED, 'p-[8px_2px]')}>暂无事件</div>}
|
||||
{!!events.length && !shownEvents.length && (
|
||||
<div className={cn(MUTED, 'flex flex-wrap items-center gap-[9px] p-[8px_2px]')}>
|
||||
当前筛选条件下没有事件。
|
||||
<Button variant="outline" size="sm" onClick={() => { setEventLevel(''); setEventKeyword('') }}>清除筛选</Button>
|
||||
</div>
|
||||
)}
|
||||
</LogBox>
|
||||
</Panel>
|
||||
</Grid>
|
||||
</TabStack>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建项目时直接勾选要引入的资源库母版。
|
||||
*
|
||||
* 资源库里的人物定妆图 / 场景母图 / 角色声线是跨项目复用的,但以前必须先建项目、
|
||||
* 再跳到资源库页面逐条「引入到项目」,新项目的第一镜总是零素材起步。
|
||||
* 这里勾好后随创建请求一起提交(platform_assets),后端逐条引入并回报失败原因。
|
||||
*/
|
||||
function LibraryPicker({ open, type, onType, query, onQuery, rows, loading, error,
|
||||
picked, pickedByType, onToggle, onPick, onRefresh }: {
|
||||
open: boolean
|
||||
type: LibType
|
||||
onType: (kind: LibType) => void
|
||||
query: string
|
||||
onQuery: (next: string) => void
|
||||
rows: any[]
|
||||
loading: boolean
|
||||
error: string
|
||||
picked: Record<string, any>
|
||||
pickedByType: Record<string, any[]>
|
||||
onToggle: () => void
|
||||
onPick: (row: any) => void
|
||||
onRefresh: () => void
|
||||
}) {
|
||||
const pickedRows = Object.values(picked)
|
||||
const empty = !rows.length
|
||||
return (
|
||||
<div className="mb-3 mt-[2px] min-w-0">
|
||||
<Row className="gap-[10px]">
|
||||
<Button variant="add" type="button" onClick={onToggle}
|
||||
title="可选:把资源库里现成的人物定妆图、场景母图、角色声线直接带进新项目。引入的是母版当前版本的副本:人物会连带默认声线与定妆图,场景带母图,声线带音色样本;之后资源库里升级版本不会自动改写项目内的资产。">
|
||||
{open ? '收起资源库'
|
||||
: (pickedRows.length ? `已选 ${pickedRows.length} 个资源` : '+ 从资源库引入人物 / 场景 / 声线')}
|
||||
</Button>
|
||||
{pickedRows.length > 0 && <Tag tone="ok">创建时自动引入 {pickedRows.length} 个母版</Tag>}
|
||||
</Row>
|
||||
|
||||
{open && (
|
||||
<div className="mt-[10px] rounded-[10px] border border-emphasis bg-panel p-3">
|
||||
<div className="mb-[10px] flex min-w-0 flex-wrap items-center gap-2">
|
||||
{LIB_TYPES.map((t) => (
|
||||
<Chip key={t.value} active={type === t.value} onClick={() => onType(t.value)}>
|
||||
{t.label}
|
||||
{pickedByType[t.value]?.length
|
||||
? <em className="text-accent not-italic"> {pickedByType[t.value].length}</em> : null}
|
||||
</Chip>
|
||||
))}
|
||||
<Field label="搜索" width="grow" className="max-w-[260px]">
|
||||
<input value={query} placeholder="名称 / 编号 / 标签"
|
||||
onChange={(e) => onQuery(e.target.value)} />
|
||||
</Field>
|
||||
<Button variant="outline" size="sm" disabled={loading} onClick={onRefresh}>刷新</Button>
|
||||
</div>
|
||||
|
||||
<ErrorText>{error}</ErrorText>
|
||||
{!error && loading && empty && <div className={cn(MUTED, 'px-0.5 py-[14px]')}>正在读取资源库…</div>}
|
||||
{!error && !loading && empty && (
|
||||
<div className={cn(MUTED, 'px-0.5 py-[14px] leading-[1.6]')}>
|
||||
资源库里还没有{LIB_TYPES.find((t) => t.value === type)?.label}母版。可以先建项目,之后到「资源库」页面引入。
|
||||
</div>
|
||||
)}
|
||||
{!empty && (
|
||||
<div className="grid max-h-[268px] min-w-0 grid-cols-[repeat(auto-fill,minmax(212px,1fr))] gap-2 overflow-auto pr-0.5 scrollbar-slim">
|
||||
{rows.map((row) => (
|
||||
<LibCard key={libKey(row)} row={row} on={!!picked[libKey(row)]} onToggle={() => onPick(row)} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{pickedRows.length > 0 && (
|
||||
<div className="mt-[10px] flex min-w-0 flex-wrap items-center gap-[6px]">
|
||||
<Eyebrow className="mr-[2px]">将引入</Eyebrow>
|
||||
{pickedRows.map((row: any) => (
|
||||
<TagChip key={`p${row.owner_type}${row.asset_id}`}
|
||||
removeTitle={`不再引入 ${row.name}`}
|
||||
onRemove={() => onPick(row)}>
|
||||
{row.type_label}·{row.name}
|
||||
</TagChip>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 资源库母版卡片:缩略图 + 名称 + 摘要,勾中后整圈描边(只有一个下拉框时谁也看不见自己选了啥) */
|
||||
function LibCard({ row, on, onToggle }: { row: any; on: boolean; onToggle: () => void }) {
|
||||
const cover = coverOf(row)
|
||||
return (
|
||||
<button type="button" onClick={onToggle}
|
||||
className={cn('flex min-w-0 cursor-pointer items-center gap-[9px] rounded-tile border bg-card '
|
||||
+ 'p-2 text-left text-ink',
|
||||
on ? 'border-accent shadow-[inset_0_0_0_1px_var(--c-accent)]' : 'border-line hover:border-line-strong')}>
|
||||
<span className="grid h-10 w-[52px] flex-none place-items-center overflow-hidden rounded-[6px] bg-emphasis">
|
||||
{cover ? <MediaThumb item={fromAsset(cover)} size="xs" width="52px" radius={6} />
|
||||
: <b className="text-muted text-[17px]">{audioOfRow(row) ? '♪' : '◻'}</b>}
|
||||
</span>
|
||||
<span className="grid min-w-0 flex-1 gap-px">
|
||||
<b className="block truncate text-[12px]">{row.name}</b>
|
||||
<small className={cn(MUTED, 'block truncate text-tiny')}>{subLabel(row) || row.type_label}</small>
|
||||
<small className={cn(MUTED, 'block truncate text-tiny')}>
|
||||
{(row.assets || []).length} 个素材
|
||||
{row.usage_count ? ` · 已用于 ${row.usage_count} 个项目` : ''}
|
||||
</small>
|
||||
</span>
|
||||
<span className="w-[18px] flex-none text-accent font-bold">{on ? '✓' : ''}</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/** 窄屏项目卡:表格里那些列,在手机上换成一张卡逐项列出 */
|
||||
function ProjectCard({ p, onRemove }: { p: any; onRemove: (p: any) => void }) {
|
||||
return (
|
||||
<article className="min-w-0 rounded-[10px] border border-emphasis bg-card p-3">
|
||||
<div className="mb-[5px] flex min-w-0 flex-wrap items-start justify-between gap-2">
|
||||
{p.cover_url && <MediaThumb src={p.cover_url} size="xs" width="56px" radius={6} title={`${p.name} 首帧`} />}
|
||||
<Link to={`/projects/${p.id}/overview`} className={cn(LINK_CLS, 'min-w-0 flex-1 text-ink')}>
|
||||
<b>{p.name}</b>
|
||||
</Link>
|
||||
<Status value={p.status} />
|
||||
</div>
|
||||
<div className={MUTED}>{p.aspect_ratio} · {p.resolution} · {p.fps}fps{p.genre ? ` · ${p.genre}` : ''}</div>
|
||||
|
||||
<div className="my-[10px] flex min-w-0 items-baseline justify-between gap-[10px]">
|
||||
<span className="flex-none text-muted text-tiny">流程节点</span>
|
||||
<b className="text-right text-ink-2 text-caption">{stageNote(p)}</b>
|
||||
</div>
|
||||
<div className="mb-2 grid min-w-0 grid-cols-2 gap-[5px_12px] text-muted text-tiny [&_b]:text-ink-2">
|
||||
<span>镜头 <b>{p.stats?.shots || 0}</b> / 合格 {p.stats?.shots_approved || 0}</span>
|
||||
<span>时长 <b>{(p.stats?.planned_duration || 0).toFixed(0)}s</b></span>
|
||||
<span>进度 <b>{pct(p.stats?.progress_ratio)}</b></span>
|
||||
<span>成本 <b>{fmtMoney(p.stats?.cost?.total_cost)}</b></span>
|
||||
</div>
|
||||
<ProgressBar className="w-full" value={Math.round((p.stats?.progress_ratio || 0) * 100)} />
|
||||
|
||||
<div className="mt-[10px] flex min-w-0 flex-wrap items-center gap-[10px] [--ctl-h:var(--ctl-h-md)]">
|
||||
<Link to={`/projects/${p.id}/overview`}
|
||||
className={buttonCls({ variant: 'outline', size: 'sm', className: 'no-underline' })}>进入项目 →</Link>
|
||||
<Button variant="del" title="删除这个项目" onClick={() => onRemove(p)}>删除</Button>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue