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:
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
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, { useContext, useMemo, useState } from 'react';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
import { ChevronDown, Code2, Copy, KeyRound } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
import { copy, showSuccess } from '../../../helpers';
|
||||
import { trackCreationEvent } from '../../../helpers/creationEvents';
|
||||
import {
|
||||
API_CODE_LANGS,
|
||||
apiBaseUrlOf,
|
||||
buildApiCall,
|
||||
renderApiCode,
|
||||
} from '../../../hooks/creation/creationApiCode';
|
||||
|
||||
/** 秘钥管理模块;from=creation_studio 用于记录 key_created_from_studio(WP C-1)。 */
|
||||
export const KEY_MANAGEMENT_FROM_STUDIO =
|
||||
'/key-management?from=creation_studio';
|
||||
|
||||
const LANG_LABELS = {
|
||||
curl: 'cURL',
|
||||
python: 'Python',
|
||||
javascript: 'JavaScript',
|
||||
};
|
||||
|
||||
const currentOrigin = () => {
|
||||
try {
|
||||
return window.location.origin;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取 API 代码(WP C-1,方案 §4.4):详情抽屉内的折叠面板,由参数快照生成等价的
|
||||
* /v1/images|video/generations 调用(curl / Python / JavaScript),标注"API 同价",
|
||||
* "创建密钥"直达秘钥管理。首次展开记 api_code_open。
|
||||
*/
|
||||
const ApiCodePanel = ({ task }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [lang, setLang] = useState('curl');
|
||||
const [tracked, setTracked] = useState(false);
|
||||
|
||||
const baseUrl = apiBaseUrlOf(statusState?.status, currentOrigin());
|
||||
const call = useMemo(() => buildApiCall(task, { baseUrl }), [task, baseUrl]);
|
||||
const code = useMemo(() => renderApiCode(call, lang), [call, lang]);
|
||||
const panelId = `wf-api-${task?.id || 'x'}`;
|
||||
|
||||
const toggle = () => {
|
||||
const next = !open;
|
||||
setOpen(next);
|
||||
if (next && !tracked) {
|
||||
setTracked(true);
|
||||
trackCreationEvent('api_code_open', {
|
||||
kind: task?.kind || '',
|
||||
model: call.body.model || '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<section className='wf-api'>
|
||||
<button
|
||||
type='button'
|
||||
className='wf-api-toggle'
|
||||
aria-expanded={open}
|
||||
aria-controls={panelId}
|
||||
onClick={toggle}
|
||||
>
|
||||
<Code2 size={14} aria-hidden='true' />
|
||||
<span className='wf-api-title'>{t('获取 API 代码')}</span>
|
||||
<span className='wf-api-badge'>{t('API 同价')}</span>
|
||||
<ChevronDown
|
||||
size={14}
|
||||
aria-hidden='true'
|
||||
className={`wf-api-caret${open ? ' is-open' : ''}`}
|
||||
/>
|
||||
</button>
|
||||
{open ? (
|
||||
<div id={panelId} className='wf-api-body'>
|
||||
<p className='wf-api-desc'>
|
||||
{t('用同样的参数通过 API 调用,价格与体验中心一致')}
|
||||
</p>
|
||||
<div className='wf-api-bar'>
|
||||
<div
|
||||
className='wf-api-tabs'
|
||||
role='tablist'
|
||||
aria-label={t('代码语言')}
|
||||
>
|
||||
{API_CODE_LANGS.map((key) => (
|
||||
<button
|
||||
key={key}
|
||||
type='button'
|
||||
role='tab'
|
||||
aria-selected={lang === key}
|
||||
className={`wf-api-tab${lang === key ? ' is-active' : ''}`}
|
||||
onClick={() => setLang(key)}
|
||||
>
|
||||
{LANG_LABELS[key]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Copy size={12} aria-hidden='true' />}
|
||||
onClick={async () => {
|
||||
if (await copy(code)) showSuccess(t('已复制'));
|
||||
}}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
</div>
|
||||
<pre
|
||||
className='wf-api-code app-scrollbar'
|
||||
role='tabpanel'
|
||||
aria-label={LANG_LABELS[lang]}
|
||||
tabIndex={0}
|
||||
>
|
||||
<code>{code}</code>
|
||||
</pre>
|
||||
{call.notes.length ? (
|
||||
<ul className='wf-api-notes'>
|
||||
{call.notes.map((note) => (
|
||||
<li key={note}>{t(note, { path: call.path })}</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
<div className='wf-api-foot'>
|
||||
<span className='wf-api-hint'>
|
||||
{t('把 sk-xxx 替换为你的 API 密钥')}
|
||||
</span>
|
||||
<Button
|
||||
size='small'
|
||||
theme='solid'
|
||||
icon={<KeyRound size={12} aria-hidden='true' />}
|
||||
onClick={() => navigate(KEY_MANAGEMENT_FROM_STUDIO)}
|
||||
>
|
||||
{t('创建密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
export default ApiCodePanel;
|
||||
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
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,
|
||||
useSyncExternalStore,
|
||||
} from 'react';
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Input,
|
||||
Popover,
|
||||
Select,
|
||||
SideSheet,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { Filter, GitCompare, Search, Star } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import {
|
||||
activeFilterCount,
|
||||
facetsOf,
|
||||
} from '../../../hooks/creation/creationTasks';
|
||||
import './work-feed.css';
|
||||
|
||||
// 移动端与矮屏桌面:筛选栏折叠为一个"筛选"图标(与 CreationDock 的收起判定一致)
|
||||
const COMPACT_QUERY = '(max-width: 767px), (max-height: 799px)';
|
||||
|
||||
const useCompactFilters = () =>
|
||||
useSyncExternalStore(
|
||||
(callback) => {
|
||||
const mql = window.matchMedia(COMPACT_QUERY);
|
||||
mql.addEventListener('change', callback);
|
||||
return () => mql.removeEventListener('change', callback);
|
||||
},
|
||||
() => window.matchMedia(COMPACT_QUERY).matches,
|
||||
() => false,
|
||||
);
|
||||
|
||||
const STATUS_OPTIONS = [
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'active', label: '进行中' },
|
||||
{ value: 'success', label: '已完成' },
|
||||
{ value: 'failed', label: '失败' },
|
||||
];
|
||||
|
||||
/** 关键词输入:本地即时响应,250ms 防抖后写入筛选条件。 */
|
||||
const useDebouncedKeyword = (keyword, setFilters) => {
|
||||
const [input, setInput] = useState(keyword || '');
|
||||
useEffect(() => {
|
||||
setInput(keyword || '');
|
||||
}, [keyword]);
|
||||
useEffect(() => {
|
||||
if (input === (keyword || '')) return undefined;
|
||||
const timer = setTimeout(() => setFilters({ keyword: input }), 250);
|
||||
return () => clearTimeout(timer);
|
||||
}, [input, keyword, setFilters]);
|
||||
return [input, setInput];
|
||||
};
|
||||
|
||||
const Controls = ({ kind, api, facets, vertical, input, setInput }) => {
|
||||
const { t } = useTranslation();
|
||||
const { filters, setFilters } = api;
|
||||
const label = (text) =>
|
||||
vertical ? <div className='wf-filter-panel-label'>{text}</div> : null;
|
||||
const wrap = (node, text) =>
|
||||
vertical ? (
|
||||
<div>
|
||||
{label(text)}
|
||||
{node}
|
||||
</div>
|
||||
) : (
|
||||
node
|
||||
);
|
||||
|
||||
const modelOptions = [
|
||||
{ value: 'all', label: t('全部模型') },
|
||||
...facets.models.map((m) => ({ value: m, label: m })),
|
||||
];
|
||||
const sizeOptions = [
|
||||
{ value: 'all', label: t('全部尺寸') },
|
||||
...facets.sizes.map((s) => ({ value: s, label: s.replace('x', '×') })),
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
{wrap(
|
||||
<Input
|
||||
className='wf-filters-search'
|
||||
prefix={<Search size={14} aria-hidden='true' />}
|
||||
placeholder={t('搜索提示词或模型')}
|
||||
aria-label={t('搜索提示词或模型')}
|
||||
value={input}
|
||||
onChange={setInput}
|
||||
showClear
|
||||
/>,
|
||||
t('搜索'),
|
||||
)}
|
||||
{wrap(
|
||||
<Select
|
||||
aria-label={t('状态')}
|
||||
value={filters.status}
|
||||
onChange={(v) => setFilters({ status: v })}
|
||||
optionList={STATUS_OPTIONS.map((o) => ({
|
||||
value: o.value,
|
||||
label: t(o.label),
|
||||
}))}
|
||||
/>,
|
||||
t('状态'),
|
||||
)}
|
||||
{wrap(
|
||||
<Select
|
||||
aria-label={t('模型')}
|
||||
value={filters.model}
|
||||
onChange={(v) => setFilters({ model: v })}
|
||||
optionList={modelOptions}
|
||||
filter
|
||||
/>,
|
||||
t('模型'),
|
||||
)}
|
||||
{kind === 'image'
|
||||
? wrap(
|
||||
<Select
|
||||
aria-label={t('尺寸')}
|
||||
value={filters.size}
|
||||
onChange={(v) => setFilters({ size: v })}
|
||||
optionList={sizeOptions}
|
||||
/>,
|
||||
t('尺寸'),
|
||||
)
|
||||
: null}
|
||||
<Button
|
||||
theme={filters.favoritesOnly ? 'solid' : 'light'}
|
||||
type={filters.favoritesOnly ? 'warning' : 'tertiary'}
|
||||
icon={<Star size={14} aria-hidden='true' />}
|
||||
aria-pressed={filters.favoritesOnly}
|
||||
onClick={() => setFilters({ favoritesOnly: !filters.favoritesOnly })}
|
||||
>
|
||||
{t('只看收藏')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 作品流筛选栏(WP B-6):状态 / 模型 / 尺寸(图像)/ 只看收藏 / 关键词;图像页带"多选对比"开关。
|
||||
* 移动端与矮屏桌面折叠为一个"筛选"图标(移动端底部抽屉,矮屏桌面弹层)。
|
||||
*
|
||||
* props: kind, api = useCreationTasks(kind), selecting, onToggleSelecting
|
||||
*/
|
||||
const FilterBar = ({ kind, api, selecting, onToggleSelecting }) => {
|
||||
const { t } = useTranslation();
|
||||
const compact = useCompactFilters();
|
||||
const isMobile = useIsMobile();
|
||||
const [open, setOpen] = useState(false);
|
||||
const facets = useMemo(() => facetsOf(api.tasks), [api.tasks]);
|
||||
const [input, setInput] = useDebouncedKeyword(
|
||||
api.filters.keyword,
|
||||
api.setFilters,
|
||||
);
|
||||
const count = activeFilterCount(api.filters);
|
||||
|
||||
const compareButton =
|
||||
kind === 'image' && onToggleSelecting ? (
|
||||
<Button
|
||||
theme={selecting ? 'solid' : 'light'}
|
||||
type={selecting ? 'primary' : 'tertiary'}
|
||||
icon={<GitCompare size={14} aria-hidden='true' />}
|
||||
aria-pressed={selecting}
|
||||
aria-label={t('多选对比')}
|
||||
title={t('多选对比')}
|
||||
onClick={onToggleSelecting}
|
||||
>
|
||||
{compact ? null : t('多选对比')}
|
||||
</Button>
|
||||
) : null;
|
||||
|
||||
if (!compact) {
|
||||
return (
|
||||
<div className='wf-filters' role='search'>
|
||||
<Controls
|
||||
kind={kind}
|
||||
api={api}
|
||||
facets={facets}
|
||||
input={input}
|
||||
setInput={setInput}
|
||||
/>
|
||||
{compareButton}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const panel = (
|
||||
<div className='wf-filter-panel' role='search'>
|
||||
<Controls
|
||||
kind={kind}
|
||||
api={api}
|
||||
facets={facets}
|
||||
vertical
|
||||
input={input}
|
||||
setInput={setInput}
|
||||
/>
|
||||
<div className='wf-filter-panel-actions'>
|
||||
<Button
|
||||
type='tertiary'
|
||||
disabled={count === 0}
|
||||
onClick={() => {
|
||||
setInput('');
|
||||
api.resetFilters();
|
||||
}}
|
||||
>
|
||||
{t('清除筛选')}
|
||||
</Button>
|
||||
<Button theme='solid' onClick={() => setOpen(false)}>
|
||||
{t('完成')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
const trigger = (
|
||||
<Badge count={count || undefined} type='primary'>
|
||||
<Button
|
||||
theme='light'
|
||||
type='tertiary'
|
||||
icon={<Filter size={16} aria-hidden='true' />}
|
||||
aria-label={t('筛选')}
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
/>
|
||||
</Badge>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='wf-filters'>
|
||||
{compareButton}
|
||||
{isMobile ? (
|
||||
<>
|
||||
{trigger}
|
||||
<SideSheet
|
||||
className='wf-filter-sheet'
|
||||
title={t('筛选')}
|
||||
visible={open}
|
||||
placement='bottom'
|
||||
height='auto'
|
||||
onCancel={() => setOpen(false)}
|
||||
>
|
||||
{panel}
|
||||
</SideSheet>
|
||||
</>
|
||||
) : (
|
||||
<Popover
|
||||
visible={open}
|
||||
trigger='custom'
|
||||
position='bottomRight'
|
||||
onClickOutSide={() => setOpen(false)}
|
||||
onEscKeyDown={() => setOpen(false)}
|
||||
content={<div className='p-3'>{panel}</div>}
|
||||
>
|
||||
{trigger}
|
||||
</Popover>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterBar;
|
||||
@@ -0,0 +1,488 @@
|
||||
/*
|
||||
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, { memo, useEffect, useRef, useState } from 'react';
|
||||
import { Button, Dropdown } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
AlertCircle,
|
||||
Check,
|
||||
Clapperboard,
|
||||
Image as ImageIcon,
|
||||
LayoutGrid,
|
||||
MoreHorizontal,
|
||||
RefreshCw,
|
||||
Star,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { renderQuota } from '../../../helpers';
|
||||
import {
|
||||
classifyCreationError,
|
||||
describeCreationError,
|
||||
} from '../../../helpers/creationError';
|
||||
import {
|
||||
aspectRatioOf,
|
||||
elapsedSeconds,
|
||||
formatSeconds,
|
||||
isActiveTask,
|
||||
isSlowTask,
|
||||
} from '../../../hooks/creation/creationTasks';
|
||||
|
||||
const matches = (query) => {
|
||||
try {
|
||||
return window.matchMedia(query).matches;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const prefersReducedMotion = () => matches('(prefers-reduced-motion: reduce)');
|
||||
const canHover = () => matches('(hover: hover) and (pointer: fine)');
|
||||
|
||||
/** 作品默认 alt:提示词前 60 字(方案 §4.7)。 */
|
||||
export const altOf = (task, t) =>
|
||||
(task?.prompt || '').slice(0, 60) || t('生成的作品');
|
||||
|
||||
/**
|
||||
* 单张结果图:地址失效(COS 预签名过期)时自动刷新一次,仍失败显示占位 + 手动刷新。
|
||||
*/
|
||||
export const ResultImage = ({ task, index, onRefresh, className, alt }) => {
|
||||
const { t } = useTranslation();
|
||||
const image = task.images?.[index] || {};
|
||||
const [failed, setFailed] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const triedRef = useRef('');
|
||||
|
||||
useEffect(() => {
|
||||
setFailed(false);
|
||||
}, [image.url]);
|
||||
|
||||
const refresh = async () => {
|
||||
if (busy) return;
|
||||
setBusy(true);
|
||||
const url = await onRefresh(task, index);
|
||||
setBusy(false);
|
||||
if (!url) setFailed(true);
|
||||
};
|
||||
|
||||
const onError = () => {
|
||||
if (triedRef.current === image.url) {
|
||||
setFailed(true);
|
||||
return;
|
||||
}
|
||||
triedRef.current = image.url;
|
||||
refresh();
|
||||
};
|
||||
|
||||
if (!image.url || failed) {
|
||||
const canRefresh = Boolean(image.url) || (image.hasB64 && index === 0);
|
||||
return (
|
||||
<div className={`wf-placeholder ${className || ''}`}>
|
||||
<ImageIcon size={20} aria-hidden='true' />
|
||||
<span>{t('图片暂不可用')}</span>
|
||||
{canRefresh ? (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<RefreshCw size={12} aria-hidden='true' />}
|
||||
loading={busy}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
refresh();
|
||||
}}
|
||||
>
|
||||
{t('刷新链接')}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<img
|
||||
src={image.url}
|
||||
alt={alt}
|
||||
loading='lazy'
|
||||
decoding='async'
|
||||
className={className}
|
||||
onError={onError}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 视频封面:静音;桌面悬停自动播放,触屏设备进入视口播放;prefers-reduced-motion 时不自动播放。
|
||||
* 地址失效时经 ids= 刷新一次。
|
||||
*/
|
||||
const VideoThumb = ({ task, onRefresh, alt }) => {
|
||||
const { t } = useTranslation();
|
||||
const ref = useRef(null);
|
||||
const triedRef = useRef('');
|
||||
const [failed, setFailed] = useState(false);
|
||||
const url = task.videoUrl;
|
||||
|
||||
useEffect(() => {
|
||||
setFailed(false);
|
||||
}, [url]);
|
||||
|
||||
// 触屏:进入视口(≥ 60%)静音播放,离开暂停
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el || !url || canHover() || prefersReducedMotion()) return undefined;
|
||||
if (typeof IntersectionObserver === 'undefined') return undefined;
|
||||
const io = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (entry.isIntersecting) el.play?.().catch(() => {});
|
||||
else el.pause?.();
|
||||
},
|
||||
{ threshold: 0.6 },
|
||||
);
|
||||
io.observe(el);
|
||||
return () => io.disconnect();
|
||||
}, [url]);
|
||||
|
||||
if (!url || failed) {
|
||||
return (
|
||||
<div className='wf-placeholder'>
|
||||
<Clapperboard size={22} aria-hidden='true' />
|
||||
{failed ? <span>{t('视频暂不可用')}</span> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const onEnter = () => {
|
||||
if (!canHover() || prefersReducedMotion()) return;
|
||||
ref.current?.play?.().catch(() => {});
|
||||
};
|
||||
const onLeave = () => {
|
||||
const el = ref.current;
|
||||
if (!el || !canHover()) return;
|
||||
el.pause?.();
|
||||
try {
|
||||
el.currentTime = 0;
|
||||
} catch (e) {
|
||||
// 元数据未加载时不可设置
|
||||
}
|
||||
};
|
||||
const onError = async () => {
|
||||
if (triedRef.current === url) {
|
||||
setFailed(true);
|
||||
return;
|
||||
}
|
||||
triedRef.current = url;
|
||||
const next = await onRefresh(task);
|
||||
if (!next || next === url) setFailed(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<video
|
||||
ref={ref}
|
||||
// #t=0.1 让未自动播放的浏览器(iOS Safari)也显示首帧作为封面
|
||||
src={`${url}#t=0.1`}
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
preload='metadata'
|
||||
aria-label={alt}
|
||||
onMouseEnter={onEnter}
|
||||
onMouseLeave={onLeave}
|
||||
onFocus={onEnter}
|
||||
onBlur={onLeave}
|
||||
onError={onError}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const ActiveOverlay = ({ task, estSeconds, p90 = 0, now }) => {
|
||||
const { t } = useTranslation();
|
||||
const elapsed = elapsedSeconds(task, now);
|
||||
const slow = isSlowTask(task, p90, now);
|
||||
return (
|
||||
<div className='wf-active'>
|
||||
<span className='wf-active-label'>
|
||||
{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>
|
||||
{task.progress > 0 ? (
|
||||
<div
|
||||
className='wf-progress'
|
||||
role='progressbar'
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={task.progress}
|
||||
aria-label={t('生成进度')}
|
||||
>
|
||||
<span style={{ width: `${task.progress}%` }} />
|
||||
</div>
|
||||
) : null}
|
||||
{slow ? (
|
||||
<span className='wf-slow' role='note'>
|
||||
{t('比平时慢,可以切到其他页面,完成后会提醒你')}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const RefundNote = ({ task }) => {
|
||||
const { t } = useTranslation();
|
||||
if (!(task.refundedQuota > 0)) return null;
|
||||
return (
|
||||
<span className='wf-refund'>
|
||||
{t('已退还 {{amount}}', { amount: renderQuota(task.refundedQuota) })}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
/** 失败原因 → 统一错误映射({ info, title, detail, actionLabel });没有原因时为 null。 */
|
||||
export const failureOf = (t, task) => {
|
||||
if (!task?.failReason) return null;
|
||||
const info = classifyCreationError(task.failReason);
|
||||
return { info, ...describeCreationError(t, info) };
|
||||
};
|
||||
|
||||
const FailedOverlay = ({ task }) => {
|
||||
const { t } = useTranslation();
|
||||
const failure = failureOf(t, task);
|
||||
// 映射为通用"生成失败"时直接展示原始原因;否则展示可读文案,原始原因放在 title 里
|
||||
const reason = failure
|
||||
? failure.info.category === 'unknown'
|
||||
? task.failReason
|
||||
: failure.title
|
||||
: '';
|
||||
return (
|
||||
<div className='wf-failed'>
|
||||
<span className='wf-failed-title'>
|
||||
<AlertCircle size={14} aria-hidden='true' />
|
||||
{t('生成失败')}
|
||||
</span>
|
||||
{reason ? (
|
||||
<span className='wf-failed-reason' title={task.failReason}>
|
||||
{reason}
|
||||
</span>
|
||||
) : null}
|
||||
<RefundNote task={task} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const ImageMedia = ({ task, onRefreshImage, alt }) => {
|
||||
const { t } = useTranslation();
|
||||
const count = task.images.length;
|
||||
if (count > 1) {
|
||||
return (
|
||||
<>
|
||||
<div className='wf-grid4'>
|
||||
{task.images.slice(0, 4).map((_, i) => (
|
||||
<ResultImage
|
||||
key={i}
|
||||
task={task}
|
||||
index={i}
|
||||
onRefresh={onRefreshImage}
|
||||
alt={`${alt} (${i + 1})`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<span className='wf-badge wf-badge--br'>
|
||||
<LayoutGrid size={11} aria-hidden='true' />
|
||||
{t('{{n}} 张', { n: count })}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<ResultImage task={task} index={0} onRefresh={onRefreshImage} alt={alt} />
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 作品卡片(图像 / 视频)。
|
||||
* props:
|
||||
* task, estSeconds, p90(预计耗时 p90,超过时显示慢任务提示), now,
|
||||
* getActions: (task) => [{ key, label, icon, onClick, danger }](更多菜单)
|
||||
* onOpen, onFavorite, onCancel, onRefreshImage, onRefreshVideo,
|
||||
* selecting, selected, selectable, onToggleSelect
|
||||
*/
|
||||
const WorkCard = ({
|
||||
task,
|
||||
estSeconds = 0,
|
||||
p90 = 0,
|
||||
now,
|
||||
getActions,
|
||||
onOpen,
|
||||
onFavorite,
|
||||
onCancel,
|
||||
onRefreshImage,
|
||||
onRefreshVideo,
|
||||
selecting = false,
|
||||
selected = false,
|
||||
selectable = false,
|
||||
onToggleSelect,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const active = isActiveTask(task);
|
||||
const failed = task.status === 'failed';
|
||||
const alt = altOf(task, t);
|
||||
const ratio = aspectRatioOf(task);
|
||||
const actions = getActions ? getActions(task) : [];
|
||||
|
||||
const handleMediaClick = () => {
|
||||
if (selecting) {
|
||||
if (selectable) onToggleSelect?.(task);
|
||||
return;
|
||||
}
|
||||
onOpen?.(task);
|
||||
};
|
||||
|
||||
let mediaLabel = alt;
|
||||
if (selecting) {
|
||||
mediaLabel = selectable
|
||||
? `${selected ? t('取消选择') : t('选择')}:${alt}`
|
||||
: t('仅已完成的图片可参与对比');
|
||||
} else if (active) {
|
||||
mediaLabel = `${task.status === 'queued' ? t('排队中') : t('生成中')}:${alt}`;
|
||||
} else if (failed) {
|
||||
mediaLabel = `${t('生成失败')}:${alt}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<article
|
||||
className={`wf-card${selected ? ' is-selected' : ''}`}
|
||||
data-status={task.status}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='wf-media'
|
||||
style={{ aspectRatio: String(ratio) }}
|
||||
onClick={handleMediaClick}
|
||||
aria-label={mediaLabel}
|
||||
aria-pressed={selecting && selectable ? selected : undefined}
|
||||
disabled={selecting && !selectable}
|
||||
>
|
||||
{task.status === 'success' ? (
|
||||
task.kind === 'video' ? (
|
||||
<VideoThumb task={task} onRefresh={onRefreshVideo} alt={alt} />
|
||||
) : (
|
||||
<ImageMedia task={task} onRefreshImage={onRefreshImage} alt={alt} />
|
||||
)
|
||||
) : null}
|
||||
{active ? (
|
||||
<ActiveOverlay
|
||||
task={task}
|
||||
estSeconds={estSeconds}
|
||||
p90={p90}
|
||||
now={now}
|
||||
/>
|
||||
) : null}
|
||||
{failed ? <FailedOverlay task={task} /> : null}
|
||||
{task.kind === 'video' && task.duration > 0 && !active ? (
|
||||
<span className='wf-badge wf-badge--bl wf-num'>
|
||||
{formatSeconds(task.duration)}
|
||||
</span>
|
||||
) : null}
|
||||
{selecting && selectable ? (
|
||||
<span className='wf-check' aria-hidden='true'>
|
||||
{selected ? <Check size={14} /> : null}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
|
||||
{!selecting ? (
|
||||
<div className={`wf-tools${task.favorited ? ' is-pinned' : ''}`}>
|
||||
{active && task.cancelable ? (
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
theme='light'
|
||||
onClick={() => onCancel?.(task)}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
) : null}
|
||||
{!active ? (
|
||||
<button
|
||||
type='button'
|
||||
className={`wf-icon-btn${task.favorited ? ' is-on' : ''}`}
|
||||
aria-pressed={task.favorited}
|
||||
aria-label={task.favorited ? t('取消收藏') : t('收藏')}
|
||||
title={task.favorited ? t('取消收藏') : t('收藏')}
|
||||
onClick={() => onFavorite?.(task)}
|
||||
>
|
||||
<Star
|
||||
size={15}
|
||||
aria-hidden='true'
|
||||
fill={task.favorited ? 'currentColor' : 'none'}
|
||||
/>
|
||||
</button>
|
||||
) : null}
|
||||
{actions.length ? (
|
||||
<Dropdown
|
||||
trigger='click'
|
||||
position='bottomRight'
|
||||
render={
|
||||
<Dropdown.Menu>
|
||||
{actions.map((action) => (
|
||||
<Dropdown.Item
|
||||
key={action.key}
|
||||
icon={action.icon}
|
||||
type={action.danger ? 'danger' : undefined}
|
||||
onClick={() => action.onClick(task)}
|
||||
>
|
||||
{action.label}
|
||||
</Dropdown.Item>
|
||||
))}
|
||||
</Dropdown.Menu>
|
||||
}
|
||||
>
|
||||
<button
|
||||
type='button'
|
||||
className='wf-icon-btn'
|
||||
aria-label={t('更多操作')}
|
||||
title={t('更多操作')}
|
||||
>
|
||||
<MoreHorizontal size={15} aria-hidden='true' />
|
||||
</button>
|
||||
</Dropdown>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className='wf-body'>
|
||||
<p className='wf-prompt' title={task.prompt}>
|
||||
{task.prompt || t('(无提示词)')}
|
||||
</p>
|
||||
<div className='wf-meta'>
|
||||
<span title={task.model}>{task.model || t('未知模型')}</span>
|
||||
{task.kind === 'image' && task.size ? (
|
||||
<span className='wf-num'>{task.size.replace('x', '×')}</span>
|
||||
) : null}
|
||||
{task.kind === 'video' && task.resolution ? (
|
||||
<span>{task.resolution}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(WorkCard);
|
||||
@@ -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;
|
||||
@@ -0,0 +1,988 @@
|
||||
/*
|
||||
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, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Button, Modal, Spin } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
Clapperboard,
|
||||
Columns2,
|
||||
Dices,
|
||||
Download,
|
||||
Film,
|
||||
ImageIcon,
|
||||
ImagePlus,
|
||||
PenLine,
|
||||
RotateCcw,
|
||||
SlidersHorizontal,
|
||||
Trash2,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { showError, showInfo, showSuccess } from '../../../helpers';
|
||||
import { trackCreationEvent } from '../../../helpers/creationEvents';
|
||||
import { templateGroupsOf } from '../../../constants/creationTemplates';
|
||||
import { templateParamsSummary } from '../../../hooks/creation/creationDock';
|
||||
import {
|
||||
formFromImageRequest,
|
||||
formFromLegacyTask,
|
||||
} from '../../../hooks/image/imageCreation';
|
||||
import { formFromTaskRequest } from '../../../hooks/video/videoCreation';
|
||||
import { adapterOf } from '../../../hooks/creation/creationForm';
|
||||
import {
|
||||
comparableBatchTasks,
|
||||
groupBatchRows,
|
||||
} from '../../../hooks/creation/creationCompare';
|
||||
import {
|
||||
GROUP_LABEL_KEYS,
|
||||
PAGE_SIZE,
|
||||
activeFilterCount,
|
||||
filterTasks,
|
||||
groupTasksByDate,
|
||||
hasClientFilter,
|
||||
isActiveTask,
|
||||
nextEmptyStreak,
|
||||
shouldAutoLoad,
|
||||
taskImageRef,
|
||||
taskLastFrameRef,
|
||||
variationParams,
|
||||
} from '../../../hooks/creation/creationTasks';
|
||||
import ImageCompareModal from '../../../pages/ExperienceCenter/components/AICreation/ImageCompareModal';
|
||||
import WorkCard from './WorkCard';
|
||||
import WorkDetailDrawer from './WorkDetailDrawer';
|
||||
import './work-feed.css';
|
||||
|
||||
const COMPARE_MAX = 4;
|
||||
|
||||
/** 对比视图(ImageCompareModal)需要的作品结构。 */
|
||||
const compareItemOf = (task) => ({
|
||||
id: task.id,
|
||||
imageUrl: task.images?.[0]?.url,
|
||||
model: task.model,
|
||||
width: task.width,
|
||||
height: task.height,
|
||||
quality: task.quality,
|
||||
prompt: task.prompt,
|
||||
});
|
||||
|
||||
const newSlotId = () =>
|
||||
`slot-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
||||
|
||||
// 结果不可按 task:// 引用时,下载后按本地图片处理
|
||||
const urlToFile = async (url, filename) => {
|
||||
const resp = await fetch(url);
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||||
const blob = await resp.blob();
|
||||
const ext = (blob.type.split('/')[1] || 'png').replace('jpeg', 'jpg');
|
||||
return new File([blob], `${filename}.${ext}`, {
|
||||
type: blob.type || 'image/png',
|
||||
});
|
||||
};
|
||||
|
||||
const triggerDownload = (href, filename) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = href;
|
||||
link.download = filename;
|
||||
link.target = '_blank';
|
||||
link.rel = 'noopener';
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
requestAnimationFrame(() => document.body.removeChild(link));
|
||||
};
|
||||
|
||||
/** 作品 → formFromLegacyTask 需要的旧任务结构(无参数快照的旧任务)。 */
|
||||
const legacyShapeOf = (task) => ({
|
||||
taskData: task.taskData || {},
|
||||
width: task.width,
|
||||
height: task.height,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.taskData?.negative_prompt,
|
||||
mode: task.mode,
|
||||
sourceImageUrl: task.sourceImageUrl,
|
||||
prompt: task.prompt,
|
||||
model: task.model,
|
||||
});
|
||||
|
||||
/** 每秒刷新"已用时"(仅在有进行中作品时计时)。 */
|
||||
const useNow = (enabled) => {
|
||||
const [now, setNow] = useState(() => Date.now());
|
||||
useEffect(() => {
|
||||
if (!enabled) return undefined;
|
||||
setNow(Date.now());
|
||||
const timer = setInterval(() => setNow(Date.now()), 1000);
|
||||
return () => clearInterval(timer);
|
||||
}, [enabled]);
|
||||
return now;
|
||||
};
|
||||
|
||||
/**
|
||||
* 空作品流 = 灵感模板墙(WP B-7,方案 §4.4):按分组展示静态模板,点击填入提示词 +
|
||||
* 推荐模型 / 参数并聚焦创作台。
|
||||
*/
|
||||
const TemplateWall = ({ kind, onApply, onStart }) => {
|
||||
const { t } = useTranslation();
|
||||
const groups = useMemo(() => templateGroupsOf(kind), [kind]);
|
||||
const Icon = kind === 'video' ? Clapperboard : ImageIcon;
|
||||
return (
|
||||
<div className='wf-wall'>
|
||||
<div className='wf-wall-head'>
|
||||
<p className='wf-wall-eyebrow'>{t('灵感模板')}</p>
|
||||
<h2 className='wf-wall-title'>
|
||||
{kind === 'video'
|
||||
? t('从一个模板开始你的第一个视频')
|
||||
: t('从一个模板开始你的第一张作品')}
|
||||
</h2>
|
||||
<p className='wf-wall-desc'>
|
||||
{t('点击模板会填好提示词与推荐参数,可在下方创作台继续修改')}
|
||||
</p>
|
||||
</div>
|
||||
{groups.map((group) => (
|
||||
<section
|
||||
key={group.group || 'default'}
|
||||
className='wf-wall-group'
|
||||
aria-label={group.group ? t(group.group) : t('灵感模板')}
|
||||
>
|
||||
{group.group ? (
|
||||
<h3 className='wf-group-title'>
|
||||
{t(group.group)}
|
||||
<span className='wf-group-count'>{group.items.length}</span>
|
||||
</h3>
|
||||
) : null}
|
||||
<div className='wf-wall-grid'>
|
||||
{group.items.map((tpl) => {
|
||||
const summary = templateParamsSummary(tpl);
|
||||
return (
|
||||
<button
|
||||
key={tpl.id}
|
||||
type='button'
|
||||
className='wf-tpl'
|
||||
onClick={() => onApply(tpl)}
|
||||
aria-label={t('使用模板:{{title}}', { title: t(tpl.title) })}
|
||||
>
|
||||
<span className='wf-tpl-head'>
|
||||
<span className='wf-tpl-icon' aria-hidden='true'>
|
||||
<Icon size={16} />
|
||||
</span>
|
||||
<span className='wf-tpl-title'>{t(tpl.title)}</span>
|
||||
{summary ? (
|
||||
<span className='wf-tpl-meta'>{summary}</span>
|
||||
) : null}
|
||||
</span>
|
||||
<span className='wf-tpl-prompt'>{tpl.prompt}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
<div className='wf-wall-foot'>
|
||||
<Button onClick={onStart}>{t('自己写提示词')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 作品流(WP B-6,方案 §4.1 / §4.4 / §4.5):按日期分组、进行中置顶;图像 / 视频卡片;详情抽屉;
|
||||
* 多选对比(图像);无限滚动;加载 / 空 / 错误态;状态变化 aria-live 播报。
|
||||
*
|
||||
* props:
|
||||
* kind, api = useCreationTasks(kind), form = useCreationForm(kind),
|
||||
* selecting / onSelectingChange(图像多选对比,开关在 FilterBar)
|
||||
* onUseAsVideoFirstFrame?(task, ref, previewUrl):图像"用作视频首帧"跨页入口(WP C-3,未传时不显示)
|
||||
* onContinueVideo?(task):覆盖视频"续写下一段"的默认实现(默认在本页回填尾帧为首帧)
|
||||
*/
|
||||
const WorkFeed = ({
|
||||
kind,
|
||||
api,
|
||||
form,
|
||||
selecting = false,
|
||||
onSelectingChange,
|
||||
onUseAsVideoFirstFrame,
|
||||
onContinueVideo,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
tasks,
|
||||
filters,
|
||||
loading,
|
||||
loadingMore,
|
||||
error,
|
||||
hasMore,
|
||||
loadMore,
|
||||
reload,
|
||||
resetFilters,
|
||||
announcement,
|
||||
} = api;
|
||||
|
||||
const visibleTasks = useMemo(
|
||||
() => filterTasks(tasks, filters),
|
||||
[tasks, filters],
|
||||
);
|
||||
const hasActive = useMemo(() => tasks.some(isActiveTask), [tasks]);
|
||||
const now = useNow(hasActive);
|
||||
const groups = useMemo(
|
||||
() => groupTasksByDate(visibleTasks, Date.now()),
|
||||
[visibleTasks],
|
||||
);
|
||||
|
||||
// 预计耗时 p50 / p90(来自 schema est_seconds;超过 p90 显示慢任务提示)
|
||||
const estByModel = useMemo(() => {
|
||||
const map = new Map();
|
||||
(form.models || []).forEach((m) => {
|
||||
const p50 = Number(m?.est_seconds?.p50) || 0;
|
||||
if (m?.model && p50 > 0) map.set(m.model, p50);
|
||||
});
|
||||
return map;
|
||||
}, [form.models]);
|
||||
const p90ByModel = useMemo(() => {
|
||||
const map = new Map();
|
||||
(form.models || []).forEach((m) => {
|
||||
const p90 = Number(m?.est_seconds?.p90) || 0;
|
||||
if (m?.model && p90 > 0) map.set(m.model, p90);
|
||||
});
|
||||
return map;
|
||||
}, [form.models]);
|
||||
// 模型 schema 中的种子参数("换种子再来"只对支持指定种子的模型显示)
|
||||
const seedParamOf = useCallback(
|
||||
(modelName) => {
|
||||
const model = (form.models || []).find((m) => m?.model === modelName);
|
||||
if (!model) return null;
|
||||
return (
|
||||
adapterOf(kind)
|
||||
.requestParamsOf(model)
|
||||
.find((p) => p.key === 'seed') || null
|
||||
);
|
||||
},
|
||||
[form.models, kind],
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 详情抽屉
|
||||
// ---------------------------------------------------------------------------
|
||||
const [detailId, setDetailId] = useState('');
|
||||
const detailTask = useMemo(
|
||||
() => tasks.find((task) => task.id === detailId) || null,
|
||||
[tasks, detailId],
|
||||
);
|
||||
const openDetail = useCallback((task) => setDetailId(task.id), []);
|
||||
const closeDetail = useCallback(() => setDetailId(''), []);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 二次创作:复用参数 / 再生成 / 用作参考图 / 编辑此图 / 下载 / 删除
|
||||
// ---------------------------------------------------------------------------
|
||||
const resolveFilled = useCallback(
|
||||
async (task) => {
|
||||
let full = task;
|
||||
if (!full.request) full = (await api.fetchDetail(task)) || task;
|
||||
if (kind === 'video') {
|
||||
if (!full.request) {
|
||||
showError(t('该任务不支持复用参数'));
|
||||
return null;
|
||||
}
|
||||
const filled = formFromTaskRequest(full.request, { newId: newSlotId });
|
||||
return {
|
||||
filled: { ...filled, modelName: filled.modelName || full.model },
|
||||
missing: 0,
|
||||
supported: full.regenerateSupported === true,
|
||||
};
|
||||
}
|
||||
const filled = full.request
|
||||
? formFromImageRequest(full.request, { newId: newSlotId })
|
||||
: formFromLegacyTask(legacyShapeOf(full), { newId: newSlotId });
|
||||
return {
|
||||
filled: {
|
||||
modelName: filled.modelName || full.model || '',
|
||||
mode: filled.mode,
|
||||
prompt: filled.prompt,
|
||||
params: filled.params,
|
||||
images: {
|
||||
first_frame: null,
|
||||
last_frame: null,
|
||||
reference_images: filled.references,
|
||||
},
|
||||
},
|
||||
missing: filled.missingReferences,
|
||||
supported: Boolean(full.request) && full.regenerateSupported !== false,
|
||||
};
|
||||
},
|
||||
[api, kind, t],
|
||||
);
|
||||
|
||||
const reuse = useCallback(
|
||||
async (task) => {
|
||||
const r = await resolveFilled(task);
|
||||
if (!r) return;
|
||||
if (r.missing > 0) showInfo(t('部分参考图已失效,请重新上传'));
|
||||
if (form.prefill(r.filled)) {
|
||||
trackCreationEvent('reuse_params', {
|
||||
kind,
|
||||
model: r.filled.modelName || '',
|
||||
regenerate: false,
|
||||
});
|
||||
closeDetail();
|
||||
}
|
||||
},
|
||||
[resolveFilled, form, closeDetail, kind, t],
|
||||
);
|
||||
|
||||
// 再生成 = 回填 + 参数仍有效时立即提交;参考图失效 / 快照不完整时只回填并提示
|
||||
const regenerate = useCallback(
|
||||
async (task) => {
|
||||
const r = await resolveFilled(task);
|
||||
if (!r) return;
|
||||
const autoSubmit = r.supported && r.missing === 0;
|
||||
if (!autoSubmit) {
|
||||
showInfo(t('原参数部分已失效,已回填,请确认后生成'));
|
||||
}
|
||||
if (form.prefill(r.filled, { autoSubmit })) {
|
||||
trackCreationEvent('reuse_params', {
|
||||
kind,
|
||||
model: r.filled.modelName || '',
|
||||
regenerate: true,
|
||||
});
|
||||
closeDetail();
|
||||
}
|
||||
},
|
||||
[resolveFilled, form, closeDetail, kind, t],
|
||||
);
|
||||
|
||||
// 换种子再来(WP C-3):同一请求换一个随机种子;参数原样有效时立即提交,否则只回填
|
||||
const variation = useCallback(
|
||||
async (task) => {
|
||||
const r = await resolveFilled(task);
|
||||
if (!r) return;
|
||||
const filled = {
|
||||
...r.filled,
|
||||
params: variationParams(
|
||||
r.filled.params,
|
||||
seedParamOf(r.filled.modelName || task.model),
|
||||
),
|
||||
};
|
||||
const autoSubmit = r.supported && r.missing === 0;
|
||||
if (!autoSubmit) {
|
||||
showInfo(t('原参数部分已失效,已回填,请确认后生成'));
|
||||
}
|
||||
if (form.prefill(filled, { autoSubmit })) {
|
||||
trackCreationEvent('reuse_params', {
|
||||
kind,
|
||||
model: filled.modelName || '',
|
||||
regenerate: true,
|
||||
variation: true,
|
||||
});
|
||||
closeDetail();
|
||||
}
|
||||
},
|
||||
[resolveFilled, seedParamOf, form, closeDetail, kind, t],
|
||||
);
|
||||
|
||||
// 续写下一段(WP C-3):尾帧作为首帧(task://id#last_frame,后端优先已转存的尾帧),
|
||||
// 图生视频、同模型同参数,提示词沿用原文供修改
|
||||
const continueVideo = useCallback(
|
||||
async (task) => {
|
||||
let full = task;
|
||||
if (!full.request) full = (await api.fetchDetail(task)) || task;
|
||||
const base = full.request
|
||||
? formFromTaskRequest(full.request, { newId: newSlotId })
|
||||
: { modelName: '', prompt: '', params: {} };
|
||||
const filled = {
|
||||
modelName: base.modelName || full.model,
|
||||
mode: 'image2video',
|
||||
prompt: base.prompt || full.prompt || '',
|
||||
params: base.params || {},
|
||||
images: {
|
||||
first_frame: {
|
||||
id: newSlotId(),
|
||||
status: 'ready',
|
||||
ref: taskLastFrameRef(full.id),
|
||||
previewUrl: full.lastFrameUrl || null,
|
||||
source: 'task',
|
||||
identityType: 'aigc',
|
||||
},
|
||||
last_frame: null,
|
||||
reference_images: [],
|
||||
},
|
||||
};
|
||||
if (
|
||||
form.prefill(filled, {
|
||||
notice: t('已将尾帧放入首帧,描述下一段内容后生成'),
|
||||
})
|
||||
) {
|
||||
closeDetail();
|
||||
}
|
||||
},
|
||||
[api, form, closeDetail, t],
|
||||
);
|
||||
const handleContinueVideo = onContinueVideo || continueVideo;
|
||||
|
||||
const addReference = useCallback(
|
||||
async (task, index) => {
|
||||
const image = task.images?.[index];
|
||||
if (!image?.url) {
|
||||
showError(t('该图片暂不可用作参考图'));
|
||||
return false;
|
||||
}
|
||||
if (image.reusable) {
|
||||
form.setImageRef('reference_images', undefined, {
|
||||
ref: taskImageRef(task.id, index),
|
||||
previewUrl: image.url,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const file = await urlToFile(
|
||||
image.url,
|
||||
`reference-${task.id}-${index}`,
|
||||
);
|
||||
return await form.pickImage('reference_images', undefined, file);
|
||||
} catch (e) {
|
||||
showError(t('参考图加载失败'));
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[form, t],
|
||||
);
|
||||
|
||||
const applyAsReference = useCallback(
|
||||
async (task, index = 0) => {
|
||||
if (!(await addReference(task, index))) return;
|
||||
form.setMode('edit');
|
||||
showInfo(t('已加入参考图'));
|
||||
closeDetail();
|
||||
form.requestFocus();
|
||||
},
|
||||
[addReference, form, closeDetail, t],
|
||||
);
|
||||
|
||||
// 编辑此图:替换参考图槽为这张图,切到编辑模式,光标进入提示词
|
||||
const editImage = useCallback(
|
||||
async (task, index = 0) => {
|
||||
const images = form.form.images || {};
|
||||
form.setImages({ ...images, reference_images: [] });
|
||||
if (!(await addReference(task, index))) {
|
||||
form.setImages(images);
|
||||
return;
|
||||
}
|
||||
form.setMode('edit');
|
||||
closeDetail();
|
||||
form.requestFocus();
|
||||
},
|
||||
[addReference, form, closeDetail],
|
||||
);
|
||||
|
||||
const download = useCallback(
|
||||
async (task, index = 0) => {
|
||||
if (task.kind === 'video') {
|
||||
const url = task.videoUrl || (await api.refreshVideoUrl(task));
|
||||
if (!url) {
|
||||
showError(t('未找到视频URL'));
|
||||
return;
|
||||
}
|
||||
triggerDownload(url, `video_${task.id}.mp4`);
|
||||
showSuccess(t('开始下载'));
|
||||
return;
|
||||
}
|
||||
const url = task.images?.[index]?.url;
|
||||
if (!url) {
|
||||
showError(t('图片不存在'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const resp = await fetch(url);
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
|
||||
const blob = await resp.blob();
|
||||
const ext = (blob.type.split('/')[1] || 'png').replace('jpeg', 'jpg');
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
triggerDownload(objectUrl, `image_${task.id}_${index + 1}.${ext}`);
|
||||
setTimeout(() => URL.revokeObjectURL(objectUrl), 1000);
|
||||
showSuccess(t('开始下载'));
|
||||
} catch (e) {
|
||||
// 跨域等原因无法读取时,在新窗口打开由用户另存
|
||||
window.open(url, '_blank', 'noopener');
|
||||
}
|
||||
},
|
||||
[api, t],
|
||||
);
|
||||
|
||||
const confirmDelete = useCallback(
|
||||
(task) => {
|
||||
Modal.confirm({
|
||||
title: t('删除作品'),
|
||||
content: t('删除后不可恢复,确定删除这个作品吗?'),
|
||||
okButtonProps: { type: 'danger' },
|
||||
okText: t('删除'),
|
||||
cancelText: t('取消'),
|
||||
onOk: async () => {
|
||||
if (await api.deleteTask(task)) {
|
||||
if (detailId === task.id) closeDetail();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
[api, detailId, closeDetail, t],
|
||||
);
|
||||
|
||||
const getActions = useCallback(
|
||||
(task, index = 0) => {
|
||||
const list = [];
|
||||
const done = task.status === 'success';
|
||||
const active = isActiveTask(task);
|
||||
if (!active) {
|
||||
list.push({
|
||||
key: 'reuse',
|
||||
label: t('复用参数'),
|
||||
icon: <SlidersHorizontal size={14} aria-hidden='true' />,
|
||||
onClick: () => reuse(task),
|
||||
});
|
||||
list.push({
|
||||
key: 'regenerate',
|
||||
label: t('再生成'),
|
||||
icon: <RotateCcw size={14} aria-hidden='true' />,
|
||||
onClick: () => regenerate(task),
|
||||
});
|
||||
}
|
||||
if (done && seedParamOf(task.model)) {
|
||||
list.push({
|
||||
key: 'variation',
|
||||
label: t('换种子再来'),
|
||||
icon: <Dices size={14} aria-hidden='true' />,
|
||||
onClick: () => variation(task),
|
||||
});
|
||||
}
|
||||
if (kind === 'image' && done && task.images?.[index]?.url) {
|
||||
list.push({
|
||||
key: 'reference',
|
||||
label: t('用作参考图'),
|
||||
icon: <ImagePlus size={14} aria-hidden='true' />,
|
||||
onClick: () => applyAsReference(task, index),
|
||||
});
|
||||
list.push({
|
||||
key: 'edit',
|
||||
label: t('编辑此图'),
|
||||
icon: <PenLine size={14} aria-hidden='true' />,
|
||||
onClick: () => editImage(task, index),
|
||||
});
|
||||
// 只有服务端判定可复用(reusable_as_input)的结果才能以 task:// 带到视频页
|
||||
if (onUseAsVideoFirstFrame && task.images[index].reusable) {
|
||||
list.push({
|
||||
key: 'video-first-frame',
|
||||
label: t('用作视频首帧'),
|
||||
icon: <Film size={14} aria-hidden='true' />,
|
||||
onClick: () =>
|
||||
onUseAsVideoFirstFrame(
|
||||
task,
|
||||
taskImageRef(task.id, index),
|
||||
task.images[index].url,
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (
|
||||
kind === 'video' &&
|
||||
done &&
|
||||
task.reusableAsInput !== false &&
|
||||
(task.reusableAsInput === true || task.lastFrameUrl)
|
||||
) {
|
||||
list.push({
|
||||
key: 'continue',
|
||||
label: t('续写下一段'),
|
||||
icon: <Clapperboard size={14} aria-hidden='true' />,
|
||||
onClick: () => handleContinueVideo(task),
|
||||
});
|
||||
}
|
||||
if (done) {
|
||||
list.push({
|
||||
key: 'download',
|
||||
label: t('下载'),
|
||||
icon: <Download size={14} aria-hidden='true' />,
|
||||
onClick: () => download(task, index),
|
||||
});
|
||||
}
|
||||
if (!active) {
|
||||
list.push({
|
||||
key: 'delete',
|
||||
label: t('删除'),
|
||||
icon: <Trash2 size={14} aria-hidden='true' />,
|
||||
danger: true,
|
||||
onClick: () => confirmDelete(task),
|
||||
});
|
||||
}
|
||||
return list;
|
||||
},
|
||||
[
|
||||
kind,
|
||||
reuse,
|
||||
regenerate,
|
||||
applyAsReference,
|
||||
editImage,
|
||||
download,
|
||||
confirmDelete,
|
||||
onUseAsVideoFirstFrame,
|
||||
handleContinueVideo,
|
||||
variation,
|
||||
seedParamOf,
|
||||
t,
|
||||
],
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 多选对比(图像)
|
||||
// ---------------------------------------------------------------------------
|
||||
const [selectedIds, setSelectedIds] = useState([]);
|
||||
const [compareOpen, setCompareOpen] = useState(false);
|
||||
useEffect(() => {
|
||||
if (!selecting) setSelectedIds([]);
|
||||
}, [selecting]);
|
||||
const isSelectable = useCallback(
|
||||
(task) =>
|
||||
kind === 'image' &&
|
||||
task.status === 'success' &&
|
||||
Boolean(task.images?.[0]?.url),
|
||||
[kind],
|
||||
);
|
||||
const toggleSelect = useCallback(
|
||||
(task) => {
|
||||
setSelectedIds((prev) => {
|
||||
if (prev.includes(task.id)) return prev.filter((id) => id !== task.id);
|
||||
if (prev.length >= COMPARE_MAX) {
|
||||
showInfo(t('最多选择 {{n}} 张', { n: COMPARE_MAX }));
|
||||
return prev;
|
||||
}
|
||||
return [...prev, task.id];
|
||||
});
|
||||
},
|
||||
[t],
|
||||
);
|
||||
const compareTasks = useMemo(
|
||||
() =>
|
||||
selectedIds
|
||||
.map((id) => tasks.find((task) => task.id === id))
|
||||
.filter(Boolean)
|
||||
.map(compareItemOf),
|
||||
[selectedIds, tasks],
|
||||
);
|
||||
// 对比生成批次的"对比视图"(WP C-2)
|
||||
const [batchCompare, setBatchCompare] = useState(null);
|
||||
const openBatchCompare = useCallback(
|
||||
(batchTasks) => {
|
||||
const items = comparableBatchTasks(batchTasks).map(compareItemOf);
|
||||
if (items.length < 2) {
|
||||
showInfo(t('至少需要 2 张已完成的图片才能对比'));
|
||||
return;
|
||||
}
|
||||
setBatchCompare(items);
|
||||
},
|
||||
[t],
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 无限滚动:哨兵在滚动容器(.cs-feed)内可见时持续加载下一页
|
||||
// ---------------------------------------------------------------------------
|
||||
const [sentinelVisible, setSentinelVisible] = useState(false);
|
||||
const observerRef = useRef(null);
|
||||
const sentinelRef = useCallback((el) => {
|
||||
observerRef.current?.disconnect();
|
||||
observerRef.current = null;
|
||||
if (!el || typeof IntersectionObserver === 'undefined') {
|
||||
setSentinelVisible(false);
|
||||
return;
|
||||
}
|
||||
const io = new IntersectionObserver(
|
||||
([entry]) => setSentinelVisible(entry.isIntersecting),
|
||||
{ root: el.closest('.cs-feed'), rootMargin: '400px 0px' },
|
||||
);
|
||||
io.observe(el);
|
||||
observerRef.current = io;
|
||||
}, []);
|
||||
useEffect(() => () => observerRef.current?.disconnect(), []);
|
||||
|
||||
// 本地过滤(关键词 / 模型 / 尺寸 / 进行中)时不把全部历史自动翻完:连续 3 页没有新命中就停,
|
||||
// 改为"加载更多"按钮(WP B-7)。服务端过滤(成功 / 失败 / 收藏)不受影响。
|
||||
const clientFiltered = hasClientFilter(filters);
|
||||
const clientKey = `${filters.status}|${filters.model}|${filters.size}|${filters.keyword}`;
|
||||
const [emptyStreak, setEmptyStreak] = useState(0);
|
||||
const matchesBeforeRef = useRef(null);
|
||||
useEffect(() => {
|
||||
setEmptyStreak(0);
|
||||
matchesBeforeRef.current = null;
|
||||
}, [clientKey]);
|
||||
const loadNextPage = useCallback(() => {
|
||||
matchesBeforeRef.current = visibleTasks.length;
|
||||
loadMore();
|
||||
}, [visibleTasks.length, loadMore]);
|
||||
useEffect(() => {
|
||||
if (loadingMore || matchesBeforeRef.current === null) return;
|
||||
const before = matchesBeforeRef.current;
|
||||
matchesBeforeRef.current = null;
|
||||
if (!clientFiltered) return;
|
||||
setEmptyStreak((n) => nextEmptyStreak(n, before, visibleTasks.length));
|
||||
// 只在一页加载结束时结算
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [loadingMore]);
|
||||
const autoLoad = shouldAutoLoad(filters, emptyStreak);
|
||||
const loadMoreManually = useCallback(() => {
|
||||
setEmptyStreak(0);
|
||||
loadNextPage();
|
||||
}, [loadNextPage]);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
autoLoad &&
|
||||
sentinelVisible &&
|
||||
hasMore &&
|
||||
!loading &&
|
||||
!loadingMore &&
|
||||
!error
|
||||
) {
|
||||
loadNextPage();
|
||||
}
|
||||
}, [
|
||||
autoLoad,
|
||||
sentinelVisible,
|
||||
hasMore,
|
||||
loading,
|
||||
loadingMore,
|
||||
error,
|
||||
loadNextPage,
|
||||
]);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 渲染
|
||||
// ---------------------------------------------------------------------------
|
||||
const filtered = activeFilterCount(filters) > 0;
|
||||
const renderCard = (task) => {
|
||||
const active = isActiveTask(task);
|
||||
return (
|
||||
<WorkCard
|
||||
key={task.id}
|
||||
task={task}
|
||||
estSeconds={estByModel.get(task.model) || 0}
|
||||
p90={p90ByModel.get(task.model) || 0}
|
||||
now={active ? now : 0}
|
||||
getActions={getActions}
|
||||
onOpen={openDetail}
|
||||
onFavorite={api.toggleFavorite}
|
||||
onCancel={api.cancelTask}
|
||||
onRefreshImage={api.refreshImageUrl}
|
||||
onRefreshVideo={api.refreshVideoUrl}
|
||||
selecting={selecting}
|
||||
selectable={selecting && isSelectable(task)}
|
||||
selected={selectedIds.includes(task.id)}
|
||||
onToggleSelect={toggleSelect}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const liveRegion = (
|
||||
<div className='wf-sr-only' role='status' aria-live='polite'>
|
||||
{announcement}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (loading && tasks.length === 0) {
|
||||
return (
|
||||
<div className='wf' aria-busy='true'>
|
||||
{liveRegion}
|
||||
<div className='wf-grid'>
|
||||
{Array.from({ length: 8 }, (_, i) => (
|
||||
<div key={i} className='wf-skeleton' />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error && tasks.length === 0) {
|
||||
return (
|
||||
<div className='wf'>
|
||||
{liveRegion}
|
||||
<div className='wf-state' role='alert'>
|
||||
<p className='wf-state-title'>{t('作品加载失败')}</p>
|
||||
<span>{t('请检查网络后重试')}</span>
|
||||
<Button onClick={reload}>{t('重试')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (tasks.length === 0 && !filtered) {
|
||||
return (
|
||||
<div className='wf'>
|
||||
{liveRegion}
|
||||
<TemplateWall
|
||||
kind={kind}
|
||||
onApply={(tpl) => {
|
||||
if (form.applyTemplate(tpl)) {
|
||||
showSuccess(t('已套用模板:{{title}}', { title: t(tpl.title) }));
|
||||
}
|
||||
}}
|
||||
onStart={form.requestFocus}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='wf'>
|
||||
{liveRegion}
|
||||
|
||||
{selecting ? (
|
||||
<div className='wf-selectbar' role='region' aria-label={t('多选对比')}>
|
||||
<span className='wf-selectbar-text'>
|
||||
{t('已选 {{n}} / {{max}} 张,选择 2~4 张已完成的图片进行对比', {
|
||||
n: selectedIds.length,
|
||||
max: COMPARE_MAX,
|
||||
})}
|
||||
</span>
|
||||
<Button
|
||||
theme='solid'
|
||||
disabled={selectedIds.length < 2}
|
||||
onClick={() => setCompareOpen(true)}
|
||||
>
|
||||
{t('对比')}
|
||||
</Button>
|
||||
<Button type='tertiary' onClick={() => onSelectingChange?.(false)}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{visibleTasks.length === 0 ? (
|
||||
<div className='wf-state'>
|
||||
<p className='wf-state-title'>{t('没有符合条件的作品')}</p>
|
||||
{hasMore && autoLoad ? (
|
||||
<span>{t('正在继续查找更早的作品…')}</span>
|
||||
) : null}
|
||||
{hasMore && !autoLoad ? (
|
||||
<span>{t('已加载的作品中没有匹配项,可继续加载更早的作品')}</span>
|
||||
) : null}
|
||||
<div className='wf-state-actions'>
|
||||
{hasMore && !autoLoad ? (
|
||||
<Button loading={loadingMore} onClick={loadMoreManually}>
|
||||
{t('加载更多')}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button onClick={resetFilters}>{t('清除筛选')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
groups.map((group) => (
|
||||
<section key={group.key} aria-label={t(GROUP_LABEL_KEYS[group.key])}>
|
||||
<h2 className='wf-group-title'>
|
||||
{t(GROUP_LABEL_KEYS[group.key])}
|
||||
<span className='wf-group-count'>{group.tasks.length}</span>
|
||||
</h2>
|
||||
<div className='wf-grid'>
|
||||
{groupBatchRows(group.tasks).map((row) =>
|
||||
row.type === 'batch' ? (
|
||||
<div
|
||||
key={row.key}
|
||||
className='wf-batch'
|
||||
role='group'
|
||||
aria-label={t('对比生成 · {{n}} 个模型', {
|
||||
n: row.tasks.length,
|
||||
})}
|
||||
>
|
||||
<div className='wf-batch-head'>
|
||||
<Columns2 size={14} aria-hidden='true' />
|
||||
<span className='wf-batch-title'>
|
||||
{t('对比生成 · {{n}} 个模型', {
|
||||
n: row.tasks.length,
|
||||
})}
|
||||
</span>
|
||||
{kind === 'image' && !selecting ? (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
disabled={comparableBatchTasks(row.tasks).length < 2}
|
||||
onClick={() => openBatchCompare(row.tasks)}
|
||||
>
|
||||
{t('对比视图')}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<div className='wf-grid'>
|
||||
{row.tasks.map((task) => renderCard(task))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
renderCard(row.task)
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
))
|
||||
)}
|
||||
|
||||
<div ref={sentinelRef} className='wf-more'>
|
||||
{loadingMore ? <Spin size='small' /> : null}
|
||||
{!loadingMore && error ? (
|
||||
<Button size='small' type='tertiary' onClick={loadNextPage}>
|
||||
{t('加载失败,点击重试')}
|
||||
</Button>
|
||||
) : null}
|
||||
{!loadingMore &&
|
||||
!error &&
|
||||
hasMore &&
|
||||
!autoLoad &&
|
||||
visibleTasks.length > 0 ? (
|
||||
<Button size='small' type='tertiary' onClick={loadMoreManually}>
|
||||
{t('加载更多')}
|
||||
</Button>
|
||||
) : null}
|
||||
{!loadingMore && !error && !hasMore && tasks.length > PAGE_SIZE ? (
|
||||
<span>{t('没有更多了')}</span>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<WorkDetailDrawer
|
||||
task={detailTask}
|
||||
visible={Boolean(detailTask)}
|
||||
onClose={closeDetail}
|
||||
estSeconds={detailTask ? estByModel.get(detailTask.model) || 0 : 0}
|
||||
p90={detailTask ? p90ByModel.get(detailTask.model) || 0 : 0}
|
||||
now={now}
|
||||
getActions={getActions}
|
||||
onFavorite={api.toggleFavorite}
|
||||
onCancel={api.cancelTask}
|
||||
fetchDetail={api.fetchDetail}
|
||||
onRefreshImage={api.refreshImageUrl}
|
||||
onRefreshVideo={api.refreshVideoUrl}
|
||||
/>
|
||||
|
||||
{kind === 'image' ? (
|
||||
<ImageCompareModal
|
||||
visible={compareOpen || Boolean(batchCompare)}
|
||||
tasks={batchCompare || compareTasks}
|
||||
onClose={() => {
|
||||
setCompareOpen(false);
|
||||
setBatchCompare(null);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WorkFeed;
|
||||
@@ -0,0 +1,962 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/*
|
||||
* 作品流(WP B-6,方案 §4.1 / §4.4 / §4.5)。
|
||||
* 配色全部从 --studio-*(creation.css)与语义 token 派生;不画整页背景。
|
||||
*/
|
||||
.wf {
|
||||
--wf-radius: 12px;
|
||||
--wf-media-bg: color-mix(in srgb, var(--text-primary) 5%, transparent);
|
||||
--wf-overlay: color-mix(in srgb, var(--surface-card) 82%, transparent);
|
||||
--wf-scrim: color-mix(in srgb, var(--text-primary) 55%, transparent);
|
||||
--wf-on-scrim: var(--surface-card);
|
||||
--wf-success: var(--semi-color-success);
|
||||
--wf-warning: var(--semi-color-warning);
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.wf-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* ---------- 分组 ---------- */
|
||||
.wf-group-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 8px;
|
||||
color: var(--studio-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.wf-group-count {
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 500;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.wf-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
align-items: start;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* ---------- 卡片 ---------- */
|
||||
.wf-card {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--studio-line);
|
||||
border-radius: var(--wf-radius);
|
||||
background: var(--studio-card);
|
||||
transition:
|
||||
transform var(--studio-dur),
|
||||
box-shadow var(--studio-dur),
|
||||
border-color var(--studio-dur);
|
||||
}
|
||||
|
||||
.wf-card:hover {
|
||||
border-color: color-mix(in srgb, var(--semi-color-primary) 30%, transparent);
|
||||
box-shadow: 0 6px 20px color-mix(in srgb, var(--text-primary) 8%, transparent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.wf-card.is-selected {
|
||||
border-color: var(--studio-accent);
|
||||
box-shadow: 0 0 0 2px var(--studio-tint);
|
||||
}
|
||||
|
||||
.wf-media {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: var(--wf-media-bg);
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wf-media img,
|
||||
.wf-media video {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.wf-media:focus-visible {
|
||||
outline: 2px solid var(--studio-ring);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.wf-grid4 {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-rows: 1fr 1fr;
|
||||
gap: 2px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.wf-grid4 > * {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wf-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 12px;
|
||||
color: var(--studio-muted);
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wf-badge {
|
||||
position: absolute;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--wf-scrim);
|
||||
color: var(--wf-on-scrim);
|
||||
font-size: 11px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.wf-badge--br {
|
||||
right: 8px;
|
||||
bottom: 8px;
|
||||
}
|
||||
|
||||
.wf-badge--bl {
|
||||
left: 8px;
|
||||
bottom: 8px;
|
||||
}
|
||||
|
||||
/* 悬停操作:收藏 + 更多(触屏常显) */
|
||||
.wf-tools {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
opacity: 0;
|
||||
transition: opacity var(--studio-dur);
|
||||
}
|
||||
|
||||
.wf-card:hover .wf-tools,
|
||||
.wf-card:focus-within .wf-tools,
|
||||
.wf-tools.is-pinned {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
.wf-tools {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.wf-icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--studio-line);
|
||||
border-radius: 8px;
|
||||
background: var(--wf-overlay);
|
||||
color: var(--studio-ink);
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.wf-icon-btn:hover {
|
||||
border-color: color-mix(in srgb, var(--semi-color-primary) 45%, transparent);
|
||||
color: var(--studio-accent);
|
||||
}
|
||||
|
||||
.wf-icon-btn.is-on {
|
||||
color: var(--wf-warning);
|
||||
}
|
||||
|
||||
.wf-check {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border: 2px solid var(--wf-on-scrim);
|
||||
border-radius: 6px;
|
||||
background: var(--wf-scrim);
|
||||
color: var(--wf-on-scrim);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.wf-card.is-selected .wf-check {
|
||||
border-color: var(--studio-accent);
|
||||
background: var(--studio-accent);
|
||||
}
|
||||
|
||||
.wf-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 8px 10px 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wf-prompt {
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
color: var(--studio-ink);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wf-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
color: var(--studio-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.wf-meta > span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wf-num {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ---------- 进行中 ---------- */
|
||||
.wf-active {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
background: linear-gradient(
|
||||
110deg,
|
||||
var(--wf-media-bg) 30%,
|
||||
color-mix(in srgb, var(--semi-color-primary) 10%, transparent) 50%,
|
||||
var(--wf-media-bg) 70%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
animation: wf-shimmer 1.8s linear infinite;
|
||||
color: var(--studio-muted);
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wf-active-label {
|
||||
color: var(--studio-ink);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-progress {
|
||||
width: 70%;
|
||||
height: 4px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--semi-color-primary) 15%, transparent);
|
||||
}
|
||||
|
||||
.wf-progress > span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--studio-accent);
|
||||
transition: width 0.2s;
|
||||
}
|
||||
|
||||
@keyframes wf-shimmer {
|
||||
to {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 失败 ---------- */
|
||||
.wf-failed {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 12px;
|
||||
color: var(--studio-muted);
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wf-failed-title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: var(--studio-danger);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-failed-reason {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 3;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.wf-refund {
|
||||
color: var(--wf-success);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ---------- 状态区 ---------- */
|
||||
.wf-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
min-height: 240px;
|
||||
padding: 24px 16px;
|
||||
color: var(--studio-muted);
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wf-state-title {
|
||||
margin: 0;
|
||||
color: var(--studio-ink);
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-skeleton {
|
||||
border-radius: var(--wf-radius);
|
||||
background: linear-gradient(
|
||||
110deg,
|
||||
var(--wf-media-bg) 30%,
|
||||
color-mix(in srgb, var(--text-primary) 9%, transparent) 50%,
|
||||
var(--wf-media-bg) 70%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
animation: wf-shimmer 1.8s linear infinite;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
|
||||
.wf-more {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
min-height: 40px;
|
||||
padding: 8px 0 4px;
|
||||
color: var(--studio-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 多选对比操作条 */
|
||||
.wf-selectbar {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 25%, transparent);
|
||||
border-radius: var(--wf-radius);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 6%,
|
||||
var(--surface-card)
|
||||
);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.wf-selectbar-text {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* ---------- 筛选栏 ---------- */
|
||||
.wf-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wf-filters .semi-select {
|
||||
min-width: 112px;
|
||||
max-width: 180px;
|
||||
}
|
||||
|
||||
.wf-filters-search {
|
||||
width: 200px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.wf-filter-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 280px;
|
||||
max-width: 100%;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.wf-filter-panel .semi-select,
|
||||
.wf-filter-panel .semi-input-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wf-filter-panel-label {
|
||||
margin-bottom: 4px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.wf-filter-panel-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wf-filter-sheet .wf-filter-panel {
|
||||
width: 100%;
|
||||
padding: 0 0 calc(8px + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
|
||||
/* ---------- 详情抽屉 ---------- */
|
||||
.wf-detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
color: var(--studio-ink, var(--text-primary));
|
||||
}
|
||||
|
||||
.wf-detail-media {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
border-radius: var(--wf-radius);
|
||||
background: color-mix(in srgb, var(--text-primary) 5%, transparent);
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.wf-detail-media img,
|
||||
.wf-detail-media video {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 62vh;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.wf-thumbs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.wf-thumb {
|
||||
flex-shrink: 0;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--text-primary) 5%, transparent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wf-thumb img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.wf-thumb.is-active {
|
||||
border-color: var(--semi-color-primary);
|
||||
}
|
||||
|
||||
.wf-detail-section-title {
|
||||
margin: 0 0 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.wf-detail-prompt {
|
||||
margin: 0;
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.wf-params {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
gap: 8px 16px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wf-params dt {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.wf-params dd {
|
||||
margin: 2px 0 0;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wf-detail-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wf-detail-alert {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--semi-color-danger) 30%, transparent);
|
||||
border-radius: 10px;
|
||||
background: color-mix(in srgb, var(--semi-color-danger) 6%, transparent);
|
||||
font-size: 13px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.wf button:focus-visible,
|
||||
.wf-detail button:focus-visible,
|
||||
.wf-filters button:focus-visible {
|
||||
outline: 2px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 55%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.wf-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wf-body {
|
||||
padding: 6px 8px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.wf-card,
|
||||
.wf-tools,
|
||||
.wf-progress > span {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.wf-card:hover {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.wf-active,
|
||||
.wf-skeleton {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 空状态:灵感模板墙(WP B-7) ---------- */
|
||||
.wf-wall {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
max-width: 1080px;
|
||||
margin: 0 auto;
|
||||
padding: 8px 0 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wf-wall-eyebrow {
|
||||
margin: 0 0 4px;
|
||||
color: var(--studio-accent, var(--semi-color-primary));
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.wf-wall-title {
|
||||
margin: 0;
|
||||
color: var(--studio-ink, var(--text-primary));
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.wf-wall-desc {
|
||||
margin: 4px 0 0;
|
||||
color: var(--studio-muted, var(--text-secondary));
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.wf-wall-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.wf-tpl {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--studio-line, var(--border-subtle));
|
||||
border-radius: var(--wf-radius);
|
||||
background: var(--studio-card, var(--surface-card));
|
||||
color: var(--studio-ink, var(--text-primary));
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color var(--studio-dur, 150ms),
|
||||
transform var(--studio-dur, 150ms),
|
||||
background-color var(--studio-dur, 150ms);
|
||||
}
|
||||
|
||||
.wf-tpl:hover {
|
||||
border-color: color-mix(in srgb, var(--semi-color-primary) 45%, transparent);
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--semi-color-primary) 4%,
|
||||
var(--surface-card)
|
||||
);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.wf-tpl-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wf-tpl-icon {
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--semi-color-primary) 10%, transparent);
|
||||
color: var(--semi-color-primary);
|
||||
}
|
||||
|
||||
.wf-tpl-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.wf-tpl-meta {
|
||||
flex-shrink: 0;
|
||||
color: var(--studio-muted, var(--text-secondary));
|
||||
font-size: 11px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.wf-tpl-prompt {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
color: var(--studio-muted, var(--text-secondary));
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.wf-tpl:focus-visible {
|
||||
outline: 2px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 55%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.wf-wall-foot {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wf-state-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wf-detail-alert {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.wf-detail-raw {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.wf-wall-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.wf-wall-title {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.wf-tpl {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.wf-tpl:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 获取 API 代码(WP C-1):详情抽屉在 portal 中,直接用语义 token ---------- */
|
||||
.wf-api {
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wf-api-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wf-api-toggle:hover {
|
||||
background: color-mix(in srgb, var(--semi-color-primary) 5%, transparent);
|
||||
}
|
||||
|
||||
.wf-api-toggle:focus-visible,
|
||||
.wf-api-tab:focus-visible,
|
||||
.wf-api-code:focus-visible {
|
||||
outline: 2px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 55%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.wf-api-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wf-api-badge {
|
||||
padding: 1px 8px;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--semi-color-success) 12%, transparent);
|
||||
color: var(--semi-color-success);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-api-caret {
|
||||
color: var(--text-secondary);
|
||||
transition: transform 150ms ease;
|
||||
}
|
||||
|
||||
.wf-api-caret.is-open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.wf-api-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 0 12px 12px;
|
||||
}
|
||||
|
||||
.wf-api-desc,
|
||||
.wf-api-hint {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.wf-api-bar,
|
||||
.wf-api-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wf-api-tabs {
|
||||
display: inline-flex;
|
||||
padding: 2px;
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--text-primary) 6%, transparent);
|
||||
}
|
||||
|
||||
.wf-api-tab {
|
||||
padding: 3px 10px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.wf-api-tab.is-active {
|
||||
background: var(--surface-card);
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-api-code {
|
||||
max-height: 320px;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 8px;
|
||||
background: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
|
||||
color: var(--text-primary);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.wf-api-notes {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* ---------- 对比生成成组(WP C-2) ---------- */
|
||||
.wf-batch {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--semi-color-primary) 25%, transparent);
|
||||
border-radius: 14px;
|
||||
background: color-mix(in srgb, var(--semi-color-primary) 4%, transparent);
|
||||
}
|
||||
|
||||
.wf-batch-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wf-batch-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* ---------- 慢任务提示(WP C-4) ---------- */
|
||||
.wf-slow {
|
||||
max-width: 92%;
|
||||
color: var(--wf-warning, var(--semi-color-warning));
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
text-align: center;
|
||||
}
|
||||
Reference in New Issue
Block a user