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

对齐表单、预览与任务区,跟随系统主题色,修复图片尺寸选择和视频高级参数显示。已通过本地浏览器验收、Lint、UI 审计和单测;未做生产测试。
This commit is contained in:
zhanjunhao
2026-11-20 18:30:13 +08:00
parent 461f0c577a
commit ab79dfd357
17 changed files with 1819 additions and 1812 deletions
@@ -7,12 +7,20 @@
--igf-muted: var(--text-secondary);
--igf-line: var(--border-subtle);
--igf-surface: var(--surface-card);
--igf-accent: var(--ui-color-primary);
--igf-accent: var(--brand-accent);
--igf-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
--igf-danger: var(--ui-color-danger);
--igf-warning: var(--ui-color-warning);
--igf-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
--igf-ring: var(--brand-accent);
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
overflow: hidden;
border: 1px solid var(--igf-line);
border-radius: 12px;
background: var(--igf-surface);
color: var(--igf-ink);
}
.igf-form-scroll {
@@ -20,7 +28,182 @@
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
padding: 16px;
padding: 14px 16px 16px;
scrollbar-width: thin;
}
.igf-form-scroll[hidden] {
display: none;
}
.igf-header {
display: flex;
flex: none;
align-items: center;
gap: 10px;
padding: 15px 16px;
border-bottom: 1px solid var(--igf-line);
}
.igf-header-icon {
display: grid;
flex: none;
place-items: center;
width: 40px;
height: 40px;
border-radius: 10px;
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-header-copy {
flex: 1;
min-width: 0;
}
.igf-header-actions {
display: flex;
flex: none;
gap: 6px;
}
.igf-title {
margin: 0;
font-size: 21px;
font-weight: 650;
line-height: 27px;
}
.igf-description {
display: block;
overflow: hidden;
color: var(--igf-muted);
font-size: 12px;
line-height: 18px;
text-overflow: ellipsis;
}
.igf-section + .igf-section {
margin-top: 16px;
}
.igf-field-heading {
margin: 0 0 8px;
font-size: 13px;
font-weight: 650;
line-height: 20px;
}
.igf-configuration,
.igf-parameters {
padding: 12px;
border: 1px solid var(--igf-line);
border-radius: 10px;
background: var(--igf-fill);
}
.igf-mode-field {
margin-top: 10px;
}
.igf-mode-group.cp-option-group {
display: flex;
width: 100%;
gap: 3px;
background: var(--igf-surface);
}
.igf-mode-group .cp-option {
flex: 1 1 auto;
padding-inline: 6px;
}
.igf-mode-group .cp-option.is-selected {
border-color: var(--igf-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-editor {
border: 1px solid var(--igf-line);
border-radius: 10px;
background: var(--igf-fill);
}
.igf-editor:focus-within {
border-color: var(--igf-accent);
}
.igf-editor textarea.ant-input {
min-height: 78px;
padding: 9px 10px;
resize: vertical;
font-size: 13px;
line-height: 20px;
}
.igf-editor-toolbar,
.igf-editor-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px;
}
.igf-editor-toolbar {
justify-content: space-between;
padding: 4px 6px;
border-top: 1px solid var(--igf-line);
}
.igf-editor-actions .ant-btn {
padding-inline: 7px;
font-size: 12px;
}
.igf-shortcut {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 1px 5px;
border: 1px solid var(--igf-line);
border-radius: 5px;
color: var(--igf-muted);
font-size: 11px;
white-space: nowrap;
}
.igf-history-item {
display: block;
overflow: hidden;
max-width: min(280px, 70vw);
text-overflow: ellipsis;
white-space: nowrap;
}
.igf-templates {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.igf-templates .ant-btn {
flex: 1 1 27%;
min-height: 28px;
box-shadow: none;
}
.igf-templates-label {
flex-basis: 100%;
color: var(--igf-muted);
font-size: 12px;
}
.igf-generate .igf-submit.ant-btn {
height: 42px;
font-size: 14px;
font-weight: 600;
}
/* Keep disabled generation actions grounded in the same surface and border token. */
@@ -139,13 +322,36 @@
}
.igf-slots {
display: flex;
flex-wrap: wrap;
gap: 10px;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
}
.igf-slots .cp-slot {
width: 100%;
height: auto;
aspect-ratio: 1;
border-radius: 9px;
}
.igf-reference-hint {
margin: 6px 0 0;
}
.igf-size .cp-option-group--ratio {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 78px), 1fr));
}
.igf-size .cp-option-group--ratio .cp-option {
min-width: 64px;
gap: 3px;
min-width: 0;
padding: 6px 4px;
}
.igf-size .cp-option-group--ratio .cp-option-label {
white-space: normal;
overflow-wrap: anywhere;
}
.igf-size-dims {
@@ -175,6 +381,35 @@
margin-top: 12px;
}
.igf-advanced-trigger {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
min-height: 34px;
padding: 6px 10px;
border: 1px solid var(--igf-line);
border-radius: 8px;
color: var(--igf-muted);
font-size: 13px;
text-align: start;
}
.igf-advanced-trigger span {
flex: 1;
}
.igf-advanced-trigger:hover,
.igf-advanced-trigger[aria-expanded='true'] {
border-color: var(--igf-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-advanced-content {
padding-top: 12px;
}
.igf-generate {
display: flex;
flex-direction: column;
@@ -183,11 +418,20 @@
.igf-generate-wrap {
flex: 0 0 auto;
padding: 16px 16px max(16px, env(safe-area-inset-bottom));
padding: 12px 16px max(12px, env(safe-area-inset-bottom));
border-top: 1px solid var(--igf-line);
background: var(--igf-surface);
}
.igf-collapsed-summary {
overflow: hidden;
margin: 0 0 8px;
color: var(--igf-muted);
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.igf-quote {
min-height: 18px;
color: var(--igf-muted);
@@ -15,6 +15,20 @@ import {
const CUSTOM = '__custom__';
const formatPreset = ({ width, height, label }) => {
const dimensions = `${width}×${height}`;
const caption = label
.replace(/\s*[((]\s*\d+\s*[x×]\s*\d+\s*[))]\s*$/i, '')
.trim();
return {
dimensions,
caption:
caption.toLowerCase().replace(/\s/g, '').replace('x', '×') === dimensions
? ''
: caption,
};
};
/**
* 图像尺寸(schema type = 'size'):预设按宽高比图标展示;仅当 schema 下发 custom_size 时
* 提供"自定义",宽高输入框失焦 / 回车时按 min / max / step 吸附。
@@ -83,7 +97,9 @@ const ImageSizePicker = ({ param, value, onChange }) => {
getOptionAriaLabel={(opt) => {
if (opt === CUSTOM) return t('自定义尺寸');
const p = presets.find((x) => x.value === opt);
return p ? `${p.label || ''} ${p.width}×${p.height}`.trim() : opt;
if (!p) return opt;
const { caption, dimensions } = formatPreset(p);
return caption ? `${caption} ${dimensions}` : dimensions;
}}
renderOption={(opt) => {
if (opt === CUSTOM) {
@@ -97,16 +113,16 @@ const ImageSizePicker = ({ param, value, onChange }) => {
);
}
const p = presets.find((x) => x.value === opt);
if (!p) return opt;
const { caption, dimensions } = formatPreset(p);
return (
<>
<RatioShape ratio={`${p.width}:${p.height}`} />
<span className='cp-option-label tabular-nums'>
{p.label || `${p.width}×${p.height}`}
{caption || dimensions}
</span>
{p.label ? (
<span className='igf-size-dims tabular-nums'>
{p.width}×{p.height}
</span>
{caption ? (
<span className='igf-size-dims tabular-nums'>{dimensions}</span>
) : null}
</>
);
@@ -1,13 +1,14 @@
import { I18N_TECHNICAL_TEXT } from '../../../../i18n/technicalText.js';
import {
Wallet as ActionWallet,
Zap as ActionZap,
RotateCcw as ActionRotateCcw,
ChevronDown as ActionChevronDown,
ChevronUp as ActionChevronUp,
History as ActionHistory,
Settings as ActionSettings,
} from '@/components/common/icons/ActionIcons';
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useId, useRef, useState } from 'react';
import {
Button,
Collapsible,
@@ -43,7 +44,7 @@ import {
import ImageSizePicker from './Image/ImageSizePicker';
import './Image/ImageGenerationForm.css';
const { Title, Text } = Typography;
const { Text } = Typography;
// sessionStorage prompt 历史 key
const PROMPT_HISTORY_KEY = 'expCenter.imageGen.promptHistory.v1';
@@ -119,20 +120,9 @@ const hasImageTaskType = (dataTransfer) =>
Array.from(dataTransfer.types).includes('application/x-image-task'),
);
const Section = ({ title, extra, children, className = '' }) => (
<div
className={`mb-4 rounded-3xl border border-[var(--igf-line)] bg-white/[0.28] p-3 backdrop-blur-xl dark:bg-white/[0.045] ${className}`}
>
{title || extra ? (
<div className='flex items-center justify-between gap-2 mb-2'>
{title ? (
<Text strong className='text-sm text-gray-700 dark:text-gray-200'>
{title}
</Text>
) : null}
{extra}
</div>
) : null}
const Section = ({ title, children, className = '' }) => (
<div className={`igf-section ${className}`}>
{title && <h2 className='igf-field-heading'>{title}</h2>}
{children}
</div>
);
@@ -145,6 +135,10 @@ const ImageGenerationForm = ({ creation }) => {
const { t } = useTranslation();
const navigate = useNavigate();
const isMobile = useIsMobile();
const bodyId = useId();
const advancedId = useId();
const promptId = useId();
const quoteId = useId();
const [mobileCollapsed, setMobileCollapsed] = useState(false);
const [showAdvanced, setShowAdvanced] = useState(false);
const [dropActive, setDropActive] = useState(false);
@@ -348,10 +342,10 @@ const ImageGenerationForm = ({ creation }) => {
theme='solid'
size='large'
block
icon={<ActionWallet size={16} />}
icon={<ActionWallet size={16} aria-hidden='true' />}
aria-describedby={quoteId}
onClick={() => navigate('/console/topup')}
className='!rounded-2xl'
style={{ height: '48px', fontSize: '15px', fontWeight: 700 }}
className='igf-submit'
>
{t('去充值')}
</Button>
@@ -362,26 +356,17 @@ const ImageGenerationForm = ({ creation }) => {
size='large'
block
loading={submitting}
icon={<ActionZap size={16} aria-hidden='true' />}
aria-describedby={quoteId}
onClick={handleSubmit}
disabled={isButtonDisabled}
className='!rounded-2xl !transition-colors'
style={{
background: isButtonDisabled
? 'var(--ui-color-fill-1)'
: 'linear-gradient(135deg, var(--brand-gradient-from) 0%, var(--brand-primary) 52%, var(--brand-gradient-to) 100%)',
border: isButtonDisabled
? '1px solid var(--igf-line)'
: '1px solid transparent',
color: isButtonDisabled ? 'var(--ui-color-text-3)' : 'white',
height: '48px',
fontSize: '15px',
fontWeight: '700',
}}
className='igf-submit'
>
{submitting ? t('提交中...') : t('生成图片')}
</Button>
)}
<div
id={quoteId}
className={`igf-quote${needTopUp ? ' is-warning' : ''}`}
aria-live='polite'
role={isButtonDisabled ? 'note' : undefined}
@@ -521,245 +506,202 @@ const ImageGenerationForm = ({ creation }) => {
return (
<div
className={`image-generation-form relative flex h-full min-h-0 flex-col overflow-hidden rounded-[28px] border border-[var(--igf-line)] bg-white/[0.42] shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`}
className={`image-generation-form${dropActive ? ' is-drop-active' : ''}`}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
>
<div className='igf-form-scroll app-scrollbar'>
{/* 标题 */}
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'>
<div className='flex items-center justify-between gap-2'>
<div className='flex-1 min-w-0'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'>
<Sparkles size={12} />
{t('AI 图片创作')}
</div>
<Title
heading={4}
style={{ margin: 0 }}
className='text-gray-900 dark:text-white'
>
{t('图片生成')}
</Title>
<Text
type='secondary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
</Text>
</div>
<div className='flex items-center gap-1'>
{!formBodyHidden && (
<Button
icon={<ActionRotateCcw size={12} />}
size='small'
theme='borderless'
onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
>
{t('重置')}
</Button>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={14} />
) : (
<ActionChevronUp size={14} />
)
}
size='small'
theme='borderless'
onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500'
>
{mobileCollapsed ? t('展开') : t('收起')}
</Button>
)}
</div>
</div>
<header className='igf-header'>
<span className='igf-header-icon' aria-hidden='true'>
<Sparkles size={19} />
</span>
<div className='igf-header-copy'>
<h1 className='igf-title'>{t('图片生成')}</h1>
<span
className='igf-description'
title={
formBodyHidden
? selectedModel?.display_name || selectedModel?.model
: undefined
}
>
{formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')}
</span>
</div>
<div className='igf-header-actions'>
{!formBodyHidden && (
<Tooltip content={t('重置')}>
<Button
icon={<ActionRotateCcw size={15} aria-hidden='true' />}
theme='outline'
aria-label={t('重置')}
onClick={handleReset}
/>
</Tooltip>
)}
{isMobile && (
<Button
icon={
mobileCollapsed ? (
<ActionChevronDown size={15} aria-hidden='true' />
) : (
<ActionChevronUp size={15} aria-hidden='true' />
)
}
theme='outline'
title={mobileCollapsed ? t('展开') : t('收起')}
onClick={() => setMobileCollapsed(!mobileCollapsed)}
aria-label={mobileCollapsed ? t('展开') : t('收起')}
aria-controls={bodyId}
aria-expanded={!formBodyHidden}
/>
)}
</div>
</header>
{/* 移动端折叠时只显示生成按钮 + 简略 */}
{formBodyHidden && (
<div className='mt-2'>
{renderGenerateArea()}
<Text
type='tertiary'
size='small'
className='block mt-2 text-center'
>
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
)}
<div
id={bodyId}
className='igf-form-scroll app-scrollbar'
hidden={formBodyHidden}
>
{!formBodyHidden && (
<>
{/* 模型选择 */}
<Section title={t('选择模型')}>{renderModelSection()}</Section>
<Section className='igf-configuration'>
<div className='igf-field-heading'>{t('选择模型')}</div>
{renderModelSection()}
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<Section 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] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</Section>
) : null}
{/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? (
<div className='igf-mode-field'>
<div className='igf-field-heading'>{t('生成方式')}</div>
<OptionGroup
variant='segmented'
className='igf-mode-group'
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] || Type;
return (
<span className='igf-mode-option'>
<Icon size={14} aria-hidden='true' />
{t(MODE_LABEL_KEYS[mode] || mode)}
</span>
);
}}
/>
</div>
) : null}
</Section>
{/* 提示词 + 模板 + 历史 */}
<Section
title={t('提示词')}
extra={
<div className='flex items-center gap-2'>
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */}
<button
type='button'
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
className={[
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<Sparkles
size={10}
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => (
<Dropdown.Item
key={idx}
onClick={() => setPrompt(p)}
>
<div
style={{
maxWidth: 320,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item>
))}
</Dropdown.Menu>
title={<label htmlFor={promptId}>{t('提示词')}</label>}
className='igf-prompt-section'
>
<div className='igf-editor'>
<TextArea
id={promptId}
variant='borderless'
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
/>
<div className='igf-editor-toolbar'>
<div className='igf-editor-actions'>
<Button
type='text'
size='small'
icon={<ActionZap size={13} aria-hidden='true' />}
onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')}
aria-busy={optimizing}
title={
textModels?.length
? t('AI 优化提示词 (使用 {{m}})', {
m: textModels[0].model_name,
})
: t('AI 优化提示词')
}
>
<button
type='button'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
{optimizing ? t('优化中...') : t('AI 优化')}
</Button>
{promptHistory.length > 0 && (
<Dropdown
trigger='click'
position='bottomLeft'
render={
<Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((item) => (
<Dropdown.Item
key={item}
onClick={() => setPrompt(item)}
>
<span className='igf-history-item' title={item}>
{item}
</span>
</Dropdown.Item>
))}
</Dropdown.Menu>
}
>
<ActionHistory size={10} />
<span>{t('历史')}</span>
</button>
</Dropdown>
)}
<span className='flex items-center gap-1 text-[10px] text-gray-400'>
{IS_MAC ? (
<Command size={10} />
) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span>
<Button
type='text'
size='small'
icon={<ActionHistory size={13} aria-hidden='true' />}
>
{t('历史')}
</Button>
</Dropdown>
)}
<span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span>
<span>{t('生成')}</span>
</span>
</div>
{!isMobile && (
<kbd className='igf-shortcut' title={t('生成图片')}>
{IS_MAC ? (
<Command size={11} />
) : (
I18N_TECHNICAL_TEXT.CTRL
)}
<span>+</span>
{I18N_TECHNICAL_TEXT.ENTER}
</kbd>
)}
</div>
}
>
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
</div>
<div className='flex flex-wrap items-center gap-1.5 mt-2'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'>
<Sparkles size={10} />
<div className='igf-templates'>
<div className='igf-templates-label'>
<span>{t('快速模板')}</span>
</div>
{PROMPT_TEMPLATES.map((tpl) => (
<Tag
<Button
key={tpl.label}
theme='outline'
size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
>
{t(tpl.label)}
</Tag>
</Button>
))}
</div>
</Section>
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? (
<Section
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
}
>
<Section title={t('参考图片')} className='igf-reference'>
<div className='igf-slots'>
{imageSlots.map((entry) => {
const slot = entry.slot;
@@ -784,6 +726,11 @@ const ImageGenerationForm = ({ creation }) => {
);
})}
</div>
{!isMobile && (
<p className='igf-muted igf-reference-hint'>
{t('可从右侧历史拖拽图片到这里')}
</p>
)}
{hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'>
{t(
@@ -796,7 +743,10 @@ const ImageGenerationForm = ({ creation }) => {
{/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}>
<Section
className='igf-parameters'
title={sizeParam ? t('尺寸') : t('生成参数')}
>
{sizeParam ? (
<ImageSizePicker
param={sizeParam}
@@ -819,14 +769,15 @@ const ImageGenerationForm = ({ creation }) => {
{/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? (
<Section>
<Section className='igf-advanced'>
<button
type='button'
onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors'
aria-controls={advancedId}
className='igf-advanced-trigger'
>
<ActionSettings size={12} />
<ActionSettings size={15} aria-hidden='true' />
<span>{t('高级选项')}</span>
{showAdvanced ? (
<ActionChevronUp size={12} />
@@ -835,7 +786,7 @@ const ImageGenerationForm = ({ creation }) => {
)}
</button>
<Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'>
<div id={advancedId} className='igf-advanced-content'>
<ParamRenderer
params={visibleParams}
values={formData.params}
@@ -850,9 +801,14 @@ const ImageGenerationForm = ({ creation }) => {
</>
)}
</div>
{!formBodyHidden && (
<div className='igf-generate-wrap'>{renderGenerateArea()}</div>
)}
<footer className='igf-generate-wrap'>
{formBodyHidden && (
<p className='igf-collapsed-summary' title={prompt || undefined}>
{prompt || t('点击展开编辑参数')}
</p>
)}
{renderGenerateArea()}
</footer>
</div>
);
};
@@ -60,17 +60,15 @@ const ImageGenerationTab = () => {
return (
<>
{/*
移动端(< md):Tab 整体允许竖向滚动 —— 表单和任务列表按自然高度堆叠,用户上下滚浏览。
桌面端(>= md):保持 overflow-hidden,左右两栏各自内部滚动。
窄屏堆叠并整体滚动,宽屏双栏各自滚动。
*/}
<div className='h-full min-h-0 flex flex-col md:flex-row gap-4 p-3 sm:p-4 overflow-y-auto md:overflow-hidden'>
<div className='image-generation-workspace h-full min-h-0 flex flex-col lg:flex-row gap-4 p-4 lg:p-6 overflow-y-auto lg:overflow-hidden'>
{/* 左侧:生成参数表单 */}
<div className='w-full md:w-[22rem] xl:w-[24rem] md:flex-shrink-0 md:h-full'>
<div className='w-full shrink-0 lg:w-[20rem] xl:w-[22rem] lg:h-full'>
<ImageGenerationForm creation={creation} />
</div>
{/* 右侧:任务列表 —— flex-1 只在桌面端生效,移动端按内容高度展开 */}
<div className='md:flex-1 md:min-h-0 flex flex-col'>
<div className='min-w-0 lg:flex-1 lg:min-h-0 flex flex-col'>
<ImageTaskList
tasks={tasks}
onRefresh={refreshTasks}
@@ -227,22 +227,19 @@ useCallback; // 事件处理函数优化
### CSS 变量
```css
--ui-color-primary // 主色
--ui-color-success // 成功色
--ui-color-warning // 警告色
--ui-color-danger // 危险色
--ui-color-bg-2 // 背景色
--ui-color-border // 边框色
--brand-accent // 聚焦与选中边框
--brand-selection-bg // 筛选和收藏选中底色
--surface-card // 卡片背景
--border-subtle // 描边与操作区分隔线
```
### 自定义类
```css
.task-card-hover // 卡片悬停效果
.task-list-scroll // 滚动条样式
.stat-card // 统计卡片样式
.image-preview-container // 图片预览容器
.progress-pulse // 进度条动画
.image-task-grid // 密度与响应式列数
.image-task-card // 统一描边卡片
.image-task-media // 统一 4:3 缩略图与状态占位
.image-task-actions // 各密度均可访问的卡片操作
```
## 浏览器兼容性
@@ -1,155 +1,429 @@
/* 任务卡片悬停效果 */
.task-card-hover {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
.image-task-list {
--ih-status-warning: var(--ui-color-warning);
--ih-status-error: var(--ui-color-danger);
--ih-dimension-bg: rgb(15 23 42 / 0.8);
--ih-dimension-text: white;
display: flex;
flex-direction: column;
min-width: 0;
min-height: 0;
height: 100%;
color: var(--text-primary);
}
.task-card-hover:hover {
transform: translateY(-2px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
.image-history-toolbar {
flex: none;
padding: 16px;
border: 1px solid var(--border-subtle);
border-radius: 12px;
background: var(--surface-card);
}
/* 滚动条样式已统一到 index.css 的 .app-scrollbar */
/* 统计卡片悬停效果 */
.stat-card {
transition: all 0.3s ease;
.image-history-heading,
.image-history-title-row,
.image-history-tools,
.image-history-status,
.image-history-filters,
.image-history-compare {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}
.stat-card:hover {
transform: scale(1.02);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
.image-history-heading {
justify-content: space-between;
gap: 12px 16px;
}
/* 图片预览悬停效果 */
.image-preview-container {
position: relative;
overflow: hidden;
.image-history-title-row {
gap: 12px 16px;
}
.image-history-title-row h2 {
margin: 0;
font-size: 18px;
line-height: 26px;
font-weight: 650;
}
.image-history-status {
gap: 4px;
}
.image-preview-container::after {
.image-history-status-button,
.image-history-clear {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 34px;
padding: 4px 8px;
border: 1px solid transparent;
border-radius: 8px;
color: var(--text-secondary);
font-size: 12px;
white-space: nowrap;
}
.image-history-status-button:hover,
.image-history-status-button[aria-pressed='true'],
.image-history-clear:hover {
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.image-history-status-button[aria-pressed='true'] {
border-color: var(--brand-accent);
font-weight: 600;
}
.image-history-count {
display: inline-flex;
justify-content: center;
min-width: 18px;
padding: 0 4px;
border-radius: 5px;
background: var(--surface-bg-base);
color: var(--text-secondary);
font-size: 11px;
line-height: 18px;
font-variant-numeric: tabular-nums;
}
.image-history-status-button[aria-pressed='true'] .image-history-count {
background: var(--surface-card);
color: inherit;
}
.image-history-filters {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid var(--border-subtle);
}
.image-history-tools {
flex-wrap: nowrap;
min-width: 0;
max-width: 100%;
gap: 6px;
}
.image-history-tools .image-task-search {
width: 180px;
min-width: 0;
}
.image-history-tools .ant-btn {
flex-shrink: 0;
}
.image-task-model-filter {
width: min(100%, 190px);
}
.image-task-size-filter {
width: min(100%, 128px);
}
.image-history-tools .ant-btn[aria-pressed='true'],
.image-task-favorite.ant-btn[aria-pressed='true'] {
border-color: var(--brand-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.image-history-compare {
margin-top: 12px;
padding: 8px 12px;
border-radius: 8px;
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
font-size: 13px;
}
.image-task-list .task-list-scrollable {
flex: 1;
min-height: 0;
}
.image-history-content {
padding: 16px 0 4px;
}
.image-history-empty-description {
display: grid;
gap: 4px;
color: var(--text-secondary);
}
.image-history-empty-description strong {
color: var(--text-primary);
font-size: 16px;
font-weight: 600;
}
.image-task-group-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
.image-task-group-header h3 {
margin: 0;
font-size: 15px;
line-height: 22px;
font-weight: 650;
}
.image-task-group-header::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0);
transition: background 0.3s;
pointer-events: none;
flex: 1;
border-top: 1px solid var(--border-subtle);
}
.image-preview-container:hover::after {
background: rgba(0, 0, 0, 0.05);
.image-task-grid {
--ih-card-min: 268px;
display: grid;
grid-template-columns: repeat(
auto-fill,
minmax(min(100%, var(--ih-card-min)), 1fr)
);
gap: 16px;
}
/* 进度条动画 */
@keyframes pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
.image-task-grid[data-density='compact'] {
--ih-card-min: 208px;
gap: 12px;
}
.image-task-grid[data-density='grid'] {
--ih-card-min: 144px;
gap: 12px;
}
/* 处理中状态左侧彩条流光 */
@keyframes brandShimmer {
0% {
background-position: 0% 0%;
}
100% {
background-position: 0% 200%;
}
.image-task-card.ant-card {
min-width: 0;
border-color: var(--border-subtle);
border-radius: 12px;
background: var(--surface-card);
color: var(--text-primary);
box-shadow: none;
}
/* drop target highlight */
.image-ref-drop-active {
outline: 2px dashed var(--brand-primary) !important;
outline-offset: -4px;
.image-task-card.ant-card:focus-within,
.image-task-card.ant-card[data-selected='true'] {
border-color: var(--brand-accent);
}
.image-task-card.ant-card > .image-task-card-layout {
display: flex;
flex-direction: column;
height: 100%;
padding: 10px;
}
.image-task-media {
position: relative;
aspect-ratio: 4 / 3;
overflow: hidden;
border-radius: 8px;
background: var(--surface-bg-base);
}
.image-task-media[data-status='failed'] {
background: color-mix(
in srgb,
var(--brand-primary) 8%,
transparent
) !important;
var(--ih-status-error) 5%,
var(--surface-bg-base)
);
}
.progress-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
.image-task-preview {
position: absolute;
inset: 0;
width: 100%;
border-radius: inherit;
cursor: zoom-in;
}
.image-task-preview[aria-pressed] {
cursor: pointer;
}
.image-task-preview img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
/* 按钮组动画 */
.action-buttons {
.image-task-dimensions {
position: absolute;
right: 8px;
bottom: 8px;
padding: 2px 6px;
border-radius: 5px;
background: var(--ih-dimension-bg);
color: var(--ih-dimension-text);
font-size: 11px;
line-height: 16px;
font-variant-numeric: tabular-nums;
}
.image-task-favorite.ant-btn,
.image-task-select.ant-checkbox-wrapper {
position: absolute;
top: 8px;
right: 8px;
z-index: 1;
display: grid;
place-items: center;
min-width: 34px;
height: 34px;
margin: 0;
border: 1px solid var(--border-subtle);
border-radius: 8px;
background: var(--surface-card);
color: var(--text-secondary);
}
.image-task-select.ant-checkbox-wrapper .ant-checkbox {
align-self: center;
}
.image-task-placeholder {
position: absolute;
inset: 0;
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.action-buttons > * {
transition: all 0.2s;
}
.action-buttons > *:hover {
transform: translateY(-1px);
}
/* 空状态样式 */
.empty-state {
padding: 60px 20px;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
padding: 8px;
color: var(--text-secondary);
text-align: center;
font-size: 11px;
line-height: 15px;
}
/* 搜索框样式增强 */
.search-input-enhanced {
transition: all 0.3s;
.image-task-placeholder strong {
color: var(--text-primary);
font-size: 13px;
font-weight: 600;
}
.search-input-enhanced:focus-within {
box-shadow: 0 0 0 2px rgba(var(--ui-color-primary-rgb), 0.2);
.image-task-status-icon {
display: grid;
flex-shrink: 0;
place-items: center;
width: 34px;
height: 34px;
margin-bottom: 2px;
border: 1px solid var(--border-subtle);
border-radius: 9px;
background: var(--surface-card);
color: var(--brand-accent);
}
/* 标签组样式 */
.tag-group {
.image-task-media[data-status='failed'] .image-task-status-icon {
color: var(--ih-status-error);
}
.image-task-media[data-status='success'] .image-task-status-icon {
color: var(--ih-status-warning);
}
.image-task-progress {
width: min(100%, 132px);
}
.image-task-error,
.image-task-prompt {
display: -webkit-box;
overflow: hidden;
overflow-wrap: anywhere;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.image-task-error {
max-width: 90%;
color: inherit;
text-decoration: underline;
text-underline-offset: 2px;
}
.image-task-error-detail {
max-width: min(70vw, 300px);
max-height: 200px;
overflow: auto;
overflow-wrap: anywhere;
white-space: pre-wrap;
}
.image-task-info {
display: flex;
flex: 1;
flex-direction: column;
gap: 6px;
padding: 10px 3px 2px;
min-width: 0;
}
.image-task-prompt {
min-height: 40px;
font-size: 14px;
line-height: 20px;
font-weight: 600;
}
.image-task-meta {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
flex-wrap: wrap;
color: var(--text-secondary);
font-size: 11px;
line-height: 16px;
}
.image-task-meta time {
flex-shrink: 0;
font-variant-numeric: tabular-nums;
}
.image-task-model {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.image-task-actions {
display: flex;
gap: 6px;
margin-top: auto;
padding-top: 8px;
border-top: 1px solid var(--border-subtle);
}
.image-task-primary-action {
flex: 1;
min-width: 0;
}
.image-task-actions .ant-btn {
min-height: 30px;
}
.image-task-list button:focus-visible {
outline: 2px solid var(--brand-accent);
outline-offset: 1px;
}
.image-task-list .image-task-preview:focus-visible {
outline-offset: -3px;
}
/* 响应式设计 */
@media (max-width: 768px) {
.task-card-content {
flex-direction: column !important;
}
.image-preview-container {
width: 100% !important;
min-height: 200px !important;
}
.stat-cards-grid {
grid-template-columns: 1fr !important;
@media (hover: hover) {
.image-task-card.ant-card:hover {
border-color: var(--brand-accent);
}
}
/* Badge 样式覆盖 - 修复默认蓝色圆形背景 */
/* 历史标题区域的 Badge 特定样式 */
/* 图片生成页局部控件留白:避免搜索/筛选内容贴住玻璃卡片边框 */
.image-task-list .image-task-group-header {
margin-left: -4px;
margin-right: -4px;
border: 1px solid rgb(255 255 255 / 0.45);
border-radius: 14px;
box-shadow: 0 10px 26px rgb(15 23 42 / 0.06);
@media (min-width: 1024px) {
.image-task-list .task-list-scrollable {
overflow: auto;
}
}
.dark .image-task-list .image-task-group-header {
border-color: rgb(255 255 255 / 0.1);
box-shadow: 0 10px 26px rgb(0 0 0 / 0.24);
}
/* ===== 触屏命中区兜底 ===== */
@media (hover: none) {
@media (max-width: 599px) {
.image-history-toolbar {
padding: 12px;
}
.image-history-tools {
width: 100%;
}
.image-history-tools .image-task-search {
flex: 1;
}
.image-task-model-filter,
.image-task-size-filter {
flex: 1 1 110px;
min-width: 0;
}
}
File diff suppressed because it is too large Load Diff
@@ -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;
}
}
@@ -1,31 +1,21 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import VideoInputPanel from './Video/VideoInputPanel';
import VideoPreviewPanel from './Video/VideoPreviewPanel';
import VideoTaskQueue from './Video/VideoTaskQueue';
import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration';
import { showInfo } from '../../../../helpers';
import './Video/VideoWorkspace.css';
const VideoGenerationTab = () => {
const { t } = useTranslation();
const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(false);
const [taskQueueVisible, setTaskQueueVisible] = useState(false);
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const [selectedTaskForPlay, setSelectedTaskForPlay] = useState(null);
// 输入面板容器:再生成回填后滚动到面板顶部
const inputPanelRef = useRef(null);
const inputScrollRef = useRef(null);
// 监听窗口大小变化
useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
const creation = useVideoGeneration();
const {
// 表单数据
@@ -95,197 +85,52 @@ const VideoGenerationTab = () => {
showInfo(t('已回填原参数,确认后点击生成'));
// 等面板展开渲染后再滚动
requestAnimationFrame(() => {
inputScrollRef.current?.scrollTo?.({ top: 0, behavior: 'smooth' });
inputScrollRef.current?.scrollTo?.({ top: 0 });
inputPanelRef.current?.scrollIntoView?.({
behavior: 'smooth',
block: 'start',
});
});
};
// 响应式布局配置 - 两列布局(左侧配置区 + 右侧预览区)
const getLayoutConfig = () => {
// 超大屏幕 (>1920px): 25% - 75%
if (windowWidth > 1920) {
return {
leftWidth: '25%',
centerWidth: '75%',
minLeftWidth: '350px',
minCenterWidth: '800px',
direction: 'row',
};
}
// 大屏幕 (1600-1920px): 28% - 72%
if (windowWidth > 1600) {
return {
leftWidth: '28%',
centerWidth: '72%',
minLeftWidth: '320px',
minCenterWidth: '700px',
direction: 'row',
};
}
// 中等屏幕 (1280-1600px): 32% - 68%
if (windowWidth > 1280) {
return {
leftWidth: '32%',
centerWidth: '68%',
minLeftWidth: '300px',
minCenterWidth: '600px',
direction: 'row',
};
}
// 小屏幕 (1024-1280px): 35% - 65%
if (windowWidth > 1024) {
return {
leftWidth: '35%',
centerWidth: '65%',
minLeftWidth: '280px',
minCenterWidth: '500px',
direction: 'row',
};
}
// 超小屏幕 (<1024px): 单列布局
return {
leftWidth: '100%',
centerWidth: '100%',
minLeftWidth: '100%',
minCenterWidth: '100%',
direction: 'column',
};
};
const layoutConfig = getLayoutConfig();
return (
<div
style={{
height: '100%',
display: 'flex',
flexDirection: 'column',
position: 'relative',
overflow: 'hidden',
}}
>
<div
style={{
flex: 1,
overflow: layoutConfig.direction === 'row' ? 'hidden' : 'auto',
display: 'flex',
flexDirection: layoutConfig.direction === 'row' ? 'row' : 'column',
gap: layoutConfig.direction === 'column' ? '16px' : '0',
position: 'relative',
paddingBottom: '40px', // 为任务队列触发器留出空间
}}
>
{/* 左侧:输入区域(区域1) */}
<div
ref={inputPanelRef}
style={{
width:
layoutConfig.direction === 'row'
? layoutConfig.leftWidth
: '100%',
minWidth: layoutConfig.minLeftWidth,
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
// 折叠态不能再预留 500px:面板收起后只剩一个 fixed 定位的浮动箭头,
// 这 500px 会变成页面顶部一整块空白
minHeight:
layoutConfig.direction === 'column' && !leftPanelCollapsed
? '500px'
: 'auto',
flexShrink: layoutConfig.direction === 'row' ? 0 : 1,
backgroundColor: 'var(--ui-color-bg-1)',
borderRight:
layoutConfig.direction === 'row'
? '1px solid var(--ui-color-border)'
: 'none',
borderBottom:
layoutConfig.direction === 'column'
? '1px solid var(--ui-color-border)'
: 'none',
display: 'flex',
flexDirection: 'column',
}}
>
<div
ref={inputScrollRef}
className='app-scrollbar'
style={{
height: '100%',
overflow: 'auto',
paddingBottom: layoutConfig.direction === 'row' ? '16px' : '16px',
}}
>
<VideoInputPanel
creation={creation}
onCollapse={() => setLeftPanelCollapsed(!leftPanelCollapsed)}
collapsed={leftPanelCollapsed}
collapsible={layoutConfig.direction === 'row'}
/>
</div>
<div className='video-workspace-body'>
<div className='video-workspace-grid'>
<div ref={inputPanelRef} className='video-workspace-composer'>
<VideoInputPanel
creation={creation}
collapsed={leftPanelCollapsed}
onCollapse={() => setLeftPanelCollapsed((current) => !current)}
scrollRef={inputScrollRef}
/>
</div>
{/* 右侧:预览+生成区域 */}
<div
style={{
flex: 1,
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
minHeight: layoutConfig.direction === 'column' ? '600px' : 'auto',
minWidth: 0,
}}
>
<div
className='app-scrollbar'
style={{
height: '100%',
backgroundColor: 'var(--ui-color-bg-0)',
padding: windowWidth > 768 ? '16px' : '12px',
overflow: 'auto',
}}
>
<VideoPreviewPanel
formData={formData}
generating={generating}
currentTask={currentTask}
onGenerate={handleGenerate}
onCancel={handleCancel}
selectedModel={selectedModel}
submitBlock={submitBlock}
submitting={submitting}
quote={quote}
quoteLoading={quoteLoading}
quoteFailed={quoteFailed}
estSeconds={estSeconds}
selectedTaskForPlay={selectedTaskForPlay}
onRegenerate={handleRegenerate}
onClearSelectedTask={handleClearSelectedTask}
/>
</div>
</div>
</div>
{/* 底部:任务队列(区域4) - 使用 absolute 定位,相对于父容器 */}
<div
style={{
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
zIndex: 1000,
}}
>
<VideoTaskQueue
visible={taskQueueVisible}
setVisible={setTaskQueueVisible}
tasks={tasks}
onRefresh={refreshTasks}
onDelete={deleteTask}
onDownload={downloadTask}
onPlay={handlePlayTask}
<VideoPreviewPanel
formData={formData}
generating={generating}
currentTask={currentTask}
onGenerate={handleGenerate}
onCancel={handleCancel}
selectedModel={selectedModel}
submitBlock={submitBlock}
submitting={submitting}
quote={quote}
quoteLoading={quoteLoading}
quoteFailed={quoteFailed}
estSeconds={estSeconds}
selectedTaskForPlay={selectedTaskForPlay}
onRegenerate={handleRegenerate}
onClearSelectedTask={handleClearSelectedTask}
/>
</div>
<VideoTaskQueue
visible={taskQueueVisible}
setVisible={setTaskQueueVisible}
tasks={tasks}
onRefresh={refreshTasks}
onDelete={deleteTask}
onDownload={downloadTask}
onPlay={handlePlayTask}
onRegenerate={handleRegenerate}
/>
</div>
);
};
@@ -1,6 +1,6 @@
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { Video, Sparkles, Clapperboard, Film, Play } from 'lucide-react';
import { Video } from 'lucide-react';
import VideoGenerationTab from './AICreation/VideoGenerationTab';
import CreationStudio from '../../../components/creation/CreationStudio';
import { StatusContext } from '../../../context/Status';
@@ -16,81 +16,17 @@ const VideoGeneration = () => {
}
return (
<div className='h-full flex flex-col p-6 relative overflow-hidden'>
{/* 背景由父级 ExperienceCenter 的 PageBackground(rich) 统一提供,此处不再渲染 */}
{/* Header */}
<div className='relative z-10 flex-shrink-0 mb-6'>
<div className='flex items-center gap-4'>
{/* 图标容器 */}
<div className='relative'>
<div className='absolute -inset-2 bg-gradient-to-r from-cyan-500/30 to-blue-500/30 rounded-2xl blur-lg opacity-60' />
<div className='relative p-3 bg-gradient-to-br from-cyan-500 via-blue-500 to-brand-to rounded-2xl shadow-xl shadow-cyan-500/30'>
<Video size={26} className='text-white' />
</div>
<Sparkles
size={16}
className='absolute -top-1 -right-1 text-amber-400 animate-pulse'
/>
{/* 播放动画指示器 */}
<div className='absolute -bottom-1 -left-1 w-5 h-5 rounded-full bg-green-500 flex items-center justify-center shadow-lg shadow-green-500/50'>
<Play size={10} className='text-white ml-0.5' fill='white' />
</div>
</div>
{/* 标题文字 */}
<div>
<h1 className='text-2xl md:text-3xl font-bold flex items-center gap-2'>
<span className='bg-clip-text text-transparent bg-gradient-to-r from-cyan-600 via-blue-600 to-brand-to dark:from-cyan-400 dark:via-blue-400 dark:to-brand-to'>
{t('视频生成')}
</span>
</h1>
<p className='text-sm text-gray-500 dark:text-gray-400 mt-1'>
{t('使用 AI 创建令人惊叹的视频内容')}
</p>
</div>
{/* 右侧装饰标签 */}
<div className='hidden md:flex items-center gap-2 ml-auto'>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-cyan-50 to-teal-50 dark:from-cyan-950/30 dark:to-teal-950/30 border border-cyan-200/50 dark:border-cyan-800/30'>
<Clapperboard size={14} className='text-cyan-500' />
<span className='text-xs font-medium text-cyan-600 dark:text-cyan-400'>
{t('图生视频')}
</span>
</div>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-blue-50 to-brand-to/5 dark:from-blue-950/30 dark:to-brand-to/30 border border-blue-200/50 dark:border-blue-800/30'>
<Film size={14} className='text-blue-500' />
<span className='text-xs font-medium text-blue-600 dark:text-blue-400'>
{t('文生视频')}
</span>
</div>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-brand-from/5 to-brand-to/5 dark:from-brand-from/30 dark:to-brand-to/30 border border-brand/50 dark:border-brand-deep/30'>
<Sparkles size={14} className='text-brand' />
<span className='text-xs font-medium text-brand-deep dark:text-brand-from'>
{t('多模型支持')}
</span>
</div>
</div>
<div className='video-workspace app-scrollbar'>
<header className='video-workspace-heading'>
<span className='video-workspace-icon' aria-hidden='true'>
<Video size={22} />
</span>
<div>
<h1>{t('视频生成')}</h1>
<p>{t('使用 AI 创建令人惊叹的视频内容')}</p>
</div>
</div>
{/* Content */}
<div className='relative z-10 flex-1 min-h-0'>
{/* 卡片装饰边框 */}
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 via-blue-500/20 to-brand-to/20 rounded-[20px] blur-sm opacity-60' />
{/* 内容卡片 */}
<div className='relative h-full bg-white/70 dark:bg-neutral-900/70 backdrop-blur-xl rounded-2xl border border-white/50 dark:border-neutral-800/50 shadow-xl shadow-cyan-500/5 overflow-hidden'>
{/* 顶部装饰线 */}
<div className='absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent' />
{/* 左侧装饰线 */}
<div className='absolute top-0 bottom-0 left-0 w-[2px] bg-gradient-to-b from-transparent via-blue-500/30 to-transparent' />
<VideoGenerationTab />
</div>
</div>
</header>
<VideoGenerationTab />
</div>
);
};
+10 -6
View File
@@ -190,12 +190,16 @@ const ExperienceCenter = () => {
* 子组件不再各自渲染背景,避免双层叠加。
* text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。
* 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */}
{!isTextModel && (
<PageBackground
variant={isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'}
animate
/>
)}
{!isTextModel &&
(!(isVideoGeneration || isImageGeneration) ||
creationStudioEnabled) && (
<PageBackground
variant={
isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'
}
animate
/>
)}
{/* 内容区域 */}
<div