sync: 同步总仓库 luoguang/monkey-ai weiyuan@bfdfb339 的 web/ 改动

同步基准:总仓库 a2ca13cb(= 本仓库初始导入 d8f3aee2)
范围:a2ca13cb..bfdfb339 中触及 web/ 的提交(不含 web/.claude/settings.local.json)

- 8490ac02 feat(aliyun): integrate Wan 3 and Qwen Image models
- 2aff08ec perf(analytics): 运营看板概览改读汇总表,首屏从 19s 降到 0.4s
- dc69335e feat(experience): 体验中心图像/视频创作升级(能力 schema、估价、新创作台)
- b059c657 fix(org): 下线 /org/create 自助加入企业页与 POST /api/org/join
- 4fcf47e6 fix(i18n): 修复中/英/韩/繁体多语言错乱,补齐日/越/泰译文
- e4c301d5 fix: merge enterprise task record date filters
- c9369b95 feat: expose enterprise image and video task records
- a410fee5 feat(claude): 无断点请求自动注入 cache_control 断点(方案 2)
- 521b3376 feat(claude): 缓存命中率优化——上游粘性路由 + 缓存时长强制改写
- 73b615dd feat(pricing): 企业成员不论登录身份均按所属企业等级计价与扣费
- f73f55c3 feat(client): 新增 WeyAi 版本说明管理与公开读取接口
- 8cdf1994 fix(topup): reset amount when switching from PayPal
- 93a4ac34 feat(baidu): configure Seedance liveness header by channel
- cb1818c5 fix(weyai): 按评审修正内容清理竞态、默认适用端与中文退回(M21)
- 04214d83 feat(weyai): WeyAi 内容管理与客户端内容接口(M21 第二部分)
- e3c4a57c feat(weyai): 设置页新增 WeyAi 页签与内容专用 COS 桶(M21 第一部分)
- b5ee8e70 fix(auth): 会话角色/状态以 DB 为准,修复提升管理员后管理接口报权限不足
- e4618fc2 fix: 修复企业看板日志聚合死循环导致 CPU 打满,并降低看板查询开销
- 584aad52 style(web): 个人中心侧边栏按 prettier 换行
- b8d87064 fix: 小程序教程隐藏充值后保留原步骤编号,企业充值判断直接用 isMiniProgramWebView
- eee7f5b2 fix: 小程序里企业首页不落到充值页,隐藏钱包入口与教程充值步骤
- 8b254d49 fix: 小程序里隐藏企业充值入口与页面
- a67661b4 fix(web): 小程序里个人中心默认页跳过充值和发票,避免来回跳转
- cff6c543 feat(web): WeyAi 小程序里打开个人中心时不出现充值和开票
- c6c99eb6 feat(billing): Claude 全部缓存写入统一按 1h 倍率计费
- 0699d1bf fix(web): 小程序 web-view 里注册页同样只显示站内方式
- 04853331 feat(web): WeyAi 小程序 web-view 里登录页只显示站内登录方式
This commit is contained in:
qiubaishen
2026-11-10 11:05:34 +08:00
parent d8f3aee261
commit 6160a23117
275 changed files with 38656 additions and 7694 deletions
@@ -0,0 +1,367 @@
/*
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, useRef, useState } from 'react';
import { Button, SideSheet, Spin } from '@douyinfe/semi-ui';
import { Copy, Star } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { ERROR_ACTIONS } from '../../../helpers/creationError';
import { copy, renderQuota, showSuccess } from '../../../helpers';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
import { adapterOf } from '../../../hooks/creation/creationForm';
import {
elapsedSeconds,
formatSeconds,
isActiveTask,
isSlowTask,
} from '../../../hooks/creation/creationTasks';
import { RefundNote, ResultImage, altOf, failureOf } from './WorkCard';
import ApiCodePanel from './ApiCodePanel';
import { sheetHeight } from '../viewport';
import './work-feed.css';
const LEGACY_MODE_LABELS = {
'text-to-image': '文生图',
'image-to-image': '图生图',
};
const formatTime = (ms) => {
if (!ms) return '-';
try {
return new Date(ms).toLocaleString();
} catch (e) {
return '-';
}
};
const DetailVideo = ({ task, onRefresh }) => {
const { t } = useTranslation();
const triedRef = useRef('');
const [failed, setFailed] = useState(false);
useEffect(() => setFailed(false), [task.videoUrl]);
if (!task.videoUrl || failed) {
return (
<div className='wf-placeholder'>
{failed ? t('视频暂不可用') : <Spin />}
</div>
);
}
return (
<video
src={task.videoUrl}
controls
playsInline
preload='metadata'
aria-label={altOf(task, t)}
onError={async () => {
if (triedRef.current === task.videoUrl) {
setFailed(true);
return;
}
triedRef.current = task.videoUrl;
const next = await onRefresh(task);
if (!next || next === task.videoUrl) setFailed(true);
}}
/>
);
};
/**
* 作品详情抽屉(WP B-6,改造自 ImageDetailModal):大图 / 播放器 + 参数 + 操作。
* 桌面右侧抽屉,移动端底部抽屉。打开时拉取详情(参数快照 request、视频播放地址)。
*
* props: task(作品流中的最新对象), visible, onClose, estSeconds,
* getActions(task, index) → [{ key, label, icon, onClick, danger }],
* onFavorite, onCancel, fetchDetail, onRefreshImage, onRefreshVideo
*/
const WorkDetailDrawer = ({
task,
visible,
onClose,
estSeconds = 0,
p90 = 0,
now,
getActions,
onFavorite,
onCancel,
fetchDetail,
onRefreshImage,
onRefreshVideo,
}) => {
const { t } = useTranslation();
const navigate = useNavigate();
const isMobile = useIsMobile();
const [index, setIndex] = useState(0);
const [loadingDetail, setLoadingDetail] = useState(false);
const taskId = task?.id;
useEffect(() => {
setIndex(0);
}, [taskId]);
// 打开时拉取一次详情(快照 / 播放地址 / regenerate_supported)
const fetchedRef = useRef('');
useEffect(() => {
if (!visible || !task || fetchedRef.current === task.id) return;
fetchedRef.current = task.id;
let alive = true;
setLoadingDetail(true);
fetchDetail(task).finally(() => {
if (alive) setLoadingDetail(false);
});
return () => {
alive = false;
};
// 只按作品 id 触发
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [visible, taskId]);
useEffect(() => {
if (!visible) fetchedRef.current = '';
}, [visible]);
if (!task) return null;
const active = isActiveTask(task);
const req = task.request || {};
const modeLabels = adapterOf(task.kind).modeLabels || {};
const modeKey = task.mode || req.mode || '';
const modeLabel = modeKey
? t(modeLabels[modeKey] || LEGACY_MODE_LABELS[modeKey] || modeKey)
: '';
const actions = getActions ? getActions(task, index) : [];
// 失败原因的下一步动作:重试 → 再生成;修改提示词 / 重新上传 → 复用参数;余额不足 → 去充值
const failure = task.status === 'failed' ? failureOf(t, task) : null;
const failureAction = (() => {
if (!failure || !failure.actionLabel) return null;
const action = failure.info.action;
if (action === ERROR_ACTIONS.TOPUP) {
return { topup: true, onClick: () => navigate('/console/topup') };
}
const key = action === ERROR_ACTIONS.RETRY ? 'regenerate' : 'reuse';
const hit = actions.find((a) => a.key === key);
return hit ? { onClick: hit.onClick } : null;
})();
const params = [
[t('模型'), task.model || '-'],
modeLabel ? [t('生成模式'), modeLabel] : null,
task.kind === 'image' && task.size
? [t('尺寸'), task.size.replace('x', '×')]
: null,
task.kind === 'image' && task.quality ? [t('画质'), task.quality] : null,
task.kind === 'image' && task.n > 1 ? [t('张数'), task.n] : null,
task.kind === 'video' && task.ratio ? [t('比例'), task.ratio] : null,
task.kind === 'video' && task.resolution
? [t('分辨率'), task.resolution]
: null,
task.kind === 'video' && task.duration > 0
? [t('时长'), formatSeconds(task.duration)]
: null,
typeof req.seed === 'number' ? [t('种子'), req.seed] : null,
[t('创建时间'), formatTime(task.createdAt)],
task.finishedAt && task.startedAt && !active
? [t('耗时'), formatSeconds((task.finishedAt - task.startedAt) / 1000)]
: null,
task.quota > 0 ? [t('消耗'), renderQuota(task.quota)] : null,
task.quotedQuota > 0 ? [t('预估'), renderQuota(task.quotedQuota)] : null,
].filter(Boolean);
const images = task.images || [];
const elapsed = elapsedSeconds(task, now);
let media;
if (task.status === 'success') {
media =
task.kind === 'video' ? (
<DetailVideo task={task} onRefresh={onRefreshVideo} />
) : (
<ResultImage
task={task}
index={index}
onRefresh={onRefreshImage}
alt={altOf(task, t)}
/>
);
} else if (active) {
media = (
<div className='wf-placeholder'>
<Spin />
<span>{task.status === 'queued' ? t('排队中') : t('生成中')}</span>
<span className='wf-num'>
{estSeconds > 0
? t('已用时 {{elapsed}} / 预计 {{est}}', {
elapsed: formatSeconds(elapsed),
est: formatSeconds(estSeconds),
})
: t('已用时 {{elapsed}}', { elapsed: formatSeconds(elapsed) })}
</span>
{isSlowTask(task, p90, now) ? (
<span className='wf-slow' role='note'>
{t('比平时慢,可以切到其他页面,完成后会提醒你')}
</span>
) : null}
</div>
);
} else {
media = <div className='wf-placeholder'>{t('生成失败')}</div>;
}
return (
<SideSheet
visible={visible}
onCancel={onClose}
title={task.kind === 'video' ? t('视频详情') : t('图片详情')}
placement={isMobile ? 'bottom' : 'right'}
width={isMobile ? undefined : 'min(720px, 92vw)'}
height={isMobile ? sheetHeight(92) : undefined}
bodyStyle={{
paddingBottom: 'calc(16px + env(safe-area-inset-bottom, 0px))',
}}
className='app-scrollbar'
>
<div className='wf-detail'>
<div className='wf-detail-media'>{media}</div>
{task.kind === 'image' && images.length > 1 ? (
<div
className='wf-thumbs app-scrollbar'
role='tablist'
aria-label={t('结果图片')}
>
{images.map((img, i) => (
<button
key={i}
type='button'
role='tab'
aria-selected={i === index}
aria-label={t('第 {{n}} 张', { n: i + 1 })}
className={`wf-thumb${i === index ? ' is-active' : ''}`}
onClick={() => setIndex(i)}
>
{img.url ? <img src={img.url} alt='' loading='lazy' /> : null}
</button>
))}
</div>
) : null}
{task.status === 'failed' ? (
<div className='wf-detail-alert' role='note'>
{failure ? (
<>
<strong>{failure.title}</strong>
{failure.detail ? <div>{failure.detail}</div> : null}
{failure.info.category !== 'unknown' &&
failure.title !== task.failReason ? (
<div className='wf-detail-raw'>{task.failReason}</div>
) : null}
</>
) : (
<div>{t('生成失败')}</div>
)}
<RefundNote task={task} />
{failureAction ? (
<Button
size='small'
type={failureAction.topup ? 'warning' : 'tertiary'}
onClick={failureAction.onClick}
>
{failure.actionLabel}
</Button>
) : null}
</div>
) : null}
<div className='wf-detail-actions'>
{!active ? (
<Button
icon={
<Star
size={14}
aria-hidden='true'
fill={task.favorited ? 'currentColor' : 'none'}
/>
}
type={task.favorited ? 'warning' : 'tertiary'}
aria-pressed={task.favorited}
onClick={() => onFavorite(task)}
>
{task.favorited ? t('已收藏') : t('收藏')}
</Button>
) : null}
{active && task.cancelable ? (
<Button type='danger' onClick={() => onCancel(task)}>
{t('取消任务')}
</Button>
) : null}
{actions.map((action) => (
<Button
key={action.key}
icon={action.icon}
type={action.danger ? 'danger' : 'tertiary'}
onClick={() => action.onClick(task)}
>
{action.label}
</Button>
))}
</div>
<section>
<div className='flex items-center justify-between gap-2'>
<h3 className='wf-detail-section-title'>{t('提示词')}</h3>
{task.prompt ? (
<Button
size='small'
theme='borderless'
icon={<Copy size={12} aria-hidden='true' />}
onClick={async () => {
if (await copy(task.prompt)) showSuccess(t('已复制'));
}}
>
{t('复制')}
</Button>
) : null}
</div>
<p className='wf-detail-prompt'>{task.prompt || t('(无提示词)')}</p>
</section>
<section>
<h3 className='wf-detail-section-title'>
{t('参数')}
{loadingDetail ? (
<Spin size='small' wrapperClassName='ml-2' />
) : null}
</h3>
<dl className='wf-params'>
{params.map(([label, value]) => (
<div key={label}>
<dt>{label}</dt>
<dd title={String(value)}>{value}</dd>
</div>
))}
</dl>
</section>
{!active ? <ApiCodePanel key={task.id} task={task} /> : null}
</div>
</SideSheet>
);
};
export default WorkDetailDrawer;