fix(experience-center): 统一图像与视频生成界面并修复参数显示

对齐表单、预览与任务区,跟随系统主题色,修复图片尺寸选择和视频高级参数显示。已通过本地浏览器验收、Lint、UI 审计和单测;未做生产测试。
This commit is contained in:
zhanjunhao
2026-11-20 18:30:13 +08:00
parent b7b19d01f6
commit 41ce8b5e58
17 changed files with 1819 additions and 1812 deletions
@@ -7,17 +7,21 @@
--vip-muted: var(--text-secondary);
--vip-line: var(--border-subtle);
--vip-surface: var(--surface-card);
--vip-accent: var(--ui-color-primary);
--vip-tint: color-mix(in srgb, var(--ui-color-primary) 10%, transparent);
--vip-accent: var(--brand-accent);
--vip-tint: var(--brand-selection-bg);
--vip-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
--vip-danger: var(--ui-color-danger);
--vip-warning: var(--ui-color-warning);
--vip-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
--vip-ring: var(--brand-accent);
position: relative;
height: 100%;
overflow: auto;
padding: 16px;
display: flex;
flex-direction: column;
width: 100%;
max-height: 100%;
min-height: 0;
border: 1px solid var(--vip-line);
border-radius: 12px;
background: var(--vip-surface);
}
.video-input-panel button:focus-visible,
@@ -26,36 +30,35 @@
outline-offset: 2px;
}
.vip-collapse-row {
display: flex;
justify-content: flex-end;
margin-bottom: 12px;
.vip-fields {
flex: 1;
min-height: 0;
padding: 12px;
overflow: auto;
scrollbar-width: thin;
}
.vip-collapse-btn {
color: var(--vip-accent) !important;
.vip-fields:not([hidden]) {
display: grid;
align-content: start;
grid-auto-rows: max-content;
gap: 12px;
}
.vip-expand-fab {
position: fixed;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: 100;
.vip-fields[hidden] {
display: none;
}
.vip-expand-fab .ant-btn {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
color: var(--ui-color-primary);
.vip-prompt textarea::placeholder,
textarea.vip-prompt::placeholder {
color: var(--vip-muted);
}
.vip-card {
margin-bottom: 12px;
padding: 14px 16px;
padding: 12px;
border: 1px solid var(--vip-line);
border-radius: 12px;
background: var(--vip-surface);
border-radius: 10px;
background: var(--vip-fill);
min-width: 0;
}
@@ -79,7 +82,7 @@
height: 26px;
border-radius: 8px;
background: var(--vip-tint);
color: var(--vip-accent);
color: var(--brand-selection-text);
}
.vip-card-extra {
@@ -158,6 +161,13 @@
color: var(--vip-danger);
}
.video-input-panel .cp-option-group {
--cp-accent: var(--brand-selection-text);
--cp-accent-tint: var(--brand-selection-bg);
--cp-accent-line: color-mix(in srgb, var(--brand-accent) 45%, transparent);
--cp-ring: var(--brand-accent);
}
.vip-mode-option {
display: inline-flex;
align-items: center;
@@ -198,8 +208,8 @@
.vip-advanced {
border: 1px solid var(--vip-line);
border-radius: 12px;
background: var(--vip-surface);
border-radius: 10px;
background: var(--vip-fill);
overflow: hidden;
}
@@ -1,8 +1,8 @@
import {
ChevronRight as ActionChevronRight,
ChevronLeft as ActionChevronLeft,
ChevronDown as ActionChevronDown,
ChevronUp as ActionChevronUp,
} from '@/components/common/icons/ActionIcons';
import React from 'react';
import React, { useId } from 'react';
import {
Button,
Collapse,
@@ -76,13 +76,9 @@ const formatModelPrice = (t, model, resolution) => {
return unit ? `${amount}${t(unit)}` : amount;
};
const VideoInputPanel = ({
creation,
onCollapse,
collapsed,
collapsible = true,
}) => {
const VideoInputPanel = ({ creation, onCollapse, collapsed, scrollRef }) => {
const { t } = useTranslation();
const fieldsId = useId();
const {
formData,
setFormData,
@@ -109,20 +105,6 @@ const VideoInputPanel = ({
setFormData((prev) => ({ ...prev, [field]: value }));
};
// 单列(手机)布局不提供折叠:没有相邻面板可以让位,收起只会留下一片空白,
// 而唯一的恢复入口是一个浮在屏幕左侧垂直中央的裸箭头。
if (collapsed && collapsible) {
return (
<div className='vip-expand-fab'>
<Button
icon={<ActionChevronRight size={20} />}
onClick={onCollapse}
aria-label={t('展开')}
/>
</div>
);
}
const advancedParams = visibleParams.filter(
(p) => p.placement === 'advanced',
);
@@ -248,181 +230,200 @@ const VideoInputPanel = ({
entry.labelIndex ? `${t(entry.label)} ${entry.labelIndex}` : t(entry.label);
return (
<div className='video-input-panel'>
{collapsible && (
<div className='vip-collapse-row'>
<Button
icon={<ActionChevronLeft size={18} />}
onClick={onCollapse}
size='small'
type='tertiary'
className='vip-collapse-btn'
aria-label={t('收起')}
/>
<section className='video-input-panel'>
<header className='video-panel-header'>
<div className='video-panel-heading'>
<SlidersHorizontal size={17} aria-hidden='true' />
<h2>{t('参数设置')}</h2>
</div>
)}
<Section icon={Wand2} title={t('选择模型')}>
{renderModelSection()}
</Section>
{selectedModel && modeOptions.length > 0 ? (
<Section icon={Layers} title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Film;
return (
<span className='vip-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
<Button
icon={
collapsed ? (
<ActionChevronDown size={16} />
) : (
<ActionChevronUp size={16} />
)
}
onClick={onCollapse}
size='small'
type='tertiary'
aria-label={collapsed ? t('展开创作台') : t('收起创作台')}
aria-expanded={!collapsed}
aria-controls={fieldsId}
/>
</header>
<div
id={fieldsId}
hidden={collapsed}
ref={scrollRef}
className='vip-fields app-scrollbar'
>
<Section icon={Wand2} title={t('选择模型')}>
{renderModelSection()}
</Section>
) : null}
{selectedModel && imageSlots.length > 0 ? (
<Section icon={ImageIcon} title={t('参考图片')}>
<div className='vip-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active ? slot.status || 'ready' : 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`${entry.key}-${entry.index ?? 0}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.key, entry.index, file)}
onRemove={() => removeImage(entry.key, entry.index)}
onRetry={() => retryImage(entry.key, entry.index, slot)}
disabledReason={
!cosEnabled && !slot
? t('对象存储(COS)未开启,暂不支持上传图片')
{selectedModel && modeOptions.length > 0 ? (
<Section icon={Layers} title={t('生成方式')}>
<OptionGroup
options={modeOptions.map((o) => o.mode)}
value={formData.mode}
onChange={setMode}
ariaLabel={t('生成方式')}
optionDisabledReasons={Object.fromEntries(
modeOptions
.filter((o) => o.disabled)
.map((o) => [o.mode, t(o.reason || '当前不可用')]),
)}
renderOption={(mode) => {
const Icon = MODE_ICONS[mode] || Film;
return (
<span className='vip-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{selectedModel && imageSlots.length > 0 ? (
<Section icon={ImageIcon} title={t('参考图片')}>
<div className='vip-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
const value = slot
? {
previewUrl: slot.previewUrl,
status: entry.active ? slot.status || 'ready' : 'unused',
error: slot.error,
}
: null;
return (
<ImageSlot
key={`${entry.key}-${entry.index ?? 0}-${slot?.id || 'empty'}`}
label={slotLabel(entry)}
value={value}
onPick={(file) => pickImage(entry.key, entry.index, file)}
onRemove={() => removeImage(entry.key, entry.index)}
onRetry={() => retryImage(entry.key, entry.index, slot)}
disabledReason={
!cosEnabled && !slot
? t('对象存储(COS)未开启,暂不支持上传图片')
: ''
}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='vip-muted vip-slot-note' role='note'>
{t('置灰的图片当前不会提交,切回支持的模型或模式后自动恢复')}
</div>
) : null}
{firstFrameSlot ? (
<div className='vip-portrait-row'>
<PortraitAssetPicker
onSelect={selectPortraitAsset}
selectedAssetId={
firstFrameRef.startsWith('asset://')
? firstFrameRef.slice('asset://'.length)
: ''
}
onClearSelection={clearPortraitAsset}
/>
);
})}
</div>
{hasUnusedImage ? (
<div className='vip-muted vip-slot-note' role='note'>
{t('置灰的图片当前不会提交,切回支持的模型或模式后自动恢复')}
</div>
) : null}
{firstFrameSlot ? (
<div className='vip-portrait-row'>
<PortraitAssetPicker
onSelect={selectPortraitAsset}
selectedAssetId={
firstFrameRef.startsWith('asset://')
? firstFrameRef.slice('asset://'.length)
: ''
}
onClearSelection={clearPortraitAsset}
/>
{formData.images?.first_frame?.identityType === 'real_person' ? (
<Tag color='green' size='small'>
{t('真人人像')}
</Tag>
) : null}
</div>
) : null}
</Section>
) : null}
{formData.images?.first_frame?.identityType ===
'real_person' ? (
<Tag color='green' size='small'>
{t('真人人像')}
</Tag>
) : null}
</div>
) : null}
</Section>
) : null}
<Section icon={Sparkles} title={t('场景模板')}>
<Select
placeholder={t('选择场景模板(可选)')}
value={formData.selectedTemplate}
onChange={(value) => updateField('selectedTemplate', value)}
style={{ width: '100%' }}
showClear
>
{PROMPT_TEMPLATES.map((template, index) => (
<Select.Option key={index} value={template.prompt}>
{t(template.label)}
</Select.Option>
))}
</Select>
{formData.selectedTemplate && (
<div className='vip-template-preview'>
<Text type='tertiary' size='small'>
{t('模板内容')}: {formData.selectedTemplate}
</Text>
</div>
)}
</Section>
<Section icon={Video} title={t('提示词')}>
<TextArea
placeholder={t(
'描述你想要生成的视频内容,例如:一只可爱的猫咪在草地上玩耍',
<Section icon={Sparkles} title={t('场景模板')}>
<Select
aria-label={t('场景模板')}
placeholder={t('选择场景模板(可选)')}
value={formData.selectedTemplate || undefined}
onChange={(value) => updateField('selectedTemplate', value)}
style={{ width: '100%' }}
showClear
>
{PROMPT_TEMPLATES.map((template, index) => (
<Select.Option key={index} value={template.prompt}>
{t(template.label)}
</Select.Option>
))}
</Select>
{formData.selectedTemplate && (
<div className='vip-template-preview'>
<Text type='tertiary' size='small'>
{t('模板内容')}: {formData.selectedTemplate}
</Text>
</div>
)}
value={formData.prompt}
onChange={(value) => updateField('prompt', value)}
autosize={{ minRows: 4, maxRows: 8 }}
maxLength={2000}
showClear
/>
<Text type='tertiary' size='small' className='vip-counter'>
{formData.prompt?.length || 0} / 2000
</Text>
</Section>
{selectedModel && dockParams.length > 0 ? (
<Section icon={SlidersHorizontal} title={t('生成参数')}>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='dock'
constraints={constraints}
/>
</Section>
) : null}
{selectedModel && advancedParams.length > 0 ? (
<div className='vip-advanced'>
<Collapse defaultActiveKey={[]}>
<Collapse.Panel
itemKey='advanced'
header={
<div className='vip-card-head' style={{ margin: 0 }}>
<span className='vip-card-icon' aria-hidden='true'>
<Settings2 size={14} />
</span>
<span>{t('高级参数')}</span>
</div>
}
>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
constraints={constraints}
/>
</Collapse.Panel>
</Collapse>
</div>
) : null}
</div>
<Section icon={Video} title={t('提示词')}>
<TextArea
aria-label={t('提示词')}
placeholder={t(
'描述你想要生成的视频内容,例如:一只可爱的猫咪在草地上玩耍',
)}
value={formData.prompt}
onChange={(value) => updateField('prompt', value)}
autosize={{ minRows: 4, maxRows: 8 }}
maxLength={2000}
showClear
className='vip-prompt'
/>
<Text type='tertiary' size='small' className='vip-counter'>
{formData.prompt?.length || 0} / 2000
</Text>
</Section>
{selectedModel && dockParams.length > 0 ? (
<Section icon={SlidersHorizontal} title={t('生成参数')}>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='dock'
constraints={constraints}
/>
</Section>
) : null}
{selectedModel && advancedParams.length > 0 ? (
<div className='vip-advanced'>
<Collapse defaultActiveKey={[]}>
<Collapse.Panel
itemKey='advanced'
header={
<div className='vip-card-head' style={{ margin: 0 }}>
<span className='vip-card-icon' aria-hidden='true'>
<Settings2 size={14} />
</span>
<span>{t('高级参数')}</span>
</div>
}
>
<ParamRenderer
params={visibleParams}
values={formData.params}
onChange={updateParam}
placement='advanced'
constraints={constraints}
/>
</Collapse.Panel>
</Collapse>
</div>
) : null}
</div>
</section>
);
};
@@ -1,66 +1,107 @@
/* 视频预览面板 - 电影感动画背景(增强版) */
/* 动态光晕1 - 缓慢飘动 */
@keyframes videoPreviewFloat1 {
0%,
100% {
transform: translate3d(0, 0, 0);
}
25% {
transform: translate3d(50px, -30px, 0);
}
50% {
transform: translate3d(80px, 20px, 0);
}
75% {
transform: translate3d(30px, 50px, 0);
}
.video-preview-panel.ant-card {
display: flex;
flex-direction: column;
min-width: 0;
min-height: 0;
border-color: var(--border-subtle);
border-radius: 12px;
background: var(--surface-card);
}
/* 动态光晕2 - 反向飘动 */
@keyframes videoPreviewFloat2 {
0%,
100% {
transform: translate3d(0, 0, 0);
}
25% {
transform: translate3d(-60px, 40px, 0);
}
50% {
transform: translate3d(-30px, -50px, 0);
}
75% {
transform: translate3d(-70px, -20px, 0);
}
.video-preview-panel > .ant-card-body {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
min-height: 0;
padding: 0;
}
/* 脉动效果 */
@keyframes videoPreviewPulse {
0%,
100% {
opacity: 0.4;
transform: scale(1);
.video-preview-header {
flex-wrap: wrap;
}
.video-preview-actions {
display: flex;
flex: 1;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 8px 12px;
min-width: 0;
}
.video-preview-actions .ant-typography {
overflow-wrap: anywhere;
}
.video-generate-button {
font-weight: 600;
}
.video-preview-stage {
flex: 1;
min-height: 0;
overflow: auto;
border-end-start-radius: 11px;
border-end-end-radius: 11px;
}
.video-preview-empty {
--vp-stage: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
display: grid;
align-content: center;
justify-items: center;
gap: 10px;
height: calc(100% - 32px);
min-height: 180px;
margin: 16px;
padding: 24px;
border: 1px dashed var(--border-subtle);
border-radius: 10px;
background: var(--vp-stage);
text-align: center;
}
.video-preview-empty-icon {
width: 56px;
height: 56px;
margin-bottom: 4px;
}
.video-preview-empty h3 {
margin: 0;
color: var(--text-primary);
font-size: 18px;
font-weight: 650;
}
.video-preview-empty p {
margin: 0;
color: var(--text-secondary);
font-size: 13px;
line-height: 20px;
}
@media (max-width: 767px) {
.video-preview-header {
align-items: flex-start;
flex-direction: column;
}
50% {
opacity: 1;
transform: scale(1.1);
.video-preview-actions {
justify-content: flex-start;
width: 100%;
}
.video-help-button {
margin-inline-start: auto;
}
.video-preview-empty {
height: auto;
min-height: 190px;
margin: 12px;
padding: 16px;
}
}
/* 动画类 - GPU 加速 */
.video-preview-glow1 {
animation: videoPreviewFloat1 12s ease-in-out infinite;
will-change: transform;
backface-visibility: hidden;
}
.video-preview-glow2 {
animation: videoPreviewFloat2 15s ease-in-out infinite;
will-change: transform;
backface-visibility: hidden;
}
.video-preview-glow3 {
animation: videoPreviewPulse 6s ease-in-out infinite;
will-change: opacity, transform;
}
@@ -91,7 +91,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '600px',
buttonSize: 'large',
titleSize: 4,
iconSize: 64,
progressWidth: 120,
};
}
@@ -102,7 +101,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '500px',
buttonSize: 'default',
titleSize: 5,
iconSize: 56,
progressWidth: 100,
};
}
@@ -113,7 +111,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '400px',
buttonSize: 'default',
titleSize: 5,
iconSize: 48,
progressWidth: 90,
};
}
@@ -124,7 +121,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '350px',
buttonSize: 'small',
titleSize: 6,
iconSize: 40,
progressWidth: 80,
};
};
@@ -241,28 +237,8 @@ const VideoPreviewPanel = ({
const renderTopBar = () => {
// 优先显示从任务列表选择的任务
const displayTask = selectedTaskForPlay || currentTask;
const normalizedStatus = normalizeVideoTaskStatus(displayTask?.status);
const isCompleted = normalizedStatus === 'success';
// 检查是否有视频URL
let _hasVideo = false;
if (displayTask) {
const videoUrl = getVideoURLFromDetail(displayTask);
_hasVideo = isCompleted && !!videoUrl;
}
return (
<div
style={{
padding: windowWidth > 768 ? '16px 20px' : '12px 16px',
display: 'flex',
alignItems: 'center',
gap: '12px',
backgroundColor: 'var(--ui-color-bg-1)',
borderBottom: '1px solid var(--ui-color-border)',
flexShrink: 0,
}}
>
<div className='video-preview-actions'>
{needTopUp ? (
<Button
type='warning'
@@ -283,14 +259,7 @@ const VideoPreviewPanel = ({
onClick={isButtonDisabled ? undefined : handleGenerate}
disabled={isButtonDisabled || submitting}
loading={submitting}
style={{
fontWeight: 600,
background:
isButtonDisabled || submitting
? undefined
: 'linear-gradient(135deg, var(--ui-color-primary) 0%, var(--ui-color-primary-active, var(--ui-color-primary)) 100%)',
border: 'none',
}}
className='video-generate-button'
>
{submitting
? t('提交中...')
@@ -344,8 +313,6 @@ const VideoPreviewPanel = ({
</Text>
)}
<div style={{ flex: 1 }} />
<Tooltip
content={
<div style={{ padding: '12px', maxWidth: '300px' }}>
@@ -368,11 +335,13 @@ const VideoPreviewPanel = ({
</div>
}
position='bottomRight'
trigger='hover'
trigger={['hover', 'focus']}
showArrow={true}
>
<Button
icon={<ActionHelpCircle size={18} />}
className='video-help-button'
aria-label={t('使用提示')}
type='tertiary'
size={windowWidth > 768 ? 'default' : 'small'}
/>
@@ -702,199 +671,31 @@ const VideoPreviewPanel = ({
);
}
// 默认空状态 - 纯CSS电影感动画背景(无网络资源消耗)
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
minHeight: config.minHeight,
height: '100%',
position: 'relative',
borderRadius: '12px',
overflow: 'hidden',
margin: '16px',
background:
'linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%)',
}}
>
{/* CSS动画背景 - 流动光效(增强版) */}
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
overflow: 'hidden',
pointerEvents: 'none',
}}
>
{/* 动态光晕1 - 紫色 */}
<div
className='video-preview-glow1'
style={{
position: 'absolute',
width: '60%',
height: '60%',
top: '10%',
left: '5%',
background:
'radial-gradient(ellipse at center, color-mix(in srgb, var(--brand-gradient-via) 35%, transparent) 0%, color-mix(in srgb, var(--brand-gradient-via) 10%, transparent) 40%, transparent 70%)',
borderRadius: '50%',
filter: 'blur(40px)',
}}
/>
{/* 动态光晕2 - 橙红色 */}
<div
className='video-preview-glow2'
style={{
position: 'absolute',
width: '50%',
height: '50%',
bottom: '10%',
right: '5%',
background:
'radial-gradient(ellipse at center, rgba(251, 146, 60, 0.3) 0%, rgba(251, 146, 60, 0.1) 40%, transparent 70%)',
borderRadius: '50%',
filter: 'blur(40px)',
}}
/>
{/* 动态光晕3 - 金色中心 */}
<div
className='video-preview-glow3'
style={{
position: 'absolute',
width: '40%',
height: '40%',
top: '30%',
left: '30%',
background:
'radial-gradient(ellipse at center, rgba(251, 191, 36, 0.25) 0%, transparent 60%)',
borderRadius: '50%',
filter: 'blur(30px)',
}}
/>
</div>
{/* 电影宽银幕效果 - 上下黑边 */}
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
height: '6%',
background:
'linear-gradient(180deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
zIndex: 2,
}}
/>
<div
style={{
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
height: '6%',
background:
'linear-gradient(0deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
zIndex: 2,
}}
/>
{/* 中央内容区域 */}
<div
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: config.padding,
color: 'white',
position: 'relative',
zIndex: 3,
}}
>
<div
style={{
backgroundColor: 'rgba(255, 255, 255, 0.1)',
borderRadius: '50%',
padding: windowWidth > 1024 ? '32px' : '24px',
marginBottom: windowWidth > 768 ? '32px' : '24px',
border: '1px solid rgba(255, 255, 255, 0.2)',
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.3)',
transition: 'transform 0.3s ease',
}}
onMouseEnter={(e) => {
e.currentTarget.style.transform = 'scale(1.05)';
}}
onMouseLeave={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
<Film
size={config.iconSize}
style={{
color: 'rgba(255, 220, 180, 0.9)',
filter: 'drop-shadow(0 2px 12px rgba(255,200,150,0.4))',
}}
/>
</div>
<Title
heading={config.titleSize}
style={{
marginBottom: '12px',
color: 'rgba(255, 250, 245, 0.95)',
fontWeight: 700,
textShadow: '0 4px 20px rgba(0, 0, 0, 0.6)',
letterSpacing: '3px',
}}
>
{t('AI 视频生成')}
</Title>
<Text
style={{
marginBottom: windowWidth > 768 ? '24px' : '16px',
textAlign: 'center',
fontSize: windowWidth > 768 ? '16px' : '14px',
padding: '0 16px',
color: 'rgba(255, 255, 255, 0.7)',
maxWidth: '500px',
lineHeight: '1.8',
textShadow: '0 2px 8px rgba(0, 0, 0, 0.5)',
}}
>
{formData.mode === 'text2video'
? t('输入提示词,让 AI 为你创造精彩视频')
: t('上传图片并输入提示词,生成动态视频')}
</Text>
</div>
<div className='video-preview-empty'>
<span className='video-preview-empty-icon' aria-hidden='true'>
<Film size={28} />
</span>
<h3>{t('AI 视频生成')}</h3>
<p>
{formData.mode === 'text2video'
? t('输入提示词,让 AI 为你创造精彩视频')
: t('上传图片并输入提示词,生成动态视频')}
</p>
</div>
);
};
return (
<Card
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
styles={{
body: {
flex: 1,
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
padding: 0,
},
}}
>
{/* 始终显示的顶部操作栏 */}
{renderTopBar()}
{/* 内容区域 */}
<div style={{ flex: 1, overflow: 'auto' }}>{renderPreview()}</div>
<Card className='video-preview-panel'>
<header className='video-panel-header video-preview-header'>
<div className='video-panel-heading'>
<Film size={17} aria-hidden='true' />
<h2>{t('视频预览')}</h2>
</div>
{renderTopBar()}
</header>
<div className='video-preview-stage app-scrollbar'>{renderPreview()}</div>
</Card>
);
};
@@ -4,8 +4,9 @@ import {
RefreshCw as ActionRefreshCw,
Trash2 as ActionTrash2,
AlertCircle as ActionAlertCircle,
ChevronDown as ActionChevronDown,
} from '@/components/common/icons/ActionIcons';
import React, { useState, useEffect } from 'react';
import React, { useState, useId } from 'react';
import {
Table,
Button,
@@ -17,8 +18,7 @@ import {
Badge,
} from '@/components/ui';
import {
ChevronUp,
ChevronDown,
ListVideo,
CheckCircle2,
AlertCircle,
Clock,
@@ -47,32 +47,7 @@ const VideoTaskQueue = ({
// 8 列合计 1190px 塞进 ~340px 容器、按钮全带文字,实际完全用不了。
const isCompact = useIsMobile();
const [selectedTasks, setSelectedTasks] = useState([]);
const [windowHeight, setWindowHeight] = useState(window.innerHeight);
// 监听窗口高度变化
useEffect(() => {
const handleResize = () => {
setWindowHeight(window.innerHeight);
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
// 计算任务队列高度:不超过屏幕高度的20%(五分之一)
// 同时设置最小高度150px,最大高度300px
const getQueueHeight = () => {
const maxHeightPercent = windowHeight * 0.2; // 屏幕高度的20%
// 手机端工具栏本身会换行占掉 ~100px,再按 20%(844px 屏上仅 169px)会让表格只剩
// 不到 70px,连表头带分页都放不下。窄屏改用更宽松的下限。
const minHeight = isCompact ? 300 : 150;
const maxHeight = isCompact ? 420 : 300;
// 在最小和最大值之间取适当的高度
return Math.max(minHeight, Math.min(maxHeightPercent, maxHeight));
};
const queueHeight = getQueueHeight();
const queueId = useId();
// 状态标签映射
const getStatusTag = (status) => {
@@ -303,65 +278,30 @@ const VideoTaskQueue = ({
};
return (
<>
{/* 折叠触发器 */}
<div
style={{
position: 'absolute',
bottom: visible ? `${queueHeight}px` : '0',
left: 0,
right: 0,
height: '40px',
backgroundColor: 'var(--ui-color-bg-1)',
borderTop: '1px solid var(--ui-color-border)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer',
transition: 'bottom 0.3s',
zIndex: 10,
}}
onClick={() => setVisible(!visible)}
>
<Space>
{visible ? <ChevronDown size={16} /> : <ChevronUp size={16} />}
<span style={{ fontSize: !isCompact ? '14px' : '12px' }}>
{t('任务队列')} ({taskStats.total})
</span>
<section className='video-queue'>
<h2 className='video-queue-heading'>
<button
type='button'
className='video-queue-toggle'
aria-expanded={visible}
aria-controls={queueId}
onClick={() => setVisible(!visible)}
>
<ListVideo size={19} aria-hidden='true' />
<span>{t('任务队列')}</span>
<span className='video-queue-count'>{taskStats.total}</span>
{taskStats.in_progress > 0 && (
<Badge count={taskStats.in_progress} type='danger' />
)}
</Space>
</div>
{/* 任务队列抽屉 */}
<div
style={{
position: 'absolute',
bottom: visible ? '0' : `-${queueHeight}px`,
left: 0,
right: 0,
height: `${queueHeight}px`,
backgroundColor: 'var(--ui-color-bg-0)',
borderTop: '1px solid var(--ui-color-border)',
transition: 'bottom 0.3s',
display: 'flex',
flexDirection: 'column',
zIndex: 9,
}}
>
{/* 工具栏 */}
<div
style={{
padding: !isCompact ? '12px 16px' : '8px 12px',
borderBottom: '1px solid var(--ui-color-border)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
flexWrap: 'wrap',
gap: '8px',
}}
>
<ActionChevronDown
size={16}
className='video-queue-chevron'
aria-hidden='true'
/>
</button>
</h2>
<div id={queueId} className='video-queue-content' hidden={!visible}>
<div className='video-queue-toolbar'>
<Space wrap>
<Button
size={!isCompact ? 'default' : 'small'}
@@ -427,7 +367,7 @@ const VideoTaskQueue = ({
</div>
{/* 任务表格 */}
<div style={{ flex: 1, overflow: 'auto' }}>
<div className='video-queue-table app-scrollbar'>
<Table
columns={columns}
dataSource={tasks}
@@ -446,7 +386,7 @@ const VideoTaskQueue = ({
/>
</div>
</div>
</>
</section>
);
};
@@ -0,0 +1,211 @@
.video-workspace {
display: flex;
flex-direction: column;
gap: 20px;
height: 100%;
padding: 24px;
overflow: auto;
}
.video-workspace-heading,
.video-panel-heading {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.video-workspace-icon,
.video-preview-empty-icon {
display: grid;
flex: none;
place-items: center;
width: 46px;
height: 46px;
color: var(--brand-selection-text);
background: var(--brand-selection-bg);
border-radius: 10px;
}
.video-workspace-heading h1 {
margin: 0;
color: var(--text-primary);
font-size: 28px;
font-weight: 650;
line-height: 32px;
}
.video-workspace-heading p {
margin: 4px 0 0;
color: var(--text-secondary);
font-size: 13px;
}
.video-workspace-body {
display: flex;
flex: 1;
flex-direction: column;
gap: 16px;
height: 100%;
min-height: 0;
min-width: 0;
}
.video-workspace-grid {
display: grid;
flex: 1;
grid-template-columns: clamp(312px, 26%, 420px) minmax(0, 1fr);
gap: 16px;
min-height: 310px;
}
.video-workspace-composer {
display: flex;
align-items: flex-start;
min-width: 0;
min-height: 0;
}
.video-panel-header {
display: flex;
flex: none;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 57px;
padding: 10px 16px;
border-bottom: 1px solid var(--border-subtle);
}
.video-panel-header:last-child {
border-bottom: 0;
}
.video-panel-heading {
gap: 8px;
color: var(--brand-accent);
}
.video-panel-heading h2 {
margin: 0;
color: var(--text-primary);
font-size: 15px;
font-weight: 600;
line-height: 22px;
}
.video-queue {
flex: none;
min-width: 0;
background: var(--surface-card);
border: 1px solid var(--border-subtle);
border-radius: 12px;
}
.video-queue-heading {
margin: 0;
}
.video-queue-toggle {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
min-height: 52px;
padding: 8px 16px;
border: 0;
border-radius: 11px;
background: transparent;
color: var(--text-primary);
text-align: start;
font: inherit;
font-size: 15px;
font-weight: 600;
cursor: pointer;
}
.video-queue-toggle > svg:first-child {
color: var(--brand-accent);
}
.video-queue-toggle:hover {
background: var(--surface-bg-base);
}
.video-queue-toggle:focus-visible {
outline: 2px solid var(--brand-accent);
outline-offset: -3px;
}
.video-queue-toggle[aria-expanded='true'] {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
.video-queue-count {
min-width: 23px;
padding: 2px 6px;
border-radius: 6px;
background: var(--surface-bg-base);
color: var(--text-secondary);
text-align: center;
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.video-queue-chevron {
margin-inline-start: auto;
color: var(--text-secondary);
}
.video-queue-toggle[aria-expanded='true'] .video-queue-chevron {
transform: rotate(180deg);
}
.video-queue-content {
border-top: 1px solid var(--border-subtle);
}
.video-queue-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px 16px;
padding: 10px 16px;
border-bottom: 1px solid var(--border-subtle);
}
.video-queue-table {
min-width: 0;
max-height: clamp(120px, 24dvh, 260px);
overflow: auto;
border-end-start-radius: 11px;
border-end-end-radius: 11px;
}
@media (max-width: 1024px) {
.video-workspace {
gap: 16px;
padding: 16px;
}
.video-workspace-body {
flex: none;
height: auto;
}
.video-workspace-grid {
grid-template-columns: minmax(0, 1fr);
min-height: 0;
}
.video-workspace-heading h1 {
font-size: 24px;
line-height: 28px;
}
.video-queue-table {
max-height: 320px;
}
}