feat(ai): 自由创作视频生成全量移植(/free-create)——Seedance 文/图生视频+按时长计费+人物素材库

后端:
- free_video.py: 提交/轮询/收藏/软删全链路,复用 AITask(新增 is_deleted/is_favorited, migration 0022)
- video_pricing.py: 按时长 token 计费(×1.10 buffer+clamp); video_errors.py 错误归一; media_probe.py 时长探测
- catalog/volcano: Seedance free-video 模型接入+seed(migration 0023)
- 素材库: FreeAssetGroup/FreeAsset(火山 Assets API 引用登记, migration 0009)+ 上传/轮询/删除接口
- settings: FREE_VIDEO_MAX_CONCURRENT 团队并发闸(默认3); CELERY_TASK_ALWAYS_EAGER 本地联调开关(生产恒关)
- 测试: test_free_video.py 新增; billing/products/projects tests 配套调整

前端:
- /free-create 页面+components/free-create/ 全套(输入栏/@mention 素材引用/生成卡/视频详情弹窗/素材库弹窗)
- api.ts/types.ts 扩展 free-video 与 free-assets 接口; 路由/侧边栏入口接入

bug/: 测试清单 (11)(12) 与截图归档

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
zyc
2026-07-06 10:58:36 +08:00
co-authored by Claude Fable 5
parent 94202e7bce
commit c5f7eb2acc
45 changed files with 5186 additions and 21 deletions
+568
View File
@@ -0,0 +1,568 @@
/* 自由创作页(free-create)· 私有样式,全部 .fc- 前缀。
颜色/圆角/间距全部走 design-restraint token(§8 Don't List:禁裸 hex / >12px 圆角 / 灰阴影)。 */
.fc-page { display: flex; flex-direction: column; min-height: calc(100vh - 64px - 120px); }
/* —— 任务流 —— */
.fc-feed-wrap { flex: 1; padding-bottom: 24px; }
.fc-feed {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 14px;
align-items: start;
}
.fc-loading, .fc-sentinel {
padding: 28px 0;
text-align: center;
font-size: 11px;
letter-spacing: 0.04em;
color: var(--black-alpha-48);
}
.fc-empty { margin: 48px auto; }
/* —— 任务卡 —— */
.fc-card {
background: var(--surface);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
overflow: hidden;
display: flex;
flex-direction: column;
transition: border-color 0.2s;
}
.fc-card.done { cursor: pointer; }
.fc-card.done:hover { border-color: var(--black-alpha-48); }
.fc-card-media {
position: relative;
background: var(--background-base);
max-height: 420px;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.fc-card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fc-card-generating {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
background: linear-gradient(110deg, var(--black-alpha-4) 30%, var(--black-alpha-7) 50%, var(--black-alpha-4) 70%);
background-size: 200% 100%;
animation: fc-shimmer 1.6s linear infinite;
font-size: 11px;
color: var(--black-alpha-56);
}
@keyframes fc-shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
.fc-progress {
width: 60%;
height: 4px;
border-radius: 2px;
background: var(--black-alpha-12);
overflow: hidden;
}
.fc-progress span { display: block; height: 100%; border-radius: 2px; background: var(--heat); transition: width 0.6s ease; }
.fc-card-failed {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
padding: 16px;
text-align: center;
}
.fc-card-failed p { font-size: 12px; line-height: 1.65; color: var(--black-alpha-64); max-width: 90%; margin: 0; }
.fc-card-hover {
position: absolute;
top: 10px;
right: 10px;
display: flex;
gap: 6px;
opacity: 0;
transition: opacity 0.2s;
}
.fc-card:hover .fc-card-hover { opacity: 1; }
.fc-hover-btn {
width: 30px;
height: 30px;
border-radius: var(--r-md);
border: 1px solid var(--border-faint);
background: var(--surface);
color: var(--black-alpha-56);
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background 0.2s, color 0.2s;
}
.fc-hover-btn:hover { background: var(--black-alpha-4); color: var(--accent-black); }
.fc-hover-btn.fav { color: var(--heat); }
.fc-hover-btn.danger:hover { color: var(--accent-crimson); }
.fc-card-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.fc-card-prompt {
font-size: 13px;
color: var(--accent-black);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.fc-card-sub { font-size: 11px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
/* —— 底部输入条 —— */
.fc-inputbar {
position: sticky;
bottom: 16px;
z-index: 5;
background: var(--surface-raised);
border: 1px solid var(--border-muted);
border-radius: var(--r-md);
padding: 14px 16px 12px;
display: flex;
flex-direction: column;
gap: 10px;
box-shadow: var(--shadow-floating);
}
.fc-inputbar.drag { border-color: var(--heat-40); }
.fc-drop-hint {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background: var(--heat-12);
border-radius: inherit;
color: var(--heat);
font-size: 12px;
pointer-events: none;
}
.fc-input-top { display: flex; gap: 12px; align-items: flex-start; }
/* 参考素材条(universal) */
.fc-refs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: 300px; }
.fc-add {
width: 56px;
height: 56px;
border-radius: var(--r-md);
border: 1px dashed var(--black-alpha-24);
background: var(--background-base);
color: var(--black-alpha-56);
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 2px;
cursor: pointer;
font-size: 12px;
transition: border-color 0.2s, color 0.2s;
}
.fc-add:hover { border-color: var(--heat-40); color: var(--heat); }
.fc-ref {
position: relative;
width: 56px;
height: 56px;
border-radius: var(--r-md);
border: 1px solid var(--border-faint);
overflow: hidden;
background: var(--background-base);
display: flex;
align-items: center;
justify-content: center;
}
.fc-ref img { width: 100%; height: 100%; object-fit: cover; }
.fc-ref.uploading img { opacity: 0.4; }
.fc-ref .spinner { position: absolute; }
.fc-ref-kind { font-size: 11px; color: var(--black-alpha-48); }
.fc-ref-dur {
position: absolute;
right: 3px;
bottom: 3px;
font-size: 8.5px;
padding: 1px 4px;
border-radius: var(--r-sm);
background: var(--black-alpha-56);
color: var(--surface);
}
.fc-ref-label {
position: absolute;
left: 0;
right: 0;
bottom: 0;
font-size: 9px;
padding: 1px 4px;
background: var(--black-alpha-56);
color: var(--surface);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.fc-ref-x {
position: absolute;
top: 2px;
right: 2px;
width: 16px;
height: 16px;
border-radius: 999px;
border: none;
background: var(--black-alpha-56);
color: var(--surface);
font-size: 11px;
line-height: 1;
cursor: pointer;
display: none;
align-items: center;
justify-content: center;
}
.fc-ref:hover .fc-ref-x, .fc-kf-slot:hover .fc-ref-x { display: inline-flex; }
/* 首尾帧(keyframe) */
.fc-keyframes { display: flex; align-items: center; gap: 8px; }
.fc-kf-slot {
position: relative;
width: 88px;
height: 66px;
border-radius: var(--r-md);
border: 1px dashed var(--black-alpha-24);
background: var(--background-base);
color: var(--black-alpha-56);
display: inline-flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
cursor: pointer;
font-size: 11px;
overflow: hidden;
transition: border-color 0.2s, color 0.2s;
}
.fc-kf-slot:hover { border-color: var(--heat-40); color: var(--heat); }
.fc-kf-slot.filled { border-style: solid; border-color: var(--border-faint); cursor: default; }
.fc-kf-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fc-kf-slot .spinner { position: absolute; }
.fc-kf-tag {
position: absolute;
left: 3px;
top: 3px;
font-size: 8.5px;
padding: 1px 4px;
border-radius: var(--r-sm);
background: var(--black-alpha-56);
color: var(--surface);
}
.fc-kf-arrow { color: var(--black-alpha-48); font-size: 13px; }
/* 提示词编辑器(contenteditable) */
.fc-prompt-wrap { flex: 1; min-width: 0; }
.fc-prompt {
min-height: 64px;
max-height: 160px;
overflow-y: auto;
font-size: 13px;
line-height: 1.65;
color: var(--accent-black);
outline: none;
padding: 6px 2px;
word-break: break-word;
}
.fc-prompt:empty::before { content: attr(data-placeholder); color: var(--black-alpha-48); pointer-events: none; }
.fc-mention {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 1px 6px;
margin: 0 1px;
border-radius: var(--r-sm);
background: var(--heat-12);
border: 1px solid var(--heat-20);
color: var(--heat);
font-size: 12px;
vertical-align: middle;
user-select: none;
white-space: nowrap;
}
.fc-mention img { width: 16px; height: 16px; border-radius: 3px; object-fit: cover; }
/* @ 候选菜单(fixed,朝上弹) */
.fc-mention-menu { position: fixed; z-index: 300; transform: translateY(-100%); }
.fc-mention-menu-inner {
min-width: 220px;
max-width: 280px;
max-height: 260px;
overflow-y: auto;
background: var(--surface-raised);
border: 1px solid var(--border-muted);
border-radius: var(--r-md);
box-shadow: var(--shadow-floating);
padding: 6px;
}
.fc-mention-menu-head { font-size: 11px; letter-spacing: 0.04em; color: var(--black-alpha-48); padding: 4px 8px; }
.fc-mention-item {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
padding: 6px 8px;
border: none;
border-radius: var(--r-sm);
background: transparent;
cursor: pointer;
font-size: 12.5px;
color: var(--accent-black);
text-align: left;
}
.fc-mention-item.active { background: var(--black-alpha-4); }
.fc-mention-item img { width: 24px; height: 24px; border-radius: var(--r-sm); object-fit: cover; }
.fc-mention-ph { width: 24px; height: 24px; border-radius: var(--r-sm); background: var(--black-alpha-7); }
.fc-mention-item .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-mention-item .lbl.lib { color: var(--black-alpha-56); }
/* —— 工具栏 —— */
.fc-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border-faint); padding-top: 10px; }
.fc-toolbar-l { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fc-toolbar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.fc-estimate { font-size: 11px; letter-spacing: 0.04em; color: var(--black-alpha-48); font-variant-numeric: tabular-nums; }
.fc-dd { position: relative; }
.fc-dd-btn {
height: 28px;
padding: 0 10px;
border-radius: var(--r-md);
border: 1px solid var(--border-faint);
background: var(--surface);
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 12px;
color: var(--accent-black);
cursor: pointer;
transition: background 0.2s, border-color 0.2s;
}
.fc-dd-btn:hover { background: var(--black-alpha-4); border-color: var(--black-alpha-24); }
.fc-dd-btn:disabled { color: var(--black-alpha-32); cursor: not-allowed; }
.fc-dd-btn svg { color: var(--black-alpha-48); transition: transform 0.2s; }
.fc-dd.open .fc-dd-btn svg { transform: rotate(180deg); }
.fc-dd-lbl { font-size: 10.5px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-dd-val { font-weight: 500; }
.fc-dd-menu {
position: absolute;
bottom: calc(100% + 6px);
left: 0;
z-index: 60;
min-width: 180px;
background: var(--surface-raised);
border: 1px solid var(--border-muted);
border-radius: var(--r-md);
box-shadow: var(--shadow-floating);
padding: 6px;
}
.fc-dd-item {
display: flex;
flex-direction: column;
gap: 2px;
width: 100%;
padding: 7px 10px;
border: none;
border-radius: var(--r-sm);
background: transparent;
cursor: pointer;
text-align: left;
}
.fc-dd-item:hover { background: var(--black-alpha-4); }
.fc-dd-item.selected { background: var(--heat-12); }
.fc-dd-item.selected .ti { color: var(--heat); }
.fc-dd-item.disabled { cursor: not-allowed; }
.fc-dd-item.disabled .ti, .fc-dd-item.disabled .de { color: var(--black-alpha-32); }
.fc-dd-item .ti { font-size: 12.5px; font-weight: 500; color: var(--accent-black); }
.fc-dd-item .de { font-size: 10.5px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-seed-menu { min-width: 220px; padding: 10px; }
.fc-seed-row { display: flex; gap: 8px; align-items: center; }
.fc-seed-row .input { height: 30px; flex: 1; }
.fc-seed-hint { margin-top: 6px; font-size: 10.5px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-fav-on { color: var(--heat); }
/* —— 全屏播放器 —— */
.fc-player-bg {
position: fixed;
inset: 0;
z-index: 200;
background: rgba(21, 20, 15, 0.72);
backdrop-filter: blur(8px);
display: flex;
align-items: center;
justify-content: center;
padding: 40px 72px;
}
.fc-player-x {
position: absolute;
top: 20px;
right: 24px;
width: 36px;
height: 36px;
border-radius: var(--r-md);
border: none;
background: var(--black-alpha-24);
color: var(--surface);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
}
.fc-player-nav {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 40px;
height: 40px;
border-radius: 999px;
border: none;
background: var(--black-alpha-24);
color: var(--surface);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
z-index: 2;
}
.fc-player-nav.prev { left: 20px; }
.fc-player-nav.next { right: 20px; }
.fc-player-nav:hover, .fc-player-x:hover { background: var(--black-alpha-48); }
.fc-player {
width: min(920px, 100%);
max-height: 100%;
display: flex;
flex-direction: column;
gap: 10px;
}
.fc-player-stage {
max-height: 62vh;
margin: 0 auto;
max-width: 100%;
background: #000; /* 视频画布留黑,行业惯例,非界面色 */
border-radius: var(--r-md);
overflow: hidden;
cursor: pointer;
}
.fc-player-stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.fc-player-controls {
display: flex;
align-items: center;
gap: 10px;
background: var(--surface-raised);
border-radius: var(--r-md);
padding: 8px 12px;
}
.fc-ctl {
width: 30px;
height: 30px;
border: none;
border-radius: var(--r-md);
background: transparent;
color: var(--black-alpha-56);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
}
.fc-ctl:hover { background: var(--black-alpha-4); color: var(--accent-black); }
.fc-time { font-size: 11px; color: var(--black-alpha-56); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-seek { flex: 1; accent-color: var(--heat); }
.fc-vol { width: 72px; accent-color: var(--heat); }
.fc-player-info {
background: var(--surface-raised);
border-radius: var(--r-md);
padding: 12px 14px;
display: flex;
flex-direction: column;
gap: 6px;
}
.fc-player-prompt { font-size: 13px; line-height: 1.65; color: var(--accent-black); max-height: 72px; overflow-y: auto; }
.fc-player-sub { font-size: 11px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-player-warn { font-size: 11px; color: var(--accent-honey); }
.fc-player-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
/* —— 素材库弹窗 —— */
.fc-lib-modal { width: min(720px, 92vw); }
.fc-lib-body { max-height: 60vh; overflow-y: auto; }
.fc-lib-back {
display: inline-flex;
align-items: center;
gap: 4px;
border: none;
background: transparent;
font-size: inherit;
font-weight: inherit;
color: inherit;
cursor: pointer;
padding: 0;
}
.fc-lib-back:hover { color: var(--heat); }
.fc-lib-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.fc-lib-hint { font-size: 11px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-lib-create { display: flex; gap: 8px; align-items: center; flex: 1; }
.fc-lib-create .input { height: 30px; flex: 1; max-width: 260px; }
.fc-lib-groups, .fc-lib-assets {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
gap: 12px;
}
.fc-lib-group, .fc-lib-asset {
position: relative;
background: var(--background-lighter);
border: 1px solid var(--border-faint);
border-radius: var(--r-md);
padding: 10px;
display: flex;
flex-direction: column;
gap: 6px;
cursor: pointer;
transition: background 0.2s, border-color 0.2s;
}
.fc-lib-group:hover, .fc-lib-asset.pickable:hover { background: var(--surface); border-color: var(--heat-40); }
.fc-lib-asset:not(.pickable) { cursor: default; }
.fc-lib-thumb {
position: relative;
aspect-ratio: 1;
border-radius: var(--r-sm);
background: var(--black-alpha-4);
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
color: var(--black-alpha-48);
}
.fc-lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fc-lib-name { font-size: 12.5px; font-weight: 500; color: var(--accent-black); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-lib-count { font-size: 10.5px; letter-spacing: 0.04em; color: var(--black-alpha-48); }
.fc-lib-err { font-size: 10.5px; color: var(--accent-crimson); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-lib-ops { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.fc-lib-group:hover .fc-lib-ops, .fc-lib-asset:hover .fc-lib-ops { opacity: 1; }
.fc-lib-ops button {
width: 22px;
height: 22px;
border: none;
border-radius: var(--r-sm);
background: var(--black-alpha-56);
color: var(--surface);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
}
.fc-lib-ops button:hover { background: var(--accent-black); }
/* 移动端:输入条参数换行、任务流单列 */
@media (max-width: 720px) {
.fc-feed { grid-template-columns: 1fr; }
.fc-input-top { flex-direction: column; }
.fc-refs { max-width: none; }
.fc-player-bg { padding: 16px; }
.fc-player-nav.prev { left: 6px; }
.fc-player-nav.next { right: 6px; }
}