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:
qiubaishen
2026-11-10 12:01:21 +08:00
266 changed files with 38432 additions and 7570 deletions
@@ -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>
)}