fix(experience-center): 统一图像与视频生成界面并修复参数显示
对齐表单、预览与任务区,跟随系统主题色,修复图片尺寸选择和视频高级参数显示。已通过本地浏览器验收、Lint、UI 审计和单测;未做生产测试。
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user