1881 lines
105 KiB
Vue
1881 lines
105 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||
import * as api from '../api'
|
||
import { fmtAgo, fmtBytes, opt, statusLabel } from '../format'
|
||
import { fromAsset, isAudio as audioOf, isImage as imageOf, type MediaItem } from '../media'
|
||
import MediaThumb from '../components/MediaThumb.vue'
|
||
import AudioPlay from '../components/AudioPlay.vue'
|
||
import AutoRefresh from '../components/AutoRefresh.vue'
|
||
import {
|
||
capsOfRef, defaultFor, imageAspectChoices, imageCanvas, imageTiers, isMock,
|
||
loadModels, modelsOf, parseRef, refOf, registry, type Caps, type ModelRow,
|
||
} from '../models'
|
||
import FMultiSelect from '../components/FMultiSelect.vue'
|
||
import RecordAudio from '../components/RecordAudio.vue'
|
||
import { recordingBusy } from '../recordingGuard'
|
||
import { defaultAssetName, existingNames, keepOrRestoreCurrent } from '../versions'
|
||
import FSelect from '../components/FSelect.vue'
|
||
|
||
type AssetType = 'human' | 'scene' | 'voice'
|
||
|
||
const type = ref<AssetType>('human')
|
||
const rows = ref<any[]>([])
|
||
const projects = ref<any[]>([])
|
||
|
||
/** 「引入到哪个项目」下拉里的副标题:已经收尾的项目不再报「导出完整视频」 */
|
||
const projectHint = (p: any) =>
|
||
p?.status === 'delivered' || p?.status === 'archived'
|
||
? statusLabel(p.status)
|
||
: p?.stage_label || '准备中'
|
||
const voices = ref<any[]>([])
|
||
const importAsset = ref<any | null>(null)
|
||
const importProjectId = ref<number | null>(null)
|
||
const error = ref('')
|
||
const notice = ref('')
|
||
const busy = ref('')
|
||
const drawer = ref(false)
|
||
const confirmDelete = ref<any | null>(null)
|
||
const editingId = ref<number | null>(null)
|
||
const form = reactive<any>({})
|
||
const uploadKinds = reactive<Record<string, string>>({})
|
||
const generation = reactive<Record<string, any>>({})
|
||
|
||
/* ── AS-2:工具栏状态。所有维度都由后端过滤,前端只负责拼参数与回显 ─────
|
||
AS-1:AI 生成表单从每张卡片里挪进右侧抽屉,卡片列表不再被 600px 表单撑爆 */
|
||
const filters = reactive({
|
||
q: '', tag: '', kind: '', has_media: '', status: '',
|
||
duplicate_only: false, sort: 'updated', page_size: 60, page: 1,
|
||
})
|
||
const view = ref<'grid' | 'list' | 'media'>('grid')
|
||
const wall = reactive<any>({ items: [], stats: {}, kinds: [], total: 0, page: 1, pages: 1, multi_only: false, sort: 'created' })
|
||
const selected = ref<Set<string>>(new Set())
|
||
const selectedMedia = ref<Set<number>>(new Set())
|
||
const lastIndex = ref(-1)
|
||
const lastMediaIndex = ref(-1)
|
||
const batchDialog = ref<'' | 'tag' | 'delete' | 'media-delete'>('')
|
||
const batchTags = reactive({ add: '', remove: '' })
|
||
const genTarget = ref<any | null>(null)
|
||
const genDrawer = ref(false)
|
||
|
||
/** 只承载概览统计:列表一次拉全量,页面内不再维护分页 / 筛选 / 多选状态 */
|
||
const summary = reactive<any>({ stats: { by_owner: {}, media_by_owner: {} }, filtered: 0, page: 1, pages: 1 })
|
||
const meta = reactive<any>({ tags: [], sorts: [], duplicates: [] })
|
||
const typeMeta: Record<AssetType, any> = {
|
||
human: { label: '人物', icon: '☺', eyebrow: 'CASTING WALL', hint: '定妆、造型与角色一致性' },
|
||
scene: { label: '场景', icon: '▧', eyebrow: 'LOCATION BIBLE', hint: '空间、光线与美术基调' },
|
||
voice: { label: '声线', icon: '◉', eyebrow: 'VOICE ARCHIVE', hint: '音色样本与方言 / 情绪参数' },
|
||
}
|
||
const uploadKindOptions: Record<AssetType, string[]> = {
|
||
human: ['portrait', 'turnaround', 'costume', 'expression', 'reference'],
|
||
scene: ['scene_image', 'reference'],
|
||
voice: ['voice_sample', 'reference'],
|
||
}
|
||
/** 生成模型只认注册表:mock 演练通道不进选择列表,报错直接显示在生成区 */
|
||
const imageModels = computed<ModelRow[]>(() => modelsOf('image', false))
|
||
const ttsModels = computed<ModelRow[]>(() => modelsOf('tts', false))
|
||
function genModels(): ModelRow[] {
|
||
return type.value === 'voice' ? ttsModels.value : imageModels.value
|
||
}
|
||
const totals = computed(() => {
|
||
const stats = summary.stats || {}
|
||
const byOwner = stats.by_owner || {}
|
||
return {
|
||
human: Number(byOwner.human || 0), scene: Number(byOwner.scene || 0), voice: Number(byOwner.voice || 0),
|
||
media: Number(stats.media_count || 0),
|
||
}
|
||
})
|
||
/** AS-7:指标卡改成能点的统计入口,数据全部来自后端 stats */
|
||
const mediaStats = computed<any>(() => summary.stats || {})
|
||
const tagOptions = computed<any[]>(() => meta.tags || [])
|
||
const sortOptions = computed<any[]>(() => meta.sorts?.length
|
||
? meta.sorts
|
||
: [{ value: 'updated', label: '按更新时间' }, { value: 'created', label: '按创建时间' },
|
||
{ value: 'name', label: '按名称' }, { value: 'media', label: '按素材数量' },
|
||
{ value: 'size', label: '按素材体积' }, { value: 'usage', label: '按被引用项目数' }])
|
||
const wallSortOptions = [
|
||
{ value: 'created', label: '按上传时间' }, { value: 'size', label: '按文件体积' },
|
||
{ value: 'name', label: '按名称' }, { value: 'version', label: '按版本数' },
|
||
]
|
||
/**
|
||
* 「素材类型」选项:只列**当前大分类**该有的类型。
|
||
*
|
||
* 之前直接用全库 by_kind,于是在「人物」下能筛「音色样本 / 场景图」——选了永远 0 条。
|
||
* 数据源分两种视角:素材墙用墙自己的 by_kind(后端已按 owner_type 过滤),
|
||
* 母版视角用 stats.by_kind_by_owner[type];两者都拿不到的空分类,退回该分类的
|
||
* 登记类型清单(uploadKindOptions),保证下拉不为空且仍属于这个大分类。
|
||
*/
|
||
const kindOptions = computed<{ value: string; label: string; count: number }[]>(() => {
|
||
const scoped: Record<string, number> = view.value === 'media'
|
||
? (wall.stats?.by_kind || {})
|
||
: ((mediaStats.value.by_kind_by_owner || {})[type.value] || {})
|
||
const seen = view.value === 'media'
|
||
? (wall.kinds || []).map((k: any) => String(k.value))
|
||
: Object.keys(scoped)
|
||
const canonical = uploadKindOptions[type.value] || []
|
||
const keys = [...new Set([...canonical, ...seen])]
|
||
.filter((key) => Number(scoped[key] || 0) > 0 || seen.includes(key))
|
||
if (!keys.length) {
|
||
return canonical.map((key) => ({ value: key, label: opt('asset_kinds', key), count: 0 }))
|
||
}
|
||
return keys
|
||
.map((key) => ({ value: key, label: opt('asset_kinds', key), count: Number(scoped[key] || 0) }))
|
||
.sort((a, b) => b.count - a.count
|
||
|| (canonical.indexOf(a.value) - canonical.indexOf(b.value))
|
||
|| a.label.localeCompare(b.label, 'zh-CN'))
|
||
})
|
||
/** 切大分类后原来选中的类型可能已经不属于这个分类 → 自动清掉,避免「0 条结果」的假象 */
|
||
function dropIncompatibleKind() {
|
||
if (!filters.kind) return
|
||
if (kindOptions.value.some((entry) => entry.value === filters.kind)) return
|
||
filters.kind = ''
|
||
}
|
||
/** 有弹窗 / 抽屉 / 批量确认挡在页面上时暂停自动刷新,避免列表在用户手下换人 */
|
||
const modalOpen = computed(() => drawer.value || genDrawer.value || !!confirmDelete.value
|
||
|| !!importAsset.value || !!batchDialog.value)
|
||
|
||
const filtersActive = computed(() => Boolean(
|
||
filters.q.trim() || filters.tag || filters.kind || filters.has_media || filters.status
|
||
|| filters.duplicate_only || filters.page > 1,
|
||
))
|
||
const resultCount = computed(() => Number(summary.filtered ?? rows.value.length))
|
||
const selectedImportProject = computed(
|
||
() => projects.value.find((p) => p.id === importProjectId.value) || null,
|
||
)
|
||
/** 卡片缩略与预览队列:统一走 media.ts 归一化,不再各页面自己拼 <img> */
|
||
/** 卡片/列表里的图片条:列表视图只露前 N 张,其余到预览器里翻 */
|
||
function stripOf(row: any, limit = 99) {
|
||
return (row.assets || []).filter((item: any) => !isAudio(item)).slice(0, limit)
|
||
}
|
||
|
||
function itemsOf(row: any): MediaItem[] {
|
||
return (row?.assets || []).map((media: any) => fromAsset(media)).filter(Boolean) as MediaItem[]
|
||
}
|
||
/** MediaThumb 的 ←/→ 队列需要 item 在队列里的下标,统一用归一化后的 key 对齐 */
|
||
function mediaIndex(row: any, media: any): number {
|
||
const key = fromAsset(media)?.key
|
||
const at = itemsOf(row).findIndex((item) => item.key === key)
|
||
return at < 0 ? 0 : at
|
||
}
|
||
|
||
function latestImage(row: any, kinds: string[] = []) {
|
||
return [...(row.assets || [])]
|
||
.filter((asset) => isImage(asset) && (!kinds.length || kinds.includes(asset.kind)))
|
||
.sort((a, b) => Number(b.id) - Number(a.id))[0] || null
|
||
}
|
||
|
||
function blank(kind = type.value) {
|
||
return {
|
||
type: kind, name: '', code: '', role: '主角', appearance: '', personality: '',
|
||
persona_prompt: '', voice_profile: '', default_voice_id: null, style_version: 'v1',
|
||
tags: '', notes: '', is_active: true, description: '', prompt: '', lighting: '',
|
||
time_of_day: '', palette: '', provider: '',
|
||
provider_voice_id: '', language: 'zh-CN', gender: '', version: 'v1',
|
||
is_default: false, tuning: {} as Record<string, any>, tuning_speed: 1, tuning_effect: '',
|
||
}
|
||
}
|
||
|
||
function splitTags(value: string) {
|
||
return String(value || '').split(/[,,\s]+/).map((item) => item.trim()).filter(Boolean)
|
||
}
|
||
|
||
/** 把工具栏映射成查询参数:空值不发送,便于命中后端「不过滤」分支 */
|
||
function assetParams() {
|
||
const params: Record<string, any> = {
|
||
owner_type: type.value, sort: filters.sort, page: filters.page, page_size: filters.page_size,
|
||
}
|
||
const needle = filters.q.trim()
|
||
if (needle) params.q = needle
|
||
if (filters.tag) params.tag = filters.tag
|
||
if (filters.kind) params.kind = filters.kind
|
||
if (filters.has_media) params.has_media = filters.has_media
|
||
if (filters.status) params.status = filters.status
|
||
if (filters.duplicate_only) params.duplicate_only = true
|
||
return params
|
||
}
|
||
|
||
function wallParams() {
|
||
const params: Record<string, any> = {
|
||
owner_type: type.value, sort: wall.sort, page: wall.page, page_size: filters.page_size || 120,
|
||
}
|
||
const needle = filters.q.trim()
|
||
if (needle) params.q = needle
|
||
if (filters.kind) params.kind = filters.kind
|
||
if (wall.multi_only) params.multi_version_only = true
|
||
return params
|
||
}
|
||
|
||
async function load() {
|
||
error.value = ''
|
||
// 模型注册表不参与首屏:列表拿到就能渲染,生成抽屉里的模型下拉是 computed,
|
||
// 注册表回来后自己会填上(未回来时显示「模型注册表读取中…」)。
|
||
// 以前它和素材列表一起 await,而 /api/providers 是全站最慢的接口,
|
||
// 白屏时间全被它一个人占走。
|
||
loadModels().catch(() => {})
|
||
try {
|
||
const [library, projectList] = await Promise.all([
|
||
api.get('/api/platform/assets', assetParams()),
|
||
api.get('/api/projects', { brief: 1 }),
|
||
])
|
||
rows.value = library.items || []
|
||
voices.value = library.voice || (rows.value.filter((row: any) => row.owner_type === 'voice'))
|
||
if (type.value === 'human' && !voices.value.length) {
|
||
// 人物母版要绑默认声线,声线列表得是全库的,不能受当前筛选影响
|
||
api.get('/api/platform/assets', { owner_type: 'voice', page_size: 0 })
|
||
.then((extra: any) => { voices.value = extra.voice || [] })
|
||
.catch(() => {})
|
||
}
|
||
projects.value = projectList.projects || []
|
||
summary.stats = library.stats || {}
|
||
summary.filtered = library.filtered ?? rows.value.length
|
||
summary.pages = library.pages ?? 1
|
||
summary.page = library.page ?? 1
|
||
meta.tags = library.tags || []
|
||
meta.sorts = library.sorts || []
|
||
meta.duplicates = library.duplicates || []
|
||
// 生成抽屉里的母版在刷新后可能换了对象,重新指认一次,避免表单写进野对象
|
||
if (genTarget.value) {
|
||
genTarget.value = rows.value.find((row) => row.id === genTarget.value.id) || genTarget.value
|
||
}
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
}
|
||
}
|
||
|
||
/** AS-3:跨母版素材墙,找一张图不必先猜它挂在哪个角色下 */
|
||
async function loadWall() {
|
||
error.value = ''
|
||
try {
|
||
const data = await api.get('/api/platform/media', wallParams())
|
||
wall.items = data.items || []
|
||
wall.stats = data.stats || {}
|
||
wall.kinds = data.kinds || []
|
||
wall.total = data.total || 0
|
||
wall.pages = data.pages || 1
|
||
wall.page = data.page || 1
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
}
|
||
}
|
||
|
||
function reload() {
|
||
return view.value === 'media' ? loadWall() : load()
|
||
}
|
||
/** 一次交互里可能同时改 page 和其它条件,合并成一次请求 */
|
||
let coalesce: ReturnType<typeof setTimeout> | undefined
|
||
function reloadSoon() {
|
||
clearTimeout(coalesce)
|
||
coalesce = setTimeout(reload, 30)
|
||
}
|
||
|
||
let searchTimer: ReturnType<typeof setTimeout> | undefined
|
||
watch(() => filters.q, () => {
|
||
clearTimeout(searchTimer)
|
||
searchTimer = setTimeout(() => { filters.page = 1; wall.page = 1; reloadSoon() }, 320)
|
||
})
|
||
watch([() => filters.tag, () => filters.kind, () => filters.has_media, () => filters.status,
|
||
() => filters.duplicate_only, () => filters.sort, () => filters.page_size,
|
||
() => wall.sort, () => wall.multi_only],
|
||
() => { filters.page = 1; wall.page = 1; reloadSoon() })
|
||
watch([() => filters.page, () => wall.page], () => reloadSoon())
|
||
|
||
watch(() => type.value, () => {
|
||
filters.page = 1
|
||
wall.page = 1
|
||
dropIncompatibleKind()
|
||
clearSelection()
|
||
reloadSoon()
|
||
})
|
||
watch(view, () => { clearSelection(); reloadSoon() })
|
||
|
||
/* ── AS-10:多选与批量。Shift 范围选择 + 全选当前筛选结果 ──────────── */
|
||
function keyOf(row: any) { return `${row.owner_type || type.value}:${row.id}` }
|
||
function isSelected(row: any) { return selected.value.has(keyOf(row)) }
|
||
function toggleSelect(row: any, index: number, shift = false) {
|
||
const next = new Set(selected.value)
|
||
if (shift && lastIndex.value >= 0) {
|
||
const [from, to] = [Math.min(lastIndex.value, index), Math.max(lastIndex.value, index)]
|
||
const adding = !next.has(keyOf(row))
|
||
for (let i = from; i <= to; i += 1) {
|
||
const key = keyOf(rows.value[i])
|
||
if (adding) next.add(key); else next.delete(key)
|
||
}
|
||
} else if (next.has(keyOf(row))) next.delete(keyOf(row))
|
||
else next.add(keyOf(row))
|
||
selected.value = next
|
||
lastIndex.value = index
|
||
}
|
||
function selectAllFiltered() {
|
||
const next = new Set(selected.value)
|
||
const full = rows.value.every((row) => next.has(keyOf(row)))
|
||
rows.value.forEach((row) => { if (full) next.delete(keyOf(row)); else next.add(keyOf(row)) })
|
||
selected.value = next
|
||
}
|
||
function clearSelection() {
|
||
selected.value = new Set()
|
||
selectedMedia.value = new Set()
|
||
lastIndex.value = -1
|
||
}
|
||
const selectedRows = computed(() => rows.value.filter((row) => selected.value.has(keyOf(row))))
|
||
const selectedCount = computed(() => selected.value.size)
|
||
const allSelected = computed(() => rows.value.length > 0
|
||
&& rows.value.every((row) => selected.value.has(keyOf(row))))
|
||
const selectionRefs = () => selectedRows.value.map((row) => ({ owner_type: row.owner_type || type.value, asset_id: row.id }))
|
||
/** 批量条上的影响面摘要:勾选后要先看清「素材量 / 谁在引用」再动手 */
|
||
const selectedSummary = computed(() => {
|
||
const list = selectedRows.value
|
||
if (!list.length) return ''
|
||
const media = list.reduce((sum, row) => sum + Number(row.media_count || 0), 0)
|
||
const bytes = list.reduce((sum, row) => sum + Number(row.media_bytes || 0), 0)
|
||
const used = list.filter((row) => Number(row.usage_count || 0) > 0).length
|
||
return `共 ${media} 个素材 · ${fmtBytes(bytes)}`
|
||
+ (used ? `;${used} 个已被项目引用,删除母版不影响项目内的快照副本` : ';均未被项目引用')
|
||
})
|
||
/** 素材墙与预览队列一一对齐(下标即墙上的位置),←/→ 才能顺着墙翻 */
|
||
const wallQueue = computed<(MediaItem | null)[]>(() => wall.items.map((media: any) => fromAsset(media)))
|
||
const selectedMediaRows = computed<any[]>(() => wall.items.filter((media: any) => selectedMedia.value.has(media.id)))
|
||
function toggleMedia(media: any, index: number, event: MouseEvent) {
|
||
const on = (event.target as HTMLInputElement).checked
|
||
const next = new Set(selectedMedia.value)
|
||
if (event.shiftKey && lastMediaIndex.value >= 0) {
|
||
const [from, to] = [Math.min(lastMediaIndex.value, index), Math.max(lastMediaIndex.value, index)]
|
||
for (let i = from; i <= to; i += 1) {
|
||
const id = wall.items[i]?.id
|
||
if (id) { if (on) next.add(id); else next.delete(id) }
|
||
}
|
||
} else if (on) next.add(media.id)
|
||
else next.delete(media.id)
|
||
selectedMedia.value = next
|
||
lastMediaIndex.value = index
|
||
}
|
||
|
||
/* ── AS-9:筛选无结果与真空态分开处理 ─────────────────────────────── */
|
||
function clearFilters() {
|
||
filters.q = ''
|
||
filters.tag = ''
|
||
filters.kind = ''
|
||
filters.has_media = ''
|
||
filters.status = ''
|
||
filters.duplicate_only = false
|
||
filters.page = 1
|
||
wall.page = 1
|
||
wall.multi_only = false
|
||
reload()
|
||
}
|
||
function focusMasters() { view.value = 'grid'; clearFilters() }
|
||
function focusWall() { view.value = 'media'; wall.page = 1; loadWall() }
|
||
function focusWithout() { view.value = 'grid'; filters.has_media = 'without'; filters.page = 1; load() }
|
||
function focusDuplicates() { view.value = 'grid'; filters.duplicate_only = true; filters.page = 1; load() }
|
||
|
||
function openCreate() {
|
||
editingId.value = null
|
||
Object.assign(form, blank())
|
||
drawer.value = true
|
||
notice.value = ''
|
||
}
|
||
|
||
function openEdit(kind: AssetType, row: any) {
|
||
type.value = kind
|
||
editingId.value = row.id
|
||
Object.assign(form, blank(kind), row, {
|
||
tags: (row.tags || []).join(' '),
|
||
tuning: { ...(row.tuning || {}) },
|
||
tuning_speed: Number(row.tuning?.speed || 1),
|
||
tuning_effect: (row.tuning?.params && row.tuning.params.effect) || '',
|
||
})
|
||
drawer.value = true
|
||
notice.value = ''
|
||
}
|
||
|
||
function payload() {
|
||
const common = { name: form.name.trim(), code: form.code.trim(), tags: splitTags(form.tags) }
|
||
if (form.type === 'human') {
|
||
return {
|
||
...common, role: form.role, appearance: form.appearance, personality: form.personality,
|
||
persona_prompt: form.persona_prompt, voice_profile: form.voice_profile,
|
||
default_voice_id: form.default_voice_id || null, style_version: form.style_version,
|
||
notes: form.notes, is_active: form.is_active,
|
||
}
|
||
}
|
||
if (form.type === 'scene') {
|
||
return {
|
||
...common, description: form.description, prompt: form.prompt, lighting: form.lighting,
|
||
time_of_day: form.time_of_day, palette: form.palette,
|
||
}
|
||
}
|
||
// tuning 是整字典覆盖:先保留后端已有键(如 sample_rate),再改界面能控制的两项
|
||
const base = { ...(form.tuning && typeof form.tuning === 'object' ? form.tuning : {}) }
|
||
const params = { ...((base.params as Record<string, any>) || {}) }
|
||
if (form.tuning_effect) params.effect = form.tuning_effect
|
||
else delete params.effect
|
||
return {
|
||
...common, provider: form.provider, provider_voice_id: form.provider_voice_id,
|
||
language: form.language, gender: form.gender, description: form.description,
|
||
version: form.version, is_active: form.is_active, is_default: !!form.is_default,
|
||
tuning: { ...base, speed: Number(form.tuning_speed) || 1, params },
|
||
}
|
||
}
|
||
|
||
async function save() {
|
||
if (!form.name.trim()) {
|
||
error.value = '名称不能为空'
|
||
return
|
||
}
|
||
const path = form.type === 'human' ? 'characters' : form.type === 'scene' ? 'scenes' : 'voices'
|
||
busy.value = editingId.value ? '保存平台资产' : '创建平台资产'
|
||
error.value = ''
|
||
try {
|
||
if (editingId.value) await api.patch(`/api/platform/${path}/${editingId.value}`, payload())
|
||
else await api.post(`/api/platform/${path}`, payload())
|
||
drawer.value = false
|
||
notice.value = `${typeMeta[form.type as AssetType].label}「${form.name}」已保存`
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
/** 删除前把「谁在引用这个母版」摊开:项目里已引入的副本不会被改动,但要让用户知道影响面 */
|
||
function askDelete(row: any) {
|
||
confirmDelete.value = row
|
||
}
|
||
async function runDelete() {
|
||
const target = confirmDelete.value
|
||
if (!target) return
|
||
if (selected.value.has(keyOf(target)) && selectedCount.value > 1) {
|
||
await runBatchDelete()
|
||
return
|
||
}
|
||
busy.value = '删除母版'
|
||
error.value = ''
|
||
try {
|
||
await api.del(`/api/platform/${target.owner_type || type.value}/${target.id}`)
|
||
notice.value = `「${target.name}」已删除,项目内的历史引入副本不受影响`
|
||
confirmDelete.value = null
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
function uploadKey(row: any) {
|
||
const key = `${type.value}:${row.id}`
|
||
if (!uploadKinds[key]) uploadKinds[key] = uploadKindOptions[type.value][0]
|
||
return key
|
||
}
|
||
|
||
/** 上传/录音的公共出口:拿到 File 就登记为新版本,两种入口的行为必须一模一样 */
|
||
async function uploadFile(row: any, file: File, kind: string, note = '') {
|
||
busy.value = `上传${opt('asset_kinds', kind)}`
|
||
error.value = ''
|
||
try {
|
||
const media: any = await api.upload(
|
||
`/api/platform/${type.value}/${row.id}/media`,
|
||
api.formData({ kind, name: file.name.replace(/\.[^.]+$/, ''), note }, file),
|
||
)
|
||
notice.value = `${file.name} 已登记为新版本`
|
||
await load()
|
||
return media || true // 返回媒体行(含 id/version/versions)供「当前版本」回退
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
return false
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function upload(row: any, event: Event) {
|
||
const input = event.target as HTMLInputElement
|
||
const file = input.files?.[0]
|
||
if (!file) return
|
||
await uploadFile(row, file, uploadKinds[uploadKey(row)])
|
||
input.value = ''
|
||
}
|
||
|
||
/** 录音面板的默认落点:能顺着已有素材追加版本,就别让随手一段试音长出第二条素材 */
|
||
function recordDefaultName(row: any, kind: string) {
|
||
return defaultAssetName(row?.assets, `${row?.name || '素材'} · ${opt('asset_kinds', kind)}`, kind)
|
||
}
|
||
|
||
/** 录完的样本:先登记,再顺手把它选成本次生成的参考,省得用户再去下拉里找 */
|
||
async function recordSample(row: any, file: File,
|
||
meta: { durationMs: number; warning: string; name?: string; setCurrent?: boolean }) {
|
||
const media = await uploadFile(row, file, uploadKinds[uploadKey(row)], '页面录制')
|
||
if (!media) return
|
||
await keepOrRestoreCurrent(media, meta.setCurrent !== false)
|
||
if (meta.warning) notice.value = `已录入库:${meta.warning}`
|
||
}
|
||
|
||
/* 声线的「音色预告」:参考音频才决定音色,所以打开抽屉时先问后端「这次会拿到谁的嗓子」 */
|
||
const voiceRefStatus = ref<any | null>(null)
|
||
const voiceRefBusy = ref(false)
|
||
|
||
async function loadVoiceReferenceStatus(row: any) {
|
||
voiceRefStatus.value = null
|
||
if (type.value !== 'voice') return
|
||
voiceRefBusy.value = true
|
||
try {
|
||
voiceRefStatus.value = await api.get(`/api/platform/voice/${row.id}/reference-status`)
|
||
} catch {
|
||
voiceRefStatus.value = null // 预告拿不到不挡生成,后端仍会在缺参考时明确报错
|
||
} finally {
|
||
voiceRefBusy.value = false
|
||
}
|
||
}
|
||
|
||
function openGenerate(row: any) {
|
||
genTarget.value = row
|
||
genFor(row)
|
||
genDrawer.value = true
|
||
error.value = ''
|
||
void loadVoiceReferenceStatus(row)
|
||
}
|
||
|
||
function genFor(row: any) {
|
||
const key = `${type.value}:${row.id}`
|
||
if (!generation[key]) {
|
||
const currentScene = type.value === 'scene' ? latestImage(row, ['scene_image']) || latestImage(row) : null
|
||
generation[key] = reactive({
|
||
model: '',
|
||
kind: type.value === 'human' ? 'portrait' : type.value === 'scene' ? 'scene_image' : 'voice_sample',
|
||
prompt: '',
|
||
// 试听文本是「模型要念出来的台词」,音色描述不是台词,不能拿它当默认值糊上去
|
||
sample_text: '',
|
||
reference_media_id: null,
|
||
reference_media_ids: currentScene ? [currentScene.id] : [],
|
||
tier: '', aspect: type.value === 'human' ? '3:4' : '16:9',
|
||
})
|
||
}
|
||
return generation[key]
|
||
}
|
||
|
||
/** 注册表可能比首屏晚到,所以模型绑定走「草稿值 || 平台默认」而不是初始化时写死 */
|
||
function modelRef(row: any): string {
|
||
const draft = genFor(row)
|
||
return draft.model || refOf(defaultFor(type.value === 'voice' ? 'tts' : 'image'))
|
||
}
|
||
function onModelSelect(row: any, event: Event) {
|
||
genFor(row).model = String((event.target as HTMLSelectElement).value || '')
|
||
}
|
||
function setDraft(row: any, field: string, value: any) {
|
||
genFor(row)[field] = value
|
||
}
|
||
function specCaps(row: any): Caps {
|
||
return capsOfRef(modelRef(row))
|
||
}
|
||
function tierChoices(row: any) {
|
||
return imageTiers(...parseRef(modelRef(row)))
|
||
}
|
||
function aspectOptions(row: any) {
|
||
return imageAspectChoices(...parseRef(modelRef(row)))
|
||
}
|
||
function draftTier(row: any): string {
|
||
const draft = genFor(row)
|
||
return tierChoices(row).some((t) => t.value === draft.tier)
|
||
? draft.tier : (tierChoices(row)[0]?.value || '')
|
||
}
|
||
function draftAspect(row: any): string {
|
||
const draft = genFor(row)
|
||
return aspectOptions(row).some((a) => a.value === draft.aspect)
|
||
? draft.aspect : (aspectOptions(row)[0]?.value || '16:9')
|
||
}
|
||
function canvasOf(row: any) {
|
||
return imageCanvas(draftTier(row), draftAspect(row))
|
||
}
|
||
|
||
function selectAtmosphereReference(row: any) {
|
||
const draft = genFor(row)
|
||
if (type.value === 'scene' && draft.kind === 'reference' && !draft.reference_media_ids.length) {
|
||
const currentScene = latestImage(row, ['scene_image']) || latestImage(row)
|
||
if (currentScene) draft.reference_media_ids = [currentScene.id]
|
||
}
|
||
}
|
||
|
||
function generationSpec(row: any): ModelRow | null {
|
||
const ref = modelRef(row)
|
||
return registry.rows.find((r) => refOf(r) === ref) || null
|
||
}
|
||
|
||
function pickReferences(row: any, event: Event) {
|
||
const select = event.target as HTMLSelectElement
|
||
const ids = Array.from(select.selectedOptions).map((o) => Number(o.value)).filter(Boolean)
|
||
const max = specCaps(row).maxReferenceImages || 1
|
||
genFor(row).reference_media_ids = ids.slice(0, max)
|
||
}
|
||
|
||
function referenceOptions(row: any) {
|
||
return (row.assets || []).filter(isAudio)
|
||
}
|
||
|
||
function isAudioPath(value: any) {
|
||
return /\.(wav|mp3|m4a|aac|flac|ogg|opus)(?:[?#].*)?$/i.test(String(value || ''))
|
||
}
|
||
|
||
function imageReferenceOptions(row: any) {
|
||
return (row.assets || []).filter(isImage)
|
||
}
|
||
|
||
function voiceHasReference(row: any) {
|
||
const draft = genFor(row)
|
||
const caps = specCaps(row)
|
||
if (!caps.requiresReference || draft.reference_media_id) return true
|
||
// 后端的预告优先于「字段里有个 .wav」这种猜测:绑定指向 AI 试听样本时路径看着能用,
|
||
// 实际不能当克隆参考(否则错音色会自我强化),按钮必须跟后端口径一致。
|
||
if (voiceRefStatus.value) return !!voiceRefStatus.value.ready
|
||
if (isAudioPath(row.provider_voice_id)) return true
|
||
return !!generationSpec(row)?.config?.reference_audio
|
||
}
|
||
|
||
async function uploadReferenceFile(row: any, file: File, note = '') {
|
||
busy.value = '上传参考音色'
|
||
error.value = ''
|
||
try {
|
||
const media: any = await api.upload(
|
||
`/api/platform/voice/${row.id}/media`,
|
||
api.formData({ kind: 'reference', name: file.name.replace(/\.[^.]+$/, ''), note }, file),
|
||
)
|
||
genFor(row).reference_media_id = media?.id || null
|
||
notice.value = `${file.name} 已作为参考音色(当前模型:${generationSpec(row)?.display_name || '未注册'})`
|
||
await Promise.all([load(), loadVoiceReferenceStatus(row)])
|
||
return media || true
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
return false
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function uploadReference(row: any, event: Event) {
|
||
const input = event.target as HTMLInputElement
|
||
const file = input.files?.[0]
|
||
if (!file) return
|
||
await uploadReferenceFile(row, file)
|
||
input.value = ''
|
||
}
|
||
|
||
async function recordReference(row: any, file: File,
|
||
meta: { durationMs: number; warning: string; name?: string; setCurrent?: boolean }) {
|
||
const media = await uploadReferenceFile(row, file, '页面录制')
|
||
if (!media) return
|
||
await keepOrRestoreCurrent(media, meta.setCurrent !== false)
|
||
if (meta.warning) notice.value = `参考音色已录:${meta.warning}`
|
||
}
|
||
|
||
async function uploadImageReference(row: any, event: Event) {
|
||
const input = event.target as HTMLInputElement
|
||
const file = input.files?.[0]
|
||
if (!file) return
|
||
busy.value = '上传参考图'
|
||
error.value = ''
|
||
try {
|
||
const media = await api.upload(
|
||
`/api/platform/${type.value}/${row.id}/media`,
|
||
api.formData({ kind: 'reference', name: file.name.replace(/\.[^.]+$/, '') }, file),
|
||
)
|
||
const draft = genFor(row)
|
||
const max = specCaps(row).maxReferenceImages || 1
|
||
if (media?.id) draft.reference_media_ids = [...new Set([...draft.reference_media_ids, media.id])].slice(0, max)
|
||
notice.value = `${file.name} 已作为生成参考图(最多 ${max} 张)`
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
input.value = ''
|
||
}
|
||
}
|
||
|
||
async function generate(row: any) {
|
||
const draft = genFor(row)
|
||
const spec = generationSpec(row)
|
||
if (!spec) {
|
||
error.value = `尚未启用真实${type.value === 'voice' ? '声音' : '图像'}模型;Mock 模型已从生产选择中隐藏`
|
||
return
|
||
}
|
||
if (isMock(spec)) {
|
||
error.value = 'Mock 模型仅用于内部自检,不能在平台资产库中生成正式素材'
|
||
return
|
||
}
|
||
if (type.value === 'voice' && !String(draft.sample_text || '').trim()) {
|
||
error.value = '请先填写试听文本:它是模型要朗读的台词,「音色描述」是声线设定,不会被念出来'
|
||
return
|
||
}
|
||
if (type.value === 'voice' && specCaps(row).requiresReference && !voiceHasReference(row)) {
|
||
error.value = '该声线模型需要参考音色,请上传参考音频或使用模型默认参考音频'
|
||
return
|
||
}
|
||
const body: any = type.value === 'voice'
|
||
? {
|
||
kind: 'voice_sample', provider: spec.provider, model: spec.model,
|
||
sample_text: draft.sample_text, reference_media_id: draft.reference_media_id || null,
|
||
}
|
||
: {
|
||
kind: draft.kind, provider: spec.provider, model: spec.model, prompt: draft.prompt,
|
||
...canvasOf(row),
|
||
reference_media_ids: draft.reference_media_ids.slice(0, specCaps(row).maxReferenceImages || 1),
|
||
}
|
||
busy.value = `生成${typeMeta[type.value].label}资产`
|
||
error.value = ''
|
||
try {
|
||
const media = await api.post(`/api/platform/${type.value}/${row.id}/generate`, body)
|
||
notice.value = `${row.name} 的${type.value === 'voice' ? '试听样本' : opt('asset_kinds', draft.kind)}`
|
||
+ `已生成(${spec.provider}/${spec.model}${media?.id ? ` · v${media.version}` : ''})`
|
||
await load()
|
||
if (view.value === 'media') await loadWall()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function deleteMedia(media: any) {
|
||
if (!confirm(`确认删除「${media.name || media.kind_label}」这个媒体文件?`)) return
|
||
const wasWall = view.value === 'media'
|
||
busy.value = '删除媒体文件'
|
||
error.value = ''
|
||
try {
|
||
await api.del(`/api/platform/media/${media.id}`)
|
||
notice.value = `「${media.name || media.kind_label}」已删除`
|
||
if (wasWall) await loadWall()
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function runBatchTag() {
|
||
const items = selectionRefs()
|
||
if (!items.length) return
|
||
const add = splitTags(batchTags.add)
|
||
const remove = splitTags(batchTags.remove)
|
||
if (!add.length && !remove.length) {
|
||
error.value = '请填写要添加或移除的标签'
|
||
return
|
||
}
|
||
busy.value = '批量整理标签'
|
||
error.value = ''
|
||
try {
|
||
const result = await api.post('/api/platform/assets/batch-tag', { items, add, remove })
|
||
notice.value = `已为 ${result?.count ?? items.length} 个母版${add.length ? ` 添加「${add.join('、')}」` : ''}${remove.length ? ` 移除「${remove.join('、')}」` : ''}`
|
||
batchTags.add = ''
|
||
batchTags.remove = ''
|
||
batchDialog.value = ''
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function runBatchDelete() {
|
||
const items = selectionRefs()
|
||
if (!items.length) return
|
||
busy.value = '批量删除母版'
|
||
error.value = ''
|
||
try {
|
||
const result = await api.post('/api/platform/assets/batch-delete', { items })
|
||
const failed = result?.failures || []
|
||
notice.value = `已删除 ${result?.deleted_count ?? items.length} 个母版`
|
||
+ (failed.length ? `,${failed.length} 个失败:${failed[0].detail}` : ';项目内已引入的快照副本不受影响')
|
||
confirmDelete.value = null
|
||
batchDialog.value = ''
|
||
clearSelection()
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
async function runBatchMediaDelete() {
|
||
const ids = [...selectedMedia.value]
|
||
if (!ids.length) return
|
||
busy.value = '批量删除素材'
|
||
error.value = ''
|
||
try {
|
||
const result = await api.post('/api/platform/media/batch-delete', { media_ids: ids })
|
||
const failed = result?.failures || []
|
||
notice.value = `已删除 ${result?.deleted_count ?? ids.length} 个素材`
|
||
+ (failed.length ? `,${failed.length} 个失败:${failed[0].detail}` : '')
|
||
batchDialog.value = ''
|
||
clearSelection()
|
||
await loadWall()
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
function openImport(row: any) {
|
||
importAsset.value = row
|
||
importTargets.value = [row]
|
||
importProjectId.value = null
|
||
error.value = ''
|
||
}
|
||
/** AS-10:多选后走批量引入,未选中就只引入点开的这一张 */
|
||
const importTargets = ref<any[]>([])
|
||
function openImportSelection(row?: any) {
|
||
const list = row ? [row] : selectedRows.value
|
||
if (!list.length) return
|
||
importTargets.value = list
|
||
importAsset.value = list[0]
|
||
importProjectId.value = null
|
||
error.value = ''
|
||
}
|
||
|
||
async function importIntoProject() {
|
||
if (!importAsset.value) return
|
||
if (!importProjectId.value) {
|
||
error.value = '请先选择一个目标项目'
|
||
return
|
||
}
|
||
busy.value = importTargets.value.length > 1 ? '批量引入项目' : '引入项目'
|
||
error.value = ''
|
||
try {
|
||
const refs = importTargets.value.map((row) => ({ owner_type: row.owner_type || type.value, asset_id: row.id }))
|
||
if (refs.length > 1) {
|
||
const result = await api.post('/api/platform/assets/batch-import', {
|
||
project_id: importProjectId.value, items: refs,
|
||
})
|
||
const failed = result?.failures || []
|
||
notice.value = `已引入 ${result?.imported_count ?? refs.length} 个母版到《${selectedImportProject.value?.name || '项目'}》`
|
||
+ (failed.length ? `,${failed.length} 个失败:${failed[0].detail}` : '')
|
||
} else {
|
||
const result = await api.post('/api/platform/import', {
|
||
project_id: importProjectId.value,
|
||
asset_type: type.value,
|
||
asset_id: importAsset.value.id,
|
||
})
|
||
notice.value = `「${result.name}」已引入《${selectedImportProject.value?.name || '项目'}》`
|
||
}
|
||
importAsset.value = null
|
||
importTargets.value = []
|
||
importProjectId.value = null
|
||
clearSelection()
|
||
await load()
|
||
} catch (exc: any) {
|
||
error.value = exc.message
|
||
} finally {
|
||
busy.value = ''
|
||
}
|
||
}
|
||
|
||
/** 平台素材没有 mime 字段,靠 path 扩展名 + 业务 kind 判定即可 */
|
||
function isImage(item: any) {
|
||
return imageOf(item?.path || item?.url, item?.kind) || Boolean(item?.width)
|
||
}
|
||
|
||
function isAudio(item: any) {
|
||
return audioOf(item?.path || item?.url, item?.kind)
|
||
}
|
||
|
||
/** 音频控件右侧那截灰色小字:说清「现在是第几版 / 一共几版」,
|
||
* 多版素材一眼就知道还能去预览器里管版本。 */
|
||
function versionHint(media: any) {
|
||
const total = (media?.versions || []).length || media?.version_count || 1
|
||
return total > 1 ? `v${media.version} · 共 ${total} 版` : `v${media.version}`
|
||
}
|
||
|
||
/** 试听样本上的「音色自检」标记。
|
||
* 后端生成试听时会量一次中位基频,和声线设定的性别比对(见 services/timbre.py):
|
||
* zero-shot 克隆模型只认参考音频,表单里填「男声」并不会让它变成男声,
|
||
* 所以必须由界面把实测结论摊开说,而不是让用户自己听出来。 */
|
||
/** 素材出身标记:AI 试听样本能配音,但**不能**反过来当克隆参考。
|
||
* 少了这一层,用户会以为「列表里有声音文件 = 这角色有自己的嗓子」,
|
||
* 于是缺真人参考时反复重新生成——每次都在克隆上一次那个错的女声。 */
|
||
function provenanceBadge(media: any) {
|
||
if (!isAudio(media) || !media?.metadata?.generated) return null
|
||
return '模型生成的试听样本:可用于镜头配音,但不会作为下次生成的克隆参考。'
|
||
+ '要给这个角色固定嗓子,请上传一段真人参考音频。'
|
||
}
|
||
|
||
function timbreBadge(media: any) {
|
||
const check = media?.metadata?.timbre_check
|
||
if (!check || !check.f0_hz) return null
|
||
if (check.matched === false) {
|
||
return { tone: 'bad', label: `音色不符 · ${check.timbre_gender_label}`, title: check.note }
|
||
}
|
||
if (check.matched === true) {
|
||
return { tone: 'ok', label: `音色一致 · ${check.timbre_gender_label}`, title: check.note }
|
||
}
|
||
return { tone: 'warn', label: `基频 ${check.f0_hz} Hz`, title: check.note }
|
||
}
|
||
|
||
onMounted(load)
|
||
|
||
/** 预览器里做了版本操作(设为当前 / 删除某版)→ 列表自己跟进,
|
||
* 否则卡片缩略图和版本号会停在被改之前的旧状态。 */
|
||
function onMediaChanged() {
|
||
reloadSoon()
|
||
}
|
||
onMounted(() => window.addEventListener('nex:media-changed', onMediaChanged))
|
||
onBeforeUnmount(() => window.removeEventListener('nex:media-changed', onMediaChanged))
|
||
</script>
|
||
|
||
<template>
|
||
<div class="asset-library">
|
||
<header class="hero">
|
||
<div>
|
||
<small class="eyebrow">PLATFORM ASSET CONSTELLATION · 跨项目复用</small>
|
||
<h1 title="人物、场景与声线在这里沉淀为可复用母版;项目可随时引入快照,已锁定的版本会随生成记录一起留痕。">平台资产库</h1>
|
||
</div>
|
||
<div class="row">
|
||
<button class="primary" @click="openCreate">+ 新建{{ typeMeta[type].label }}</button>
|
||
</div>
|
||
</header>
|
||
|
||
<p v-if="error" class="error banner">{{ error }}</p>
|
||
<p v-if="notice" class="notice">{{ notice }}</p>
|
||
|
||
<section class="constellation">
|
||
<button class="metric lead" :class="{ on: view !== 'media' && !filtersActive }"
|
||
title="查看全部母版:清空筛选并回到网格视图" @click="focusMasters">
|
||
<span>母版资产</span>
|
||
<strong>{{ totals.human + totals.scene + totals.voice }}</strong>
|
||
<small>人物 {{ totals.human }} · 场景 {{ totals.scene }} · 声线 {{ totals.voice }}</small>
|
||
</button>
|
||
<button class="metric" :class="{ on: view === 'media' }"
|
||
title="切换到跨母版的「全部素材」视角,直接翻找图片与音频" @click="focusWall">
|
||
<span>已登记素材</span>
|
||
<strong>{{ totals.media }}</strong>
|
||
<small>{{ fmtBytes(mediaStats.media_bytes) }} · {{ mediaStats.versions || 0 }} 个版本 · 平均
|
||
{{ totals.media ? Math.round((mediaStats.media_bytes || 0) / totals.media / 1024) : 0 }} KB/个</small>
|
||
</button>
|
||
<button class="metric" :class="{ on: filters.has_media === 'without' && view !== 'media' }"
|
||
title="只看还没有任何素材的母版(补齐定妆图 / 试听样本)" @click="focusWithout">
|
||
<span>待补素材</span>
|
||
<strong>{{ mediaStats.without_media || 0 }}</strong>
|
||
<small>母版已建档,但一张图 / 一段音都没有</small>
|
||
</button>
|
||
<button class="metric dup" :class="{ on: filters.duplicate_only && view !== 'media' }"
|
||
title="同名或同代号的母版分组,建议人工确认后合并" @click="focusDuplicates">
|
||
<span>疑似重复</span>
|
||
<strong>{{ mediaStats.duplicate_masters || 0 }}</strong>
|
||
<small>{{ mediaStats.duplicate_groups || 0 }} 组同名 / 同代号 · 已引用母版 {{ mediaStats.referenced || 0 }}</small>
|
||
</button>
|
||
</section>
|
||
|
||
<div class="workspace">
|
||
<aside class="type-rail">
|
||
<button v-for="(meta, key) in typeMeta" :key="key" class="type-button"
|
||
:class="{ on: type === key }" @click="type = key as AssetType">
|
||
<span class="glyph">{{ meta.icon }}</span>
|
||
<span><b>{{ meta.label }}</b><small>{{ meta.hint }}</small></span>
|
||
<em>{{ totals[key as AssetType] }}</em>
|
||
</button>
|
||
<div class="rail-caption" :title="`${typeMeta[type].hint}。资产在此管理母版,进入项目后仍可独立改版`">
|
||
<small>{{ typeMeta[type].eyebrow }}</small>
|
||
<p v-if="view === 'media'" class="val">素材墙按 <b>当前类型</b> 过滤:{{ typeMeta[type].label }}素材
|
||
{{ wall.stats.by_owner?.[type] || 0 }} 个。</p>
|
||
</div>
|
||
</aside>
|
||
|
||
<section class="catalog">
|
||
<div class="catalog-head">
|
||
<div>
|
||
<small class="eyebrow">{{ typeMeta[type].eyebrow }}</small>
|
||
<h2>{{ view === 'media' ? '全部素材墙' : `${typeMeta[type].label}母版` }}</h2>
|
||
<p class="result-line">
|
||
<template v-if="view === 'media'">共 {{ wall.total }} 个素材,当前第 {{ wall.page }} / {{ wall.pages }} 页</template>
|
||
<template v-else-if="filtersActive">筛选出 {{ resultCount }} 个母版,本页 {{ rows.length }} 个(第 {{ summary.page }} / {{ summary.pages }} 页)</template>
|
||
<template v-else>共 {{ resultCount }} 个母版</template>
|
||
</p>
|
||
</div>
|
||
<div class="views" role="group" aria-label="切换视图">
|
||
<button class="view-btn" :class="{ on: view === 'grid' }" title="网格视图:卡片信息最全" @click="view = 'grid'"><i>▦</i>网格</button>
|
||
<button class="view-btn" :class="{ on: view === 'list' }" title="列表视图:一屏看更多母版,便于批量勾选" @click="view = 'list'"><i>☰</i>列表</button>
|
||
<button class="view-btn" :class="{ on: view === 'media' }" title="素材墙:跨母版直接翻图片 / 音频" @click="view = 'media'"><i>▣</i>全部素材</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="ctlbar toolbar">
|
||
<label class="fld grow"><span>搜索</span>
|
||
<input v-model="filters.q" class="search" aria-label="搜索平台资产"
|
||
placeholder="名称 / 代号 / 设定 / 提示词 / 标签(跨字段)" />
|
||
</label>
|
||
<label class="fld"><span>素材类型</span>
|
||
<FSelect v-model="filters.kind">
|
||
<option value="">全部类型</option>
|
||
<option v-for="entry in kindOptions" :key="entry.value" :value="entry.value">
|
||
{{ entry.label }}{{ entry.count ? ` · ${entry.count}` : '' }}
|
||
</option>
|
||
</FSelect>
|
||
</label>
|
||
<template v-if="view !== 'media'">
|
||
<label class="fld"><span>素材情况</span>
|
||
<FSelect v-model="filters.has_media">
|
||
<option value="">全部情况</option><option value="with">已有素材</option><option value="without">待补素材</option>
|
||
</FSelect>
|
||
</label>
|
||
<label class="fld"><span>状态</span>
|
||
<FSelect v-model="filters.status">
|
||
<option value="">全部状态</option><option value="active">启用中</option><option value="inactive">已停用</option>
|
||
</FSelect>
|
||
</label>
|
||
</template>
|
||
<label v-else class="check"><input v-model="wall.multi_only" type="checkbox" />仅多版本素材</label>
|
||
<label class="fld narrow"><span>排序</span>
|
||
<FSelect v-if="view === 'media'" v-model="wall.sort">
|
||
<option v-for="entry in wallSortOptions" :key="entry.value" :value="entry.value">{{ entry.label }}</option>
|
||
</FSelect>
|
||
<FSelect v-else v-model="filters.sort">
|
||
<option v-for="entry in sortOptions" :key="entry.value" :value="entry.value">{{ entry.label }}</option>
|
||
</FSelect>
|
||
</label>
|
||
<label v-if="view !== 'media'" class="check"><input v-model="filters.duplicate_only" type="checkbox" />仅疑似重复</label>
|
||
<span class="bar-right"><AutoRefresh :busy="!!busy" :every="20000" :paused="modalOpen || recordingBusy" @refresh="reload()" /></span>
|
||
</div>
|
||
|
||
<div v-if="tagOptions.length" class="chipbar">
|
||
<span class="chipbar-label">标签</span>
|
||
<button class="tag-chip" :class="{ on: !filters.tag }" @click="filters.tag = ''">全部</button>
|
||
<button v-for="entry in tagOptions" :key="entry.tag" class="tag-chip"
|
||
:class="{ on: filters.tag === entry.tag }"
|
||
:title="`只看带「${entry.tag}」标签的母版(${entry.count} 个)`"
|
||
@click="filters.tag = filters.tag === entry.tag ? '' : entry.tag">
|
||
{{ entry.tag }}<em>{{ entry.count }}</em>
|
||
</button>
|
||
<button v-if="filtersActive" class="tag-chip clear" @click="clearFilters()">✕ 清除全部筛选</button>
|
||
</div>
|
||
|
||
<div v-if="view !== 'media' && selectedCount" class="batchbar">
|
||
<b>已选 {{ selectedCount }} 个{{ typeMeta[type].label }}母版</b>
|
||
<span class="muted">{{ selectedSummary }}</span>
|
||
<span class="grow"></span>
|
||
<button class="outline tiny" @click="selectAllFiltered()">{{ allSelected ? '取消全选' : '全选本页筛选结果' }}</button>
|
||
<button class="outline tiny" @click="openImportSelection()">引入项目 →</button>
|
||
<button class="outline tiny" @click="batchDialog = 'tag'; error = ''">批量标签</button>
|
||
<button class="btn-del" :disabled="!!busy" @click="batchDialog = 'delete'">批量删除</button>
|
||
<button class="ghost tiny" @click="clearSelection()">取消选择</button>
|
||
</div>
|
||
<div v-else-if="view === 'media' && selectedMedia.size" class="batchbar">
|
||
<b>已选 {{ selectedMedia.size }} 个素材</b>
|
||
<span class="grow"></span>
|
||
<button title="Shift 可范围勾选;删除会连同全部历史版本一起移除" class="btn-del" :disabled="!!busy" @click="batchDialog = 'media-delete'">批量删除素材</button>
|
||
<button class="ghost tiny" @click="clearSelection()">取消选择</button>
|
||
</div>
|
||
|
||
<!-- 素材墙(AS-3):跨母版直接翻找图片与音频 -->
|
||
<template v-if="view === 'media'">
|
||
<div v-if="!wall.items.length" class="empty">
|
||
<template v-if="filtersActive">没有符合条件的素材。<button class="link" @click="clearFilters()">清除全部筛选</button></template>
|
||
<template v-else>当前类型还没有登记任何素材。切回母版视图,用卡片上的「AI 生成」或「上传」补素材。</template>
|
||
</div>
|
||
<div v-else class="wall">
|
||
<div v-for="(media, idx) in wall.items" :key="media.id"
|
||
class="wall-item" :class="{ picked: selectedMedia.has(media.id) }">
|
||
<label class="pick" title="勾选后可批量删除(Shift 范围选择)">
|
||
<input type="checkbox" :checked="selectedMedia.has(media.id)"
|
||
@click.stop="toggleMedia(media, idx, $event)" />
|
||
</label>
|
||
<MediaThumb :item="wallQueue[idx]" size="sm" :radius="8"
|
||
:badge="(media.version_count || media.versions?.length || 1) > 1 ? `v${media.version}` : ''"
|
||
:title="`${media.name || media.kind_label} · ${media.owner_name}`"
|
||
:queue="wallQueue" :index="idx" />
|
||
<div class="wall-meta">
|
||
<b :title="media.name || media.kind_label">{{ media.name || media.kind_label }}</b>
|
||
<small>{{ media.kind_label }} · {{ media.owner_name }}
|
||
<template v-if="media.width"> · {{ media.width }}×{{ media.height }}</template>
|
||
<template v-if="media.duration_ms"> · {{ Math.round(media.duration_ms / 100) / 10 }}s</template>
|
||
</small>
|
||
<small class="mono">{{ fmtBytes(media.size_bytes) }} · v{{ media.version }}
|
||
<template v-if="media.version_count > 1">(共 {{ media.version_count }} 版)</template></small>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<!-- 母版视图(网格 / 列表) -->
|
||
<template v-else>
|
||
<div v-if="!rows.length" class="empty">
|
||
<template v-if="filtersActive">
|
||
没有符合当前筛选条件的{{ typeMeta[type].label }}母版。
|
||
<button class="link" @click="clearFilters()">清除全部筛选</button>
|
||
</template>
|
||
<template v-else>
|
||
还没有{{ typeMeta[type].label }}母版。
|
||
<button class="link" @click="openCreate">新建{{ typeMeta[type].label }}母版</button>
|
||
,或到项目资产库把已有资产「上架到平台」。
|
||
</template>
|
||
</div>
|
||
<!-- 列表视图:一行一个母版,一屏能看十几个,专为批量勾选与巡检设计 -->
|
||
<div v-else-if="view === 'list'" class="asset-list">
|
||
<article v-for="(row, idx) in rows" :key="row.id" class="asset-row"
|
||
:class="{ picked: isSelected(row), dup: row.duplicate_of?.length }">
|
||
<label class="check pick-inline" :title="isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'">
|
||
<input type="checkbox" :checked="isSelected(row)" @click.stop="toggleSelect(row, idx, ($event as MouseEvent).shiftKey)" />
|
||
</label>
|
||
<div class="portrait-badge sm">{{ row.name.slice(0, 1) }}</div>
|
||
<div class="row-main">
|
||
<div class="title-line">
|
||
<b class="row-name">{{ row.name }}</b>
|
||
<span class="mono muted tiny">{{ row.code || `${type}-${row.id}` }}</span>
|
||
<span v-if="row.is_default" class="tag ok">默认声线</span>
|
||
<span v-if="row.is_active === false" class="tag bad">停用</span>
|
||
<span v-if="row.duplicate_of?.length" class="tag bad"
|
||
:title="`与 ${row.duplicate_of.map((d: any) => d.name || d.asset_name).join('、')} 同名或同代号,建议合并`">疑似重复</span>
|
||
<span v-if="!row.media_count" class="tag warn">待补素材</span>
|
||
</div>
|
||
<p class="row-blurb">{{ row.persona_prompt || row.appearance || row.description || row.prompt || row.voice_profile || '尚未填写设定。' }}</p>
|
||
<div class="tags">
|
||
<button v-for="tag in (row.tags || []).slice(0, 4)" :key="tag" class="chip link-chip"
|
||
:title="`只看标签「${tag}」`" @click="filters.tag = tag">{{ tag }}</button>
|
||
<span class="tag scope" :class="{ used: row.usage_count }"
|
||
:title="row.usage_count
|
||
? `已引入 ${row.usage_count} 个项目:${(row.usage || []).map((u: any) => u.project_name).join('、')}\n删除母版不会影响这些快照副本`
|
||
: '还没有任何项目引入过这个母版'">
|
||
{{ row.usage_count ? `已引入 ${row.usage_count} 个项目` : '未被项目引用' }}
|
||
</span>
|
||
<span class="tag" :title="`共 ${row.media_count} 个素材,占 ${fmtBytes(row.media_bytes)}`">
|
||
{{ row.media_count }} 素材 · {{ fmtBytes(row.media_bytes) }}
|
||
</span>
|
||
<span class="tag">{{ row.style_version || row.version || 'v1' }} · {{ fmtAgo(row.updated_at) }}</span>
|
||
</div>
|
||
</div>
|
||
<div class="row-media">
|
||
<div v-for="media in stripOf(row, 5)" :key="media.id" class="media-tile xs">
|
||
<MediaThumb v-if="isImage(media)" :item="fromAsset(media)" size="xs" width="58px" :radius="6"
|
||
:badge="(media.versions || []).length > 1 ? `v${media.version}` : ''"
|
||
:title="media.name || media.kind_label"
|
||
:queue="itemsOf(row)" :index="mediaIndex(row, media)" />
|
||
<div v-else class="media-file"><b>{{ media.kind_label }}</b><span>{{ fmtBytes(media.size_bytes) }}</span></div>
|
||
<button class="media-remove" title="单独删除此媒体(含全部历史版本)" @click.stop="deleteMedia(media)">×</button>
|
||
</div>
|
||
<AudioPlay v-for="media in row.assets?.filter(isAudio).slice(0, 2)" :key="`a-${media.id}`"
|
||
:src="media.url" size="sm" compact :label="media.kind_label"
|
||
:duration-ms="media.duration_ms" />
|
||
<span v-if="!row.assets?.length" class="muted tiny">暂无素材</span>
|
||
</div>
|
||
<div class="row-actions">
|
||
<button class="primary tiny" @click="openGenerate(row)">▤ {{ type === 'voice' ? '生成试听' : 'AI 生成' }}</button>
|
||
<span class="row-actions-line">
|
||
<label class="upload tiny">上传<input type="file" @change="upload(row, $event)" /></label>
|
||
<button class="outline tiny" @click="openImportSelection(row)">引入</button>
|
||
</span>
|
||
<span class="row-actions-line">
|
||
<button class="outline tiny" @click="openEdit(type, row)">编辑</button>
|
||
<button class="btn-del" title="删除这个资源" @click="askDelete(row)">删除</button>
|
||
</span>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
<div v-else class="asset-grid">
|
||
<article v-for="(row, idx) in rows" :key="row.id" class="asset-card"
|
||
:class="{ picked: isSelected(row), dup: row.duplicate_of?.length }">
|
||
<label class="pick" :title="isSelected(row) ? '取消选择' : '勾选后可批量引入 / 打标签 / 删除(Shift 范围选择)'">
|
||
<input type="checkbox" :checked="isSelected(row)" @click.stop="toggleSelect(row, idx, ($event as MouseEvent).shiftKey)" />
|
||
</label>
|
||
<div class="card-head">
|
||
<div class="portrait-badge">{{ row.name.slice(0, 1) }}</div>
|
||
<div class="grow">
|
||
<div class="title-line">
|
||
<h3>{{ row.name }}</h3>
|
||
<span v-if="row.is_default" class="tag ok">默认声线</span>
|
||
<span v-if="row.is_active === false" class="tag bad">停用</span>
|
||
<span v-if="row.duplicate_of?.length" class="tag bad"
|
||
:title="`与 ${row.duplicate_of.map((d: any) => d.name || d.asset_name).join('、')} 同名或同代号,建议合并`">疑似重复</span>
|
||
<span v-if="!row.media_count" class="tag warn">待补素材</span>
|
||
</div>
|
||
<div class="mono muted">{{ row.code || `${type}-${row.id}` }}</div>
|
||
</div>
|
||
<button class="outline tiny" @click="openEdit(type, row)">编辑</button>
|
||
</div>
|
||
|
||
<p class="summary">{{ row.persona_prompt || row.appearance || row.description || row.prompt || row.voice_profile || '尚未填写设定。' }}</p>
|
||
<div class="tags">
|
||
<button v-for="tag in (row.tags || []).slice(0, 5)" :key="tag" class="chip link-chip"
|
||
:title="`只看标签「${tag}」`" @click="filters.tag = tag">{{ tag }}</button>
|
||
<span v-if="type === 'human'" class="tag">{{ row.role || '角色' }}</span>
|
||
<span v-if="type === 'human' && row.default_voice_name" class="tag" :title="`默认声线:${row.default_voice_name}`">声线 · {{ row.default_voice_name }}</span>
|
||
<span v-if="type === 'scene'" class="tag">{{ [row.lighting, row.time_of_day, row.palette].filter(Boolean).join(' · ') || '未设定光线' }}</span>
|
||
<span v-if="type === 'voice'" class="tag">{{ row.provider || '生成时选模型' }} · {{ row.language || 'zh-CN' }}</span>
|
||
<span class="tag scope" :class="{ used: row.usage_count }"
|
||
:title="row.usage_count
|
||
? `已引入 ${row.usage_count} 个项目:${(row.usage || []).map((u: any) => u.project_name).join('、')}\n删除母版不会影响这些快照副本`
|
||
: '还没有任何项目引入过这个母版'">
|
||
{{ row.usage_count ? `已引入 ${row.usage_count} 个项目` : '未被项目引用' }}
|
||
</span>
|
||
<span class="tag" :title="`共 ${row.media_count} 个素材,占 ${fmtBytes(row.media_bytes)}`">
|
||
{{ row.media_count }} 素材 · {{ fmtBytes(row.media_bytes) }}
|
||
</span>
|
||
</div>
|
||
|
||
<div v-if="row.assets?.length" class="media-strip">
|
||
<template v-for="media in stripOf(row)" :key="media.id">
|
||
<div class="media-tile">
|
||
<MediaThumb v-if="isImage(media)" :item="fromAsset(media)" size="sm" :radius="7"
|
||
:badge="(media.versions || []).length > 1 ? `v${media.version}` : ''"
|
||
:title="media.name || media.kind_label"
|
||
:queue="itemsOf(row)" :index="mediaIndex(row, media)" />
|
||
<div v-else class="media-file">
|
||
<b>{{ media.kind_label }}</b>
|
||
<span>{{ fmtBytes(media.size_bytes) }} · v{{ media.version }}</span>
|
||
</div>
|
||
<button class="media-remove" title="单独删除此媒体(含全部历史版本)" @click.stop="deleteMedia(media)">×</button>
|
||
</div>
|
||
</template>
|
||
</div>
|
||
<div v-for="media in row.assets?.filter(isAudio)" :key="`audio-${media.id}`" class="audio-row">
|
||
<AudioPlay class="audio" :src="media.url" size="sm"
|
||
:label="media.name || media.kind_label" :duration-ms="media.duration_ms"
|
||
:hint="versionHint(media)" />
|
||
<span v-if="timbreBadge(media)" class="timbre-flag" :class="timbreBadge(media).tone"
|
||
:title="timbreBadge(media).title">◈ {{ timbreBadge(media).label }}</span>
|
||
<span v-if="provenanceBadge(media)" class="timbre-flag warn" :title="provenanceBadge(media)">
|
||
◌ AI 样本 · 非参考</span>
|
||
<button class="btn-del sq" title="单独删除此音频(含全部历史版本)" aria-label="删除这条音频"
|
||
@click.stop="deleteMedia(media)">×</button>
|
||
</div>
|
||
<div v-if="!row.assets?.length" class="no-media">
|
||
暂无素材:用下方「AI 生成」出图 / 出试听,或直接上传现成文件。
|
||
</div>
|
||
|
||
<div class="card-actions">
|
||
<button class="primary tiny" @click="openGenerate(row)">
|
||
▤ {{ type === 'voice' ? '生成试听' : 'AI 生成' }}
|
||
</button>
|
||
<FSelect v-model="uploadKinds[uploadKey(row)]" class="kind-select" aria-label="选择要上传的资产类型">
|
||
<option v-for="kind in uploadKindOptions[type]" :key="kind" :value="kind">{{ opt('asset_kinds', kind) }}</option>
|
||
</FSelect>
|
||
<label class="upload">上传<input type="file" @change="upload(row, $event)" /></label>
|
||
<RecordAudio v-if="type === 'voice'" label="录制"
|
||
:target="opt('asset_kinds', uploadKinds[uploadKey(row)])"
|
||
:default-name="recordDefaultName(row, uploadKinds[uploadKey(row)])"
|
||
:names="existingNames(row.assets)"
|
||
hint="弹出小面板:录 → 试听 → 再决定存成哪条素材的哪个版本"
|
||
@pick="(file, meta) => recordSample(row, file, meta)" />
|
||
<button class="outline tiny" @click="openImportSelection(row)">引入项目 →</button>
|
||
<button class="btn-del" title="删除这个资源" @click="askDelete(row)">删除</button>
|
||
<span class="stamp">{{ row.style_version || row.version || 'v1' }} · 更新于 {{ fmtAgo(row.updated_at) }}</span>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
|
||
<div v-if="rows.length" class="pager">
|
||
<button class="outline tiny" :disabled="summary.page <= 1" @click="filters.page = summary.page - 1">← 上一页</button>
|
||
<label class="fld narrow"><span>每页</span>
|
||
<FSelect v-model.number="filters.page_size">
|
||
<option :value="24">24</option><option :value="60">60</option><option :value="120">120</option><option :value="0">全部</option>
|
||
</FSelect>
|
||
</label>
|
||
<span>第 {{ summary.page }} / {{ summary.pages }} 页 · 共 {{ resultCount }} 个母版</span>
|
||
<button class="outline tiny" :disabled="summary.page >= summary.pages" @click="filters.page = summary.page + 1">下一页 →</button>
|
||
</div>
|
||
</template>
|
||
|
||
<div v-if="view === 'media' && wall.total" class="pager">
|
||
<button class="outline tiny" :disabled="wall.page <= 1" @click="wall.page = wall.page - 1">← 上一页</button>
|
||
<label class="fld narrow"><span>每页</span>
|
||
<FSelect v-model.number="filters.page_size">
|
||
<option :value="24">24</option><option :value="60">60</option><option :value="120">120</option><option :value="0">全部</option>
|
||
</FSelect>
|
||
</label>
|
||
<span>第 {{ wall.page }} / {{ wall.pages }} 页 · 共 {{ wall.total }} 个素材</span>
|
||
<button class="outline tiny" :disabled="wall.page >= wall.pages" @click="wall.page = wall.page + 1">下一页 →</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
|
||
<Teleport to="body">
|
||
<div v-if="drawer" class="drawer-backdrop" @click.self="drawer = false">
|
||
<section class="drawer">
|
||
<header class="drawer-head">
|
||
<div>
|
||
<small class="eyebrow">{{ editingId ? 'EDIT MASTER' : 'NEW MASTER' }}</small>
|
||
<h2 title="修改只影响平台母版;项目中的历史引入副本仍按快照独立存在。">{{ editingId ? '编辑' : '新建' }}{{ typeMeta[form.type].label }}母版</h2>
|
||
</div>
|
||
<button class="outline tiny" @click="drawer = false">关闭</button>
|
||
</header>
|
||
<form class="drawer-body" @submit.prevent="save">
|
||
<div class="frow">
|
||
<label class="fld"><span>名称 <b class="req">*</b></span><input v-model="form.name" placeholder="角色 / 场景 / 声线名称" /></label>
|
||
<label class="fld"><span>代号</span><input v-model="form.code" placeholder="可留空" /></label>
|
||
<label class="fld"><span>标签</span><input v-model="form.tags" placeholder="科幻 主角 冷色" /></label>
|
||
</div>
|
||
|
||
<template v-if="form.type === 'human'">
|
||
<div class="frow">
|
||
<label class="fld"><span>定位</span><FSelect v-model="form.role"><option>主角</option><option>配角</option><option>反派</option><option>旁白</option><option>群众</option></FSelect></label>
|
||
<label class="fld"><span>造型版本</span><input v-model="form.style_version" /></label>
|
||
<label class="fld"><span>默认声线</span><FSelect v-model="form.default_voice_id"><option :value="null">不绑定</option><option v-for="voice in voices" :key="voice.id" :value="voice.id">{{ voice.name }}</option></FSelect></label>
|
||
</div>
|
||
<label class="field"><span class="lbl">外观</span><textarea v-model="form.appearance" rows="2" placeholder="五官、发型、体型、服装与配饰"></textarea></label>
|
||
<label class="field"><span class="lbl">性格与表演</span><textarea v-model="form.personality" rows="2"></textarea></label>
|
||
<label class="field"><span class="lbl">一致性提示词</span><textarea v-model="form.persona_prompt" rows="3"></textarea></label>
|
||
<div class="frow">
|
||
<label class="fld"><span>声音描述</span><input v-model="form.voice_profile" /></label>
|
||
</div>
|
||
</template>
|
||
|
||
<template v-else-if="form.type === 'scene'">
|
||
<div class="frow">
|
||
<label class="fld"><span>光线</span><input v-model="form.lighting" /></label>
|
||
<label class="fld"><span>时间</span><input v-model="form.time_of_day" /></label>
|
||
<label class="fld"><span>主色调</span><input v-model="form.palette" /></label>
|
||
</div>
|
||
<label class="field"><span class="lbl">场景描述</span><textarea v-model="form.description" rows="2"></textarea></label>
|
||
<label class="field"><span class="lbl">一致性提示词</span><textarea v-model="form.prompt" rows="3"></textarea></label>
|
||
</template>
|
||
|
||
<template v-else>
|
||
<div class="frow">
|
||
<label class="fld"><span>语言</span><input v-model="form.language" /></label>
|
||
<label class="fld"><span>性别</span><FSelect v-model="form.gender"><option value="">未指定</option><option value="female">女声</option><option value="male">男声</option><option value="neutral">中性</option></FSelect></label>
|
||
<label class="fld"><span>语速</span><input v-model.number="form.tuning_speed" type="number" min="0.5" max="2" step="0.05" /></label>
|
||
<label title="「外星低吼」是 macOS 系统语音适配器的滤镜参数,IndexTTS2 等模型会忽略它;后端整字典覆盖 tuning,已保留的采样率等参数不会被这次保存清掉。" class="fld"><span>效果</span><FSelect v-model="form.tuning_effect">
|
||
<option value="">真实人声</option>
|
||
<option value="alien">外星低吼(仅 macos-say 支持)</option>
|
||
</FSelect></label>
|
||
<label class="check"><input v-model="form.is_default" type="checkbox" />设为平台默认声线</label>
|
||
</div>
|
||
<label class="field"><span class="lbl">音色描述</span><textarea v-model="form.description" rows="3"></textarea></label>
|
||
<div class="frow">
|
||
<label class="fld"><span>版本</span><input v-model="form.version" /></label>
|
||
</div>
|
||
</template>
|
||
|
||
<label class="field"><span class="lbl">备注</span><textarea v-model="form.notes" rows="2"></textarea></label>
|
||
<div class="drawer-actions">
|
||
<button class="primary" type="submit" :disabled="!!busy">{{ busy ? '处理中…' : '保存母版' }}</button>
|
||
<button class="outline" type="button" @click="drawer = false">取消</button>
|
||
</div>
|
||
</form>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<Teleport to="body">
|
||
<div v-if="confirmDelete" class="dialog-backdrop" @click.self="confirmDelete = null">
|
||
<section class="import-dialog" role="dialog" aria-modal="true" aria-label="确认删除平台母版">
|
||
<header>
|
||
<div>
|
||
<small class="eyebrow">DELETE MASTER</small>
|
||
<h2>删除{{ (typeMeta[confirmDelete.owner_type] || typeMeta[type]).label }}母版?</h2>
|
||
</div>
|
||
<button class="outline tiny" @click="confirmDelete = null">关闭</button>
|
||
</header>
|
||
<p class="import-subject">
|
||
将从平台资产库移除 <strong>「{{ confirmDelete.name }}」</strong>
|
||
以及其母版媒体文件的全部版本;项目内已引入的快照副本不受影响。
|
||
</p>
|
||
<div class="dialog-actions">
|
||
<button class="btn-del solid lg" :disabled="!!busy" @click="runDelete">确认删除</button>
|
||
<button class="outline tiny" :disabled="!!busy" @click="confirmDelete = null">取消</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<Teleport to="body">
|
||
<div v-if="importAsset" class="dialog-backdrop" @click.self="importAsset = null">
|
||
<section class="import-dialog">
|
||
<header>
|
||
<div>
|
||
<small class="eyebrow">IMPORT SNAPSHOT</small>
|
||
<h2>引入到项目资产库<template v-if="importTargets.length > 1">({{ importTargets.length }} 个母版)</template></h2>
|
||
</div>
|
||
<button class="outline tiny" @click="importAsset = null">关闭</button>
|
||
</header>
|
||
<p class="import-subject">
|
||
<template v-if="importTargets.length > 1">将把已选的 <strong>{{ importTargets.length }} 个{{ typeMeta[type].label }}母版</strong>
|
||
——{{ importTargets.slice(0, 8).map((row: any) => `「${row.name}」`).join('、') }}{{ importTargets.length > 8 ? ' 等' : '' }}
|
||
—— 复制为项目内独立快照,母版后续改版不影响项目。
|
||
</template>
|
||
<template v-else>将{{ typeMeta[type].label }}母版
|
||
<strong>「{{ importAsset.name }}」</strong>
|
||
复制为项目内独立快照,后续改动互不影响。
|
||
</template>
|
||
</p>
|
||
<label class="field"><span class="lbl">目标项目</span>
|
||
<FSelect v-model="importProjectId" :disabled="!projects.length">
|
||
<option :value="null" disabled>请选择要引入的项目</option>
|
||
<option v-for="project in projects" :key="project.id" :value="project.id">
|
||
《{{ project.name }}》 · {{ projectHint(project) }}
|
||
</option>
|
||
</FSelect>
|
||
</label>
|
||
<p v-if="!projects.length" class="muted">还没有项目可引入,请先创建项目。</p>
|
||
<p v-if="error" class="error banner">{{ error }}</p>
|
||
<div class="dialog-actions">
|
||
<button class="primary" :disabled="!!busy || !importProjectId" @click="importIntoProject">
|
||
{{ busy ? '引入中…' : '确认引入' }}
|
||
</button>
|
||
<button class="outline" @click="importAsset = null">取消</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<!-- AS-1:AI 生成表单收进右侧抽屉。以前每张卡片里塞一个 600px 的表单,
|
||
三个人物就能把页面撑出三屏,现在卡片只留「AI 生成」入口。 -->
|
||
<Teleport to="body">
|
||
<div v-if="genDrawer && genTarget" class="drawer-backdrop" @click.self="genDrawer = false">
|
||
<section class="drawer gen-drawer" role="dialog" aria-modal="true" aria-label="生成平台素材">
|
||
<header class="drawer-head">
|
||
<div>
|
||
<small class="eyebrow">{{ typeMeta[genTarget.owner_type || type].eyebrow }} · GENERATE</small>
|
||
<h2>{{ genTarget.name }}</h2>
|
||
<p class="mono">
|
||
{{ genTarget.code || `${type}-${genTarget.id}` }} · 现有 {{ genTarget.media_count || 0 }} 个素材
|
||
· {{ fmtBytes(genTarget.media_bytes) }}
|
||
<template v-if="genTarget.usage_count"> · 已引入 {{ genTarget.usage_count }} 个项目</template>
|
||
</p>
|
||
</div>
|
||
<button class="outline tiny" @click="genDrawer = false">关闭</button>
|
||
</header>
|
||
<div class="drawer-body">
|
||
<div class="ai-box">
|
||
<div class="between ai-head">
|
||
<b>AI {{ type === 'voice' ? '试听' : '母版生成' }}</b>
|
||
<span class="muted">{{ specCaps(genTarget).label || '模型注册表读取中…' }}</span>
|
||
</div>
|
||
<div class="frow gen-fields">
|
||
<label class="fld"><span>模型</span>
|
||
<FSelect :model-value="modelRef(genTarget)" @change="onModelSelect(genTarget, $event)">
|
||
<option v-if="!genModels().length" :value="modelRef(genTarget)" disabled>
|
||
没有已启用的真实{{ type === 'voice' ? '声音' : '图像' }}模型
|
||
</option>
|
||
<option v-for="p in genModels()" :key="p.id" :value="refOf(p)">
|
||
{{ p.display_name || `${p.provider}/${p.model}` }}{{ p.is_default ? '(平台默认)' : '' }}
|
||
</option>
|
||
</FSelect>
|
||
</label>
|
||
<label v-if="type !== 'voice'" class="fld"><span>类型</span>
|
||
<FSelect v-model="genFor(genTarget).kind" @change="selectAtmosphereReference(genTarget)">
|
||
<option v-if="type === 'human'" value="portrait">定妆图</option>
|
||
<option v-if="type === 'human'" value="turnaround">三视图</option>
|
||
<option v-if="type === 'human'" value="expression">表情参考</option>
|
||
<option v-if="type === 'scene'" value="scene_image">场景图</option>
|
||
<option v-if="type === 'scene'" value="reference">氛围图</option>
|
||
</FSelect>
|
||
</label>
|
||
</div>
|
||
<label v-if="type === 'voice'" class="field">
|
||
<span class="lbl">试听文本 <b class="req">*</b></span>
|
||
<textarea title="这是要念出来的台词,不是声线设定;「音色描述」不会被当成台词。" v-model="genFor(genTarget).sample_text" rows="2"
|
||
placeholder="输入一句要让模型朗读的台词,例如:我是俊杰,公司的产品专家。" />
|
||
</label>
|
||
<div v-if="type !== 'voice'" class="frow gen-fields">
|
||
<label class="fld"><span>分辨率档位</span>
|
||
<FSelect :model-value="draftTier(genTarget)"
|
||
@change="setDraft(genTarget, 'tier', ($event.target as HTMLSelectElement).value)">
|
||
<option v-for="tk in tierChoices(genTarget)" :key="tk.value" :value="tk.value">
|
||
{{ tk.label }}(长边 {{ tk.edge }}px)
|
||
</option>
|
||
</FSelect>
|
||
</label>
|
||
<label class="fld"><span>画幅</span>
|
||
<FSelect :model-value="draftAspect(genTarget)"
|
||
@change="setDraft(genTarget, 'aspect', ($event.target as HTMLSelectElement).value)">
|
||
<option v-for="a in aspectOptions(genTarget)" :key="a.value" :value="a.value">{{ a.label }}</option>
|
||
</FSelect>
|
||
</label>
|
||
</div>
|
||
<div v-if="type !== 'voice'" class="capsline">
|
||
<span v-if="specCaps(genTarget).resolutions.length" class="tag">档位 {{ specCaps(genTarget).resolutions.join(' / ') }}</span>
|
||
<span v-if="specCaps(genTarget).aspectRatios.length" class="tag">画幅 {{ specCaps(genTarget).aspectRatios.join(' / ') }}</span>
|
||
<span class="tag">输出 {{ canvasOf(genTarget).width }}×{{ canvasOf(genTarget).height }}</span>
|
||
<span v-if="specCaps(genTarget).maxReferenceImages" class="tag">参考图 ≤ {{ specCaps(genTarget).maxReferenceImages }}</span>
|
||
<span v-if="!specCaps(genTarget).known" class="tag bad">模型未注册</span>
|
||
</div>
|
||
<div v-if="type !== 'voice'" class="voice-reference">
|
||
<label class="field"><span class="lbl">参考图(可多选,留空即纯文生图)</span>
|
||
<FMultiSelect :model-value="genFor(genTarget).reference_media_ids"
|
||
:aria-label="(genTarget?.name || genTarget?.kind || '素材') + ':参考图'" @change="pickReferences(genTarget, $event)">
|
||
<option v-for="media in imageReferenceOptions(genTarget)" :key="media.id" :value="media.id">
|
||
{{ media.name || media.kind_label }} · v{{ media.version }}
|
||
</option>
|
||
</FMultiSelect>
|
||
</label>
|
||
<label class="upload reference-upload">上传参考图
|
||
<input type="file" accept="image/*" @change="uploadImageReference(genTarget, $event)" />
|
||
</label>
|
||
<small>已选 {{ genFor(genTarget).reference_media_ids.length }} / {{ specCaps(genTarget).maxReferenceImages || 1 }} 张。
|
||
定妆图、三视图或场景图可作一致性锚点;超出上限时按勾选顺序取前几张。</small>
|
||
</div>
|
||
<div v-if="type === 'voice'" class="voice-reference">
|
||
<label class="field"><span class="lbl">参考音色</span>
|
||
<FSelect v-model="genFor(genTarget).reference_media_id"
|
||
@change="void loadVoiceReferenceStatus(genTarget)">
|
||
<option :value="null">自动(本声线 → 同性别声线 → 模型默认)</option>
|
||
<option v-for="media in referenceOptions(genTarget)" :key="media.id" :value="media.id">
|
||
{{ media.name || media.kind_label }} · v{{ media.version }}
|
||
</option>
|
||
</FSelect>
|
||
</label>
|
||
<label class="upload reference-upload">上传参考音色
|
||
<input type="file" accept="audio/*" @change="uploadReference(genTarget, $event)" />
|
||
</label>
|
||
<RecordAudio label="录制参考音色" target="参考音色"
|
||
:default-name="defaultAssetName(genTarget?.assets, `${genTarget?.name || '声线'}参考音色`, 'reference')"
|
||
:names="existingNames(genTarget?.assets)"
|
||
hint="弹出小面板:对着麦克风念几句话即可当作克隆参考,录完自动转成 WAV"
|
||
@pick="(file, meta) => recordReference(genTarget, file, meta)" />
|
||
<div v-if="voiceRefBusy" class="ref-status muted">正在确认这次会用谁的嗓子…</div>
|
||
<div v-else-if="voiceRefStatus" class="ref-status"
|
||
:class="{ warn: voiceRefStatus.borrowed || voiceRefStatus.bound_generated,
|
||
bad: !voiceRefStatus.ready }">
|
||
<b>本次音色:{{ voiceRefStatus.note }}</b>
|
||
<small v-if="voiceRefStatus.bound_generated">
|
||
这条声线现在挂着的音频是**模型生成的试听样本**,不是真人录音:
|
||
它可以拿去给镜头配音,但不能反过来当克隆参考,
|
||
否则第一次生成错了性别,之后每次重试都会继续克隆那个错的嗓子。
|
||
上传一段{{ voiceRefStatus.gender_label }}真人参考音频就能固定成这个角色自己的音色。
|
||
</small>
|
||
<small v-else>设定性别:{{ voiceRefStatus.gender_label }}。
|
||
音色由参考音频决定,「性别 / 音色描述」只是标注——
|
||
要给这个角色一副自己的嗓子,请上传一段同性别参考音频。</small>
|
||
</div>
|
||
<small>需要参考音频的模型(如 IndexTTS2)用参考音频做 zero-shot 音色克隆;
|
||
设定了性别却没有任何同性别参考时,平台会直接拒绝生成,而不是悄悄给你一个陌生人的嗓门。</small>
|
||
</div>
|
||
<label v-if="type !== 'voice'" class="field"><span class="lbl">补充提示</span>
|
||
<textarea v-model="genFor(genTarget).prompt" rows="2" placeholder="留空则自动使用母版设定"></textarea>
|
||
</label>
|
||
<button class="primary tiny"
|
||
:disabled="!!busy || !genModels().length || !generationSpec(genTarget)
|
||
|| (type === 'voice' && (!String(genFor(genTarget).sample_text || '').trim()
|
||
|| !voiceHasReference(genTarget)))"
|
||
@click="generate(genTarget)">{{ busy ? '处理中…' : (type === 'voice' ? '◉ 生成试听样本' : '▧ 生成母版图像') }}</button>
|
||
<small v-if="registry.error" class="provider-warning">模型注册表读取失败:{{ registry.error }}</small>
|
||
<small v-else-if="registry.busy" class="provider-warning">正在读取模型注册表…</small>
|
||
<small v-else-if="!genModels().length" class="provider-warning"
|
||
>当前没有已启用的真实{{ type === 'voice' ? '声音' : '图像' }}模型(mock 演练通道不出正式素材),请先到「模型中心」启用。</small>
|
||
</div>
|
||
<div v-if="genTarget.assets?.length" class="gen-current">
|
||
<b title="生成结果作为该母版的 新版本 登记,旧版本仍可在预览器里逐版切换;项目里已锁定的快照不会自动改版。">现有素材({{ genTarget.assets.length }})</b>
|
||
<div class="gen-current-grid">
|
||
<MediaThumb v-for="media in genTarget.assets.filter((item: any) => isImage(item))" :key="media.id"
|
||
:item="fromAsset(media)" size="xs" :radius="6" :badge="`v${media.version}`"
|
||
:title="media.name || media.kind_label" :queue="itemsOf(genTarget)"
|
||
:index="mediaIndex(genTarget, media)" />
|
||
</div>
|
||
<div v-if="genTarget.assets.filter(isAudio).length" class="gen-current-audio">
|
||
<AudioPlay v-for="media in genTarget.assets.filter(isAudio)" :key="`a-${media.id}`" class="audio"
|
||
:src="media.url" size="sm" :label="media.kind_label" :duration-ms="media.duration_ms"
|
||
:hint="versionHint(media)" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
<!-- AS-10:批量操作确认框 -->
|
||
<Teleport to="body">
|
||
<div v-if="batchDialog === 'tag'" class="dialog-backdrop" @click.self="batchDialog = ''">
|
||
<section class="import-dialog" role="dialog" aria-modal="true" aria-label="批量标签">
|
||
<header>
|
||
<div>
|
||
<small class="eyebrow">BATCH TAG</small>
|
||
<h2>批量调整标签</h2>
|
||
</div>
|
||
<button class="outline tiny" @click="batchDialog = ''">关闭</button>
|
||
</header>
|
||
<p class="import-subject">将对已选的 <strong>{{ selectedCount }} 个{{ typeMeta[type].label }}母版</strong>生效:
|
||
{{ selectedRows.slice(0, 8).map((row: any) => `「${row.name}」`).join('、') }}{{ selectedRows.length > 8 ? ' 等' : '' }}。
|
||
追加是合并、移除按整词匹配,两边同名标签以移除为准。
|
||
</p>
|
||
<div class="dialog-fields">
|
||
<div class="frow">
|
||
<label class="fld"><span>追加标签</span><input v-model="batchTags.add" placeholder="逗号或空格分隔,例如:科幻 待打磨" /></label>
|
||
<label class="fld"><span>移除标签</span><input v-model="batchTags.remove" placeholder="留空即不移除" /></label>
|
||
</div>
|
||
</div>
|
||
<div class="dialog-actions">
|
||
<button class="primary tiny" :disabled="!!busy || (!batchTags.add.trim() && !batchTags.remove.trim())"
|
||
@click="runBatchTag">{{ busy ? '处理中…' : '应用标签' }}</button>
|
||
<button class="outline tiny" @click="batchDialog = ''">取消</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
|
||
<div v-else-if="batchDialog === 'delete'" class="dialog-backdrop" @click.self="batchDialog = ''">
|
||
<section class="import-dialog" role="dialog" aria-modal="true" aria-label="批量删除母版">
|
||
<header>
|
||
<div>
|
||
<small class="eyebrow">BATCH DELETE</small>
|
||
<h2>删除 {{ selectedCount }} 个母版?</h2>
|
||
</div>
|
||
<button class="outline tiny" @click="batchDialog = ''">关闭</button>
|
||
</header>
|
||
<p class="import-subject">将移除这些母版及其媒体文件的<strong>全部版本</strong>;
|
||
项目内已引入的快照副本与生成台账不受影响。</p>
|
||
<ul class="dialog-list">
|
||
<li v-for="row in selectedRows" :key="row.id">
|
||
<b>{{ row.name }}</b>
|
||
<span class="mono muted">{{ row.code || `${type}-${row.id}` }}</span>
|
||
<span class="tag">{{ row.media_count || 0 }} 素材</span>
|
||
<span class="tag" :class="{ warn: row.usage_count }">
|
||
{{ row.usage_count ? `已引入 ${row.usage_count} 个项目` : '未被引用' }}
|
||
</span>
|
||
</li>
|
||
</ul>
|
||
<div class="dialog-actions">
|
||
<button class="btn-del solid lg" :disabled="!!busy" @click="runBatchDelete">
|
||
{{ busy ? '处理中…' : `确认删除 ${selectedCount} 个母版` }}
|
||
</button>
|
||
<button class="outline tiny" :disabled="!!busy" @click="batchDialog = ''">取消</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
|
||
<div v-else-if="batchDialog === 'media-delete'" class="dialog-backdrop" @click.self="batchDialog = ''">
|
||
<section class="import-dialog" role="dialog" aria-modal="true" aria-label="批量删除素材">
|
||
<header>
|
||
<div>
|
||
<small class="eyebrow">BATCH DELETE MEDIA</small>
|
||
<h2>删除 {{ selectedMedia.size }} 个素材?</h2>
|
||
</div>
|
||
<button class="outline tiny" @click="batchDialog = ''">关闭</button>
|
||
</header>
|
||
<p class="import-subject">素材删除是<strong>连同全部历史版本一起移除</strong>,母版本身与项目快照副本保留。</p>
|
||
<ul class="dialog-list">
|
||
<li v-for="media in selectedMediaRows.slice(0, 30)" :key="media.id">
|
||
<b>{{ media.name || media.kind_label }}</b>
|
||
<span class="muted">{{ media.owner_name }}</span>
|
||
<span class="tag">v{{ media.version }}<template v-if="media.version_count > 1"> 共 {{ media.version_count }} 版</template></span>
|
||
<span class="tag">{{ fmtBytes(media.size_bytes) }}</span>
|
||
</li>
|
||
</ul>
|
||
<p v-if="selectedMediaRows.length > 30" class="muted dialog-more">另有 {{ selectedMediaRows.length - 30 }} 个素材未列出。</p>
|
||
<div class="dialog-actions">
|
||
<button class="btn-del solid lg" :disabled="!!busy" @click="runBatchMediaDelete">
|
||
{{ busy ? '处理中…' : `确认删除 ${selectedMedia.size} 个素材` }}
|
||
</button>
|
||
<button class="outline tiny" :disabled="!!busy" @click="batchDialog = ''">取消</button>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</Teleport>
|
||
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.asset-library { --lime: var(--c-accent); --line: var(--c-line); }
|
||
.hero { align-items: flex-start; margin-bottom: 15px; }
|
||
.hero h1 { margin: 5px 0 0; }
|
||
.hero p { color: var(--c-text-faint); font-size: 11px; line-height: 1.7; max-width: 760px; margin: 8px 0 0; }
|
||
.banner { padding: 10px 12px; border: 1px solid var(--c-danger-line); background: var(--c-danger-ink); border-radius: 8px; }
|
||
.constellation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
|
||
.metric { position: relative; overflow: hidden; min-height: 104px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(145deg, var(--c-bg-panel), var(--c-bg-card)); appearance: none; text-align: left; font-family: inherit; color: var(--c-text); cursor: pointer; transition: border-color .16s, box-shadow .16s; }
|
||
.metric::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 106% 132%, var(--c-tint-accent), transparent 58%); }
|
||
.metric span { display: block; color: var(--c-text-faint); font-size: 10px; letter-spacing: .7px; }
|
||
.metric strong { display: block; margin: 8px 0 3px; color: var(--c-text); font-size: 25px; line-height: 1.05; }
|
||
.metric small { color: var(--c-text-dim); font-size: 10px; }
|
||
.metric.lead { background: linear-gradient(145deg, var(--c-bg-raised), var(--c-bg-panel)); border-color: var(--c-warn-line); }
|
||
.metric.lead strong { color: var(--lime); }
|
||
.metric:hover { border-color: var(--c-accent-line); }
|
||
.metric.on { border-color: var(--c-success-line); box-shadow: inset 0 0 0 1px var(--c-success-line); }
|
||
.metric.on span { color: var(--c-success); }
|
||
.metric.dup strong { color: var(--c-warn); }
|
||
.metric.target strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||
.workspace { display: grid; grid-template-columns: 224px minmax(0, 1fr); gap: 13px; align-items: start; }
|
||
.type-rail { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: var(--c-bg-card); }
|
||
.type-button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--c-text-2); text-align: left; }
|
||
.type-button:hover { background: var(--c-bg-panel); }
|
||
.type-button.on { border-color: var(--c-success-line); background: var(--c-bg-raised); box-shadow: inset 3px 0 0 var(--lime); }
|
||
.type-button .glyph { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: var(--c-line-soft); color: var(--lime); font-size: 16px; }
|
||
.type-button b { display: block; font-size: 12px; }
|
||
.type-button small { display: block; margin-top: 3px; color: var(--c-text-dim); font-size: 10px; line-height: 1.35; }
|
||
.type-button em { margin-left: auto; color: var(--c-success); font-size: 18px; font-style: normal; }
|
||
.rail-caption { padding: 20px 8px 5px; border-top: 1px solid var(--c-bg-active); }
|
||
.rail-caption small { color: var(--c-accent); font-size: 10px; letter-spacing: 1px; }
|
||
.rail-caption p { margin: 6px 0 0; color: var(--c-text-dim); font-size: 10px; line-height: 1.6; }
|
||
.catalog { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--c-bg-shell); }
|
||
.catalog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
|
||
.catalog-head h2 { margin: 4px 0 0; font-size: 19px; }
|
||
.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
|
||
.asset-card { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 14px; border: 1px solid var(--c-bg-emphasis); border-radius: 11px; background: linear-gradient(145deg, var(--c-bg-panel), var(--c-bg-sunken)); }
|
||
.card-head { display: flex; align-items: flex-start; gap: 10px; }
|
||
.portrait-badge { display: grid; place-items: center; width: 38px; height: 42px; flex-shrink: 0; border: 1px solid var(--c-accent-line); border-radius: 10px 10px 13px 13px; background: var(--c-accent-tint); color: var(--lime); font-size: 18px; }
|
||
.card-head h3 { margin: 0; font-size: 13px; }
|
||
.title-line { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
|
||
.summary { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 46px; margin: 10px 0 7px; color: var(--c-text-muted); font-size: 10.5px; line-height: 1.55; }
|
||
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
|
||
.media-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
|
||
.media-tile { position: relative; min-width: 0; }
|
||
.media-file { display: flex; flex-direction: column; justify-content: space-between; min-height: 55px; padding: 6px; border-radius: 6px; background: var(--c-bg-hover); }
|
||
.media-file b { color: var(--c-text-2); font-size: 10px; }
|
||
.media-file span { color: var(--c-text-dim); font-size: 10px; }
|
||
.media-remove { position: absolute; top: 3px; right: 3px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 1px solid var(--c-danger-line); border-radius: 50%; background: color-mix(in srgb, var(--c-danger-tint2) 91%, transparent); color: var(--c-danger-bright); font-size: 15px; line-height: 1; }
|
||
.media-remove:hover { background: var(--c-danger-line); }
|
||
/* 素材缩略图右上角同时挂着「删除 ×」和 MediaThumb 的版本角标 vN,两者都贴着 right:4px,
|
||
角标会被 × 压住(审计里的 OVERLAP),这里把角标让到 × 的左侧 */
|
||
.media-tile :deep(.badge) { right: 25px }
|
||
.no-media { display: grid; place-items: center; min-height: 55px; margin-top: 10px; border: 1px dashed var(--c-line); border-radius: 7px; color: var(--c-text-dim); font-size: 10px; }
|
||
/* 音频行:外层一个框就够,控件自带的边框/背景在这里去掉,
|
||
更不能像以前那样把高度钉成 29px(内容 ~48px,会溢出压到下一行)。 */
|
||
/* 音色自检标记:紧贴音频控件右侧,宽度自适应,长文案靠 title 展开,
|
||
不能把播放键和进度条挤变形(这里以前就出过溢出)。 */
|
||
.timbre-flag { flex: 0 1 auto; min-width: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||
font-size: 10px; line-height: 1.6; padding: 1px 6px; border-radius: 999px; border: 1px solid transparent; }
|
||
.timbre-flag.ok { color: var(--c-success); border-color: var(--c-success-line); background: var(--c-success-tint) }
|
||
.timbre-flag.bad { color: var(--c-danger); border-color: var(--c-danger-line); background: var(--c-danger-tint) }
|
||
.timbre-flag.warn { color: var(--c-warn); border-color: var(--c-warn-line); background: var(--c-warn-tint) }
|
||
.audio-row { display: flex; align-items: center; gap: 4px; margin-top: 6px; padding: 2px 4px 2px 8px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-bg-input); }
|
||
.audio { flex: 1 1 auto; width: auto; min-width: 0; }
|
||
.audio-row :deep(.aplay) { border-color: transparent; background: transparent; padding: 5px 2px;
|
||
min-width: 110px }
|
||
.audio-row :deep(.aplay:hover), .audio-row :deep(.aplay.on) { border-color: transparent }
|
||
.row-media :deep(.aplay) { flex: 0 0 160px; width: 160px }
|
||
.ai-box { margin-top: 11px; padding: 10px; border: 1px solid var(--c-line-strong); border-radius: 9px; background: var(--c-bg-card); }
|
||
.ai-box b { font-size: 10.5px; }
|
||
.ai-box .muted { font-size: 10px; }
|
||
.ai-head { gap: 10px 14px; }
|
||
.ai-box label { font-size: 10px; }
|
||
.ai-box > .between { margin-bottom: 12px; }
|
||
.ai-box > .between { margin-bottom: 10px; }
|
||
.ai-box input, .ai-box :deep(.fselect-trigger) { padding-inline: 8px; font-size: 10px; }
|
||
.ai-box textarea { padding: 7px 8px; font-size: 10px; }
|
||
.provider-warning { display: block; margin-top: 7px; padding: 6px 7px; border: 1px solid var(--c-warn-line); border-radius: 5px; background: var(--c-bg-raised); color: var(--c-warn); font-size: 10px; line-height: 1.5; }
|
||
.voice-reference { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: end; margin: 7px 0; padding: 8px; border: 1px solid var(--c-line-strong); border-radius: 7px; background: var(--c-bg-input); }
|
||
.voice-reference small { grid-column: 1 / -1; color: var(--c-text-dim); font-size: 10px; line-height: 1.5; }
|
||
.gen-fields textarea { min-height: 54px; resize: vertical; line-height: 1.6; }
|
||
|
||
.ref-status { grid-column: 1 / -1; display: grid; gap: 4px; padding: 7px 8px; border-radius: 6px;
|
||
border: 1px solid var(--c-line-strong); background: var(--c-bg-card); }
|
||
.ref-status b { font-size: 10.5px; line-height: 1.5; font-weight: 600; }
|
||
.ref-status small { color: var(--c-text-faint); font-size: 9.5px; line-height: 1.5; }
|
||
.ref-status.warn { border-color: var(--c-warn-line); background: var(--c-warn-tint); }
|
||
.ref-status.warn b { color: var(--c-warn-bright); }
|
||
.ref-status.bad { border-color: var(--c-danger-line); background: var(--c-danger-tint); }
|
||
.ref-status.bad b { color: var(--c-danger); }
|
||
.reference-upload { justify-content: center; min-height: 31px; padding: 6px 9px; border: 1px solid var(--c-accent-line); border-radius: 6px; color: var(--c-success); font-size: 10px; text-align: center; cursor: pointer; }
|
||
.reference-upload input { display: none; }
|
||
.card-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: auto; padding-top: 11px; border-top: 1px solid var(--c-bg-active); }
|
||
.kind-select { width: 105px; }
|
||
.kind-select :deep(.fselect-trigger) { padding-inline: 7px; font-size: 10px; }
|
||
.danger { color: var(--c-danger); }
|
||
.stamp { margin-left: auto; min-width: 0; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
|
||
color: var(--c-text-dim); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; white-space: nowrap; }
|
||
/* 抽屉里的长文本(外观/提示词/备注)要留出可写空间,并允许用户自己继续拉高 */
|
||
.drawer-body textarea { min-height: 86px; resize: vertical; line-height: 1.65; }
|
||
.drawer-actions { position: sticky; z-index: 3; bottom: 0; display: flex; gap: 8px; margin: 22px -24px 0; padding: 14px 24px; border-top: 1px solid var(--c-line); background: var(--c-bg-shell); box-shadow: 0 -14px 26px var(--c-shade-2); }
|
||
.dialog-backdrop { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 24px; background: var(--c-scrim); backdrop-filter: blur(6px); }
|
||
.import-dialog { width: min(520px, 94vw); padding: 20px; border: 1px solid var(--c-line-strong); border-radius: 13px; background: linear-gradient(145deg, var(--c-bg-raised), var(--c-bg-shell) 60%); box-shadow: 0 30px 100px var(--c-shade-3); }
|
||
.import-dialog header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
|
||
.import-dialog h2 { margin: 5px 0 0; font-size: 20px; }
|
||
.import-subject { margin: 16px 0; padding: 11px 12px; border-left: 2px solid var(--c-accent-deep); background: var(--c-bg-card); color: var(--c-text-muted); font-size: 10px; line-height: 1.7; }
|
||
.import-subject strong { color: var(--c-accent-bright); }
|
||
.import-dialog label { display: flex; flex-direction: column; gap: 6px; color: var(--c-text-3); font-size: 10px; }
|
||
.import-dialog :deep(.fselect-trigger) { width: 100%; padding-inline: 11px; }
|
||
.import-dialog .banner { margin-top: 10px; }
|
||
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; }
|
||
/* ── AS-2 / AS-4:视图切换、工具栏、标签 chips、批量条、分页 ───────────── */
|
||
.views { display: flex; gap: 3px; flex-shrink: 0; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--c-bg-card); }
|
||
.view-btn { display: inline-flex; align-items: center; gap: 5px; min-height: 29px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--c-text-muted); font-size: 10px; white-space: nowrap; }
|
||
.view-btn i { font-style: normal; font-size: 12px; color: var(--c-text-dim); }
|
||
.view-btn:hover { background: var(--c-bg-panel); color: var(--c-text-2); }
|
||
.view-btn.on { background: var(--c-accent-fill); color: var(--c-on-accent); font-weight: 700; }
|
||
.view-btn.on i { color: inherit; }
|
||
.result-line { margin: 7px 0 0; color: var(--c-text-dim); font-size: 10px; }
|
||
/* 筛选栏只剩皮肤:布局(一行 / 行内标签 / 等高 / 下边距)全部来自 style.css 的 .ctlbar */
|
||
.toolbar { padding: 8px 10px; margin: 0 0 12px; border: 1px solid var(--c-bg-emphasis); border-radius: 10px; background: var(--c-bg-card); }
|
||
.toolbar :deep(.fselect-trigger) { padding-inline: 8px; font-size: 10px; }
|
||
.tag-chip { gap: 4px; border: 1px solid var(--c-line-strong); border-radius: 999px; background: var(--c-bg-raise); color: var(--c-text-3); }
|
||
.tag-chip em { color: var(--c-text-dim); font-style: normal; font-size: 10px; }
|
||
.tag-chip:hover { border-color: var(--c-accent-line); color: var(--c-text); }
|
||
.tag-chip.on { border-color: var(--c-accent-fill); background: var(--c-accent-fill); color: var(--c-on-accent); }
|
||
.tag-chip.on em { color: var(--c-on-accent); opacity: .72; }
|
||
.tag-chip.clear { border-style: dashed; color: var(--c-warn); }
|
||
.batchbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 9px 11px; border: 1px solid var(--c-accent-line); border-radius: 9px; background: var(--c-accent-tint); color: var(--c-text-2); font-size: 10px; }
|
||
.batchbar b { font-size: 10.5px; }
|
||
.batchbar .muted { font-size: 10px; }
|
||
|
||
/* ── AS-3:跨母版素材墙 ─────────────────────────────────────────────── */
|
||
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 9px; }
|
||
.wall-item { position: relative; display: flex; flex-direction: column; gap: 5px; padding: 7px 7px 8px; border: 1px solid var(--c-bg-emphasis); border-radius: 10px; background: var(--c-bg-card); }
|
||
.wall-item.picked { border-color: var(--c-accent-line); box-shadow: 0 0 0 1px var(--c-accent-tint); }
|
||
.wall-item .pick { left: 12px; top: 12px; }
|
||
.wall-meta b { display: block; overflow: hidden; color: var(--c-text-2); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
|
||
.wall-meta small { display: block; color: var(--c-text-dim); font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
|
||
.wall-meta .mono { font-size: 10px; }
|
||
/* ── AS-10:多选与列表视图 ─────────────────────────────────────────── */
|
||
.pick { position: absolute; left: 8px; top: 8px; z-index: 3; display: grid; place-items: center; width: 21px; height: 21px; margin: 0; padding: 0; border-radius: 6px; background: color-mix(in srgb, var(--c-bg-shell) 74%, transparent); }
|
||
.pick input { width: 13px; height: 13px; margin: 0; padding: 0; }
|
||
.asset-card.picked { border-color: var(--c-accent-line); box-shadow: 0 0 0 1px var(--c-accent-tint); }
|
||
.asset-card.dup { border-color: var(--c-warn-line); }
|
||
.asset-card .card-head { padding-left: 22px; }
|
||
.asset-list { display: flex; flex-direction: column; gap: 6px; }
|
||
.asset-row { display: grid; grid-template-columns: auto auto minmax(200px, 1fr) auto auto; align-items: center;
|
||
gap: 12px; padding: 9px 12px; border: 1px solid var(--c-bg-emphasis); border-radius: 10px;
|
||
background: linear-gradient(145deg, var(--c-bg-panel), var(--c-bg-sunken)); }
|
||
.asset-row.picked { border-color: var(--c-accent-line); box-shadow: 0 0 0 1px var(--c-accent-tint); }
|
||
.asset-row.dup { border-color: var(--c-warn-line); }
|
||
.pick-inline { flex-shrink: 0; margin: 0; }
|
||
.portrait-badge.sm { width: 30px; height: 34px; font-size: 14px; border-radius: 8px 8px 11px 11px; }
|
||
.row-main { min-width: 0; }
|
||
.row-name { font-size: 12.5px; }
|
||
.row-blurb { margin: 3px 0 4px; font-size: 10.5px; line-height: 1.45; color: var(--c-text-3);
|
||
display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
|
||
.row-main .tags { gap: 4px; flex-wrap: nowrap; overflow: hidden; }
|
||
.row-media { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
|
||
.media-tile.xs { position: relative; width: 58px; }
|
||
.row-actions { display: flex; flex-direction: column; gap: 4px; align-items: stretch; flex-shrink: 0; width: 132px; }
|
||
.row-actions-line { display: flex; gap: 4px; }
|
||
.row-actions-line > * { flex: 1; }
|
||
.row-actions .upload { justify-content: center; padding: 5px 6px; font-size: 10px; }
|
||
.link { padding: 0; border: 0; background: none; color: var(--c-success); font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer; }
|
||
.link-chip { padding: 2px 7px; font-size: 10px; }
|
||
.tag.used { background: var(--c-success-tint); color: var(--c-success); border-color: var(--c-success-line); }
|
||
/* ── AS-1:生成抽屉 ─────────────────────────────────────────────────── */
|
||
.gen-drawer { width: min(980px, calc(100vw - 64px)); }
|
||
/* 窄屏不要一屏全盖住:留出左侧上下文,抽屉内栅格自己会降列 */
|
||
@media (max-width:1180px){ .gen-drawer { width: min(760px, calc(100vw - 24px)); } }
|
||
.gen-drawer .drawer-body { display: flex; flex-direction: column; gap: 12px; }
|
||
.gen-drawer .ai-box { margin-top: 0; }
|
||
.gen-drawer .drawer-head p { color: var(--c-text-dim); font-size: 10px; }
|
||
.gen-current { display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid var(--c-line); border-radius: 9px; background: var(--c-bg-card); }
|
||
.gen-current b { color: var(--c-text-3); font-size: 10px; }
|
||
.gen-current-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; align-items: center; }
|
||
.gen-current-audio { display: flex; flex-direction: column; gap: 5px; }
|
||
.gen-current .audio { width: 100%; }
|
||
/* ── AS-10:批量确认框 ─────────────────────────────────────────────── */
|
||
.dialog-fields { display: grid; gap: 4px; }
|
||
.dialog-list { display: flex; flex-direction: column; gap: 5px; max-height: 258px; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
|
||
.dialog-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border: 1px solid var(--c-bg-emphasis); border-radius: 7px; background: var(--c-bg-card); }
|
||
.dialog-list b { font-size: 10px; }
|
||
.dialog-list .mono, .dialog-list .muted { color: var(--c-text-dim); font-size: 10px; }
|
||
.dialog-more { margin: 7px 0 0; font-size: 10px; }
|
||
.import-dialog .dialog-fields label input { width: 100%; padding: 9px 10px; }
|
||
|
||
@media (max-width: 1180px) {
|
||
.constellation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.metric.target { grid-column: 1 / -1; }
|
||
.asset-grid { grid-template-columns: 1fr; }
|
||
}
|
||
@media (max-width: 820px) {
|
||
.hero { flex-direction: column; }
|
||
.constellation { grid-template-columns: 1fr; }
|
||
.metric.target { grid-column: auto; }
|
||
.workspace { grid-template-columns: 1fr; }
|
||
.type-rail { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||
.rail-caption { grid-column: 1 / -1; }
|
||
.catalog-head { flex-direction: column; }
|
||
.drawer { width: 100vw; }
|
||
}
|
||
|
||
@media (max-width: 520px) {
|
||
.views { width: 100%; }
|
||
.view-btn { flex: 1; justify-content: center; }
|
||
.tool, .tool :deep(.fselect) { width: 100%; min-width: 0; }
|
||
.wall { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
|
||
.media-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||
.voice-reference { grid-template-columns: 1fr; }
|
||
.voice-reference small { grid-column: auto; }
|
||
}
|
||
</style>
|