Initial import of weiyuan frontend

This commit is contained in:
qiubaishen
2026-10-15 16:33:46 +08:00
commit d8f3aee261
774 changed files with 374914 additions and 0 deletions
@@ -0,0 +1,217 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from '@douyinfe/semi-ui';
import {
ListTodo,
Clock,
CheckCircle2,
Download,
XCircle,
Loader2,
FileDown,
} from 'lucide-react';
import { exportToCsv, formatTimestampForCsv } from '../../../helpers/exportCsv';
const TaskLogsActions = ({
t,
logs = [],
isAdminUser,
usageRecordMode = false,
}) => {
const ExportIcon = usageRecordMode ? FileDown : Download;
const exportButtonClass = usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: 'hover:!bg-gray-100 dark:hover:!bg-neutral-800 !transition-all !duration-300';
// 计算任务统计
const stats = React.useMemo(() => {
const successCount = logs.filter((log) => log.status === 'SUCCESS').length;
const failureCount = logs.filter((log) => log.status === 'FAILURE').length;
const pendingCount = logs.filter(
(log) =>
log.status === 'IN_PROGRESS' ||
log.status === 'SUBMITTED' ||
log.status === 'QUEUED' ||
log.status === '',
).length;
return { successCount, failureCount, pendingCount, total: logs.length };
}, [logs]);
// CSV 导出:仅当前页已加载的数据,避免一次性拉取全量产生巨大请求
const handleExportCsv = () => {
if (!logs || logs.length === 0) return;
const columns = [
{
key: 'submit_time',
title: t('提交时间'),
format: (r) => formatTimestampForCsv(r.submit_time),
},
{
key: 'finish_time',
title: t('结束时间'),
format: (r) => formatTimestampForCsv(r.finish_time),
},
{
key: 'duration',
title: t('耗时(秒)'),
format: (r) =>
r.submit_time && r.finish_time ? r.finish_time - r.submit_time : '',
},
...(isAdminUser
? [
{ key: 'channel_id', title: t('渠道ID') },
{ key: 'channel_name', title: t('渠道名称') },
]
: []),
{ key: 'platform', title: t('平台') },
{ key: 'action', title: t('类型') },
{
key: 'model',
title: t('模型'),
format: (r) =>
r.properties?.origin_model_name ||
r.properties?.upstream_model_name ||
'',
},
{ key: 'task_id', title: t('任务ID') },
{ key: 'status', title: t('状态') },
{ key: 'progress', title: t('进度') },
{ key: 'quota', title: t('费用'), format: (r) => r.quota || '' },
{ key: 'fail_reason', title: t('详情') },
];
const ts = formatTimestampForCsv(Math.floor(Date.now() / 1000)).replace(
/[: ]/g,
'-',
);
exportToCsv(columns, logs, `task-logs-${ts}.csv`);
};
const StatBadge = ({ icon: Icon, label, value, gradient, iconBg }) => (
<div className='relative group'>
<div
className={`
relative overflow-hidden
px-3 py-2 rounded-xl
bg-gradient-to-br ${gradient}
border border-white/50 dark:border-neutral-700/50
shadow-sm hover:shadow-md
transition-all duration-300
hover:scale-[1.02]
`}
>
{/* 装饰光晕 */}
<div className='absolute -top-2 -right-2 w-10 h-10 bg-white/20 rounded-full blur-xl opacity-0 group-hover:opacity-100 transition-opacity duration-300' />
<div className='relative flex items-center gap-2'>
<div
className={`flex items-center justify-center w-7 h-7 rounded-lg ${iconBg} shadow-sm`}
>
<Icon className='w-3.5 h-3.5 text-white' strokeWidth={2} />
</div>
<div className='flex flex-col'>
<span className='text-[10px] font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide'>
{label}
</span>
<span className='text-sm font-bold text-gray-800 dark:text-gray-100'>
{value}
</span>
</div>
</div>
</div>
</div>
);
return (
<div className='flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4 w-full'>
{/* 左侧:标题和统计 */}
<div className='flex flex-wrap items-center gap-3'>
{/* 页面标识 */}
<div className='flex items-center gap-2 px-3 py-2 rounded-xl bg-gradient-to-r from-cyan-50 to-blue-50 dark:from-cyan-950/40 dark:to-blue-950/40 border border-cyan-200/50 dark:border-cyan-800/30'>
<div className='flex items-center justify-center w-8 h-8 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 shadow-md'>
<ListTodo className='w-4 h-4 text-white' strokeWidth={2} />
</div>
<div className='flex flex-col'>
<span className='text-sm font-semibold text-gray-800 dark:text-gray-100'>
{t('任务记录')}
</span>
<span className='text-[10px] text-gray-500 dark:text-gray-400'>
{t('异步任务执行状态')}
</span>
</div>
</div>
{/* 快速统计 */}
{logs.length > 0 && (
<div className='hidden md:flex items-center gap-2'>
{/* 这些统计只包含当前页数据,因此 label 前缀"本页",避免用户误以为是全量统计 */}
<StatBadge
icon={CheckCircle2}
label={t('本页成功')}
value={stats.successCount}
gradient='from-emerald-50 to-green-50 dark:from-emerald-950/30 dark:to-green-950/30'
iconBg='bg-gradient-to-br from-emerald-500 to-green-600'
/>
<StatBadge
icon={XCircle}
label={t('本页失败')}
value={stats.failureCount}
gradient='from-rose-50 to-red-50 dark:from-rose-950/30 dark:to-red-950/30'
iconBg='bg-gradient-to-br from-rose-500 to-red-600'
/>
<StatBadge
icon={Loader2}
label={t('本页进行中')}
value={stats.pendingCount}
gradient='from-amber-50 to-orange-50 dark:from-amber-950/30 dark:to-orange-950/30'
iconBg='bg-gradient-to-br from-amber-500 to-orange-600'
/>
</div>
)}
</div>
{/* 右侧:操作按钮 */}
<div className='flex items-center gap-2'>
{/* 实时状态指示:只有真实存在进行中任务时才常亮,避免"实时更新"始终挂着误导用户 */}
{stats.pendingCount > 0 && (
<div className='hidden sm:flex items-center gap-1.5 px-3 py-1.5 rounded-lg 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'>
<Clock className='w-3.5 h-3.5 text-brand-deep dark:text-brand-from animate-pulse' />
<span className='text-xs font-medium text-brand-deep dark:text-brand-from'>
{t('实时更新中')}
</span>
</div>
)}
{/* 导出当前页为 CSV,空列表时禁用避免生成只有表头的无用文件 */}
<Button
size='small'
icon={<ExportIcon className='w-3.5 h-3.5' />}
onClick={handleExportCsv}
disabled={!logs || logs.length === 0}
className={exportButtonClass}
>
{t('导出本页')}
</Button>
</div>
</div>
);
};
export default TaskLogsActions;
@@ -0,0 +1,519 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Progress, Tooltip, Typography } from '@douyinfe/semi-ui';
import {
Music,
FileText,
HelpCircle,
CheckCircle,
Pause,
Clock,
Play,
XCircle,
Loader,
List,
Hash,
Video,
Sparkles,
Timer,
Image as ImageIcon,
ImagePlus,
Coins,
Cpu,
} from 'lucide-react';
import {
TASK_ACTION_FIRST_TAIL_GENERATE,
TASK_ACTION_GENERATE,
TASK_ACTION_REFERENCE_GENERATE,
TASK_ACTION_TEXT_GENERATE,
IMAGE_ACTION_GENERATE,
IMAGE_ACTION_EDIT,
} from '../../../constants/common.constant';
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
import { renderQuota } from '../../../helpers';
// 仅保留与下方 COLOR_CONFIG 一一对应的色值,避免 amber/lime/violet/teal/indigo/light-blue
// 经历多级三元 fallback 后被挤压到少数颜色上,渠道颜色分布严重偏斜
const colors = [
'blue',
'cyan',
'green',
'grey',
'orange',
'pink',
'purple',
'red',
'yellow',
];
// 颜色配置映射
const COLOR_CONFIG = {
green: {
bg: 'bg-emerald-50 dark:bg-emerald-950/30',
text: 'text-emerald-600 dark:text-emerald-400',
border: 'border-emerald-200/50 dark:border-emerald-800/50',
gradient: 'from-emerald-500 to-green-600',
},
yellow: {
bg: 'bg-amber-50 dark:bg-amber-950/30',
text: 'text-amber-600 dark:text-amber-400',
border: 'border-amber-200/50 dark:border-amber-800/50',
gradient: 'from-amber-500 to-yellow-600',
},
blue: {
bg: 'bg-blue-50 dark:bg-blue-950/30',
text: 'text-blue-600 dark:text-blue-400',
border: 'border-blue-200/50 dark:border-blue-800/50',
gradient: 'from-blue-500 to-brand-to',
},
red: {
bg: 'bg-rose-50 dark:bg-rose-950/30',
text: 'text-rose-600 dark:text-rose-400',
border: 'border-rose-200/50 dark:border-rose-800/50',
gradient: 'from-rose-500 to-red-600',
},
orange: {
bg: 'bg-orange-50 dark:bg-orange-950/30',
text: 'text-orange-600 dark:text-orange-400',
border: 'border-orange-200/50 dark:border-orange-800/50',
gradient: 'from-orange-500 to-amber-600',
},
grey: {
bg: 'bg-gray-50 dark:bg-gray-900/30',
text: 'text-gray-600 dark:text-gray-400',
border: 'border-gray-200/50 dark:border-gray-700/50',
gradient: 'from-gray-400 to-gray-600',
},
pink: {
bg: 'bg-pink-50 dark:bg-pink-950/30',
text: 'text-pink-600 dark:text-pink-400',
border: 'border-pink-200/50 dark:border-pink-800/50',
gradient: 'from-pink-500 to-rose-600',
},
purple: {
bg: 'bg-brand/5 dark:bg-brand-deep/30',
text: 'text-brand-deep dark:text-brand-from',
border: 'border-brand/50 dark:border-brand-deep/50',
gradient: 'from-brand-from to-brand-to',
},
cyan: {
bg: 'bg-cyan-50 dark:bg-cyan-950/30',
text: 'text-cyan-600 dark:text-cyan-400',
border: 'border-cyan-200/50 dark:border-cyan-800/50',
gradient: 'from-cyan-500 to-teal-600',
},
};
// 自定义标签组件
const CustomTag = ({
icon: Icon,
label,
colorKey = 'grey',
animate = false,
}) => {
const config = COLOR_CONFIG[colorKey] || COLOR_CONFIG.grey;
return (
<span
className={`
inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium
${config.bg} ${config.text} border ${config.border}
transition-all duration-200 hover:scale-105
`}
>
<span
className={`flex items-center justify-center w-4 h-4 rounded-full bg-gradient-to-br ${config.gradient}`}
>
<Icon
className={`w-2.5 h-2.5 text-white ${animate ? 'animate-spin' : ''}`}
strokeWidth={2.5}
/>
</span>
{label}
</span>
);
};
// Render functions
const renderTimestamp = (timestampInSeconds) => {
const date = new Date(timestampInSeconds * 1000);
const year = date.getFullYear();
const month = ('0' + (date.getMonth() + 1)).slice(-2);
const day = ('0' + date.getDate()).slice(-2);
const hours = ('0' + date.getHours()).slice(-2);
const minutes = ('0' + date.getMinutes()).slice(-2);
const seconds = ('0' + date.getSeconds()).slice(-2);
return (
<span className='text-xs text-gray-600 dark:text-gray-300 font-mono'>
{`${year}-${month}-${day}`}
<span className='text-gray-400 dark:text-gray-500 mx-1'>|</span>
{`${hours}:${minutes}:${seconds}`}
</span>
);
};
function renderDuration(submit_time, finishTime) {
if (!submit_time || !finishTime) return '-';
const durationSec = finishTime - submit_time;
const colorKey = durationSec > 60 ? 'red' : 'green';
return (
<CustomTag icon={Timer} label={`${durationSec} 秒`} colorKey={colorKey} />
);
}
const renderType = (type, t) => {
const typeConfig = {
MUSIC: { icon: Music, label: t('生成音乐'), color: 'grey' },
LYRICS: { icon: FileText, label: t('生成歌词'), color: 'pink' },
[TASK_ACTION_GENERATE]: {
icon: Sparkles,
label: t('图生视频'),
color: 'blue',
},
[TASK_ACTION_TEXT_GENERATE]: {
icon: Sparkles,
label: t('文生视频'),
color: 'blue',
},
[TASK_ACTION_FIRST_TAIL_GENERATE]: {
icon: Sparkles,
label: t('首尾生视频'),
color: 'blue',
},
[TASK_ACTION_REFERENCE_GENERATE]: {
icon: Sparkles,
label: t('参照生视频'),
color: 'blue',
},
[IMAGE_ACTION_GENERATE]: {
icon: Sparkles,
label: t('文生图'),
color: 'cyan',
},
[IMAGE_ACTION_EDIT]: {
icon: ImagePlus,
label: t('图像编辑'),
color: 'purple',
},
};
const config = typeConfig[type] || {
icon: HelpCircle,
label: t('未知'),
color: 'grey',
};
return (
<CustomTag
icon={config.icon}
label={config.label}
colorKey={config.color}
/>
);
};
const renderPlatform = (platform, t) => {
let option = CHANNEL_OPTIONS.find(
(opt) => String(opt.value) === String(platform),
);
if (option) {
return (
<CustomTag
icon={Video}
label={option.label}
colorKey={option.color || 'cyan'}
/>
);
}
if (platform === 'suno') {
return <CustomTag icon={Music} label='Suno' colorKey='green' />;
}
if (platform === 'image') {
return <CustomTag icon={ImageIcon} label={t('图片')} colorKey='cyan' />;
}
if (platform === 'video') {
return <CustomTag icon={Video} label={t('视频')} colorKey='blue' />;
}
if (platform === 'mj') {
return <CustomTag icon={Sparkles} label='Midjourney' colorKey='purple' />;
}
return <CustomTag icon={HelpCircle} label={t('未知')} colorKey='grey' />;
};
const renderStatus = (type, t) => {
const statusConfig = {
SUCCESS: { icon: CheckCircle, label: t('成功'), color: 'green' },
NOT_START: { icon: Pause, label: t('未启动'), color: 'grey' },
SUBMITTED: { icon: Clock, label: t('队列中'), color: 'yellow' },
IN_PROGRESS: {
icon: Play,
label: t('执行中'),
color: 'blue',
animate: false,
},
FAILURE: { icon: XCircle, label: t('失败'), color: 'red' },
QUEUED: { icon: List, label: t('排队中'), color: 'orange' },
UNKNOWN: { icon: HelpCircle, label: t('未知'), color: 'grey' },
'': { icon: Loader, label: t('正在提交'), color: 'grey', animate: true },
};
const config = statusConfig[type] || statusConfig['UNKNOWN'];
return (
<CustomTag
icon={config.icon}
label={config.label}
colorKey={config.color}
animate={config.animate}
/>
);
};
export const getTaskLogsColumns = ({
t,
COLUMN_KEYS,
copyText,
openContentModal,
isAdminUser,
openVideoModal,
}) => {
return [
{
key: COLUMN_KEYS.SUBMIT_TIME,
title: t('提交时间'),
dataIndex: 'submit_time',
render: (text, record, index) => {
return <div>{text ? renderTimestamp(text) : '-'}</div>;
},
},
{
key: COLUMN_KEYS.FINISH_TIME,
title: t('结束时间'),
dataIndex: 'finish_time',
render: (text, record, index) => {
return <div>{text ? renderTimestamp(text) : '-'}</div>;
},
},
{
key: COLUMN_KEYS.DURATION,
title: t('花费时间'),
dataIndex: 'finish_time',
render: (finish, record) => {
return <>{finish ? renderDuration(record.submit_time, finish) : '-'}</>;
},
},
{
key: COLUMN_KEYS.CHANNEL,
title: t('渠道'),
dataIndex: 'channel_id',
render: (text, record, index) => {
if (!isAdminUser) return null;
const idNum = parseInt(text);
const colorIndex = Number.isFinite(idNum)
? ((idNum % colors.length) + colors.length) % colors.length
: 0;
const colorKey = colors[colorIndex];
// 若后端返回 channel_name 则在 Tooltip 中显示名称,便于管理员快速识别;否则回落为 ID
const tooltipContent = record.channel_name || text;
return (
<Tooltip content={tooltipContent}>
<span onClick={() => copyText(text)} className='cursor-pointer'>
<CustomTag icon={Hash} label={text} colorKey={colorKey} />
</span>
</Tooltip>
);
},
},
{
key: COLUMN_KEYS.PLATFORM,
title: t('平台'),
dataIndex: 'platform',
render: (text, record, index) => {
return <div>{renderPlatform(text, t)}</div>;
},
},
{
key: COLUMN_KEYS.TYPE,
title: t('类型'),
dataIndex: 'action',
render: (text, record, index) => {
return <div>{renderType(text, t)}</div>;
},
},
{
key: COLUMN_KEYS.MODEL,
title: t('模型'),
dataIndex: 'properties',
render: (properties, record, index) => {
const modelName =
properties?.origin_model_name ||
properties?.upstream_model_name ||
'';
if (!modelName) {
return (
<span className='text-xs text-gray-400 dark:text-gray-500'>-</span>
);
}
return (
<Tooltip content={modelName}>
<span
onClick={() => copyText(modelName)}
className='cursor-pointer'
>
<CustomTag icon={Cpu} label={modelName} colorKey='purple' />
</span>
</Tooltip>
);
},
},
{
key: COLUMN_KEYS.TASK_ID,
title: t('任务ID'),
dataIndex: 'task_id',
render: (text, record, index) => {
return (
<Typography.Text
ellipsis={{ showTooltip: true }}
onClick={() => {
openContentModal(JSON.stringify(record, null, 2));
}}
className='cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors font-mono text-xs'
>
{text}
</Typography.Text>
);
},
},
{
key: COLUMN_KEYS.TASK_STATUS,
title: t('任务状态'),
dataIndex: 'status',
render: (text, record, index) => {
return <div>{renderStatus(text, t)}</div>;
},
},
{
key: COLUMN_KEYS.PROGRESS,
title: t('进度'),
dataIndex: 'progress',
render: (text, record, index) => {
if (isNaN(text?.replace('%', ''))) {
return <span className='text-xs text-gray-500'>{text || '-'}</span>;
}
const percent = text ? parseInt(text.replace('%', '')) : 0;
const isFailure = record.status === 'FAILURE';
return (
<div className='min-w-[140px]'>
<Progress
stroke={
isFailure
? 'var(--semi-color-warning)'
: 'var(--semi-color-primary)'
}
percent={percent}
showInfo={true}
aria-label='task progress'
size='small'
className='task-progress'
/>
</div>
);
},
},
{
key: COLUMN_KEYS.QUOTA,
title: t('费用'),
dataIndex: 'quota',
render: (quota, record, index) => {
if (quota === undefined || quota === null || quota === 0) {
return (
<span className='text-xs text-gray-400 dark:text-gray-500'>-</span>
);
}
return (
<CustomTag
icon={Coins}
label={renderQuota(quota, 6)}
colorKey='orange'
/>
);
},
},
{
key: COLUMN_KEYS.FAIL_REASON,
title: t('详情'),
dataIndex: 'fail_reason',
fixed: 'right',
render: (text, record, index) => {
const isVideoTask =
record.action === TASK_ACTION_GENERATE ||
record.action === TASK_ACTION_TEXT_GENERATE ||
record.action === TASK_ACTION_FIRST_TAIL_GENERATE ||
record.action === TASK_ACTION_REFERENCE_GENERATE;
const isSuccess = record.status === 'SUCCESS';
const isUrl = typeof text === 'string' && /^https?:\/\//.test(text);
if (isSuccess && isVideoTask && isUrl) {
const videoUrl = `/v1/videos/${record.task_id}/content`;
// text 是上游原始视频 URL,传给弹窗用于"复制链接";代理路径仅用于播放
return (
<a
href='#'
onClick={(e) => {
e.preventDefault();
openVideoModal(videoUrl, text);
}}
className='inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium bg-gradient-to-r from-blue-500 to-brand-to text-white hover:from-blue-600 hover:to-brand-to transition-all duration-300 shadow-sm hover:shadow-md'
>
<Video className='w-3.5 h-3.5' />
{t('点击预览视频')}
</a>
);
}
if (!text) {
return (
<span className='text-xs text-gray-400 dark:text-gray-500'>
{t('无')}
</span>
);
}
return (
<Typography.Text
ellipsis={{ showTooltip: true }}
style={{ width: 100 }}
onClick={() => {
openContentModal(text);
}}
className='cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors text-xs'
>
{text}
</Typography.Text>
);
},
},
];
};
@@ -0,0 +1,359 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button, Form } from '@douyinfe/semi-ui';
import {
Calendar,
Hash,
Radio,
RefreshCcw,
RotateCcw,
Search,
SearchCheck,
Settings2,
SlidersHorizontal,
Filter,
Activity,
Layers,
} from 'lucide-react';
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
import {
TASK_ACTION_FIRST_TAIL_GENERATE,
TASK_ACTION_GENERATE,
TASK_ACTION_REFERENCE_GENERATE,
TASK_ACTION_TEXT_GENERATE,
IMAGE_ACTION_GENERATE,
IMAGE_ACTION_EDIT,
} from '../../../constants/common.constant';
const TaskLogsFilters = ({
formInitValues,
setFormApi,
refresh,
setShowColumnSelector,
formApi,
loading,
isAdminUser,
getFreshInitValues,
usageRecordMode = false,
t,
}) => {
const SearchIcon = usageRecordMode ? SearchCheck : Search;
const ResetIcon = usageRecordMode ? RefreshCcw : RotateCcw;
const ColumnsIcon = usageRecordMode ? SlidersHorizontal : Settings2;
const primaryButtonClass = usageRecordMode
? 'usage-record-action-button usage-record-action-button-primary'
: '!bg-gradient-to-r !from-cyan-500 !to-blue-600 !border-0 hover:!from-cyan-600 hover:!to-blue-700 !shadow-md hover:!shadow-lg !transition-all !duration-300';
const softButtonClass = usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: 'hover:!bg-gray-100 dark:hover:!bg-neutral-800 !transition-all !duration-300';
// 自定义输入框前缀样式
const InputPrefix = ({ icon: Icon }) => (
<div className='flex items-center justify-center w-5 h-5 text-gray-400 dark:text-gray-500'>
<Icon className='w-3.5 h-3.5' strokeWidth={2} />
</div>
);
return (
<Form
initValues={formInitValues}
getFormApi={(api) => setFormApi(api)}
onSubmit={refresh}
allowEmpty={true}
autoComplete='off'
layout='vertical'
trigger='change'
stopValidateWithError={false}
className={usageRecordMode ? 'usage-record-filter-form' : undefined}
>
<div className='flex flex-col gap-4'>
{/* 筛选区域标题 */}
<div className='flex items-center gap-2 pb-2 border-b border-gray-100 dark:border-neutral-800'>
<div className='flex items-center justify-center w-6 h-6 rounded-lg bg-gradient-to-br from-cyan-500 to-blue-600 shadow-sm'>
<Filter className='w-3.5 h-3.5 text-white' />
</div>
<span className='text-sm font-semibold text-gray-700 dark:text-gray-200'>
{t('筛选条件')}
</span>
</div>
{/* 搜索字段网格 */}
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3'>
{/* 时间选择器 */}
<div className='col-span-1 lg:col-span-2'>
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 to-blue-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.DatePicker
field='dateRange'
className='w-full'
type='dateTimeRange'
placeholder={[t('开始时间'), t('结束时间')]}
showClear
pure
size='small'
prefix={<InputPrefix icon={Calendar} />}
presets={DATE_RANGE_PRESETS.map((preset) => ({
text: t(preset.text),
start: preset.start(),
end: preset.end(),
}))}
/>
</div>
</div>
</div>
{/* 任务 ID */}
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-brand-from/20 to-brand-to/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.Input
field='task_id'
prefix={<InputPrefix icon={Hash} />}
placeholder={t('任务 ID')}
showClear
pure
size='small'
/>
</div>
</div>
{/* 任务状态 */}
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-emerald-500/20 to-green-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.Select
field='status'
prefix={<InputPrefix icon={Activity} />}
placeholder={t('任务状态')}
className='w-full'
showClear
pure
size='small'
>
<Form.Select.Option value=''>
{t('全部状态')}
</Form.Select.Option>
<Form.Select.Option value='SUBMITTED'>
{t('队列中')}
</Form.Select.Option>
<Form.Select.Option value='QUEUED'>
{t('排队中')}
</Form.Select.Option>
<Form.Select.Option value='IN_PROGRESS'>
{t('执行中')}
</Form.Select.Option>
<Form.Select.Option value='SUCCESS'>
{t('成功')}
</Form.Select.Option>
<Form.Select.Option value='FAILURE'>
{t('失败')}
</Form.Select.Option>
<Form.Select.Option value='NOT_START'>
{t('未启动')}
</Form.Select.Option>
<Form.Select.Option value='UNKNOWN'>
{t('未知')}
</Form.Select.Option>
</Form.Select>
</div>
</div>
{/* 任务类型 */}
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-teal-500/20 to-cyan-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.Select
field='action'
prefix={<InputPrefix icon={Layers} />}
placeholder={t('任务类型')}
className='w-full'
showClear
pure
size='small'
>
<Form.Select.Option value=''>
{t('全部类型')}
</Form.Select.Option>
<Form.Select.Option value='MUSIC'>
{t('生成音乐')}
</Form.Select.Option>
<Form.Select.Option value='LYRICS'>
{t('生成歌词')}
</Form.Select.Option>
<Form.Select.Option value={IMAGE_ACTION_GENERATE}>
{t('文生图')}
</Form.Select.Option>
<Form.Select.Option value={IMAGE_ACTION_EDIT}>
{t('图像编辑')}
</Form.Select.Option>
<Form.Select.Option value={TASK_ACTION_GENERATE}>
{t('图生视频')}
</Form.Select.Option>
<Form.Select.Option value={TASK_ACTION_TEXT_GENERATE}>
{t('文生视频')}
</Form.Select.Option>
<Form.Select.Option value={TASK_ACTION_FIRST_TAIL_GENERATE}>
{t('首尾生视频')}
</Form.Select.Option>
<Form.Select.Option value={TASK_ACTION_REFERENCE_GENERATE}>
{t('参照生视频')}
</Form.Select.Option>
</Form.Select>
</div>
</div>
{/* 渠道 ID - 仅管理员可见 */}
{isAdminUser && (
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-amber-500/20 to-orange-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.Input
field='channel_id'
prefix={<InputPrefix icon={Radio} />}
placeholder={t('渠道 ID')}
showClear
pure
size='small'
/>
</div>
</div>
)}
{/* 用户 ID - 仅管理员可见,与使用日志过滤器对齐 */}
{isAdminUser && (
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-sky-500/20 to-cyan-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<div className='relative'>
<Form.Input
field='user_id'
prefix={<InputPrefix icon={Hash} />}
placeholder={t('用户 ID')}
showClear
pure
size='small'
inputMode='numeric'
onKeyDown={(e) => {
if (
[
'Backspace',
'Delete',
'Tab',
'Escape',
'Enter',
'ArrowLeft',
'ArrowRight',
'ArrowUp',
'ArrowDown',
'Home',
'End',
].includes(e.key)
)
return;
if (
(e.ctrlKey || e.metaKey) &&
['a', 'c', 'v', 'x', 'z'].includes(e.key.toLowerCase())
)
return;
if (!/^\d$/.test(e.key)) e.preventDefault();
}}
onPaste={(e) => {
const paste = (
e.clipboardData || window.clipboardData
).getData('text');
if (!/^\d+$/.test(paste)) {
e.preventDefault();
const digits = paste.replace(/\D/g, '');
if (digits && formApi) {
formApi.setValue('user_id', digits);
}
}
}}
/>
</div>
</div>
)}
</div>
{/* 操作按钮区域 */}
<div className='flex justify-between items-center pt-2'>
<div></div>
<div className='flex gap-2'>
{/* 查询按钮 */}
<Button
type='tertiary'
htmlType='submit'
loading={loading}
size='small'
className={primaryButtonClass}
style={usageRecordMode ? undefined : { color: '#ffffff' }}
icon={
<SearchIcon
className='w-3.5 h-3.5'
style={{ color: '#ffffff' }}
/>
}
>
{t('查询')}
</Button>
{/* 重置按钮 */}
<Button
type='tertiary'
onClick={() => {
if (formApi) {
// 使用最新的"此刻"值重置,而不是 formApi.reset()(后者恢复挂载时的旧 dateRange,跨日 bug)
const fresh =
typeof getFreshInitValues === 'function'
? getFreshInitValues()
: formInitValues;
formApi.setValues(fresh, { isOverride: true });
setTimeout(() => {
refresh();
}, 100);
}
}}
size='small'
icon={<ResetIcon className='w-3.5 h-3.5' />}
className={softButtonClass}
>
{t('重置')}
</Button>
{/* 列设置按钮 */}
<Button
type='tertiary'
onClick={() => setShowColumnSelector(true)}
size='small'
icon={<ColumnsIcon className='w-3.5 h-3.5' />}
className={softButtonClass}
>
{t('列设置')}
</Button>
</div>
</div>
</div>
</Form>
);
};
export default TaskLogsFilters;
@@ -0,0 +1,118 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useMemo } from 'react';
import { Empty } from '@douyinfe/semi-ui';
import CardTable from '../../common/ui/CardTable';
import {
IllustrationNoResult,
IllustrationNoResultDark,
} from '../../common/illustrations';
import { getTaskLogsColumns } from './TaskLogsColumnDefs';
const TaskLogsTable = (taskLogsData) => {
const {
logs,
loading,
activePage,
pageSize,
logCount,
compactMode,
visibleColumns,
handlePageChange,
handlePageSizeChange,
copyText,
openContentModal,
openVideoModal,
isAdminUser,
t,
COLUMN_KEYS,
} = taskLogsData;
// Get all columns
const allColumns = useMemo(() => {
return getTaskLogsColumns({
t,
COLUMN_KEYS,
copyText,
openContentModal,
openVideoModal,
isAdminUser,
});
}, [t, COLUMN_KEYS, copyText, openContentModal, openVideoModal, isAdminUser]);
// Filter columns based on visibility settings
const getVisibleColumns = () => {
return allColumns.filter((column) => visibleColumns[column.key]);
};
const visibleColumnsList = useMemo(() => {
return getVisibleColumns();
}, [visibleColumns, allColumns]);
const tableColumns = useMemo(() => {
return compactMode
? visibleColumnsList.map(({ fixed, ...rest }) => rest)
: visibleColumnsList;
}, [compactMode, visibleColumnsList]);
return (
<CardTable
columns={tableColumns}
dataSource={logs}
rowKey='key'
loading={loading}
scroll={compactMode ? undefined : { x: 'max-content' }}
className='rounded-xl overflow-hidden task-logs-table'
size='middle'
empty={
<div className='py-12'>
<Empty
image={<IllustrationNoResult style={{ width: 180, height: 180 }} />}
darkModeImage={
<IllustrationNoResultDark style={{ width: 180, height: 180 }} />
}
description={
<div className='flex flex-col items-center gap-2'>
<span className='text-gray-500 dark:text-gray-400 text-sm'>
{t('搜索无结果')}
</span>
<span className='text-gray-400 dark:text-gray-500 text-xs'>
{t('暂无任务记录')}
</span>
</div>
}
/>
</div>
}
pagination={{
currentPage: activePage,
pageSize: pageSize,
total: logCount,
pageSizeOptions: [10, 20, 50, 100],
showSizeChanger: true,
onPageSizeChange: handlePageSizeChange,
onPageChange: handlePageChange,
}}
hidePagination={true}
/>
);
};
export default TaskLogsTable;
+115
View File
@@ -0,0 +1,115 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import CardPro from '../../common/ui/CardPro';
import TaskLogsTable from './TaskLogsTable';
import TaskLogsActions from './TaskLogsActions';
import TaskLogsFilters from './TaskLogsFilters';
import ColumnSelectorModal from './modals/ColumnSelectorModal';
import ContentModal from './modals/ContentModal';
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
import { createCardProPagination } from '../../../helpers/utils';
const TaskLogsPage = ({ usageRecordMode = false }) => {
const taskLogsData = useTaskLogsData();
const isMobile = useIsMobile();
return (
<div className='relative'>
{/* 装饰性网格背景 */}
<div
className='absolute inset-0 opacity-[0.015] dark:opacity-[0.03] pointer-events-none'
style={{
backgroundImage: `
linear-gradient(rgba(6, 182, 212, 0.5) 1px, transparent 1px),
linear-gradient(90deg, rgba(6, 182, 212, 0.5) 1px, transparent 1px)
`,
backgroundSize: '24px 24px',
}}
/>
{/* Modals */}
<ColumnSelectorModal
{...taskLogsData}
usageRecordMode={usageRecordMode}
/>
<ContentModal
{...taskLogsData}
isVideo={false}
usageRecordMode={usageRecordMode}
/>
{/* 视频预览弹窗 */}
<ContentModal
isModalOpen={taskLogsData.isVideoModalOpen}
setIsModalOpen={taskLogsData.setIsVideoModalOpen}
modalContent={taskLogsData.videoUrl}
sourceUrl={taskLogsData.videoSourceUrl}
isVideo={true}
usageRecordMode={usageRecordMode}
/>
{/* Main Content */}
<CardPro
type='type2'
className='!bg-transparent !border-0 !shadow-none relative'
statsArea={
<TaskLogsActions
{...taskLogsData}
logs={taskLogsData.logs}
usageRecordMode={usageRecordMode}
/>
}
searchArea={
<TaskLogsFilters
{...taskLogsData}
usageRecordMode={usageRecordMode}
/>
}
paginationArea={createCardProPagination({
currentPage: taskLogsData.activePage,
pageSize: taskLogsData.pageSize,
total: taskLogsData.logCount,
onPageChange: taskLogsData.handlePageChange,
onPageSizeChange: taskLogsData.handlePageSizeChange,
isMobile: isMobile,
t: taskLogsData.t,
})}
t={taskLogsData.t}
>
{/* 表格容器 */}
<div className='relative mt-4'>
{/* 表格装饰光晕 —— 走冷色 cyan→blue→品牌,与任务日志图标族一致 */}
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 via-blue-500/20 to-brand-to/20 rounded-2xl opacity-50 blur-sm' />
{/* 表格内容 —— 统一 .app-card 玻璃卡(去掉散乱的 bg-white/80 + border + rounded) */}
<div className='relative app-card overflow-hidden'>
<TaskLogsTable
{...taskLogsData}
compactMode={usageRecordMode ? false : taskLogsData.compactMode}
/>
</div>
</div>
</CardPro>
</div>
);
};
export default TaskLogsPage;
@@ -0,0 +1,149 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Modal, Button, Checkbox } from '@douyinfe/semi-ui';
import { Check, RefreshCcw, X } from 'lucide-react';
import { getTaskLogsColumns } from '../TaskLogsColumnDefs';
const ColumnSelectorModal = ({
showColumnSelector,
setShowColumnSelector,
visibleColumns,
handleColumnVisibilityChange,
handleSelectAll,
initDefaultColumns,
COLUMN_KEYS,
isAdminUser,
copyText,
openContentModal,
usageRecordMode = false,
t,
}) => {
// Get all columns for display in selector
const allColumns = getTaskLogsColumns({
t,
COLUMN_KEYS,
copyText,
openContentModal,
isAdminUser,
});
// 计算"全选"状态时应忽略的 key:当前角色下不可见的管理员专属列
// 否则非管理员下 CHANNEL 永远为 false,导致 every 永远为 false、全选框永远半选
const isHiddenForRole = (key) => !isAdminUser && key === COLUMN_KEYS.CHANNEL;
const effectiveValues = Object.entries(visibleColumns)
.filter(([key]) => !isHiddenForRole(key))
.map(([, v]) => v);
const allChecked =
effectiveValues.length > 0 && effectiveValues.every((v) => v === true);
const someChecked = effectiveValues.some((v) => v === true);
return (
<Modal
title={t('列设置')}
visible={showColumnSelector}
onCancel={() => setShowColumnSelector(false)}
footer={
<div className='flex justify-end gap-2'>
<Button
size={usageRecordMode ? 'small' : undefined}
icon={
usageRecordMode ? (
<RefreshCcw className='w-3.5 h-3.5' />
) : undefined
}
onClick={() => initDefaultColumns()}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('重置')}
</Button>
<Button
size={usageRecordMode ? 'small' : undefined}
icon={usageRecordMode ? <X className='w-3.5 h-3.5' /> : undefined}
onClick={() => setShowColumnSelector(false)}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('取消')}
</Button>
<Button
size={usageRecordMode ? 'small' : undefined}
icon={
usageRecordMode ? (
<Check className='w-3.5 h-3.5' style={{ color: '#fff' }} />
) : undefined
}
onClick={() => setShowColumnSelector(false)}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-primary'
: undefined
}
>
{t('确定')}
</Button>
</div>
}
>
<div style={{ marginBottom: 20 }}>
<Checkbox
checked={allChecked}
indeterminate={someChecked && !allChecked}
onChange={(e) => handleSelectAll(e.target.checked)}
>
{t('全选')}
</Checkbox>
</div>
<div
className='flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4'
style={{ border: '1px solid var(--semi-color-border)' }}
>
{allColumns.map((column) => {
// Skip admin-only columns for non-admin users
if (!isAdminUser && column.key === COLUMN_KEYS.CHANNEL) {
return null;
}
return (
<div key={column.key} className='w-1/2 mb-4 pr-2'>
<Checkbox
checked={!!visibleColumns[column.key]}
onChange={(e) =>
handleColumnVisibilityChange(column.key, e.target.checked)
}
>
{column.title}
</Checkbox>
</div>
);
})}
</div>
</Modal>
);
};
export default ColumnSelectorModal;
@@ -0,0 +1,268 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState, useEffect } from 'react';
import { Modal, Button, Typography, Spin } from '@douyinfe/semi-ui';
import { IconExternalOpen, IconCopy } from '@douyinfe/semi-icons';
import { Check, Copy, ExternalLink, X } from 'lucide-react';
import { useTranslation } from 'react-i18next';
const { Text } = Typography;
const ContentModal = ({
isModalOpen,
setIsModalOpen,
modalContent,
// 上游原始可分享 URL,用于"复制链接"/"新标签页打开";未传则回落到 modalContent
sourceUrl,
isVideo,
usageRecordMode = false,
}) => {
const { t } = useTranslation();
const [videoError, setVideoError] = useState(false);
const [isLoading, setIsLoading] = useState(false);
// 复制/打开操作都用上游原始 URL,代理路径可能带鉴权或外部无法访问
const shareUrl = sourceUrl || modalContent;
useEffect(() => {
if (isModalOpen && isVideo) {
setVideoError(false);
setIsLoading(true);
}
}, [isModalOpen, isVideo]);
const handleVideoError = () => {
setVideoError(true);
setIsLoading(false);
};
const handleVideoLoaded = () => {
setIsLoading(false);
};
const handleCopyUrl = () => {
navigator.clipboard.writeText(shareUrl);
};
const handleOpenInNewTab = () => {
window.open(shareUrl, '_blank');
};
const renderVideoContent = () => {
if (videoError) {
return (
<div style={{ textAlign: 'center', padding: '40px' }}>
<Text
type='tertiary'
style={{ display: 'block', marginBottom: '16px' }}
>
{t('视频无法在当前浏览器中播放,这可能是由于:')}
</Text>
<Text
type='tertiary'
style={{ display: 'block', marginBottom: '8px', fontSize: '12px' }}
>
{t('• 视频服务商的跨域限制')}
</Text>
<Text
type='tertiary'
style={{ display: 'block', marginBottom: '8px', fontSize: '12px' }}
>
{t('• 需要特定的请求头或认证')}
</Text>
<Text
type='tertiary'
style={{ display: 'block', marginBottom: '16px', fontSize: '12px' }}
>
{t('• 防盗链保护机制')}
</Text>
<div style={{ marginTop: '20px' }}>
<Button
icon={
usageRecordMode ? (
<ExternalLink className='w-3.5 h-3.5' />
) : (
<IconExternalOpen />
)
}
onClick={handleOpenInNewTab}
style={{ marginRight: '8px' }}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('在新标签页中打开')}
</Button>
<Button
icon={
usageRecordMode ? (
<Copy className='w-3.5 h-3.5' />
) : (
<IconCopy />
)
}
onClick={handleCopyUrl}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('复制链接')}
</Button>
</div>
<div
style={{
marginTop: '16px',
padding: '8px',
backgroundColor: '#f8f9fa',
borderRadius: '4px',
}}
>
<Text
type='tertiary'
style={{ fontSize: '10px', wordBreak: 'break-all' }}
>
{shareUrl}
</Text>
</div>
</div>
);
}
return (
<div style={{ position: 'relative' }}>
{isLoading && (
<div
style={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
zIndex: 10,
}}
>
<Spin size='large' />
</div>
)}
<video
src={modalContent}
controls
style={{ width: '100%' }}
autoPlay
crossOrigin='anonymous'
onError={handleVideoError}
onLoadedData={handleVideoLoaded}
onLoadStart={() => setIsLoading(true)}
/>
{/* 播放成功时也提供复制/新标签页按钮,复制的是上游分享 URL 而非代理路径 */}
<div
style={{
marginTop: '12px',
display: 'flex',
gap: '8px',
justifyContent: 'flex-end',
}}
>
<Button
size='small'
icon={
usageRecordMode ? <Copy className='w-3.5 h-3.5' /> : <IconCopy />
}
onClick={handleCopyUrl}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('复制链接')}
</Button>
<Button
size='small'
icon={
usageRecordMode ? (
<ExternalLink className='w-3.5 h-3.5' />
) : (
<IconExternalOpen />
)
}
onClick={handleOpenInNewTab}
className={
usageRecordMode
? 'usage-record-action-button usage-record-action-button-soft'
: undefined
}
>
{t('在新标签页打开')}
</Button>
</div>
</div>
);
};
return (
<Modal
visible={isModalOpen}
onOk={() => setIsModalOpen(false)}
onCancel={() => setIsModalOpen(false)}
closable={null}
bodyStyle={{
height: isVideo ? '450px' : '400px',
overflowX: 'hidden',
overflowY: 'auto',
padding: isVideo && videoError ? '0' : '24px',
}}
width={800}
okButtonProps={
usageRecordMode
? {
icon: <Check className='w-3.5 h-3.5' style={{ color: '#fff' }} />,
className:
'usage-record-action-button usage-record-action-button-primary',
}
: undefined
}
cancelButtonProps={
usageRecordMode
? {
icon: <X className='w-3.5 h-3.5' />,
className:
'usage-record-action-button usage-record-action-button-soft',
}
: undefined
}
>
{isVideo ? (
renderVideoContent()
) : (
<p style={{ whiteSpace: 'pre-line', overflowWrap: 'anywhere' }}>
{modalContent}
</p>
)}
</Modal>
);
};
export default ContentModal;