feat(experience-center): 统一侧栏与页头,优化云端大脑、图片和视频生成界面

This commit is contained in:
zhanjunhao
2026-11-20 21:38:32 +08:00
parent 4843d4c3ec
commit 83a0c1d499
18 changed files with 1045 additions and 678 deletions
@@ -1,5 +1,4 @@
import {
Play as ActionPlay,
Download as ActionDownload,
RefreshCw as ActionRefreshCw,
Trash2 as ActionTrash2,
@@ -7,23 +6,18 @@ import {
ChevronDown as ActionChevronDown,
} from '@/components/common/icons/ActionIcons';
import React, { useState, useId } from 'react';
import { Button as AntButton } from 'antd';
import {
Table,
Button,
Space,
Tag,
Progress,
Tooltip,
Modal,
Badge,
Pagination,
} from '@/components/ui';
import {
ListVideo,
CheckCircle2,
AlertCircle,
Clock,
Loader2,
} from 'lucide-react';
import { ListVideo } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
import {
@@ -47,55 +41,37 @@ const VideoTaskQueue = ({
// 8 列合计 1190px 塞进 ~340px 容器、按钮全带文字,实际完全用不了。
const isCompact = useIsMobile();
const [selectedTasks, setSelectedTasks] = useState([]);
// 前端分页:分页器放在表格滚动区之外(与密钥管理一致),切换每页条数时不再在滚动区内撑出滚动条造成抖动
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const queueId = useId();
const pageCount = Math.max(1, Math.ceil(tasks.length / pageSize));
const currentPage = Math.min(page, pageCount);
const pagedTasks = tasks.slice(
(currentPage - 1) * pageSize,
currentPage * pageSize,
);
// 状态标签映射
const getStatusTag = (status) => {
// 统一转换为小写进行比较
const normalizedStatus = normalizeVideoTaskStatus(status);
// 状态统一为“文字 + 边框”标签,不带图标;居中由列 align 与 .video-queue-status 控制
const statusMap = {
queued: { color: 'blue', text: t('排队中'), icon: <Clock size={12} /> },
in_progress: {
color: 'cyan',
text: t('生成中'),
icon: <Loader2 size={12} className='animate-spin' />,
},
success: {
color: 'green',
text: t('已完成'),
icon: <CheckCircle2 size={12} />,
},
completed: {
color: 'green',
text: t('已完成'),
icon: <CheckCircle2 size={12} />,
},
failure: {
color: 'red',
text: t('失败'),
icon: <AlertCircle size={12} />,
},
failed: {
color: 'red',
text: t('失败'),
icon: <AlertCircle size={12} />,
},
canceled: {
color: 'grey',
text: t('已取消'),
icon: <AlertCircle size={12} />,
},
queued: { color: 'blue', text: t('排队中') },
in_progress: { color: 'cyan', text: t('生成中') },
success: { color: 'green', text: t('已完成') },
completed: { color: 'green', text: t('已完成') },
failure: { color: 'red', text: t('失败') },
failed: { color: 'red', text: t('失败') },
canceled: { color: 'grey', text: t('已取消') },
};
const config = statusMap[normalizedStatus] || {
color: 'grey',
text: status,
};
return (
<Tag
color={config.color}
style={{ display: 'inline-flex', alignItems: 'center', gap: '4px' }}
>
{config.icon}
<Tag color={config.color} className='video-queue-status'>
{config.text}
</Tag>
);
@@ -128,12 +104,9 @@ const VideoTaskQueue = ({
{
title: t('任务ID'),
dataIndex: 'task_id',
width: !isCompact ? 120 : 100,
render: (text) => (
<Tooltip content={text}>
<span style={{ cursor: 'pointer' }}>{text?.substring(0, 8)}...</span>
</Tooltip>
),
width: 200,
// 完整展示任务 ID(纯文本,不截断)
render: (text) => text || '-',
},
{
title: t('模式'),
@@ -166,6 +139,7 @@ const VideoTaskQueue = ({
title: t('状态'),
dataIndex: 'status',
width: !isCompact ? 120 : 100,
align: 'center',
render: (status) => getStatusTag(status),
},
{
@@ -193,51 +167,53 @@ const VideoTaskQueue = ({
{
title: t('操作'),
dataIndex: 'operate',
width: !isCompact ? 220 : 180,
width: 200,
fixed: 'right',
render: (text, record) => {
const normalizedStatus = normalizeVideoTaskStatus(record.status);
return (
<Space>
// 操作列与密钥管理列表一致:文字链接按钮(主色 / 删除为危险色),不带图标与描边
<div className='video-queue-actions'>
{/* 播放和下载按钮:仅根据状态显示,视频URL在点击时才获取 */}
{normalizedStatus === 'success' && (
<>
<Button
<AntButton
type='link'
size='small'
type='tertiary'
icon={<ActionPlay size={14} />}
className='video-queue-link'
onClick={() => onPlay && onPlay(record)}
>
{!isCompact ? t('播放') : ''}
</Button>
<Button
{t('播放')}
</AntButton>
<AntButton
type='link'
size='small'
type='tertiary'
icon={<ActionDownload size={14} />}
className='video-queue-link'
onClick={() => onDownload(record)}
>
{!isCompact ? t('下载') : ''}
</Button>
{t('下载')}
</AntButton>
</>
)}
{/* 再生成按钮 - 对所有已完成或失败的任务显示 */}
{(normalizedStatus === 'success' ||
normalizedStatus === 'failure') &&
canRegenerateVideoTask(record) && (
<Button
<AntButton
type='link'
size='small'
type='primary'
icon={<ActionRefreshCw size={14} />}
className='video-queue-link'
onClick={() => onRegenerate && onRegenerate(record)}
>
{!isCompact ? t('再生成') : ''}
</Button>
{t('再生成')}
</AntButton>
)}
<Button
<AntButton
type='link'
size='small'
type='danger'
icon={<ActionTrash2 size={14} />}
danger
className='video-queue-link'
onClick={() => {
Modal.warning({
title: t('确定删除此任务?'),
@@ -253,9 +229,9 @@ const VideoTaskQueue = ({
});
}}
>
{!isCompact ? t('删除') : ''}
</Button>
</Space>
{t('删除')}
</AntButton>
</div>
);
},
},
@@ -278,112 +254,146 @@ const VideoTaskQueue = ({
};
return (
<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' />
)}
<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'}
icon={<ActionRefreshCw size={14} />}
onClick={onRefresh}
>
{t('刷新')}
</Button>
{selectedTasks.length > 0 && (
<>
<Button
size={!isCompact ? 'default' : 'small'}
icon={<ActionDownload size={14} />}
onClick={handleBatchDownload}
>
{t('批量下载')} ({selectedTasks.length})
</Button>
<Button
size={!isCompact ? 'default' : 'small'}
type='danger'
icon={<ActionTrash2 size={14} />}
onClick={() => {
Modal.warning({
title: t('确定删除选中的任务?'),
content: t('将删除 {{count}} 个任务,删除后将无法恢复', {
count: selectedTasks.length,
}),
icon: (
<ActionAlertCircle
size={24}
style={{ color: '#f59e0b' }}
/>
),
okText: t('确定删除'),
cancelText: t('取消'),
onOk: handleBatchDelete,
centered: true,
okButtonProps: { type: 'danger' },
});
}}
>
{t('批量删除')} ({selectedTasks.length})
</Button>
</>
// 外层 section 在桌面端只占折叠条高度;展开内容由 .video-queue-panel 自底向上浮层覆盖,
// 不挤压上方的参数 / 预览区域(样式见 VideoWorkspace.css)。Esc 收起并把焦点还给切换按钮。
<section
className='video-queue'
data-expanded={visible || undefined}
onKeyDown={(event) => {
if (event.key === 'Escape' && visible) {
event.stopPropagation();
setVisible(false);
event.currentTarget.querySelector('.video-queue-toggle')?.focus();
}
}}
>
<div className='video-queue-panel'>
<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>
<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'}
icon={<ActionRefreshCw size={14} />}
onClick={onRefresh}
>
{t('刷新')}
</Button>
{selectedTasks.length > 0 && (
<>
<Button
size={!isCompact ? 'default' : 'small'}
icon={<ActionDownload size={14} />}
onClick={handleBatchDownload}
>
{t('批量下载')} ({selectedTasks.length})
</Button>
<Button
size={!isCompact ? 'default' : 'small'}
type='danger'
icon={<ActionTrash2 size={14} />}
onClick={() => {
Modal.warning({
title: t('确定删除选中的任务?'),
content: t(
'将删除 {{count}} 个任务,删除后将无法恢复',
{
count: selectedTasks.length,
},
),
icon: (
<ActionAlertCircle
size={24}
style={{ color: '#f59e0b' }}
/>
),
okText: t('确定删除'),
cancelText: t('取消'),
onOk: handleBatchDelete,
centered: true,
okButtonProps: { type: 'danger' },
});
}}
>
{t('批量删除')} ({selectedTasks.length})
</Button>
</>
)}
</Space>
{/* 统计信息 */}
<Space wrap>
<Tag size={!isCompact ? 'default' : 'small'} color='blue'>
{t('排队')}: {taskStats.queued}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='cyan'>
{t('生成中')}: {taskStats.in_progress}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='green'>
{t('完成')}: {taskStats.completed}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='red'>
{t('失败')}: {taskStats.failed}
</Tag>
</Space>
</div>
{/* 统计信息 */}
<Space wrap>
<Tag size={!isCompact ? 'default' : 'small'} color='blue'>
{t('排队')}: {taskStats.queued}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='cyan'>
{t('生成中')}: {taskStats.in_progress}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='green'>
{t('完成')}: {taskStats.completed}
</Tag>
<Tag size={!isCompact ? 'default' : 'small'} color='red'>
{t('失败')}: {taskStats.failed}
</Tag>
</Space>
</div>
{/* 任务表格 */}
<div className='video-queue-table app-scrollbar'>
<Table
columns={columns}
dataSource={tasks}
rowKey='task_id'
scroll={{ x: 'max-content' }}
pagination={{ pageSize: 10 }}
rowSelection={{
selectedRowKeys: selectedTasks,
onChange: setSelectedTasks,
getCheckboxProps: (record) => ({
disabled: record.status === 'in_progress',
}),
}}
size='small'
empty={t('暂无任务')}
/>
{/* 任务表格 */}
<div className='video-queue-table app-scrollbar'>
<Table
className='video-queue-grid'
columns={columns}
dataSource={pagedTasks}
rowKey='task_id'
tableLayout='fixed'
scroll={{
x: columns.reduce((sum, column) => sum + column.width, 0),
}}
pagination={false}
rowSelection={{
selectedRowKeys: selectedTasks,
onChange: setSelectedTasks,
getCheckboxProps: (record) => ({
disabled: record.status === 'in_progress',
}),
}}
size='middle'
empty={t('暂无任务')}
/>
</div>
{tasks.length > 0 ? (
<Pagination
className='video-queue-pagination'
total={tasks.length}
currentPage={currentPage}
pageSize={pageSize}
onPageChange={setPage}
onPageSizeChange={(size) => {
setPageSize(size);
setPage(1);
}}
/>
) : null}
</div>
</div>
</section>
@@ -1,14 +1,17 @@
.video-workspace {
display: flex;
flex-direction: column;
gap: 20px;
height: 100%;
padding: 24px;
/* 内容边距与用户中心一致(GLOBAL_UI_BASELINE 4.4),底部取一半与图片生成页统一;页头与首块间距由 .uc-page-header 的 18px 提供 */
padding: var(--uc-page-pad-top) var(--uc-page-pad-x)
calc(var(--uc-page-pad-bottom) / 2);
overflow: auto;
}
.video-workspace-heading,
.video-workspace-title,
.video-workspace > .exp-page-header {
flex: none;
}
.video-panel-heading {
display: flex;
align-items: center;
@@ -16,12 +19,6 @@
min-width: 0;
}
.video-workspace-heading {
flex: none;
flex-wrap: wrap;
justify-content: space-between;
}
.video-workspace-capabilities {
--vw-capability-line: color-mix(
in srgb,
@@ -54,7 +51,6 @@
flex: none;
}
.video-workspace-icon,
.video-preview-empty-icon {
display: grid;
flex: none;
@@ -66,20 +62,6 @@
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;
@@ -134,13 +116,54 @@
}
.video-queue {
/* 表格配色与密钥管理列表(key-management.css 的 --km-*)同值 */
--vq-head-bg: #f8f9fc;
--vq-head-text: #687589;
--vq-row-split: #f0f0f0;
--vq-text: rgba(0, 0, 0, 0.88);
position: relative;
flex: none;
min-width: 0;
}
html.dark .video-queue {
--vq-head-bg: var(--ui-color-fill-0);
--vq-head-text: var(--text-secondary);
--vq-row-split: var(--border-subtle);
--vq-text: var(--uc-heading);
}
.video-queue-panel {
background: var(--surface-card);
border: 1px solid var(--border-subtle);
border-radius: 12px;
}
/* 宽屏:队列占位只保留折叠条高度(52px 按钮 + 2px 边框),展开内容以浮层自底向上覆盖,
不推挤上方的参数 / 预览区;窄屏整页滚动,保持文档流内展开 */
@media (min-width: 1025px) {
.video-queue {
height: 54px;
}
.video-queue-panel {
position: absolute;
right: 0;
bottom: 0;
left: 0;
z-index: 20;
}
.video-queue[data-expanded='true'] .video-queue-panel {
box-shadow: 0 -12px 32px
color-mix(in srgb, var(--text-primary) 14%, transparent);
}
.video-queue[data-expanded='true'] .video-queue-table {
max-height: clamp(160px, 40dvh, 400px);
}
}
.video-queue-heading {
margin: 0;
}
@@ -219,8 +242,60 @@
min-width: 0;
max-height: clamp(120px, 24dvh, 260px);
overflow: auto;
border-end-start-radius: 11px;
border-end-end-radius: 11px;
/* 预留滚动条位置:行数变化或下拉展开时不因滚动条出现 / 消失而横向抖动 */
scrollbar-gutter: stable;
}
/* 表格样式与交互对齐密钥管理列表:middle 尺寸、表头 46px 常规字重、行分隔线、文字链接操作 */
.video-queue-grid .ant-table-thead > tr > th {
--center-table-head-bg: var(--vq-head-bg);
height: 46px;
padding-block: 0;
border-bottom-color: var(--vq-row-split);
background: var(--vq-head-bg);
color: var(--vq-head-text);
font-weight: 400;
}
.video-queue-grid .ant-table-thead > tr > th::before {
display: none;
}
.video-queue-grid .ant-table-tbody > tr > td {
border-bottom-color: var(--vq-row-split);
color: var(--vq-text);
}
.video-queue-grid .ant-tag {
margin-inline-end: 0;
}
/* 状态:仅文字 + 边框,单元格内水平垂直居中 */
.video-queue-grid .video-queue-status.ant-tag {
display: inline-flex;
align-items: center;
justify-content: center;
margin: 0;
vertical-align: middle;
}
.video-queue-actions {
display: flex;
align-items: center;
gap: 6px;
}
.video-queue-actions .video-queue-link.ant-btn {
height: auto;
padding: 0;
}
/* 分页器在表格滚动区之外,位置固定,不随表格内容滚动或跳动 */
.video-queue-pagination {
display: flex;
justify-content: flex-end;
padding: 12px 16px;
border-top: 1px solid var(--vq-row-split);
}
@media (max-width: 767px) {
@@ -230,11 +305,6 @@
}
@media (max-width: 1024px) {
.video-workspace {
gap: 16px;
padding: 16px;
}
.video-workspace-body {
flex: none;
height: auto;
@@ -245,11 +315,6 @@
min-height: 0;
}
.video-workspace-heading h1 {
font-size: 24px;
line-height: 28px;
}
.video-queue-table {
max-height: 320px;
}