merge: 合入总仓库 weiyuan(bfdfb339) web/ 新功能,保留 ui-optimization 的 UI 重构
来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2
冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* 体验中心图像生成表单中 schema 驱动的新增区块(WP A2-3)。
|
||||
* 配色全部从主题 token 派生(frontend-design skill 铁律一),禁止裸色值。
|
||||
*/
|
||||
.image-generation-form {
|
||||
--igf-ink: var(--text-primary);
|
||||
--igf-muted: var(--text-secondary);
|
||||
--igf-line: var(--border-subtle);
|
||||
--igf-accent: var(--ui-color-primary);
|
||||
--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);
|
||||
}
|
||||
|
||||
.image-generation-form button:focus-visible,
|
||||
.image-generation-form [role='button']:focus-visible {
|
||||
outline: 2px solid var(--igf-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* 历史卡片拖入时的整卡高亮 */
|
||||
.image-generation-form.is-drop-active {
|
||||
outline: 2px dashed
|
||||
color-mix(in srgb, var(--ui-color-primary) 55%, transparent);
|
||||
outline-offset: -6px;
|
||||
}
|
||||
|
||||
.igf-muted {
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.igf-note {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.igf-hint {
|
||||
flex-basis: 100%;
|
||||
color: var(--igf-muted);
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.igf-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.igf-state-title {
|
||||
color: var(--igf-ink);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.igf-state.is-error .igf-state-title {
|
||||
color: var(--igf-danger);
|
||||
}
|
||||
|
||||
.igf-model-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.igf-model-name,
|
||||
.igf-model-id {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.igf-model-id {
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.igf-model-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 16px;
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--igf-fill);
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.igf-model-meta strong {
|
||||
color: var(--igf-ink);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.igf-model-desc {
|
||||
flex-basis: 100%;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.igf-mode-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.igf-slots {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.igf-size .cp-option-group--ratio .cp-option {
|
||||
min-width: 64px;
|
||||
}
|
||||
|
||||
.igf-size-dims {
|
||||
color: var(--igf-muted);
|
||||
font-size: 10px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.igf-size-custom {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.igf-size-custom .ant-input-number {
|
||||
flex: 1 1 110px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.igf-size-x {
|
||||
color: var(--igf-muted);
|
||||
}
|
||||
|
||||
.igf-dock-params {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.igf-generate {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.igf-quote {
|
||||
min-height: 18px;
|
||||
color: var(--igf-muted);
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.igf-quote.is-warning {
|
||||
color: var(--igf-warning);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
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, { useEffect, useMemo, useState } from 'react';
|
||||
import { InputNumber } from '@/components/ui';
|
||||
import { SlidersHorizontal } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
OptionGroup,
|
||||
RatioShape,
|
||||
} from '../../../../../components/creation/params';
|
||||
import {
|
||||
clampSizeSide,
|
||||
customSizeRangeOf,
|
||||
parseSize,
|
||||
sizePresetsOf,
|
||||
} from '../../../../../hooks/image/imageCreation';
|
||||
|
||||
const CUSTOM = '__custom__';
|
||||
|
||||
/**
|
||||
* 图像尺寸(schema type = 'size'):预设按宽高比图标展示;仅当 schema 下发 custom_size 时
|
||||
* 提供"自定义",宽高输入框失焦 / 回车时按 min / max / step 吸附。
|
||||
*
|
||||
* props: { param, value: "WxH", onChange(value) }
|
||||
*/
|
||||
const ImageSizePicker = ({ param, value, onChange }) => {
|
||||
const { t } = useTranslation();
|
||||
const presets = useMemo(() => sizePresetsOf(param), [param]);
|
||||
const range = useMemo(() => customSizeRangeOf(param), [param]);
|
||||
const matched = presets.find(
|
||||
(p) => p.value.toLowerCase() === String(value || '').toLowerCase(),
|
||||
);
|
||||
// 用户点了"自定义"、或当前取值不是预设时进入自定义态
|
||||
const [customActive, setCustomActive] = useState(Boolean(range && !matched));
|
||||
useEffect(() => {
|
||||
if (!range) setCustomActive(false);
|
||||
else if (value && !matched) setCustomActive(true);
|
||||
}, [range, value, matched]);
|
||||
|
||||
const parsed = parseSize(String(value || '')) ||
|
||||
(presets[0] && { width: presets[0].width, height: presets[0].height }) || {
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
};
|
||||
const [draft, setDraft] = useState(parsed);
|
||||
useEffect(() => {
|
||||
setDraft(parsed);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
|
||||
const options = useMemo(() => {
|
||||
const list = presets.map((p) => p.value);
|
||||
if (range) list.push(CUSTOM);
|
||||
return list;
|
||||
}, [presets, range]);
|
||||
|
||||
const commit = (next) => {
|
||||
const w = clampSizeSide(next.width, range);
|
||||
const h = clampSizeSide(next.height, range);
|
||||
setDraft({ width: w, height: h });
|
||||
const v = `${w}x${h}`;
|
||||
if (v !== value) onChange && onChange(v);
|
||||
};
|
||||
|
||||
const onSelect = (v) => {
|
||||
if (v === CUSTOM) {
|
||||
setCustomActive(true);
|
||||
commit(draft);
|
||||
return;
|
||||
}
|
||||
setCustomActive(false);
|
||||
onChange && onChange(v);
|
||||
};
|
||||
|
||||
const selected = customActive ? CUSTOM : matched ? matched.value : undefined;
|
||||
|
||||
return (
|
||||
<div className='igf-size'>
|
||||
<OptionGroup
|
||||
variant='ratio'
|
||||
options={options}
|
||||
value={selected}
|
||||
onChange={onSelect}
|
||||
ariaLabel={t('尺寸')}
|
||||
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;
|
||||
}}
|
||||
renderOption={(opt) => {
|
||||
if (opt === CUSTOM) {
|
||||
return (
|
||||
<>
|
||||
<span className='cp-ratio-shape-box' aria-hidden='true'>
|
||||
<SlidersHorizontal size={14} />
|
||||
</span>
|
||||
<span className='cp-option-label'>{t('自定义')}</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
const p = presets.find((x) => x.value === opt);
|
||||
return (
|
||||
<>
|
||||
<RatioShape ratio={`${p.width}:${p.height}`} />
|
||||
<span className='cp-option-label tabular-nums'>
|
||||
{p.label || `${p.width}×${p.height}`}
|
||||
</span>
|
||||
{p.label ? (
|
||||
<span className='igf-size-dims tabular-nums'>
|
||||
{p.width}×{p.height}
|
||||
</span>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{range && customActive ? (
|
||||
<div className='igf-size-custom'>
|
||||
<InputNumber
|
||||
value={draft.width}
|
||||
onChange={(v) => setDraft((d) => ({ ...d, width: v }))}
|
||||
onBlur={() => commit(draft)}
|
||||
onPressEnter={() => commit(draft)}
|
||||
min={range.min}
|
||||
max={range.max}
|
||||
step={range.step}
|
||||
prefix={t('宽')}
|
||||
suffix='px'
|
||||
size='small'
|
||||
aria-label={t('宽度(像素)')}
|
||||
/>
|
||||
<span className='igf-size-x' aria-hidden='true'>
|
||||
×
|
||||
</span>
|
||||
<InputNumber
|
||||
value={draft.height}
|
||||
onChange={(v) => setDraft((d) => ({ ...d, height: v }))}
|
||||
onBlur={() => commit(draft)}
|
||||
onPressEnter={() => commit(draft)}
|
||||
min={range.min}
|
||||
max={range.max}
|
||||
step={range.step}
|
||||
prefix={t('高')}
|
||||
suffix='px'
|
||||
size='small'
|
||||
aria-label={t('高度(像素)')}
|
||||
/>
|
||||
<div className='igf-hint'>
|
||||
{t('宽高范围 {{min}}–{{max}} 像素,按 {{step}} 像素取整', range)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageSizePicker;
|
||||
@@ -33,7 +33,7 @@ const ImageDetailModal = ({
|
||||
onReuseParams,
|
||||
onUseAsReference,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
// 跟随视口宽度,避免 900px 固定值在窄笔记本/平板上溢出
|
||||
const [viewportWidth, setViewportWidth] = useState(
|
||||
@@ -88,7 +88,7 @@ const ImageDetailModal = ({
|
||||
const formatDateTime = (isoString) => {
|
||||
if (!isoString) return '-';
|
||||
const date = new Date(isoString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
return date.toLocaleString(i18n.language, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
@@ -116,7 +116,7 @@ const ImageDetailModal = ({
|
||||
{ label: t('质量'), value: task.quality, color: 'grey' },
|
||||
{
|
||||
label: t('数量'),
|
||||
value: task.n && task.n > 1 ? `${task.n} ${t('张')}` : null,
|
||||
value: task.n && task.n > 1 ? t('{{n}} 张', { n: task.n }) : null,
|
||||
color: 'grey',
|
||||
},
|
||||
].filter((p) => p.value);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useImageTaskManagement } from '../../../../hooks/image/useImageTaskManagement';
|
||||
import { useImageCreation } from '../../../../hooks/image/useImageCreation';
|
||||
import ImageGenerationForm from './ImageGenerationForm';
|
||||
import ImageTaskList from './ImageTaskList';
|
||||
import ImageDetailModal from './ImageDetailModal';
|
||||
@@ -26,66 +27,41 @@ import ImageDetailModal from './ImageDetailModal';
|
||||
const ImageGenerationTab = () => {
|
||||
const {
|
||||
tasks,
|
||||
loading,
|
||||
addTask,
|
||||
fetchTaskDetail,
|
||||
deleteTask,
|
||||
retryTask,
|
||||
refreshTasks,
|
||||
refreshTaskUrl,
|
||||
} = useImageTaskManagement();
|
||||
|
||||
// 创作表单:模型 / 参数来自 GET /api/creation/models?kind=image(WP A2-3)
|
||||
const creation = useImageCreation({ tasks, addTask, fetchTaskDetail });
|
||||
|
||||
const [selectedTask, setSelectedTask] = useState(null);
|
||||
const [detailModalVisible, setDetailModalVisible] = useState(false);
|
||||
|
||||
// 历史卡片"复用参数":把任务参数回填到表单,但不立刻生成
|
||||
// 用对象引用变化触发 form 的 useEffect
|
||||
const [prefillSignal, setPrefillSignal] = useState(null);
|
||||
|
||||
// 处理生成提交
|
||||
const handleSubmit = (formData) => {
|
||||
addTask(formData);
|
||||
// 重新生成 / 重试:按原任务参数快照直接再提交一次
|
||||
const handleRegenerate = (task) => {
|
||||
creation.regenerateTask(task);
|
||||
};
|
||||
const handleRetry = (taskId) => {
|
||||
creation.regenerateTask(tasks.find((task) => task.id === taskId));
|
||||
};
|
||||
|
||||
// 处理重新生成(直接再跑一次)
|
||||
const handleRegenerate = (taskData) => {
|
||||
addTask(taskData);
|
||||
};
|
||||
|
||||
// 处理"复用参数"(仅回填,等用户确认后再生成)
|
||||
// "复用参数":回填表单(优先使用服务端参数快照),等用户确认后再生成
|
||||
const handleReuseParams = (task) => {
|
||||
setPrefillSignal({
|
||||
mode: task.mode,
|
||||
prompt: task.prompt,
|
||||
width: task.width,
|
||||
height: task.height,
|
||||
model: task.model,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.negativePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.prefillFromTask(task);
|
||||
};
|
||||
|
||||
// 处理"用作参考图"(生成结果 -> 切到图生图模式 + 自动回填参考图)
|
||||
// 不带 prompt:保留用户当前已输入的提示词,避免被空串覆盖。
|
||||
// 想要旧 prompt 一并回填的,请走"复用参数"。
|
||||
// "用作参考图":结果可复用时以 task:// 引用放入参考图槽,并切到图生图。
|
||||
// 不带 prompt:保留用户当前已输入的提示词;想要旧 prompt 一并回填的,请走"复用参数"。
|
||||
const handleUseAsReference = (task) => {
|
||||
if (!task?.imageUrl) return;
|
||||
setPrefillSignal({
|
||||
mode: 'image-to-image',
|
||||
referenceImageUrl: task.imageUrl,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.applyAsReference(task);
|
||||
};
|
||||
|
||||
// 空状态:用户点示例 prompt 卡片,直接填回 form
|
||||
const handleSamplePrompt = (samplePrompt) => {
|
||||
if (!samplePrompt) return;
|
||||
setPrefillSignal({
|
||||
mode: 'text-to-image',
|
||||
prompt: samplePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
creation.applySamplePrompt(samplePrompt);
|
||||
};
|
||||
|
||||
// 查看详情
|
||||
@@ -109,11 +85,7 @@ const ImageGenerationTab = () => {
|
||||
<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='w-full md:w-[22rem] xl:w-[24rem] md:flex-shrink-0 md:h-full'>
|
||||
<ImageGenerationForm
|
||||
onSubmit={handleSubmit}
|
||||
loading={loading}
|
||||
prefillSignal={prefillSignal}
|
||||
/>
|
||||
<ImageGenerationForm creation={creation} />
|
||||
</div>
|
||||
|
||||
{/* 右侧:任务列表 —— flex-1 只在桌面端生效,移动端按内容高度展开 */}
|
||||
@@ -124,7 +96,7 @@ const ImageGenerationTab = () => {
|
||||
onRefreshUrl={refreshTaskUrl}
|
||||
onViewDetail={handleViewDetail}
|
||||
onDelete={deleteTask}
|
||||
onRetry={retryTask}
|
||||
onRetry={handleRetry}
|
||||
onRegenerate={handleRegenerate}
|
||||
onReuseParams={handleReuseParams}
|
||||
onUseAsReference={handleUseAsReference}
|
||||
|
||||
@@ -54,7 +54,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { IllustrationNoContent } from '../../../../components/common/illustrations';
|
||||
import { showSuccess, showError } from '../../../../helpers';
|
||||
import { showSuccess, showError, renderQuota } from '../../../../helpers';
|
||||
import './ImageTaskList.css';
|
||||
import ImageCompareModal from './ImageCompareModal';
|
||||
|
||||
@@ -87,7 +87,7 @@ const ImageTaskList = ({
|
||||
onUseAsReference,
|
||||
onSamplePrompt,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
// ---------- 用户偏好(持久化)----------
|
||||
const [prefs, setPrefs] = useState(() => {
|
||||
@@ -378,9 +378,11 @@ const ImageTaskList = ({
|
||||
const now = new Date();
|
||||
const diff = now - date;
|
||||
if (diff < 60000) return t('刚刚');
|
||||
if (diff < 3600000) return `${Math.floor(diff / 60000)} ${t('分钟前')}`;
|
||||
if (diff < 86400000) return `${Math.floor(diff / 3600000)} ${t('小时前')}`;
|
||||
return date.toLocaleString('zh-CN', {
|
||||
if (diff < 3600000)
|
||||
return t('{{n}} 分钟前', { n: Math.floor(diff / 60000) });
|
||||
if (diff < 86400000)
|
||||
return t('{{n}} 小时前', { n: Math.floor(diff / 3600000) });
|
||||
return date.toLocaleString(i18n.language, {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
@@ -469,19 +471,8 @@ const ImageTaskList = ({
|
||||
showError(t('无法重新生成:缺少提示词'));
|
||||
return;
|
||||
}
|
||||
if (onRegenerate) {
|
||||
onRegenerate({
|
||||
prompt: task.prompt,
|
||||
width: task.width || 1024,
|
||||
height: task.height || 1024,
|
||||
model: task.model,
|
||||
mode: task.mode,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.negativePrompt,
|
||||
});
|
||||
showSuccess(t('已创建新的生成任务'));
|
||||
}
|
||||
// 按原任务参数快照再提交一次(结果提示由提交流程给出)
|
||||
if (onRegenerate) onRegenerate(task);
|
||||
};
|
||||
|
||||
// 选择 —— 用 updater 保证状态新鲜(快速连点不丢),
|
||||
@@ -530,6 +521,8 @@ const ImageTaskList = ({
|
||||
JSON.stringify({
|
||||
id: task.id,
|
||||
imageUrl: task.imageUrl,
|
||||
// 结果可按 task:// 引用复用时,表单不再下载图片
|
||||
reusableAsInput: task.reusableAsInput === true,
|
||||
prompt: task.prompt || '',
|
||||
}),
|
||||
);
|
||||
@@ -1285,6 +1278,15 @@ const ImageTaskList = ({
|
||||
</Popover>
|
||||
)}
|
||||
|
||||
{/* 失败退款:按任务实际退还额度展示(不写死"不扣费") */}
|
||||
{isFailed && task.refundedQuota > 0 && (
|
||||
<div className='text-[10px] text-gray-500 dark:text-gray-400 leading-snug mb-1.5 tabular-nums'>
|
||||
{t('已退还 {{amount}}', {
|
||||
amount: renderQuota(task.refundedQuota),
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 操作按钮 */}
|
||||
{density !== 'grid' && (
|
||||
<div className='flex gap-1 mt-auto pt-1 border-t border-gray-100 dark:border-neutral-800'>
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 体验中心视频页输入面板(WP A1-12)。
|
||||
* 配色全部从主题 token 派生(frontend-design skill 铁律一),禁止裸色值。
|
||||
*/
|
||||
.video-input-panel {
|
||||
--vip-ink: var(--text-primary);
|
||||
--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-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);
|
||||
|
||||
position: relative;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.video-input-panel button:focus-visible,
|
||||
.video-input-panel [role='button']:focus-visible {
|
||||
outline: 2px solid var(--vip-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.vip-collapse-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.vip-collapse-btn {
|
||||
color: var(--vip-accent) !important;
|
||||
}
|
||||
|
||||
.vip-expand-fab {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.vip-expand-fab .ant-btn {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
color: var(--ui-color-primary);
|
||||
}
|
||||
|
||||
.vip-card {
|
||||
margin-bottom: 12px;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid var(--vip-line);
|
||||
border-radius: 12px;
|
||||
background: var(--vip-surface);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.vip-card-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--vip-ink);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.vip-card-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-tint);
|
||||
color: var(--vip-accent);
|
||||
}
|
||||
|
||||
.vip-card-extra {
|
||||
margin-left: auto;
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.vip-muted {
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.vip-model-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.vip-model-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vip-model-id {
|
||||
overflow: hidden;
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.vip-model-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 16px;
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-fill);
|
||||
color: var(--vip-muted);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.vip-model-meta strong {
|
||||
color: var(--vip-ink);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.vip-model-desc {
|
||||
flex-basis: 100%;
|
||||
color: var(--vip-muted);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.vip-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.vip-state-title {
|
||||
color: var(--vip-ink);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.vip-state.is-error .vip-state-title {
|
||||
color: var(--vip-danger);
|
||||
}
|
||||
|
||||
.vip-mode-option {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.vip-slots {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.vip-slot-note {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.vip-portrait-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.vip-template-preview {
|
||||
margin-top: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--vip-fill);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.vip-counter {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.vip-advanced {
|
||||
border: 1px solid var(--vip-line);
|
||||
border-radius: 12px;
|
||||
background: var(--vip-surface);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.vip-advanced .ant-collapse-header {
|
||||
margin: 0;
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.vip-advanced .ant-collapse-content-box {
|
||||
padding: 4px 16px 16px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,9 +39,12 @@ import {
|
||||
HelpCircle,
|
||||
X,
|
||||
Loader2,
|
||||
Wallet,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { showError, showSuccess } from '../../../../../helpers';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { formatQuoteAmount } from '../../../../../hooks/creation/useCreationQuote';
|
||||
import {
|
||||
canCancelVideoTask,
|
||||
canRegenerateVideoTask,
|
||||
@@ -52,6 +55,21 @@ import './VideoPreviewPanel.css';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
|
||||
// 估价 budget_source → 预算层级名(i18n key);org_budget 实际值为 org_budget:<subject_type>
|
||||
const BUDGET_SOURCE_LABELS = {
|
||||
org_budget: '部门 / 项目预算',
|
||||
token: '令牌额度',
|
||||
org_member: '成员额度',
|
||||
org_gift: '企业赠送额度',
|
||||
org: '企业额度',
|
||||
membership: '会员额度',
|
||||
gift: '赠送余额',
|
||||
user: '账户余额',
|
||||
};
|
||||
|
||||
const budgetSourceLabel = (source) =>
|
||||
BUDGET_SOURCE_LABELS[String(source || '').split(':')[0]] || '';
|
||||
|
||||
const VideoPreviewPanel = ({
|
||||
formData,
|
||||
generating,
|
||||
@@ -62,8 +80,15 @@ const VideoPreviewPanel = ({
|
||||
selectedTaskForPlay, // 新增:从任务列表选择的任务
|
||||
onRegenerate, // 新增:再生成回调
|
||||
onClearSelectedTask, // 新增:清除选中任务的回调(关闭视频播放)
|
||||
submitBlock = '', // 不能提交的原因(为空表示可提交)
|
||||
submitting = false,
|
||||
quote = null,
|
||||
quoteLoading = false,
|
||||
quoteFailed = false,
|
||||
estSeconds = 0,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
|
||||
// 监听窗口大小变化
|
||||
@@ -201,12 +226,35 @@ const VideoPreviewPanel = ({
|
||||
}
|
||||
};
|
||||
|
||||
// 判断按钮是否禁用
|
||||
const isButtonDisabled =
|
||||
(!formData.prompt && !formData.selectedTemplate) ||
|
||||
!selectedModel ||
|
||||
(typeof selectedModel === 'object' && selectedModel.level_locked) ||
|
||||
(formData.mode === 'image2video' && !formData.image);
|
||||
// 判断按钮是否禁用(原因由 useVideoGeneration 按 schema 计算)
|
||||
const isButtonDisabled = Boolean(submitBlock);
|
||||
// 余额 / 预算不足:按钮变为"去充值"(估价失败时不阻止提交)
|
||||
const needTopUp = !isButtonDisabled && quote?.balance_enough === false;
|
||||
|
||||
// 估价文案:"预计 ¥x · 约 N 秒 · 失败自动退还"
|
||||
const renderQuoteText = () => {
|
||||
const parts = [];
|
||||
const item = quote?.items?.[0];
|
||||
const amount =
|
||||
item && !item.error
|
||||
? formatQuoteAmount(item.display_amount, item.currency)
|
||||
: '';
|
||||
if (quoteFailed || (quote && !amount)) {
|
||||
parts.push(t('价格以实际扣费为准'));
|
||||
} else if (amount) {
|
||||
parts.push(
|
||||
item.approximate
|
||||
? t('预计约 {{amount}}', { amount })
|
||||
: t('预计 {{amount}}', { amount }),
|
||||
);
|
||||
} else if (quoteLoading) {
|
||||
parts.push(t('正在估价...'));
|
||||
}
|
||||
if (estSeconds > 0) parts.push(t('约 {{n}} 秒', { n: estSeconds }));
|
||||
if (parts.length === 0) return null;
|
||||
parts.push(t('失败自动退还'));
|
||||
return parts.join(' · ');
|
||||
};
|
||||
|
||||
// 渲染顶部操作栏(始终显示)
|
||||
const renderTopBar = () => {
|
||||
@@ -234,52 +282,68 @@ const VideoPreviewPanel = ({
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Play size={16} fill='currentColor' />}
|
||||
onClick={isButtonDisabled ? undefined : handleGenerate}
|
||||
disabled={isButtonDisabled || generating}
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
background:
|
||||
isButtonDisabled || generating
|
||||
? undefined
|
||||
: 'linear-gradient(135deg, #1890ff 0%, #0050b3 100%)',
|
||||
border: 'none',
|
||||
}}
|
||||
>
|
||||
{generating
|
||||
? t('生成中...')
|
||||
: windowWidth > 768
|
||||
? t('开始生成')
|
||||
: t('生成')}
|
||||
</Button>
|
||||
{needTopUp ? (
|
||||
<Button
|
||||
type='warning'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Wallet size={16} />}
|
||||
onClick={() => navigate('/console/topup')}
|
||||
style={{ fontWeight: 600 }}
|
||||
>
|
||||
{t('去充值')}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Play size={16} fill='currentColor' />}
|
||||
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',
|
||||
}}
|
||||
>
|
||||
{submitting
|
||||
? t('提交中...')
|
||||
: windowWidth > 768
|
||||
? t('开始生成')
|
||||
: t('生成')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 估价 / 余额不足说明 */}
|
||||
{!isButtonDisabled && (
|
||||
<Text
|
||||
type={needTopUp ? 'warning' : 'tertiary'}
|
||||
style={{
|
||||
fontSize: '12px',
|
||||
fontVariantNumeric: 'tabular-nums',
|
||||
minWidth: 0,
|
||||
}}
|
||||
aria-live='polite'
|
||||
>
|
||||
{needTopUp
|
||||
? budgetSourceLabel(quote?.budget_source)
|
||||
? t('{{source}}不足,请充值后再生成', {
|
||||
source: t(budgetSourceLabel(quote.budget_source)),
|
||||
})
|
||||
: t('余额或预算不足,请充值后再生成')
|
||||
: renderQuoteText()}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{/* 禁用提示 */}
|
||||
{isButtonDisabled && !generating && (
|
||||
<Text type='tertiary' style={{ fontSize: '12px' }}>
|
||||
{!selectedModel && t('请选择模型')}
|
||||
{selectedModel &&
|
||||
typeof selectedModel === 'object' &&
|
||||
selectedModel.level_locked &&
|
||||
t('当前等级无权调用此模型')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
!formData.prompt &&
|
||||
!formData.selectedTemplate &&
|
||||
t('请输入提示词或选择模板')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
(formData.prompt || formData.selectedTemplate) &&
|
||||
formData.mode === 'image2video' &&
|
||||
!formData.image &&
|
||||
t('请上传图片')}
|
||||
{isButtonDisabled && !submitting && (
|
||||
<Text type='tertiary' style={{ fontSize: '12px' }} role='note'>
|
||||
{submitBlock}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
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,
|
||||
Form,
|
||||
Select,
|
||||
Input,
|
||||
InputNumber,
|
||||
Switch,
|
||||
Space,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
import ModelSelector from '../../../../../components/common/ModelSelector';
|
||||
import { MODEL_CATEGORY } from '../../../../../constants';
|
||||
import { buildVideoRegenerateRequest } from '../../../../../helpers/videoTask';
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Text } = Typography;
|
||||
|
||||
const VideoRegenerateModal = ({ visible, onCancel, onConfirm, task }) => {
|
||||
const isNarrow = useIsMobile();
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState({
|
||||
mode: 'text2video',
|
||||
prompt: '',
|
||||
negative_prompt: '',
|
||||
resolution: '1080P',
|
||||
duration: 5,
|
||||
fps: 30,
|
||||
ratio: '16:9',
|
||||
audio: false,
|
||||
seed: -1,
|
||||
prompt_extend: false,
|
||||
watermark: false,
|
||||
image: '',
|
||||
});
|
||||
const [selectedModel, setSelectedModel] = useState('');
|
||||
|
||||
// 从任务数据中提取参数
|
||||
useEffect(() => {
|
||||
if (task && visible) {
|
||||
const taskData = task.request || {};
|
||||
const mode = taskData.mode || 'text2video';
|
||||
const prompt = taskData.prompt || '';
|
||||
const negativePrompt = taskData.negative_prompt || '';
|
||||
const resolution = taskData.resolution || '1080P';
|
||||
const duration = taskData.duration || 5;
|
||||
const fps = taskData.fps || 30;
|
||||
const ratio = taskData.ratio || '16:9';
|
||||
const audio = taskData.audio === true;
|
||||
const seed = taskData.seed ?? -1;
|
||||
const promptExtend = taskData.prompt_extend === true;
|
||||
const watermark = taskData.watermark === true;
|
||||
const image = taskData.image || '';
|
||||
const model = taskData.model || '';
|
||||
|
||||
setFormData({
|
||||
mode,
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
resolution,
|
||||
duration,
|
||||
fps,
|
||||
ratio,
|
||||
audio,
|
||||
seed,
|
||||
prompt_extend: promptExtend,
|
||||
watermark,
|
||||
image,
|
||||
});
|
||||
|
||||
setSelectedModel(model);
|
||||
}
|
||||
}, [task, visible]);
|
||||
|
||||
// 处理表单提交
|
||||
const handleSubmit = () => {
|
||||
if (!selectedModel || typeof selectedModel !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建请求数据
|
||||
onConfirm(buildVideoRegenerateRequest(formData, selectedModel));
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('再生成视频')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
okText={t('确认生成')}
|
||||
cancelText={t('取消')}
|
||||
width={700}
|
||||
bodyStyle={{
|
||||
maxHeight: '70vh',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
// 窄屏改为标签在上:labelWidth=120 在 ~294px 的弹窗体里要吃掉 41%,
|
||||
// 剩给控件的宽度放不下 seed 输入框和它的说明文案
|
||||
labelPosition={isNarrow ? 'top' : 'left'}
|
||||
labelAlign='right'
|
||||
labelWidth={isNarrow ? undefined : 120}
|
||||
>
|
||||
{/* 生成模式 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('生成模式')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.mode}
|
||||
onChange={(value) => {
|
||||
setFormData({ ...formData, mode: value });
|
||||
setSelectedModel('');
|
||||
}}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='text2video'>{t('文生视频')}</Select.Option>
|
||||
<Select.Option value='image2video'>{t('图生视频')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 模型选择 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('选择模型')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<ModelSelector
|
||||
key={formData.mode}
|
||||
category={
|
||||
formData.mode === 'text2video'
|
||||
? MODEL_CATEGORY.TEXT_TO_VIDEO
|
||||
: MODEL_CATEGORY.IMAGE_TO_VIDEO
|
||||
}
|
||||
value={
|
||||
selectedModel?.id || selectedModel?.model_name || selectedModel
|
||||
}
|
||||
onChange={setSelectedModel}
|
||||
placeholder={t('请选择模型')}
|
||||
autoSelectFirst={false}
|
||||
onModelsLoaded={(models) => {
|
||||
if (typeof selectedModel !== 'string' || !selectedModel) return;
|
||||
const match = models.find(
|
||||
(model) => model.model_name === selectedModel,
|
||||
);
|
||||
setSelectedModel(match || '');
|
||||
}}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 提示词 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.prompt}
|
||||
onChange={(value) => setFormData({ ...formData, prompt: value })}
|
||||
placeholder={t('描述你想生成的视频内容')}
|
||||
rows={3}
|
||||
maxLength={2000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 反向提示词 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('反向提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.negative_prompt}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, negative_prompt: value })
|
||||
}
|
||||
placeholder={t('描述不想出现的内容')}
|
||||
rows={2}
|
||||
maxLength={1000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 分辨率 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('分辨率')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.resolution}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, resolution: value })
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='480P'>480P (832*480)</Select.Option>
|
||||
<Select.Option value='720P'>720P (1280*720)</Select.Option>
|
||||
<Select.Option value='1080P'>1080P (1920*1080)</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 时长 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('视频时长')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<InputNumber
|
||||
value={formData.duration}
|
||||
onChange={(value) => setFormData({ ...formData, duration: value })}
|
||||
min={3}
|
||||
max={10}
|
||||
suffix={t('秒')}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 宽高比 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('宽高比')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.ratio}
|
||||
onChange={(value) => setFormData({ ...formData, ratio: value })}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='16:9'>{t('16:9 (横屏)')}</Select.Option>
|
||||
<Select.Option value='9:16'>{t('9:16 (竖屏)')}</Select.Option>
|
||||
<Select.Option value='1:1'>{t('1:1 (方形)')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 高级选项 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('高级选项')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Space vertical align='start' style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.audio}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, audio: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('生成音频')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.prompt_extend}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, prompt_extend: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('提示词扩展')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<InputNumber
|
||||
value={formData.seed}
|
||||
onChange={(value) => setFormData({ ...formData, seed: value })}
|
||||
placeholder={t('随机种子(可选)')}
|
||||
min={0}
|
||||
style={{ width: '100%', maxWidth: 200 }}
|
||||
/>
|
||||
<Text type='tertiary'>{t('固定种子可复现结果')}</Text>
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Input>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoRegenerateModal;
|
||||
@@ -17,20 +17,23 @@ 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 React, { useState, useEffect, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import VideoInputPanel from './Video/VideoInputPanel';
|
||||
import VideoPreviewPanel from './Video/VideoPreviewPanel';
|
||||
import VideoTaskQueue from './Video/VideoTaskQueue';
|
||||
import VideoRegenerateModal from './Video/VideoRegenerateModal';
|
||||
import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration';
|
||||
import { showInfo } from '../../../../helpers';
|
||||
|
||||
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 [regenerateModalVisible, setRegenerateModalVisible] = useState(false);
|
||||
const [taskToRegenerate, setTaskToRegenerate] = useState(null);
|
||||
// 输入面板容器:再生成回填后滚动到面板顶部
|
||||
const inputPanelRef = useRef(null);
|
||||
const inputScrollRef = useRef(null);
|
||||
|
||||
// 监听窗口大小变化
|
||||
useEffect(() => {
|
||||
@@ -42,28 +45,32 @@ const VideoGenerationTab = () => {
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
const creation = useVideoGeneration();
|
||||
const {
|
||||
// 表单数据
|
||||
formData,
|
||||
setFormData,
|
||||
// 模型相关
|
||||
selectedModel,
|
||||
setSelectedModel,
|
||||
modelInfo,
|
||||
// 生成相关
|
||||
generating,
|
||||
currentTask,
|
||||
handleGenerate,
|
||||
submitVideo,
|
||||
handleCancel,
|
||||
submitBlock,
|
||||
submitting,
|
||||
quote,
|
||||
quoteLoading,
|
||||
quoteFailed,
|
||||
estSeconds,
|
||||
// 任务列表
|
||||
tasks,
|
||||
refreshTasks,
|
||||
deleteTask,
|
||||
getRegenerationTask,
|
||||
prefillFromTask,
|
||||
downloadTask,
|
||||
getTaskVideoUrl,
|
||||
} = useVideoGeneration();
|
||||
} = creation;
|
||||
|
||||
// 处理任务列表的播放按钮
|
||||
const handlePlayTask = async (task) => {
|
||||
@@ -98,20 +105,21 @@ const VideoGenerationTab = () => {
|
||||
setSelectedTaskForPlay(null);
|
||||
};
|
||||
|
||||
// 处理再生成按钮
|
||||
// 处理再生成按钮:用原任务参数回填输入面板,由用户确认后再点击生成
|
||||
const handleRegenerate = async (task) => {
|
||||
const detail = await getRegenerationTask(task.task_id);
|
||||
if (!detail) return;
|
||||
setTaskToRegenerate(detail);
|
||||
setRegenerateModalVisible(true);
|
||||
};
|
||||
|
||||
// 确认再生成
|
||||
const handleRegenerateConfirm = async (requestData) => {
|
||||
const submitted = await submitVideo(requestData, requestData.model);
|
||||
if (submitted) {
|
||||
setRegenerateModalVisible(false);
|
||||
}
|
||||
if (!detail || !prefillFromTask(detail)) return;
|
||||
setLeftPanelCollapsed(false);
|
||||
setTaskQueueVisible(false);
|
||||
showInfo(t('已回填原参数,确认后点击生成'));
|
||||
// 等面板展开渲染后再滚动
|
||||
requestAnimationFrame(() => {
|
||||
inputScrollRef.current?.scrollTo?.({ top: 0, behavior: 'smooth' });
|
||||
inputPanelRef.current?.scrollIntoView?.({
|
||||
behavior: 'smooth',
|
||||
block: 'start',
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// 响应式布局配置 - 两列布局(左侧配置区 + 右侧预览区)
|
||||
@@ -191,6 +199,7 @@ const VideoGenerationTab = () => {
|
||||
>
|
||||
{/* 左侧:输入区域(区域1) */}
|
||||
<div
|
||||
ref={inputPanelRef}
|
||||
style={{
|
||||
width:
|
||||
layoutConfig.direction === 'row'
|
||||
@@ -219,6 +228,7 @@ const VideoGenerationTab = () => {
|
||||
}}
|
||||
>
|
||||
<div
|
||||
ref={inputScrollRef}
|
||||
className='app-scrollbar'
|
||||
style={{
|
||||
height: '100%',
|
||||
@@ -227,14 +237,10 @@ const VideoGenerationTab = () => {
|
||||
}}
|
||||
>
|
||||
<VideoInputPanel
|
||||
formData={formData}
|
||||
setFormData={setFormData}
|
||||
creation={creation}
|
||||
onCollapse={() => setLeftPanelCollapsed(!leftPanelCollapsed)}
|
||||
collapsed={leftPanelCollapsed}
|
||||
collapsible={layoutConfig.direction === 'row'}
|
||||
selectedModel={selectedModel}
|
||||
setSelectedModel={setSelectedModel}
|
||||
modelInfo={modelInfo}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -264,6 +270,12 @@ const VideoGenerationTab = () => {
|
||||
onGenerate={handleGenerate}
|
||||
onCancel={handleCancel}
|
||||
selectedModel={selectedModel}
|
||||
submitBlock={submitBlock}
|
||||
submitting={submitting}
|
||||
quote={quote}
|
||||
quoteLoading={quoteLoading}
|
||||
quoteFailed={quoteFailed}
|
||||
estSeconds={estSeconds}
|
||||
selectedTaskForPlay={selectedTaskForPlay}
|
||||
onRegenerate={handleRegenerate}
|
||||
onClearSelectedTask={handleClearSelectedTask}
|
||||
@@ -293,14 +305,6 @@ const VideoGenerationTab = () => {
|
||||
onRegenerate={handleRegenerate}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 再生成弹窗 */}
|
||||
<VideoRegenerateModal
|
||||
visible={regenerateModalVisible}
|
||||
onCancel={() => setRegenerateModalVisible(false)}
|
||||
onConfirm={handleRegenerateConfirm}
|
||||
task={taskToRegenerate}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,8 +30,13 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../../hooks/common/useSidebarCollapsed';
|
||||
import { useExperienceModules } from '../useExperienceModules';
|
||||
import { badgeText } from '../../../hooks/creation/creationWatch';
|
||||
|
||||
const ExperienceSidebar = () => {
|
||||
/**
|
||||
* @param {{ unread?: { image: number, video: number } }} props
|
||||
* unread:新创作台中用户不在该页时完成的作品数(WP C-4 未读角标)
|
||||
*/
|
||||
const ExperienceSidebar = ({ unread }) => {
|
||||
const { t } = useTranslation();
|
||||
const [collapsed, toggleCollapsed] = useSidebarCollapsed();
|
||||
const [selectedKeys, setSelectedKeys] = useState([]);
|
||||
@@ -55,6 +60,7 @@ const ExperienceSidebar = () => {
|
||||
configKey: 'imageGeneration',
|
||||
to: '/experience-center/image-generation',
|
||||
icon: Image,
|
||||
unreadKey: 'image',
|
||||
},
|
||||
{
|
||||
text: t('视频生成'),
|
||||
@@ -62,6 +68,7 @@ const ExperienceSidebar = () => {
|
||||
configKey: 'videoGeneration',
|
||||
to: '/experience-center/video-generation',
|
||||
icon: Video,
|
||||
unreadKey: 'video',
|
||||
},
|
||||
],
|
||||
[t],
|
||||
@@ -121,11 +128,19 @@ const ExperienceSidebar = () => {
|
||||
{navItems.map((item) => {
|
||||
const isSelected = selectedKeys.includes(item.itemKey);
|
||||
const IconComponent = item.icon;
|
||||
const unreadCount =
|
||||
item.unreadKey && !isSelected ? unread?.[item.unreadKey] || 0 : 0;
|
||||
const unreadLabel = unreadCount
|
||||
? t('{{n}} 个新作品', { n: unreadCount })
|
||||
: '';
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={item.to}
|
||||
aria-label={
|
||||
unreadLabel ? `${item.text}(${unreadLabel})` : undefined
|
||||
}
|
||||
onClick={() => setSelectedKeys([item.itemKey])}
|
||||
className={`
|
||||
group relative flex items-center gap-3 rounded-xl transition-all duration-200
|
||||
@@ -162,6 +177,14 @@ const ExperienceSidebar = () => {
|
||||
: 'text-gray-500 dark:text-gray-400 group-hover:text-brand-deep dark:group-hover:text-brand-from transition-colors'
|
||||
}
|
||||
/>
|
||||
{unreadCount > 0 && collapsed ? (
|
||||
<span
|
||||
className='exp-unread-badge absolute -top-1.5 -right-1.5'
|
||||
aria-hidden='true'
|
||||
>
|
||||
{badgeText(unreadCount)}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* 文字 */}
|
||||
@@ -184,6 +207,11 @@ const ExperienceSidebar = () => {
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
{unreadCount > 0 ? (
|
||||
<span className='exp-unread-badge' aria-hidden='true'>
|
||||
{badgeText(unreadCount)}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
)}
|
||||
|
||||
|
||||
@@ -17,10 +17,18 @@ 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 React, { useContext } from 'react';
|
||||
import ImageGenerationTab from './AICreation/ImageGenerationTab';
|
||||
import CreationStudio from '../../../components/creation/CreationStudio';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
import { isCreationStudioEnabled } from '../../../helpers/creationStudio';
|
||||
|
||||
const ImageGeneration = () => {
|
||||
const [statusState] = useContext(StatusContext);
|
||||
// 灰度开关开启时使用新创作台,关闭时保持旧页面不变
|
||||
if (isCreationStudioEnabled(statusState?.status)) {
|
||||
return <CreationStudio key='image' kind='image' />;
|
||||
}
|
||||
return (
|
||||
<div className='h-full min-h-0'>
|
||||
<ImageGenerationTab />
|
||||
|
||||
@@ -17,13 +17,22 @@ 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 React, { useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Video, Sparkles, Clapperboard, Film, Play } from 'lucide-react';
|
||||
import VideoGenerationTab from './AICreation/VideoGenerationTab';
|
||||
import CreationStudio from '../../../components/creation/CreationStudio';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
import { isCreationStudioEnabled } from '../../../helpers/creationStudio';
|
||||
|
||||
const VideoGeneration = () => {
|
||||
const { t } = useTranslation();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
|
||||
// 灰度开关开启时使用新创作台,关闭时保持旧页面不变
|
||||
if (isCreationStudioEnabled(statusState?.status)) {
|
||||
return <CreationStudio key='video' kind='video' />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='h-full flex flex-col p-6 relative overflow-hidden'>
|
||||
|
||||
@@ -17,10 +17,11 @@ 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 React, { useContext } from 'react';
|
||||
import { Navigate, useLocation, useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { BrainCircuit, Image, Video } from 'lucide-react';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { useMarquee } from '../../hooks/common/useMarquee';
|
||||
import PageBackground from '../../components/common/PageBackground';
|
||||
import TextModel from './components/TextModel';
|
||||
@@ -32,13 +33,19 @@ import CloudBrain from '../CloudBrain';
|
||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import { DEFAULT_LOGIN_REDIRECT } from '../../helpers/data';
|
||||
import { isCreationStudioEnabled } from '../../helpers/creationStudio';
|
||||
import { badgeText } from '../../hooks/creation/creationWatch';
|
||||
import {
|
||||
useCreationUnread,
|
||||
useCreationWatchPoller,
|
||||
} from '../../hooks/creation/useCreationWatch';
|
||||
import {
|
||||
EXPERIENCE_MODULES,
|
||||
useExperienceModules,
|
||||
} from './useExperienceModules';
|
||||
|
||||
// 移动端底部导航组件
|
||||
const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
// 移动端底部导航组件(exp-mobile-bottom-nav:新创作台展开态期间由 creation-dock.css 隐藏)
|
||||
const MobileBottomNav = ({ currentPath, navigate, isAvailable, unread }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 与桌面侧边栏共用 useExperienceModules 判定,运营关闭的子页两端一致隐藏
|
||||
@@ -59,6 +66,7 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
label: t('图片'),
|
||||
path: '/experience-center/image-generation',
|
||||
gradient: 'from-pink-500 to-rose-600',
|
||||
unread: unread?.image || 0,
|
||||
},
|
||||
{
|
||||
key: 'video',
|
||||
@@ -67,11 +75,12 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
label: t('视频'),
|
||||
path: '/experience-center/video-generation',
|
||||
gradient: 'from-cyan-500 to-blue-600',
|
||||
unread: unread?.video || 0,
|
||||
},
|
||||
].filter((item) => isAvailable(item.configKey));
|
||||
|
||||
return (
|
||||
<div className='md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
|
||||
<div className='exp-mobile-bottom-nav md:hidden fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl border-t border-gray-200/80 dark:border-neutral-800/80 safe-area-inset-bottom'>
|
||||
<div className='flex items-center justify-around h-14'>
|
||||
{navItems.map((item) => {
|
||||
const isActive = currentPath.includes(item.key);
|
||||
@@ -109,6 +118,14 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
{item.unread > 0 && !isActive ? (
|
||||
<span
|
||||
className='exp-unread-badge absolute top-1 right-[22%]'
|
||||
aria-label={t('{{n}} 个新作品', { n: item.unread })}
|
||||
>
|
||||
{badgeText(item.unread)}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
@@ -120,10 +137,15 @@ const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => {
|
||||
const ExperienceCenter = () => {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const { ready, orgOnly, isAvailable, defaultPath } = useExperienceModules();
|
||||
|
||||
// 跑马灯公告是否存在(用于动态计算顶部间距)
|
||||
const { visible: hasMarquee } = useMarquee();
|
||||
// 新创作台:用户在体验中心其他页面时轻量轮询已提交的任务,完成后显示未读角标(WP C-4)
|
||||
const creationStudioEnabled = isCreationStudioEnabled(statusState?.status);
|
||||
useCreationWatchPoller(creationStudioEnabled);
|
||||
const unread = useCreationUnread(creationStudioEnabled);
|
||||
|
||||
// 默认落地:进第一个对当前用户可用的子页;一个都没有时,org_only 用户回企业
|
||||
// 空间,其余用户去默认登录落地页。兜底目标都不在体验中心内,不会重定向循环。
|
||||
@@ -162,13 +184,17 @@ const ExperienceCenter = () => {
|
||||
return <Navigate to='/experience-center' replace />;
|
||||
}
|
||||
|
||||
// 新创作台:视口高度用 dvh,微信 H5 / 移动端键盘弹起时底部创作台与生成按钮保持可见
|
||||
const dynamicViewport =
|
||||
(isVideoGeneration || isImageGeneration) && creationStudioEnabled;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`flex flex-col md:flex-row h-screen bg-[var(--surface-bg-base)] overflow-hidden ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
|
||||
className={`flex flex-col md:flex-row ${dynamicViewport ? 'h-screen supports-[height:100dvh]:h-dvh' : 'h-screen'} bg-[var(--surface-bg-base)] overflow-hidden ${hasMarquee ? 'pt-[91px] md:pt-[107px]' : 'pt-14 md:pt-[72px]'}`}
|
||||
>
|
||||
{/* Sidebar - 桌面端 */}
|
||||
<div className='hidden md:block'>
|
||||
<ExperienceSidebar />
|
||||
<ExperienceSidebar unread={unread} />
|
||||
</div>
|
||||
|
||||
{/* Main Content */}
|
||||
@@ -210,6 +236,7 @@ const ExperienceCenter = () => {
|
||||
currentPath={location.pathname}
|
||||
navigate={navigate}
|
||||
isAvailable={isAvailable}
|
||||
unread={unread}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user