Compare commits

..

4 Commits

Author SHA1 Message Date
zhanjunhao 6080eda584 Merge branch 'ui-optimization' into weiyuan 2026-11-20 18:48:48 +08:00
zhanjunhao fca6543445 fix(website-settings): 统一官网设置品牌文案为微元算力 2026-11-20 18:48:07 +08:00
zhanjunhao 41ce8b5e58 fix(experience-center): 统一图像与视频生成界面并修复参数显示
对齐表单、预览与任务区,跟随系统主题色,修复图片尺寸选择和视频高级参数显示。已通过本地浏览器验收、Lint、UI 审计和单测;未做生产测试。
2026-11-20 18:30:13 +08:00
zhanjunhao b7b19d01f6 fix(analytics): 对齐质量维度布局与封号历史折叠
统一维度提示与表格间距,取消无数据时的局部滚动;风控封号历史复用运营看板折叠样式。开发环境浏览器回归、875 项单测、ESLint 和 Prettier 均通过。
2026-11-20 16:03:20 +08:00
32 changed files with 1943 additions and 1839 deletions
+40
View File
@@ -10,6 +10,46 @@
## 2026-11-20 ## 2026-11-20
### 优化 · 体验中心视频生成工作区
- **范围**:视频生成页的参数面板、视频预览和任务队列。
- **变更**:以图片生成工作区的描边卡片为基准,统一标题、控件和空态;参数面板与任务队列可通过键盘折叠,任务队列不再遮挡预览;表单滚动区保留高级参数的展开高度,避免队列展开或窗口较矮时压缩折叠项。
- **影响**:跟随系统主题配置;保持模型、视频生成、计价、任务和灰度开关契约。
- **回滚**:仅逆向恢复本条对应的页面结构和样式。
- **关联**:`src/pages/ExperienceCenter/components/AICreation/VideoGenerationTab.jsx`、`src/pages/ExperienceCenter/components/AICreation/Video/VideoWorkspace.css`。
### 修复 · 官网设置品牌名称对齐
- **范围**:控制台官网设置的关于页签、说明、首页共用提示及校验提示。
- **变更**:统一使用“微元算力”,同步九个语言包。
- **影响**:不改变配置结构、表单校验或保存逻辑;联调存量文案仅替换实查命中的文章标题和正文。
- **回滚**:逆向恢复本条的文案差异;如需回滚联调数据,先比对最新配置与保存前备份,只恢复本次变动的两处,避免覆盖后续编辑。
- **关联**:`src/pages/WebsiteSettings/model.js`、`src/i18n/locales/`、`/api/website/page-config`。
### 优化 · 图片生成创作表单
- **范围**:体验中心图片生成页左侧创作表单。
- **变更**:固定桌面端标题与生成区,归组模型和生成方式,整合提示词工具、模板、参考图与参数的视觉层次;移动端可收起表单并保留生成操作。
- **影响**:沿用系统主题色与现有生成、引用、计价流程;右侧历史不变。
- **回滚**:仅逆向恢复本条对应的表单结构和局部样式差异。
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageSizePicker.jsx`。
### 优化 · 体验中心图片生成工作区
- **范围**:图片生成页的双栏工作区、创作表单和生成历史。
- **变更**:以模型超市的描边卡片为参考,统一缩略图、状态占位和操作区;窄屏堆叠,选中和焦点状态跟随系统主题色。
- **影响**:保留任务、模型和计价流程;历史卡片在各显示密度下均可打开详情和操作菜单。
- **回滚**:逆向恢复本条的页面布局、表单及历史卡片差异。
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationTab.jsx`、`ImageGenerationForm.jsx`、`ImageTaskList.jsx`。
### 修复 · 风控看板自动封号历史
- 复用运营看板折叠面板外框,展开时由分隔线连接标题和内容;保留默认展开、筛选、刷新、分页与解封行为。
### 修复 · 控制台调用质量维度分布
- 对齐维度页签、数据来源提示和表格间距;表格随内容增高,空态不滚动,仅数据列超宽时支持横向滚动。保留排序、下钻与前 50 项查询规则。
### 性能 · 开发预热与公共首屏分包 ### 性能 · 开发预热与公共首屏分包
- **范围**:Vite 开发和生产配置、应用启动、首页和认证页的加载边界。 - **范围**:Vite 开发和生产配置、应用启动、首页和认证页的加载边界。
+35 -7
View File
@@ -1,6 +1,7 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'; import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Select, Table, TabPane, Tabs, Tooltip } from '@/components/ui'; import { Select, Table, TabPane, Tabs, Tooltip } from '@/components/ui';
import { Layers } from 'lucide-react'; import { Layers } from 'lucide-react';
import { useIsMobile } from '@/hooks/common/useIsMobile';
import { import {
ORDER_OPTIONS, ORDER_OPTIONS,
ORG_DIMS, ORG_DIMS,
@@ -27,6 +28,8 @@ export const RateBar = ({ value }) => (
/** 维度分布:每行可点击,把该维度值加入筛选(下钻) */ /** 维度分布:每行可点击,把该维度值加入筛选(下钻) */
const QualityBreakdown = ({ quality, t }) => { const QualityBreakdown = ({ quality, t }) => {
const { scope, get, params, setFilters } = quality; const { scope, get, params, setFilters } = quality;
const isPlatform = scope !== 'org';
const isMobile = useIsMobile();
const dims = scope === 'org' ? ORG_DIMS : PLATFORM_DIMS; const dims = scope === 'org' ? ORG_DIMS : PLATFORM_DIMS;
const [dim, setDim] = useState('model'); const [dim, setDim] = useState('model');
const [orderBy, setOrderBy] = useState('total'); const [orderBy, setOrderBy] = useState('total');
@@ -171,6 +174,9 @@ const QualityBreakdown = ({ quality, t }) => {
setFilters({ [dimSpec.filterKey]: row.key }); setFilters({ [dimSpec.filterKey]: row.key });
}; };
const rows = data?.rows || [];
const isPlatformEmpty = isPlatform && rows.length === 0;
return ( return (
<div className='quality-card'> <div className='quality-card'>
<div className='quality-card-head'> <div className='quality-card-head'>
@@ -189,7 +195,9 @@ const QualityBreakdown = ({ quality, t }) => {
onChange={setOrderBy} onChange={setOrderBy}
/> />
</div> </div>
<div className='quality-card-body quality-nested-tabs'> <div
className={`quality-card-body quality-nested-tabs${isPlatform ? ' quality-breakdown-body' : ''}`}
>
<Tabs type='button' size='small' activeKey={dim} onChange={setDim}> <Tabs type='button' size='small' activeKey={dim} onChange={setDim}>
{dims.map((d) => ( {dims.map((d) => (
<TabPane key={d.value} itemKey={d.value} tab={t(d.label)} /> <TabPane key={d.value} itemKey={d.value} tab={t(d.label)} />
@@ -199,17 +207,37 @@ const QualityBreakdown = ({ quality, t }) => {
<QualityMetaNotice meta={data.meta} scope={scope} t={t} /> <QualityMetaNotice meta={data.meta} scope={scope} t={t} />
)} )}
{error ? ( {error ? (
<div className={isPlatform ? 'quality-breakdown-result' : undefined}>
<div className='quality-empty'>{qualityErrorText(t, error)}</div> <div className='quality-empty'>{qualityErrorText(t, error)}</div>
</div>
) : ( ) : (
<div className='overflow-x-auto app-scrollbar mt-2'> <div
className={
isPlatform
? 'quality-breakdown-result'
: 'overflow-x-auto app-scrollbar mt-2'
}
>
<Table <Table
className={
isPlatformEmpty ? 'quality-breakdown-empty' : undefined
}
size='small' size='small'
rowKey={(row) => `${row.key}|${row.key2 || ''}`} rowKey={(row) => `${row.key}|${row.key2 || ''}`}
loading={loading} loading={loading}
columns={columns} columns={
dataSource={data?.rows || []} isPlatformEmpty
? (isMobile ? columns.slice(0, 1) : columns).map(
(column) => ({
...column,
width: undefined,
}),
)
: columns
}
dataSource={rows}
pagination={false} pagination={false}
scroll={{ x: 960 }} scroll={{ x: isPlatformEmpty ? undefined : 960 }}
onRow={(row) => onRow={(row) =>
canDrill(row) canDrill(row)
? { ? {
@@ -224,11 +252,11 @@ const QualityBreakdown = ({ quality, t }) => {
} }
empty={<div className='quality-empty'>{t('暂无数据')}</div>} empty={<div className='quality-empty'>{t('暂无数据')}</div>}
/> />
{data && data.total_rows > (data.rows || []).length && ( {data && data.total_rows > rows.length && (
<div className='mt-2 text-xs text-[var(--text-secondary)]'> <div className='mt-2 text-xs text-[var(--text-secondary)]'>
{t('共 {{total}} 项,仅展示排序后的前 {{shown}} 项', { {t('共 {{total}} 项,仅展示排序后的前 {{shown}} 项', {
total: data.total_rows, total: data.total_rows,
shown: (data.rows || []).length, shown: rows.length,
})} })}
</div> </div>
)} )}
+26
View File
@@ -63,6 +63,32 @@
padding: 16px; padding: 16px;
} }
.quality-breakdown-body {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 12px;
padding-block-start: 12px;
}
.quality-breakdown-body .ant-tabs > .ant-tabs-nav {
margin-bottom: 0;
}
.quality-breakdown-result {
min-width: 0;
}
.quality-breakdown-empty .ant-table-thead > tr > th {
white-space: normal;
overflow-wrap: anywhere;
}
@media (max-width: 680px) {
.quality-breakdown-body .ant-tabs .ant-tabs-tab + .ant-tabs-tab {
margin-inline-start: 8px;
}
}
/* 筛选栏 */ /* 筛选栏 */
.quality-filter-grid { .quality-filter-grid {
display: grid; display: grid;
+4 -1
View File
@@ -11356,7 +11356,10 @@
"官网展示:{{value}}": "Website display: {{value}}", "官网展示:{{value}}": "Website display: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D ratio {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D ratio {{ratio}}",
"降幅": "reduction", "降幅": "reduction",
"首页与关于微词元共用": "shared by Home and About", "关于微元算力": "About 微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "Configure the team and service information shown in the About 微元算力 section.",
"首页与关于微元算力共用": "Shared by Home and About 微元算力",
"请完善关于微元算力的配置": "Please complete the About 微元算力 configuration",
"四个页签共用一份配置,保存时将统一校验并提交。": "All four tabs share one configuration. Saving validates and submits all settings together.", "四个页签共用一份配置,保存时将统一校验并提交。": "All four tabs share one configuration. Saving validates and submits all settings together.",
"富文本工具栏": "Rich text toolbar", "富文本工具栏": "Rich text toolbar",
"正文段落": "Body paragraph", "正文段落": "Body paragraph",
+4 -1
View File
@@ -10788,7 +10788,10 @@
"官网展示:{{value}}": "Affichage sur le site : {{value}}", "官网展示:{{value}}": "Affichage sur le site : {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · part R&D {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · part R&D {{ratio}}",
"降幅": "baisse", "降幅": "baisse",
"首页与关于微词元共用": "partagé entre Accueil et À propos", "关于微元算力": "À propos de 微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "Configurez les informations sur l’équipe et les services affichées dans la rubrique À propos de 微元算力.",
"首页与关于微元算力共用": "Commun à l’accueil et à la rubrique À propos de 微元算力",
"请完善关于微元算力的配置": "Veuillez compléter la configuration de la rubrique À propos de 微元算力",
"四个页签共用一份配置,保存时将统一校验并提交。": "Les quatre onglets partagent une configuration et sont soumis uniformément à la vérification et à la validation lorsqu 'ils sont sauvegardés.", "四个页签共用一份配置,保存时将统一校验并提交。": "Les quatre onglets partagent une configuration et sont soumis uniformément à la vérification et à la validation lorsqu 'ils sont sauvegardés.",
"结算状态: {{label}}": "Statut du règlement: {{label}}", "结算状态: {{label}}": "Statut du règlement: {{label}}",
"确认未生效:授权、凭据或操作内容已变化,请刷新任务后重试。": "La confirmation n'est pas effective: l'autorisation, les informations d'identification ou le contenu de l'action ont changé, veuillez actualiser la tâche et réessayer.", "确认未生效:授权、凭据或操作内容已变化,请刷新任务后重试。": "La confirmation n'est pas effective: l'autorisation, les informations d'identification ou le contenu de l'action ont changé, veuillez actualiser la tâche et réessayer.",
+4 -1
View File
@@ -11330,7 +11330,10 @@
"官网展示:{{value}}": "公式サイト表示:{{value}}", "官网展示:{{value}}": "公式サイト表示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研究開発比率 {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · 研究開発比率 {{ratio}}",
"降幅": "削減率", "降幅": "削減率",
"首页与关于微词元共用": "ホームと会社概要で共用", "关于微元算力": "微元算力について",
"配置官网关于微元算力区域展示的团队与服务信息。": "公式サイトの「微元算力について」に表示するチームとサービスの情報を設定します。",
"首页与关于微元算力共用": "ホームと「微元算力について」で共用",
"请完善关于微元算力的配置": "「微元算力について」の設定を完了してください",
"四个页签共用一份配置,保存时将统一校验并提交。": "4つのタブは1つの構成を共有し、保存時に均一に検証およびコミットされます。", "四个页签共用一份配置,保存时将统一校验并提交。": "4つのタブは1つの構成を共有し、保存時に均一に検証およびコミットされます。",
"富文本工具栏": "リッチテキストツールバー", "富文本工具栏": "リッチテキストツールバー",
"正文段落": "本文段落", "正文段落": "本文段落",
+4 -1
View File
@@ -11334,7 +11334,10 @@
"官网展示:{{value}}": "웹사이트 표시: {{value}}", "官网展示:{{value}}": "웹사이트 표시: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D 비율 {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · R&D 비율 {{ratio}}",
"降幅": "감소폭", "降幅": "감소폭",
"首页与关于微词元共用": "홈과 회사 소개에서 공용", "关于微元算力": "미원산력 소개",
"配置官网关于微元算力区域展示的团队与服务信息。": "공식 웹사이트의 미원산력 소개에 표시할 팀 및 서비스 정보를 설정합니다.",
"首页与关于微元算力共用": "홈과 미원산력 소개에서 공용",
"请完善关于微元算力的配置": "미원산력 소개 설정을 완료해 주세요",
"四个页签共用一份配置,保存时将统一校验并提交。": "네 개의 탭은 구성을 공유하며, 이 구성은 저장 시 확인되고 제출됩니다.", "四个页签共用一份配置,保存时将统一校验并提交。": "네 개의 탭은 구성을 공유하며, 이 구성은 저장 시 확인되고 제출됩니다.",
"富文本工具栏": "서식 있는 텍스트 도구 모음", "富文本工具栏": "서식 있는 텍스트 도구 모음",
"正文段落": "본문 단락", "正文段落": "본문 단락",
+4 -1
View File
@@ -10540,7 +10540,10 @@
"官网展示:{{value}}": "На сайте: {{value}}", "官网展示:{{value}}": "На сайте: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · доля R&D {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · доля R&D {{ratio}}",
"降幅": "снижение", "降幅": "снижение",
"首页与关于微词元共用": "общее для главной и раздела «О нас»", "关于微元算力": "О компании 微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "Настройте сведения о команде и услугах в разделе «О компании 微元算力».",
"首页与关于微元算力共用": "Общее для главной и раздела «О компании 微元算力»",
"请完善关于微元算力的配置": "Завершите настройку раздела «О компании 微元算力»",
"四个页签共用一份配置,保存时将统一校验并提交。": "Четыре страницы совместно используют один экземпляр конфигурации, при сохранении будет проведена единая проверка и отправка.", "四个页签共用一份配置,保存时将统一校验并提交。": "Четыре страницы совместно используют один экземпляр конфигурации, при сохранении будет проведена единая проверка и отправка.",
"{{count}} 处非法输入": "{{count}} неверный вход (ы)", "{{count}} 处非法输入": "{{count}} неверный вход (ы)",
"{{count}} 个已验证渠道": "{{count}} верифицированные каналы", "{{count}} 个已验证渠道": "{{count}} верифицированные каналы",
+4 -1
View File
@@ -11330,7 +11330,10 @@
"官网展示:{{value}}": "แสดงบนเว็บไซต์: {{value}}", "官网展示:{{value}}": "แสดงบนเว็บไซต์: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · สัดส่วน R&D {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · สัดส่วน R&D {{ratio}}",
"降幅": "ลดลง", "降幅": "ลดลง",
"首页与关于微词元共用": "ใช้ร่วมกันระหว่างหน้าแรกและเกี่ยวกับเรา", "关于微元算力": "เกี่ยวกับ 微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "กำหนดข้อมูลทีมและบริการที่แสดงในส่วนเกี่ยวกับ 微元算力 บนเว็บไซต์ทางการ",
"首页与关于微元算力共用": "ใช้ร่วมกันระหว่างหน้าแรกและส่วนเกี่ยวกับ 微元算力",
"请完善关于微元算力的配置": "โปรดกำหนดค่าส่วนเกี่ยวกับ 微元算力 ให้ครบถ้วน",
"四个页签共用一份配置,保存时将统一校验并提交。": "แท็บทั้งสี่จะใช้การกําหนดค่าร่วมกันและจะได้รับการตรวจสอบและส่งเมื่อบันทึก", "四个页签共用一份配置,保存时将统一校验并提交。": "แท็บทั้งสี่จะใช้การกําหนดค่าร่วมกันและจะได้รับการตรวจสอบและส่งเมื่อบันทึก",
"富文本工具栏": "แถบเครื่องมือข้อความที่มีรูปแบบ", "富文本工具栏": "แถบเครื่องมือข้อความที่มีรูปแบบ",
"正文段落": "ย่อหน้าเนื้อหา", "正文段落": "ย่อหน้าเนื้อหา",
+4 -1
View File
@@ -11330,7 +11330,10 @@
"官网展示:{{value}}": "Hiển thị trên website: {{value}}", "官网展示:{{value}}": "Hiển thị trên website: {{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · tỷ lệ R&D {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · tỷ lệ R&D {{ratio}}",
"降幅": "mức giảm", "降幅": "mức giảm",
"首页与关于微词元共用": "dùng chung cho Trang chủ và Giới thiệu", "关于微元算力": "Giới thiệu 微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "Cấu hình thông tin đội ngũ và dịch vụ hiển thị trong mục Giới thiệu 微元算力 trên trang web chính thức.",
"首页与关于微元算力共用": "Dùng chung cho Trang chủ và Giới thiệu 微元算力",
"请完善关于微元算力的配置": "Vui lòng hoàn tất cấu hình mục Giới thiệu 微元算力",
"四个页签共用一份配置,保存时将统一校验并提交。": "Bốn tab dùng chung một bản sao của bố trí và được kiểm tra và cam kết thống nhất khi bạn lưu lại.", "四个页签共用一份配置,保存时将统一校验并提交。": "Bốn tab dùng chung một bản sao của bố trí và được kiểm tra và cam kết thống nhất khi bạn lưu lại.",
"富文本工具栏": "Thanh công cụ văn bản có định dạng", "富文本工具栏": "Thanh công cụ văn bản có định dạng",
"正文段落": "Đoạn văn bản", "正文段落": "Đoạn văn bản",
+4 -1
View File
@@ -11330,7 +11330,10 @@
"官网展示:{{value}}": "官網展示:{{value}}", "官网展示:{{value}}": "官網展示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研發佔比 {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · 研發佔比 {{ratio}}",
"降幅": "降幅", "降幅": "降幅",
"首页与关于微词元共用": "首頁與關於微詞元共用", "关于微元算力": "關於微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "設定官網關於微元算力區域顯示的團隊與服務資訊。",
"首页与关于微元算力共用": "首頁與關於微元算力共用",
"请完善关于微元算力的配置": "請完善關於微元算力的設定",
"四个页签共用一份配置,保存时将统一校验并提交。": "四個頁籤共用一份配置,保存時將統一校驗並提交。", "四个页签共用一份配置,保存时将统一校验并提交。": "四個頁籤共用一份配置,保存時將統一校驗並提交。",
"富文本工具栏": "富文字工具列", "富文本工具栏": "富文字工具列",
"正文段落": "內文段落", "正文段落": "內文段落",
+4 -1
View File
@@ -11245,7 +11245,10 @@
"官网展示:{{value}}": "官网展示:{{value}}", "官网展示:{{value}}": "官网展示:{{value}}",
"{{team}} · 研发占比 {{ratio}}": "{{team}} · 研发占比 {{ratio}}", "{{team}} · 研发占比 {{ratio}}": "{{team}} · 研发占比 {{ratio}}",
"降幅": "降幅", "降幅": "降幅",
"首页与关于微词元共用": "首页与关于微词元共用", "关于微元算力": "关于微元算力",
"配置官网关于微元算力区域展示的团队与服务信息。": "配置官网关于微元算力区域展示的团队与服务信息。",
"首页与关于微元算力共用": "首页与关于微元算力共用",
"请完善关于微元算力的配置": "请完善关于微元算力的配置",
"四个页签共用一份配置,保存时将统一校验并提交。": "四个页签共用一份配置,保存时将统一校验并提交。", "四个页签共用一份配置,保存时将统一校验并提交。": "四个页签共用一份配置,保存时将统一校验并提交。",
"富文本工具栏": "富文本工具栏", "富文本工具栏": "富文本工具栏",
"正文段落": "正文段落", "正文段落": "正文段落",
+3 -3
View File
@@ -506,12 +506,12 @@ const Analytics = () => {
/> />
{/* 自动封号历史 */} {/* 自动封号历史 */}
<div className='mt-6 mb-6'> <div className='analytics-fold-panel'>
<CollapsibleHeader <CollapsibleHeader
icon={<History className='w-5 h-5' />} icon={<History className='w-5 h-5' />}
title={t('自动封号历史')} title={t('自动封号历史')}
isOpen={banLogsOpen} isOpen={banLogsOpen}
onToggle={() => setBanLogsOpen(!banLogsOpen)} onToggle={() => setBanLogsOpen((open) => !open)}
t={t} t={t}
extra={ extra={
<span className='text-xs text-gray-400 ml-2'> <span className='text-xs text-gray-400 ml-2'>
@@ -520,7 +520,7 @@ const Analytics = () => {
} }
/> />
<Collapsible isOpen={banLogsOpen} keepDOM> <Collapsible isOpen={banLogsOpen} keepDOM>
<div className='mt-2 px-5 py-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-100 dark:border-gray-700'> <div className='min-w-0 px-5 py-4'>
<RiskControlBanLogs <RiskControlBanLogs
loading={risk.banLogLoading} loading={risk.banLogLoading}
banLogs={risk.banLogs} banLogs={risk.banLogs}
@@ -7,12 +7,20 @@
--igf-muted: var(--text-secondary); --igf-muted: var(--text-secondary);
--igf-line: var(--border-subtle); --igf-line: var(--border-subtle);
--igf-surface: var(--surface-card); --igf-surface: var(--surface-card);
--igf-accent: var(--ui-color-primary); --igf-accent: var(--brand-accent);
--igf-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card)); --igf-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
--igf-danger: var(--ui-color-danger); --igf-danger: var(--ui-color-danger);
--igf-warning: var(--ui-color-warning); --igf-warning: var(--ui-color-warning);
--igf-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent); --igf-ring: var(--brand-accent);
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
overflow: hidden;
border: 1px solid var(--igf-line);
border-radius: 12px;
background: var(--igf-surface); background: var(--igf-surface);
color: var(--igf-ink);
} }
.igf-form-scroll { .igf-form-scroll {
@@ -20,7 +28,182 @@
min-height: 0; min-height: 0;
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
padding: 16px; padding: 14px 16px 16px;
scrollbar-width: thin;
}
.igf-form-scroll[hidden] {
display: none;
}
.igf-header {
display: flex;
flex: none;
align-items: center;
gap: 10px;
padding: 15px 16px;
border-bottom: 1px solid var(--igf-line);
}
.igf-header-icon {
display: grid;
flex: none;
place-items: center;
width: 40px;
height: 40px;
border-radius: 10px;
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-header-copy {
flex: 1;
min-width: 0;
}
.igf-header-actions {
display: flex;
flex: none;
gap: 6px;
}
.igf-title {
margin: 0;
font-size: 21px;
font-weight: 650;
line-height: 27px;
}
.igf-description {
display: block;
overflow: hidden;
color: var(--igf-muted);
font-size: 12px;
line-height: 18px;
text-overflow: ellipsis;
}
.igf-section + .igf-section {
margin-top: 16px;
}
.igf-field-heading {
margin: 0 0 8px;
font-size: 13px;
font-weight: 650;
line-height: 20px;
}
.igf-configuration,
.igf-parameters {
padding: 12px;
border: 1px solid var(--igf-line);
border-radius: 10px;
background: var(--igf-fill);
}
.igf-mode-field {
margin-top: 10px;
}
.igf-mode-group.cp-option-group {
display: flex;
width: 100%;
gap: 3px;
background: var(--igf-surface);
}
.igf-mode-group .cp-option {
flex: 1 1 auto;
padding-inline: 6px;
}
.igf-mode-group .cp-option.is-selected {
border-color: var(--igf-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-editor {
border: 1px solid var(--igf-line);
border-radius: 10px;
background: var(--igf-fill);
}
.igf-editor:focus-within {
border-color: var(--igf-accent);
}
.igf-editor textarea.ant-input {
min-height: 78px;
padding: 9px 10px;
resize: vertical;
font-size: 13px;
line-height: 20px;
}
.igf-editor-toolbar,
.igf-editor-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 4px;
}
.igf-editor-toolbar {
justify-content: space-between;
padding: 4px 6px;
border-top: 1px solid var(--igf-line);
}
.igf-editor-actions .ant-btn {
padding-inline: 7px;
font-size: 12px;
}
.igf-shortcut {
display: inline-flex;
align-items: center;
gap: 3px;
padding: 1px 5px;
border: 1px solid var(--igf-line);
border-radius: 5px;
color: var(--igf-muted);
font-size: 11px;
white-space: nowrap;
}
.igf-history-item {
display: block;
overflow: hidden;
max-width: min(280px, 70vw);
text-overflow: ellipsis;
white-space: nowrap;
}
.igf-templates {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.igf-templates .ant-btn {
flex: 1 1 27%;
min-height: 28px;
box-shadow: none;
}
.igf-templates-label {
flex-basis: 100%;
color: var(--igf-muted);
font-size: 12px;
}
.igf-generate .igf-submit.ant-btn {
height: 42px;
font-size: 14px;
font-weight: 600;
} }
/* Keep disabled generation actions grounded in the same surface and border token. */ /* Keep disabled generation actions grounded in the same surface and border token. */
@@ -139,13 +322,36 @@
} }
.igf-slots { .igf-slots {
display: flex; display: grid;
flex-wrap: wrap; grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px; gap: 8px;
}
.igf-slots .cp-slot {
width: 100%;
height: auto;
aspect-ratio: 1;
border-radius: 9px;
}
.igf-reference-hint {
margin: 6px 0 0;
}
.igf-size .cp-option-group--ratio {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 78px), 1fr));
} }
.igf-size .cp-option-group--ratio .cp-option { .igf-size .cp-option-group--ratio .cp-option {
min-width: 64px; gap: 3px;
min-width: 0;
padding: 6px 4px;
}
.igf-size .cp-option-group--ratio .cp-option-label {
white-space: normal;
overflow-wrap: anywhere;
} }
.igf-size-dims { .igf-size-dims {
@@ -175,6 +381,35 @@
margin-top: 12px; margin-top: 12px;
} }
.igf-advanced-trigger {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
min-height: 34px;
padding: 6px 10px;
border: 1px solid var(--igf-line);
border-radius: 8px;
color: var(--igf-muted);
font-size: 13px;
text-align: start;
}
.igf-advanced-trigger span {
flex: 1;
}
.igf-advanced-trigger:hover,
.igf-advanced-trigger[aria-expanded='true'] {
border-color: var(--igf-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.igf-advanced-content {
padding-top: 12px;
}
.igf-generate { .igf-generate {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -183,11 +418,20 @@
.igf-generate-wrap { .igf-generate-wrap {
flex: 0 0 auto; flex: 0 0 auto;
padding: 16px 16px max(16px, env(safe-area-inset-bottom)); padding: 12px 16px max(12px, env(safe-area-inset-bottom));
border-top: 1px solid var(--igf-line); border-top: 1px solid var(--igf-line);
background: var(--igf-surface); background: var(--igf-surface);
} }
.igf-collapsed-summary {
overflow: hidden;
margin: 0 0 8px;
color: var(--igf-muted);
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.igf-quote { .igf-quote {
min-height: 18px; min-height: 18px;
color: var(--igf-muted); color: var(--igf-muted);
@@ -15,6 +15,20 @@ import {
const CUSTOM = '__custom__'; const CUSTOM = '__custom__';
const formatPreset = ({ width, height, label }) => {
const dimensions = `${width}×${height}`;
const caption = label
.replace(/\s*[((]\s*\d+\s*[x×]\s*\d+\s*[))]\s*$/i, '')
.trim();
return {
dimensions,
caption:
caption.toLowerCase().replace(/\s/g, '').replace('x', '×') === dimensions
? ''
: caption,
};
};
/** /**
* 图像尺寸(schema type = 'size'):预设按宽高比图标展示;仅当 schema 下发 custom_size 时 * 图像尺寸(schema type = 'size'):预设按宽高比图标展示;仅当 schema 下发 custom_size 时
* 提供"自定义",宽高输入框失焦 / 回车时按 min / max / step 吸附。 * 提供"自定义",宽高输入框失焦 / 回车时按 min / max / step 吸附。
@@ -83,7 +97,9 @@ const ImageSizePicker = ({ param, value, onChange }) => {
getOptionAriaLabel={(opt) => { getOptionAriaLabel={(opt) => {
if (opt === CUSTOM) return t('自定义尺寸'); if (opt === CUSTOM) return t('自定义尺寸');
const p = presets.find((x) => x.value === opt); const p = presets.find((x) => x.value === opt);
return p ? `${p.label || ''} ${p.width}×${p.height}`.trim() : opt; if (!p) return opt;
const { caption, dimensions } = formatPreset(p);
return caption ? `${caption} ${dimensions}` : dimensions;
}} }}
renderOption={(opt) => { renderOption={(opt) => {
if (opt === CUSTOM) { if (opt === CUSTOM) {
@@ -97,16 +113,16 @@ const ImageSizePicker = ({ param, value, onChange }) => {
); );
} }
const p = presets.find((x) => x.value === opt); const p = presets.find((x) => x.value === opt);
if (!p) return opt;
const { caption, dimensions } = formatPreset(p);
return ( return (
<> <>
<RatioShape ratio={`${p.width}:${p.height}`} /> <RatioShape ratio={`${p.width}:${p.height}`} />
<span className='cp-option-label tabular-nums'> <span className='cp-option-label tabular-nums'>
{p.label || `${p.width}×${p.height}`} {caption || dimensions}
</span>
{p.label ? (
<span className='igf-size-dims tabular-nums'>
{p.width}×{p.height}
</span> </span>
{caption ? (
<span className='igf-size-dims tabular-nums'>{dimensions}</span>
) : null} ) : null}
</> </>
); );
@@ -1,13 +1,14 @@
import { I18N_TECHNICAL_TEXT } from '../../../../i18n/technicalText.js'; import { I18N_TECHNICAL_TEXT } from '../../../../i18n/technicalText.js';
import { import {
Wallet as ActionWallet, Wallet as ActionWallet,
Zap as ActionZap,
RotateCcw as ActionRotateCcw, RotateCcw as ActionRotateCcw,
ChevronDown as ActionChevronDown, ChevronDown as ActionChevronDown,
ChevronUp as ActionChevronUp, ChevronUp as ActionChevronUp,
History as ActionHistory, History as ActionHistory,
Settings as ActionSettings, Settings as ActionSettings,
} from '@/components/common/icons/ActionIcons'; } from '@/components/common/icons/ActionIcons';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useId, useRef, useState } from 'react';
import { import {
Button, Button,
Collapsible, Collapsible,
@@ -43,7 +44,7 @@ import {
import ImageSizePicker from './Image/ImageSizePicker'; import ImageSizePicker from './Image/ImageSizePicker';
import './Image/ImageGenerationForm.css'; import './Image/ImageGenerationForm.css';
const { Title, Text } = Typography; const { Text } = Typography;
// sessionStorage prompt 历史 key // sessionStorage prompt 历史 key
const PROMPT_HISTORY_KEY = 'expCenter.imageGen.promptHistory.v1'; const PROMPT_HISTORY_KEY = 'expCenter.imageGen.promptHistory.v1';
@@ -119,20 +120,9 @@ const hasImageTaskType = (dataTransfer) =>
Array.from(dataTransfer.types).includes('application/x-image-task'), Array.from(dataTransfer.types).includes('application/x-image-task'),
); );
const Section = ({ title, extra, children, className = '' }) => ( const Section = ({ title, children, className = '' }) => (
<div <div className={`igf-section ${className}`}>
className={`mb-4 rounded-3xl border border-[var(--igf-line)] bg-white/[0.28] p-3 backdrop-blur-xl dark:bg-white/[0.045] ${className}`} {title && <h2 className='igf-field-heading'>{title}</h2>}
>
{title || extra ? (
<div className='flex items-center justify-between gap-2 mb-2'>
{title ? (
<Text strong className='text-sm text-gray-700 dark:text-gray-200'>
{title}
</Text>
) : null}
{extra}
</div>
) : null}
{children} {children}
</div> </div>
); );
@@ -145,6 +135,10 @@ const ImageGenerationForm = ({ creation }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const navigate = useNavigate(); const navigate = useNavigate();
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const bodyId = useId();
const advancedId = useId();
const promptId = useId();
const quoteId = useId();
const [mobileCollapsed, setMobileCollapsed] = useState(false); const [mobileCollapsed, setMobileCollapsed] = useState(false);
const [showAdvanced, setShowAdvanced] = useState(false); const [showAdvanced, setShowAdvanced] = useState(false);
const [dropActive, setDropActive] = useState(false); const [dropActive, setDropActive] = useState(false);
@@ -348,10 +342,10 @@ const ImageGenerationForm = ({ creation }) => {
theme='solid' theme='solid'
size='large' size='large'
block block
icon={<ActionWallet size={16} />} icon={<ActionWallet size={16} aria-hidden='true' />}
aria-describedby={quoteId}
onClick={() => navigate('/console/topup')} onClick={() => navigate('/console/topup')}
className='!rounded-2xl' className='igf-submit'
style={{ height: '48px', fontSize: '15px', fontWeight: 700 }}
> >
{t('去充值')} {t('去充值')}
</Button> </Button>
@@ -362,26 +356,17 @@ const ImageGenerationForm = ({ creation }) => {
size='large' size='large'
block block
loading={submitting} loading={submitting}
icon={<ActionZap size={16} aria-hidden='true' />}
aria-describedby={quoteId}
onClick={handleSubmit} onClick={handleSubmit}
disabled={isButtonDisabled} disabled={isButtonDisabled}
className='!rounded-2xl !transition-colors' className='igf-submit'
style={{
background: isButtonDisabled
? 'var(--ui-color-fill-1)'
: 'linear-gradient(135deg, var(--brand-gradient-from) 0%, var(--brand-primary) 52%, var(--brand-gradient-to) 100%)',
border: isButtonDisabled
? '1px solid var(--igf-line)'
: '1px solid transparent',
color: isButtonDisabled ? 'var(--ui-color-text-3)' : 'white',
height: '48px',
fontSize: '15px',
fontWeight: '700',
}}
> >
{submitting ? t('提交中...') : t('生成图片')} {submitting ? t('提交中...') : t('生成图片')}
</Button> </Button>
)} )}
<div <div
id={quoteId}
className={`igf-quote${needTopUp ? ' is-warning' : ''}`} className={`igf-quote${needTopUp ? ' is-warning' : ''}`}
aria-live='polite' aria-live='polite'
role={isButtonDisabled ? 'note' : undefined} role={isButtonDisabled ? 'note' : undefined}
@@ -521,98 +506,80 @@ const ImageGenerationForm = ({ creation }) => {
return ( return (
<div <div
className={`image-generation-form relative flex h-full min-h-0 flex-col overflow-hidden rounded-[28px] border border-[var(--igf-line)] bg-white/[0.42] shadow-[0_24px_80px_rgba(15,23,42,0.10)] backdrop-blur-2xl backdrop-saturate-150 transition-colors dark:bg-neutral-950/[0.40] dark:shadow-[0_24px_80px_rgba(0,0,0,0.35)]${dropActive ? ' is-drop-active' : ''}`} className={`image-generation-form${dropActive ? ' is-drop-active' : ''}`}
onDragEnter={handleDragEnter} onDragEnter={handleDragEnter}
onDragOver={handleDragOver} onDragOver={handleDragOver}
onDragLeave={handleDragLeave} onDragLeave={handleDragLeave}
onDrop={handleDrop} onDrop={handleDrop}
> >
<div className='igf-form-scroll app-scrollbar'> <header className='igf-header'>
{/* 标题 */} <span className='igf-header-icon' aria-hidden='true'>
<div className='mb-5 rounded-3xl border border-white/60 bg-white/[0.50] p-4 shadow-sm backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.05]'> <Sparkles size={19} />
<div className='flex items-center justify-between gap-2'> </span>
<div className='flex-1 min-w-0'> <div className='igf-header-copy'>
<div className='mb-2 inline-flex items-center gap-2 rounded-full border border-brand/25 bg-brand/10 px-2.5 py-1 text-[11px] font-medium text-brand-deep dark:border-brand/25 dark:bg-brand/15 dark:text-brand-from'> <h1 className='igf-title'>{t('图片生成')}</h1>
<Sparkles size={12} /> <span
{t('AI 图片创作')} className='igf-description'
</div> title={
<Title formBodyHidden
heading={4} ? selectedModel?.display_name || selectedModel?.model
style={{ margin: 0 }} : undefined
className='text-gray-900 dark:text-white' }
>
{t('图片生成')}
</Title>
<Text
type='secondary'
size='small'
className='text-gray-500 dark:text-gray-400 mt-1 block truncate'
> >
{formBodyHidden && selectedModel {formBodyHidden && selectedModel
? selectedModel.display_name || selectedModel.model ? selectedModel.display_name || selectedModel.model
: t('输入描述即可生成图片')} : t('输入描述即可生成图片')}
</Text> </span>
</div> </div>
<div className='flex items-center gap-1'> <div className='igf-header-actions'>
{!formBodyHidden && ( {!formBodyHidden && (
<Tooltip content={t('重置')}>
<Button <Button
icon={<ActionRotateCcw size={12} />} icon={<ActionRotateCcw size={15} aria-hidden='true' />}
size='small' theme='outline'
theme='borderless' aria-label={t('重置')}
onClick={handleReset} onClick={handleReset}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from' />
> </Tooltip>
{t('重置')}
</Button>
)} )}
{isMobile && ( {isMobile && (
<Button <Button
icon={ icon={
mobileCollapsed ? ( mobileCollapsed ? (
<ActionChevronDown size={14} /> <ActionChevronDown size={15} aria-hidden='true' />
) : ( ) : (
<ActionChevronUp size={14} /> <ActionChevronUp size={15} aria-hidden='true' />
) )
} }
size='small' theme='outline'
theme='borderless' title={mobileCollapsed ? t('展开') : t('收起')}
onClick={() => setMobileCollapsed(!mobileCollapsed)} onClick={() => setMobileCollapsed(!mobileCollapsed)}
className='!text-gray-500' aria-label={mobileCollapsed ? t('展开') : t('收起')}
> aria-controls={bodyId}
{mobileCollapsed ? t('展开') : t('收起')} aria-expanded={!formBodyHidden}
</Button> />
)} )}
</div> </div>
</div> </header>
</div>
{/* 移动端折叠时只显示生成按钮 + 简略 */} <div
{formBodyHidden && ( id={bodyId}
<div className='mt-2'> className='igf-form-scroll app-scrollbar'
{renderGenerateArea()} hidden={formBodyHidden}
<Text
type='tertiary'
size='small'
className='block mt-2 text-center'
> >
{prompt
? prompt.length > 50
? prompt.slice(0, 50) + '...'
: prompt
: t('点击展开编辑参数')}
</Text>
</div>
)}
{!formBodyHidden && ( {!formBodyHidden && (
<> <>
{/* 模型选择 */} <Section className='igf-configuration'>
<Section title={t('选择模型')}>{renderModelSection()}</Section> <div className='igf-field-heading'>{t('选择模型')}</div>
{renderModelSection()}
{/* 生成方式(来自 schema modes) */} {/* 生成方式(来自 schema modes) */}
{selectedModel && modeOptions.length > 1 ? ( {selectedModel && modeOptions.length > 1 ? (
<Section title={t('生成方式')}> <div className='igf-mode-field'>
<div className='igf-field-heading'>{t('生成方式')}</div>
<OptionGroup <OptionGroup
variant='segmented'
className='igf-mode-group'
options={modeOptions.map((o) => o.mode)} options={modeOptions.map((o) => o.mode)}
value={formData.mode} value={formData.mode}
onChange={setMode} onChange={setMode}
@@ -632,30 +599,36 @@ const ImageGenerationForm = ({ creation }) => {
); );
}} }}
/> />
</Section> </div>
) : null} ) : null}
</Section>
{/* 提示词 + 模板 + 历史 */} {/* 提示词 + 模板 + 历史 */}
<Section <Section
title={t('提示词')} title={<label htmlFor={promptId}>{t('提示词')}</label>}
extra={ className='igf-prompt-section'
<div className='flex items-center gap-2'> >
{/* AI 优化提示词 —— 按钮始终可点击,handler 内判断并 Toast 解释原因 */} <div className='igf-editor'>
<button <TextArea
type='button' id={promptId}
variant='borderless'
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
/>
<div className='igf-editor-toolbar'>
<div className='igf-editor-actions'>
<Button
type='text'
size='small'
icon={<ActionZap size={13} aria-hidden='true' />}
onClick={handleOptimizePrompt} onClick={handleOptimizePrompt}
aria-label={t('AI 优化提示词')} aria-label={t('AI 优化提示词')}
className={[ aria-busy={optimizing}
'app-action-button',
[
'flex items-center gap-1 text-[10px] transition-colors',
optimizing
? 'text-brand-from'
: 'text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={ title={
textModels?.length textModels?.length
? t('AI 优化提示词 (使用 {{m}})', { ? t('AI 优化提示词 (使用 {{m}})', {
@@ -664,102 +637,71 @@ const ImageGenerationForm = ({ creation }) => {
: t('AI 优化提示词') : t('AI 优化提示词')
} }
> >
<Sparkles {optimizing ? t('优化中...') : t('AI 优化')}
size={10} </Button>
className={optimizing ? 'animate-pulse' : ''}
/>
<span>{optimizing ? t('优化中...') : t('AI 优化')}</span>
</button>
{promptHistory.length > 0 && ( {promptHistory.length > 0 && (
<Dropdown <Dropdown
trigger='click' trigger='click'
position='bottomRight' position='bottomLeft'
render={ render={
<Dropdown.Menu style={{ maxWidth: 360 }}> <Dropdown.Menu style={{ maxWidth: 360 }}>
{promptHistory.map((p, idx) => ( {promptHistory.map((item) => (
<Dropdown.Item <Dropdown.Item
key={idx} key={item}
onClick={() => setPrompt(p)} onClick={() => setPrompt(item)}
> >
<div <span className='igf-history-item' title={item}>
style={{ {item}
maxWidth: 320, </span>
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
}}
title={p}
>
{p}
</div>
</Dropdown.Item> </Dropdown.Item>
))} ))}
</Dropdown.Menu> </Dropdown.Menu>
} }
> >
<button <Button
type='button' type='text'
className='app-action-button flex items-center gap-1 text-[10px] text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors' size='small'
icon={<ActionHistory size={13} aria-hidden='true' />}
> >
<ActionHistory size={10} /> {t('历史')}
<span>{t('历史')}</span> </Button>
</button>
</Dropdown> </Dropdown>
)} )}
<span className='flex items-center gap-1 text-[10px] text-gray-400'> </div>
{!isMobile && (
<kbd className='igf-shortcut' title={t('生成图片')}>
{IS_MAC ? ( {IS_MAC ? (
<Command size={10} /> <Command size={11} />
) : ( ) : (
<span>{I18N_TECHNICAL_TEXT.CTRL}</span> I18N_TECHNICAL_TEXT.CTRL
)} )}
<span>+</span> <span>+</span>
<span>{I18N_TECHNICAL_TEXT.ENTER}</span> {I18N_TECHNICAL_TEXT.ENTER}
<span>{t('生成')}</span> </kbd>
</span> )}
</div>
</div> </div>
}
>
<TextArea
placeholder={t('描述你想要生成的图片内容...')}
value={prompt}
onChange={setPrompt}
onKeyDown={handlePromptKeyDown}
rows={3}
maxCount={2000}
showClear
className='[&_.ant-input-textarea]:!rounded-2xl [&_.ant-input-textarea]:!border-white/[0.55] [&_.ant-input-textarea]:!bg-white/[0.55] [&_.ant-input-textarea]:!shadow-inner dark:[&_.ant-input-textarea]:!border-white/10 dark:[&_.ant-input-textarea]:!bg-white/[0.06] [&_.ant-input-textarea:hover]:!border-brand/30 [&_.ant-input-textarea:focus]:!border-brand'
/>
<div className='flex flex-wrap items-center gap-1.5 mt-2'> <div className='igf-templates'>
<div className='flex items-center gap-1 text-[10px] text-gray-400 mr-1'> <div className='igf-templates-label'>
<Sparkles size={10} />
<span>{t('快速模板')}</span> <span>{t('快速模板')}</span>
</div> </div>
{PROMPT_TEMPLATES.map((tpl) => ( {PROMPT_TEMPLATES.map((tpl) => (
<Tag <Button
key={tpl.label} key={tpl.label}
theme='outline'
size='small' size='small'
color='grey'
onClick={() => handleApplyTemplate(tpl)} onClick={() => handleApplyTemplate(tpl)}
className='!cursor-pointer !rounded-full !border-white/50 !bg-white/[0.45] !backdrop-blur hover:!bg-brand/10 dark:!border-white/10 dark:!bg-white/[0.06] dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-colors'
> >
{t(tpl.label)} {t(tpl.label)}
</Tag> </Button>
))} ))}
</div> </div>
</Section> </Section>
{/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */} {/* 参考图:编辑模式的带标签槽位;当前模型 / 模式用不到的图片置灰保留 */}
{selectedModel && imageSlots.length > 0 ? ( {selectedModel && imageSlots.length > 0 ? (
<Section <Section title={t('参考图片')} className='igf-reference'>
title={t('参考图片')}
extra={
<Text type='tertiary' className='!text-[10px]'>
{t('可从右侧历史拖拽图片到这里')}
</Text>
}
>
<div className='igf-slots'> <div className='igf-slots'>
{imageSlots.map((entry) => { {imageSlots.map((entry) => {
const slot = entry.slot; const slot = entry.slot;
@@ -784,6 +726,11 @@ const ImageGenerationForm = ({ creation }) => {
); );
})} })}
</div> </div>
{!isMobile && (
<p className='igf-muted igf-reference-hint'>
{t('可从右侧历史拖拽图片到这里')}
</p>
)}
{hasUnusedImage ? ( {hasUnusedImage ? (
<div className='igf-muted igf-note' role='note'> <div className='igf-muted igf-note' role='note'>
{t( {t(
@@ -796,7 +743,10 @@ const ImageGenerationForm = ({ creation }) => {
{/* 尺寸 + 常用参数(画质 / 数量等) */} {/* 尺寸 + 常用参数(画质 / 数量等) */}
{selectedModel && (sizeParam || dockParams.length > 0) ? ( {selectedModel && (sizeParam || dockParams.length > 0) ? (
<Section title={sizeParam ? t('尺寸') : t('生成参数')}> <Section
className='igf-parameters'
title={sizeParam ? t('尺寸') : t('生成参数')}
>
{sizeParam ? ( {sizeParam ? (
<ImageSizePicker <ImageSizePicker
param={sizeParam} param={sizeParam}
@@ -819,14 +769,15 @@ const ImageGenerationForm = ({ creation }) => {
{/* 高级选项 */} {/* 高级选项 */}
{selectedModel && advancedParams.length > 0 ? ( {selectedModel && advancedParams.length > 0 ? (
<Section> <Section className='igf-advanced'>
<button <button
type='button' type='button'
onClick={() => setShowAdvanced(!showAdvanced)} onClick={() => setShowAdvanced(!showAdvanced)}
aria-expanded={showAdvanced} aria-expanded={showAdvanced}
className='app-action-button flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from transition-colors' aria-controls={advancedId}
className='igf-advanced-trigger'
> >
<ActionSettings size={12} /> <ActionSettings size={15} aria-hidden='true' />
<span>{t('高级选项')}</span> <span>{t('高级选项')}</span>
{showAdvanced ? ( {showAdvanced ? (
<ActionChevronUp size={12} /> <ActionChevronUp size={12} />
@@ -835,7 +786,7 @@ const ImageGenerationForm = ({ creation }) => {
)} )}
</button> </button>
<Collapsible isOpen={showAdvanced} keepDOM> <Collapsible isOpen={showAdvanced} keepDOM>
<div className='pt-3'> <div id={advancedId} className='igf-advanced-content'>
<ParamRenderer <ParamRenderer
params={visibleParams} params={visibleParams}
values={formData.params} values={formData.params}
@@ -850,9 +801,14 @@ const ImageGenerationForm = ({ creation }) => {
</> </>
)} )}
</div> </div>
{!formBodyHidden && ( <footer className='igf-generate-wrap'>
<div className='igf-generate-wrap'>{renderGenerateArea()}</div> {formBodyHidden && (
<p className='igf-collapsed-summary' title={prompt || undefined}>
{prompt || t('点击展开编辑参数')}
</p>
)} )}
{renderGenerateArea()}
</footer>
</div> </div>
); );
}; };
@@ -60,17 +60,15 @@ const ImageGenerationTab = () => {
return ( return (
<> <>
{/* {/*
移动端(< md):Tab 整体允许竖向滚动 —— 表单和任务列表按自然高度堆叠,用户上下滚浏览。 窄屏堆叠并整体滚动,宽屏双栏各自滚动。
桌面端(>= md):保持 overflow-hidden,左右两栏各自内部滚动。
*/} */}
<div className='h-full min-h-0 flex flex-col md:flex-row gap-4 p-3 sm:p-4 overflow-y-auto md:overflow-hidden'> <div className='image-generation-workspace h-full min-h-0 flex flex-col lg:flex-row gap-4 p-4 lg:p-6 overflow-y-auto lg:overflow-hidden'>
{/* 左侧:生成参数表单 */} {/* 左侧:生成参数表单 */}
<div className='w-full md:w-[22rem] xl:w-[24rem] md:flex-shrink-0 md:h-full'> <div className='w-full shrink-0 lg:w-[20rem] xl:w-[22rem] lg:h-full'>
<ImageGenerationForm creation={creation} /> <ImageGenerationForm creation={creation} />
</div> </div>
{/* 右侧:任务列表 —— flex-1 只在桌面端生效,移动端按内容高度展开 */} <div className='min-w-0 lg:flex-1 lg:min-h-0 flex flex-col'>
<div className='md:flex-1 md:min-h-0 flex flex-col'>
<ImageTaskList <ImageTaskList
tasks={tasks} tasks={tasks}
onRefresh={refreshTasks} onRefresh={refreshTasks}
@@ -227,22 +227,19 @@ useCallback; // 事件处理函数优化
### CSS 变量 ### CSS 变量
```css ```css
--ui-color-primary // 主色 --brand-accent // 聚焦与选中边框
--ui-color-success // 成功色 --brand-selection-bg // 筛选和收藏选中底色
--ui-color-warning // 警告色 --surface-card // 卡片背景
--ui-color-danger // 危险色 --border-subtle // 描边与操作区分隔线
--ui-color-bg-2 // 背景色
--ui-color-border // 边框色
``` ```
### 自定义类 ### 自定义类
```css ```css
.task-card-hover // 卡片悬停效果 .image-task-grid // 密度与响应式列数
.task-list-scroll // 滚动条样式 .image-task-card // 统一描边卡片
.stat-card // 统计卡片样式 .image-task-media // 统一 4:3 缩略图与状态占位
.image-preview-container // 图片预览容器 .image-task-actions // 各密度均可访问的卡片操作
.progress-pulse // 进度条动画
``` ```
## 浏览器兼容性 ## 浏览器兼容性
@@ -1,155 +1,429 @@
/* 任务卡片悬停效果 */ .image-task-list {
.task-card-hover { --ih-status-warning: var(--ui-color-warning);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); --ih-status-error: var(--ui-color-danger);
--ih-dimension-bg: rgb(15 23 42 / 0.8);
--ih-dimension-text: white;
display: flex;
flex-direction: column;
min-width: 0;
min-height: 0;
height: 100%;
color: var(--text-primary);
} }
.task-card-hover:hover { .image-history-toolbar {
transform: translateY(-2px); flex: none;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important; padding: 16px;
border: 1px solid var(--border-subtle);
border-radius: 12px;
background: var(--surface-card);
} }
/* 滚动条样式已统一到 index.css 的 .app-scrollbar */ .image-history-heading,
.image-history-title-row,
/* 统计卡片悬停效果 */ .image-history-tools,
.stat-card { .image-history-status,
transition: all 0.3s ease; .image-history-filters,
.image-history-compare {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
} }
.stat-card:hover { .image-history-heading {
transform: scale(1.02); justify-content: space-between;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); gap: 12px 16px;
} }
/* 图片预览悬停效果 */ .image-history-title-row {
.image-preview-container { gap: 12px 16px;
position: relative; }
overflow: hidden; .image-history-title-row h2 {
margin: 0;
font-size: 18px;
line-height: 26px;
font-weight: 650;
}
.image-history-status {
gap: 4px;
} }
.image-preview-container::after { .image-history-status-button,
.image-history-clear {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 34px;
padding: 4px 8px;
border: 1px solid transparent;
border-radius: 8px;
color: var(--text-secondary);
font-size: 12px;
white-space: nowrap;
}
.image-history-status-button:hover,
.image-history-status-button[aria-pressed='true'],
.image-history-clear:hover {
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.image-history-status-button[aria-pressed='true'] {
border-color: var(--brand-accent);
font-weight: 600;
}
.image-history-count {
display: inline-flex;
justify-content: center;
min-width: 18px;
padding: 0 4px;
border-radius: 5px;
background: var(--surface-bg-base);
color: var(--text-secondary);
font-size: 11px;
line-height: 18px;
font-variant-numeric: tabular-nums;
}
.image-history-status-button[aria-pressed='true'] .image-history-count {
background: var(--surface-card);
color: inherit;
}
.image-history-filters {
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid var(--border-subtle);
}
.image-history-tools {
flex-wrap: nowrap;
min-width: 0;
max-width: 100%;
gap: 6px;
}
.image-history-tools .image-task-search {
width: 180px;
min-width: 0;
}
.image-history-tools .ant-btn {
flex-shrink: 0;
}
.image-task-model-filter {
width: min(100%, 190px);
}
.image-task-size-filter {
width: min(100%, 128px);
}
.image-history-tools .ant-btn[aria-pressed='true'],
.image-task-favorite.ant-btn[aria-pressed='true'] {
border-color: var(--brand-accent);
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
}
.image-history-compare {
margin-top: 12px;
padding: 8px 12px;
border-radius: 8px;
background: var(--brand-selection-bg);
color: var(--brand-selection-text);
font-size: 13px;
}
.image-task-list .task-list-scrollable {
flex: 1;
min-height: 0;
}
.image-history-content {
padding: 16px 0 4px;
}
.image-history-empty-description {
display: grid;
gap: 4px;
color: var(--text-secondary);
}
.image-history-empty-description strong {
color: var(--text-primary);
font-size: 16px;
font-weight: 600;
}
.image-task-group-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
.image-task-group-header h3 {
margin: 0;
font-size: 15px;
line-height: 22px;
font-weight: 650;
}
.image-task-group-header::after {
content: ''; content: '';
position: absolute; flex: 1;
top: 0; border-top: 1px solid var(--border-subtle);
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0);
transition: background 0.3s;
pointer-events: none;
} }
.image-preview-container:hover::after { .image-task-grid {
background: rgba(0, 0, 0, 0.05); --ih-card-min: 268px;
display: grid;
grid-template-columns: repeat(
auto-fill,
minmax(min(100%, var(--ih-card-min)), 1fr)
);
gap: 16px;
} }
/* 进度条动画 */ .image-task-grid[data-density='compact'] {
@keyframes pulse { --ih-card-min: 208px;
0%, gap: 12px;
100% { }
opacity: 1; .image-task-grid[data-density='grid'] {
} --ih-card-min: 144px;
50% { gap: 12px;
opacity: 0.5;
}
} }
/* 处理中状态左侧彩条流光 */ .image-task-card.ant-card {
@keyframes brandShimmer { min-width: 0;
0% { border-color: var(--border-subtle);
background-position: 0% 0%; border-radius: 12px;
} background: var(--surface-card);
100% { color: var(--text-primary);
background-position: 0% 200%; box-shadow: none;
}
} }
/* drop target highlight */ .image-task-card.ant-card:focus-within,
.image-ref-drop-active { .image-task-card.ant-card[data-selected='true'] {
outline: 2px dashed var(--brand-primary) !important; border-color: var(--brand-accent);
outline-offset: -4px; }
.image-task-card.ant-card > .image-task-card-layout {
display: flex;
flex-direction: column;
height: 100%;
padding: 10px;
}
.image-task-media {
position: relative;
aspect-ratio: 4 / 3;
overflow: hidden;
border-radius: 8px;
background: var(--surface-bg-base);
}
.image-task-media[data-status='failed'] {
background: color-mix( background: color-mix(
in srgb, in srgb,
var(--brand-primary) 8%, var(--ih-status-error) 5%,
transparent var(--surface-bg-base)
) !important; );
} }
.progress-pulse { .image-task-preview {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; position: absolute;
inset: 0;
width: 100%;
border-radius: inherit;
cursor: zoom-in;
}
.image-task-preview[aria-pressed] {
cursor: pointer;
}
.image-task-preview img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
} }
/* 按钮组动画 */ .image-task-dimensions {
.action-buttons { position: absolute;
right: 8px;
bottom: 8px;
padding: 2px 6px;
border-radius: 5px;
background: var(--ih-dimension-bg);
color: var(--ih-dimension-text);
font-size: 11px;
line-height: 16px;
font-variant-numeric: tabular-nums;
}
.image-task-favorite.ant-btn,
.image-task-select.ant-checkbox-wrapper {
position: absolute;
top: 8px;
right: 8px;
z-index: 1;
display: grid;
place-items: center;
min-width: 34px;
height: 34px;
margin: 0;
border: 1px solid var(--border-subtle);
border-radius: 8px;
background: var(--surface-card);
color: var(--text-secondary);
}
.image-task-select.ant-checkbox-wrapper .ant-checkbox {
align-self: center;
}
.image-task-placeholder {
position: absolute;
inset: 0;
display: flex; display: flex;
gap: 8px; flex-direction: column;
flex-wrap: wrap; align-items: center;
} justify-content: center;
gap: 4px;
.action-buttons > * { padding: 8px;
transition: all 0.2s; color: var(--text-secondary);
}
.action-buttons > *:hover {
transform: translateY(-1px);
}
/* 空状态样式 */
.empty-state {
padding: 60px 20px;
text-align: center; text-align: center;
font-size: 11px;
line-height: 15px;
} }
/* 搜索框样式增强 */ .image-task-placeholder strong {
.search-input-enhanced { color: var(--text-primary);
transition: all 0.3s; font-size: 13px;
font-weight: 600;
} }
.search-input-enhanced:focus-within { .image-task-status-icon {
box-shadow: 0 0 0 2px rgba(var(--ui-color-primary-rgb), 0.2); display: grid;
flex-shrink: 0;
place-items: center;
width: 34px;
height: 34px;
margin-bottom: 2px;
border: 1px solid var(--border-subtle);
border-radius: 9px;
background: var(--surface-card);
color: var(--brand-accent);
} }
/* 标签组样式 */ .image-task-media[data-status='failed'] .image-task-status-icon {
.tag-group { color: var(--ih-status-error);
}
.image-task-media[data-status='success'] .image-task-status-icon {
color: var(--ih-status-warning);
}
.image-task-progress {
width: min(100%, 132px);
}
.image-task-error,
.image-task-prompt {
display: -webkit-box;
overflow: hidden;
overflow-wrap: anywhere;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.image-task-error {
max-width: 90%;
color: inherit;
text-decoration: underline;
text-underline-offset: 2px;
}
.image-task-error-detail {
max-width: min(70vw, 300px);
max-height: 200px;
overflow: auto;
overflow-wrap: anywhere;
white-space: pre-wrap;
}
.image-task-info {
display: flex; display: flex;
flex: 1;
flex-direction: column;
gap: 6px;
padding: 10px 3px 2px;
min-width: 0;
}
.image-task-prompt {
min-height: 40px;
font-size: 14px;
line-height: 20px;
font-weight: 600;
}
.image-task-meta {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px; gap: 8px;
flex-wrap: wrap; color: var(--text-secondary);
font-size: 11px;
line-height: 16px;
}
.image-task-meta time {
flex-shrink: 0;
font-variant-numeric: tabular-nums;
}
.image-task-model {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.image-task-actions {
display: flex;
gap: 6px;
margin-top: auto;
padding-top: 8px;
border-top: 1px solid var(--border-subtle);
}
.image-task-primary-action {
flex: 1;
min-width: 0;
}
.image-task-actions .ant-btn {
min-height: 30px;
}
.image-task-list button:focus-visible {
outline: 2px solid var(--brand-accent);
outline-offset: 1px;
}
.image-task-list .image-task-preview:focus-visible {
outline-offset: -3px;
} }
/* 响应式设计 */ @media (hover: hover) {
@media (max-width: 768px) { .image-task-card.ant-card:hover {
.task-card-content { border-color: var(--brand-accent);
flex-direction: column !important;
}
.image-preview-container {
width: 100% !important;
min-height: 200px !important;
}
.stat-cards-grid {
grid-template-columns: 1fr !important;
} }
} }
/* Badge 样式覆盖 - 修复默认蓝色圆形背景 */ @media (min-width: 1024px) {
.image-task-list .task-list-scrollable {
/* 历史标题区域的 Badge 特定样式 */ overflow: auto;
}
/* 图片生成页局部控件留白:避免搜索/筛选内容贴住玻璃卡片边框 */
.image-task-list .image-task-group-header {
margin-left: -4px;
margin-right: -4px;
border: 1px solid rgb(255 255 255 / 0.45);
border-radius: 14px;
box-shadow: 0 10px 26px rgb(15 23 42 / 0.06);
} }
.dark .image-task-list .image-task-group-header { @media (max-width: 599px) {
border-color: rgb(255 255 255 / 0.1); .image-history-toolbar {
box-shadow: 0 10px 26px rgb(0 0 0 / 0.24); padding: 12px;
} }
.image-history-tools {
/* ===== 触屏命中区兜底 ===== */ width: 100%;
@media (hover: none) { }
.image-history-tools .image-task-search {
flex: 1;
}
.image-task-model-filter,
.image-task-size-filter {
flex: 1 1 110px;
min-width: 0;
}
} }
@@ -1,3 +1,4 @@
import { Card, Checkbox } from 'antd';
import { GitCompare as ActionGitCompare } from '@/components/common/icons/ActionIcons'; import { GitCompare as ActionGitCompare } from '@/components/common/icons/ActionIcons';
import { import {
Rows as ActionRows, Rows as ActionRows,
@@ -6,8 +7,6 @@ import {
Star as ActionStar, Star as ActionStar,
RefreshCw as ActionRefreshCw, RefreshCw as ActionRefreshCw,
X as ActionX, X as ActionX,
Download as ActionDownload,
Copy as ActionCopy,
Eye as ActionEye, Eye as ActionEye,
MoreHorizontal as ActionMoreHorizontal, MoreHorizontal as ActionMoreHorizontal,
RotateCcw as ActionRotateCcw, RotateCcw as ActionRotateCcw,
@@ -33,9 +32,7 @@ import {
Download, Download,
Copy, Copy,
Search, Search,
CheckCircle2,
AlertCircle, AlertCircle,
Clock,
Image as ImageIcon, Image as ImageIcon,
CornerUpLeft, CornerUpLeft,
ImagePlus, ImagePlus,
@@ -49,7 +46,7 @@ import { showSuccess, showError, renderQuota } from '../../../../helpers';
import './ImageTaskList.css'; import './ImageTaskList.css';
import ImageCompareModal from './ImageCompareModal'; import ImageCompareModal from './ImageCompareModal';
const { Title, Text } = Typography; const { Text } = Typography;
// 持久化偏好 // 持久化偏好
const PREF_KEY = 'expCenter.imageGen.uiPrefs.v1'; const PREF_KEY = 'expCenter.imageGen.uiPrefs.v1';
@@ -337,31 +334,6 @@ const ImageTaskList = ({
return () => observer.disconnect(); return () => observer.disconnect();
}, [visibleCount, filteredTasks.length]); }, [visibleCount, filteredTasks.length]);
// 状态配置
const getStatusConfig = (status) => {
const configs = {
processing: {
color: 'brand',
bar: 'var(--brand-primary)',
text: t('生成中'),
icon: <Clock size={12} />,
},
success: {
color: 'green',
bar: '#10b981',
text: t('已完成'),
icon: <CheckCircle2 size={12} />,
},
failed: {
color: 'red',
bar: '#f43f5e',
text: t('失败'),
icon: <AlertCircle size={12} />,
},
};
return configs[status] || configs.processing;
};
// 时间格式化 // 时间格式化
const formatTime = (isoString) => { const formatTime = (isoString) => {
if (!isoString) return ''; if (!isoString) return '';
@@ -525,28 +497,23 @@ const ImageTaskList = ({
// 当前密度模式(控制卡片尺寸 + 信息密度) // 当前密度模式(控制卡片尺寸 + 信息密度)
const density = prefs.density; const density = prefs.density;
const cardMinWidth =
density === 'grid' ? 140 : density === 'compact' ? 180 : 240;
const STATUS_TABS = [ const STATUS_TABS = [
{ key: 'all', label: t('全部'), count: statistics.total, color: 'default' }, { key: 'all', label: t('全部'), count: statistics.total },
{ {
key: 'success', key: 'success',
label: t('已完成'), label: t('已完成'),
count: statistics.success, count: statistics.success,
color: 'green',
}, },
{ {
key: 'processing', key: 'processing',
label: t('生成中'), label: t('生成中'),
count: statistics.processing, count: statistics.processing,
color: 'brand',
}, },
{ {
key: 'failed', key: 'failed',
label: t('失败'), label: t('失败'),
count: statistics.failed, count: statistics.failed,
color: 'red',
}, },
]; ];
@@ -567,23 +534,14 @@ const ImageTaskList = ({
}; };
return ( return (
<div className='image-task-list h-full flex flex-col overflow-hidden rounded-[28px] border border-white/[0.55] bg-white/[0.38] shadow-[0_24px_80px_rgba(15,23,42,0.08)] backdrop-blur-2xl backdrop-saturate-150 dark:border-white/10 dark:bg-neutral-950/[0.38] dark:shadow-[0_24px_80px_rgba(0,0,0,0.32)]'> <section className='image-task-list' aria-labelledby='image-history-title'>
{/* 顶部:标题 + 状态徽标 tab + 操作 */} {/* 顶部:标题 + 状态徽标 tab + 操作 */}
<div <div className='image-history-toolbar'>
className='border-b border-white/[0.45] bg-white/25 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.035]'
style={{ padding: '12px 16px', flexShrink: 0 }}
>
{/* 第一行:状态 tabs + 操作 */} {/* 第一行:状态 tabs + 操作 */}
<div className='flex items-center justify-between gap-2 flex-wrap'> <div className='image-history-heading'>
<div className='flex items-center gap-2 flex-wrap'> <div className='image-history-title-row'>
<Title <h2 id='image-history-title'>{t('生成历史')}</h2>
heading={6} <div className='image-history-status'>
style={{ margin: 0 }}
className='text-gray-800 dark:text-gray-100 mr-1'
>
{t('生成历史')}
</Title>
<div className='flex items-center gap-1 rounded-2xl border border-white/50 bg-white/[0.35] p-0.5 backdrop-blur dark:border-white/10 dark:bg-white/[0.06]'>
{STATUS_TABS.map((tab) => { {STATUS_TABS.map((tab) => {
const active = filterStatus === tab.key; const active = filterStatus === tab.key;
return ( return (
@@ -592,45 +550,24 @@ const ImageTaskList = ({
type='button' type='button'
aria-pressed={active} aria-pressed={active}
onClick={() => setFilterStatus(tab.key)} onClick={() => setFilterStatus(tab.key)}
className={[ className='image-history-status-button'
'px-2.5 py-1 text-xs rounded-md transition-all flex items-center gap-1 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand',
active
? 'bg-white/80 dark:bg-white/10 text-brand-deep dark:text-brand-from shadow-sm font-medium'
: 'text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from',
].join(' ')}
> >
<span>{tab.label}</span> <span>{tab.label}</span>
<span <span className='image-history-count'>{tab.count}</span>
className={[
'text-[10px] rounded px-1',
active
? 'bg-brand/10 dark:bg-brand/15 text-brand-deep dark:text-brand-from'
: tab.color === 'red'
? 'bg-rose-50 dark:bg-rose-900/20 text-rose-500'
: tab.color === 'green'
? 'bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600'
: tab.color === 'brand'
? 'bg-brand/10 dark:bg-brand/15 text-brand-deep dark:text-brand-from'
: 'bg-gray-100 dark:bg-neutral-700 text-gray-500',
].join(' ')}
>
{tab.count}
</span>
</button> </button>
); );
})} })}
</div> </div>
</div> </div>
<div className='flex items-center gap-1.5'> <div className='image-history-tools'>
<Input <Input
prefix={<Search size={14} className='text-gray-400' />} prefix={<Search size={14} />}
placeholder={t('搜索...')} placeholder={t('搜索...')}
value={searchInput} value={searchInput}
onChange={setSearchInput} onChange={setSearchInput}
className='image-task-search !rounded-xl' aria-label={t('搜索...')}
size='small' className='image-task-search'
style={{ width: 168 }}
showClear showClear
/> />
@@ -671,9 +608,7 @@ const ImageTaskList = ({
<ActionLayoutGrid size={14} /> <ActionLayoutGrid size={14} />
) )
} }
size='small' theme='outline'
theme='borderless'
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
aria-label={t('切换显示密度')} aria-label={t('切换显示密度')}
title={t('切换显示密度')} title={t('切换显示密度')}
/> />
@@ -682,18 +617,12 @@ const ImageTaskList = ({
{/* 多选模式切换 */} {/* 多选模式切换 */}
<Button <Button
icon={<ActionGitCompare size={14} />} icon={<ActionGitCompare size={14} />}
size='small' theme={selectMode ? 'light' : 'outline'}
theme={selectMode ? 'light' : 'borderless'}
type={selectMode ? 'primary' : 'tertiary'} type={selectMode ? 'primary' : 'tertiary'}
onClick={() => { onClick={() => {
if (selectMode) exitSelectMode(); if (selectMode) exitSelectMode();
else setSelectMode(true); else setSelectMode(true);
}} }}
className={
selectMode
? ''
: '!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
}
aria-label={t('对比模式')} aria-label={t('对比模式')}
aria-pressed={selectMode} aria-pressed={selectMode}
title={t('对比模式')} title={t('对比模式')}
@@ -708,14 +637,8 @@ const ImageTaskList = ({
color={favOnly ? 'var(--brand-primary)' : 'currentColor'} color={favOnly ? 'var(--brand-primary)' : 'currentColor'}
/> />
} }
size='small' theme={favOnly ? 'light' : 'outline'}
theme='borderless'
onClick={() => setFavOnly((v) => !v)} onClick={() => setFavOnly((v) => !v)}
className={
favOnly
? '!text-brand-deep dark:!text-brand-from'
: '!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
}
aria-label={t('只看收藏')} aria-label={t('只看收藏')}
aria-pressed={favOnly} aria-pressed={favOnly}
title={t('只看收藏')} title={t('只看收藏')}
@@ -723,10 +646,8 @@ const ImageTaskList = ({
<Button <Button
icon={<ActionRefreshCw size={14} />} icon={<ActionRefreshCw size={14} />}
size='small' theme='outline'
theme='borderless'
onClick={() => onRefresh(true, false)} onClick={() => onRefresh(true, false)}
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
aria-label={t('刷新任务列表')} aria-label={t('刷新任务列表')}
title={t('刷新任务列表')} title={t('刷新任务列表')}
/> />
@@ -735,13 +656,12 @@ const ImageTaskList = ({
{/* 第二行:筛选 chips(仅在有可选/激活时显示) */} {/* 第二行:筛选 chips(仅在有可选/激活时显示) */}
{(modelOptions.length > 0 || sizeOptions.length > 0) && ( {(modelOptions.length > 0 || sizeOptions.length > 0) && (
<div className='flex items-center gap-1.5 flex-wrap mt-2'> <div className='image-history-filters'>
<Select <Select
value={modelFilter} value={modelFilter}
onChange={setModelFilter} onChange={setModelFilter}
size='small' className='image-task-model-filter'
style={{ width: 180 }} aria-label={t('模型')}
className='image-task-filter-select !rounded-xl'
placeholder={t('模型')} placeholder={t('模型')}
> >
<Select.Option value='all'>{t('全部模型')}</Select.Option> <Select.Option value='all'>{t('全部模型')}</Select.Option>
@@ -754,9 +674,8 @@ const ImageTaskList = ({
<Select <Select
value={sizeFilter} value={sizeFilter}
onChange={setSizeFilter} onChange={setSizeFilter}
size='small' className='image-task-size-filter'
style={{ width: 130 }} aria-label={t('尺寸')}
className='image-task-filter-select !rounded-xl'
placeholder={t('尺寸')} placeholder={t('尺寸')}
> >
<Select.Option value='all'>{t('全部尺寸')}</Select.Option> <Select.Option value='all'>{t('全部尺寸')}</Select.Option>
@@ -770,7 +689,7 @@ const ImageTaskList = ({
<button <button
type='button' type='button'
onClick={clearAllFilters} onClick={clearAllFilters}
className='app-action-button inline-flex items-center gap-1 rounded-full px-2 py-1 text-[11px] text-gray-400 hover:bg-brand/10 hover:text-brand-deep dark:hover:bg-brand/15 dark:hover:text-brand-from transition-colors' className='image-history-clear'
> >
<ActionX size={11} /> <ActionX size={11} />
{t('清除筛选')} {t('清除筛选')}
@@ -781,20 +700,17 @@ const ImageTaskList = ({
{/* 多选模式下的操作条 */} {/* 多选模式下的操作条 */}
{selectMode && ( {selectMode && (
<div className='flex items-center gap-2 mt-2 px-3 py-1.5 bg-brand/10 dark:bg-brand/15 rounded-xl'> <div className='image-history-compare'>
<Text <span>
size='small' {t('已选 {{n}} 张', { n: selectedIds.size })} · {t('最多 4 张')}
className='!text-brand-deep dark:!text-brand-from' </span>
>
{t('已选 {{n}} 张', { n: selectedIds.size })}{' '}
<span className='text-gray-400'>· {t('最多 4 张')}</span>
</Text>
<div className='flex-1' /> <div className='flex-1' />
<Button <Button
size='small' size='small'
type='primary' type='primary'
theme='solid' theme='solid'
icon={<ActionGitCompare size={12} />} icon={<ActionGitCompare size={12} />}
aria-label={t('对比')}
onClick={openCompare} onClick={openCompare}
disabled={selectedIds.size < 2} disabled={selectedIds.size < 2}
> >
@@ -808,26 +724,28 @@ const ImageTaskList = ({
</div> </div>
{/* 任务列表 */} {/* 任务列表 */}
<div <div className='task-list-scrollable app-scrollbar'>
className='task-list-scrollable app-scrollbar relative' <div className='image-history-content'>
style={{ flex: 1, overflowY: 'auto', overflowX: 'hidden' }}
>
<div style={{ padding: '16px' }}>
{filteredTasks.length === 0 ? ( {filteredTasks.length === 0 ? (
<div className='py-6'> <div className='py-6'>
<Empty <Empty
image={ image={
<IllustrationNoContent style={{ width: 150, height: 150 }} /> <IllustrationNoContent style={{ width: 150, height: 150 }} />
} }
title={
searchKeyword || hasActiveFilters
? t('未找到匹配的任务')
: t('开始你的第一张 AI 图')
}
description={ description={
searchKeyword || hasActiveFilters <span
className='image-history-empty-description'
role='status'
>
<strong>
{hasActiveFilters
? t('未找到匹配的任务')
: t('开始你的第一张 AI 图')}
</strong>
{hasActiveFilters
? t('请尝试调整搜索条件') ? t('请尝试调整搜索条件')
: t('描述你想要的画面,AI 会帮你生成') : t('描述你想要的画面,AI 会帮你生成')}
</span>
} }
/> />
{!searchKeyword && {!searchKeyword &&
@@ -861,29 +779,13 @@ const ImageTaskList = ({
<div className='space-y-4'> <div className='space-y-4'>
{groupedTasks.map((group) => ( {groupedTasks.map((group) => (
<div key={group.key}> <div key={group.key}>
<div <div className='image-task-group-header'>
className='image-task-group-header sticky top-0 z-10 bg-white/70 dark:bg-neutral-950/70 backdrop-blur-md px-3 py-1.5 mb-2 flex items-center gap-2' <h3>{group.label}</h3>
style={{ marginTop: '-4px' }} <span className='image-history-count'>
> {group.tasks.length}
<Text
strong
size='small'
className='!text-gray-600 dark:!text-gray-300'
>
{group.label}
</Text>
<span className='text-[10px] text-gray-400'>
({group.tasks.length})
</span> </span>
<div className='flex-1 h-px bg-gray-100 dark:bg-neutral-800' />
</div> </div>
<div <div className='image-task-grid' data-density={density}>
style={{
display: 'grid',
gridTemplateColumns: `repeat(auto-fill, minmax(${cardMinWidth}px, 1fr))`,
gap: density === 'grid' ? '8px' : '12px',
}}
>
{group.tasks.map((task) => renderTaskCard(task))} {group.tasks.map((task) => renderTaskCard(task))}
</div> </div>
</div> </div>
@@ -927,132 +829,74 @@ const ImageTaskList = ({
tasks={compareTasks} tasks={compareTasks}
onClose={() => setCompareOpen(false)} onClose={() => setCompareOpen(false)}
/> />
</div> </section>
); );
// ==================== 渲染任务卡 ==================== // ==================== 渲染任务卡 ====================
function renderTaskCard(task) { function renderTaskCard(task) {
const statusConfig = getStatusConfig(task.status);
const isFailed = task.status === 'failed'; const isFailed = task.status === 'failed';
const isSuccess = task.status === 'success'; const isSuccess = task.status === 'success';
const isProcessing = task.status === 'processing'; const isProcessing = task.status === 'processing';
const isFav = favorites.has(task.id); const isFav = favorites.has(task.id);
const isSelected = selectedIds.has(task.id); const isSelected = selectedIds.has(task.id);
const canSelect = selectMode && isSuccess && Boolean(task.imageUrl);
// 失败卡片视觉降级:整张红色调,图区变薄 const hasImage = isSuccess && task.imageUrl && !failedImageIds.has(task.id);
const failedClass = isFailed
? 'border-rose-200/70 dark:border-rose-900/40 bg-rose-50/[0.45] dark:bg-rose-900/10'
: 'border-white/60 dark:border-white/10 bg-white/[0.62] dark:bg-white/[0.06] backdrop-blur';
const selectedClass = isSelected
? 'ring-2 ring-brand ring-offset-1 dark:ring-offset-neutral-900'
: '';
const hoverBorderClass = isFailed
? 'hover:border-rose-300/80 dark:hover:border-rose-800/60'
: 'hover:border-brand/25';
// 图区高度:失败和紧凑统一 1:1;舒适模式按真实比例
const imageBoxStyle = isFailed
? { height: '64px' }
: density === 'comfortable' && task.width && task.height
? { aspectRatio: `${task.width} / ${task.height}` }
: { aspectRatio: '1 / 1' };
const cardClickable = selectMode && isSuccess && task.imageUrl;
return ( return (
<div <Card
key={task.id} key={task.id}
className={`image-task-card group relative rounded-2xl overflow-hidden border shadow-sm transition-all duration-200 hover:-translate-y-0.5 ${hoverBorderClass} hover:shadow-[0_18px_45px_rgba(15,23,42,0.12)] dark:hover:shadow-[0_18px_45px_rgba(0,0,0,0.35)] ${failedClass} ${selectedClass} ${cardClickable ? 'cursor-pointer' : ''}`} className='image-task-card'
onClick={ data-selected={isSelected}
cardClickable classNames={{ body: 'image-task-card-layout' }}
? (e) => {
e.stopPropagation();
toggleSelect(task.id);
}
: undefined
}
draggable={isSuccess && !!task.imageUrl && !selectMode} draggable={isSuccess && !!task.imageUrl && !selectMode}
onDragStart={(e) => handleDragStart(e, task)} onDragStart={(event) => handleDragStart(event, task)}
> >
{/* 左侧状态彩色条 */} <div className='image-task-media' data-status={task.status}>
<div {isSuccess && !selectMode && (
className='absolute left-0 top-0 bottom-0' <Button
style={{ className='image-task-favorite'
width: '3px', theme='outline'
backgroundColor: statusConfig.bar, size='small'
...(isProcessing icon={
? { <ActionStar size={15} fill={isFav ? 'currentColor' : 'none'} />
backgroundImage:
'linear-gradient(180deg, var(--brand-gradient-from), var(--brand-primary), var(--brand-gradient-from))',
backgroundSize: '100% 200%',
animation: 'brandShimmer 1.5s linear infinite',
} }
: {}), onClick={() => toggleFavorite(task.id)}
}} aria-label={isFav ? t('取消收藏') : t('收藏')}
aria-pressed={isFav}
title={isFav ? t('取消收藏') : t('收藏')}
/> />
)}
{/* 收藏按钮 - 右上 */} {canSelect && (
{isSuccess && ( <Checkbox
className='image-task-select'
checked={isSelected}
aria-label={`${t('对比')}:${task.prompt || task.model || task.id}`}
onChange={() => toggleSelect(task.id)}
/>
)}
{hasImage ? (
<button <button
type='button' type='button'
onClick={(e) => { className='image-task-preview'
e.stopPropagation(); aria-label={selectMode ? t('对比') : t('预览')}
toggleFavorite(task.id); aria-pressed={selectMode ? isSelected : undefined}
onClick={() => {
if (selectMode) {
toggleSelect(task.id);
return;
}
setPreviewImageUrl(task.imageUrl);
setPreviewTaskId(task.id);
setPreviewVisible(true);
}} }}
className={[
'app-action-button',
[
'absolute top-1.5 left-2 z-10 w-6 h-6 rounded-full flex items-center justify-center transition-all',
isFav
? 'bg-brand text-white shadow-md shadow-brand/30'
: 'bg-black/40 text-white/80 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100 hover:bg-brand',
].join(' '),
]
.filter(Boolean)
.join(' ')}
title={isFav ? t('取消收藏') : t('收藏')}
> >
<ActionStar size={11} fill={isFav ? 'white' : 'none'} />
</button>
)}
{/* 多选 checkbox */}
{selectMode && isSuccess && (
<div
className={[
'absolute top-1.5 right-1.5 z-10 w-5 h-5 rounded-full border-2 flex items-center justify-center transition-all',
isSelected
? 'bg-brand border-brand text-white'
: 'bg-white/80 border-gray-300',
].join(' ')}
>
{isSelected && (
<CheckCircle2 size={10} strokeWidth={3} color='white' />
)}
</div>
)}
{/* 图区 */}
<div
className='relative overflow-hidden bg-gray-50 dark:bg-neutral-800'
style={imageBoxStyle}
>
{isSuccess && task.imageUrl && !failedImageIds.has(task.id) ? (
<>
<img <img
// 关键:key 含 imageUrl,URL 变化时强制重新挂载 → 浏览器重新发起加载(不会沿用旧的 error 状态) // 关键:key 含 imageUrl,URL 变化时强制重新挂载 → 浏览器重新发起加载(不会沿用旧的 error 状态)
key={task.imageUrl} key={task.imageUrl}
src={task.imageUrl} src={task.imageUrl}
alt='' alt=''
className='w-full h-full object-cover transition-transform duration-300 group-hover:scale-105'
loading='lazy' loading='lazy'
onClick={() => { draggable={false}
if (selectMode) return;
setPreviewImageUrl(task.imageUrl);
setPreviewTaskId(task.id);
setPreviewVisible(true);
}}
onError={async () => { onError={async () => {
// COS 预签名 URL 过期 → 自动调一次 refresh-url;仍失败 → 标记永久占位 // COS 预签名 URL 过期 → 自动调一次 refresh-url;仍失败 → 标记永久占位
const id = task.id; const id = task.id;
@@ -1075,161 +919,62 @@ const ImageTaskList = ({
}} }}
/> />
{/* 尺寸角标(多选模式下让位给 checkbox) */} {!selectMode && task.width > 0 && task.height > 0 && (
{!selectMode && ( <span className='image-task-dimensions'>
<div className='absolute top-1.5 right-1.5 px-1.5 py-0.5 bg-black/50 rounded text-[10px] text-white'>
{task.width}×{task.height} {task.width}×{task.height}
</div> </span>
)} )}
{/* hover 浮层快捷动作 —— 容器 pointer-events:none 让渐变区点击穿透到 img(保留点图预览),
按钮单独 pointer-events:auto 恢复可点击 */}
{!selectMode && (
<div
className='absolute inset-x-0 bottom-0 px-2 py-2 bg-gradient-to-t from-black/80 via-black/40 to-transparent opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100 transition-opacity flex items-center justify-center gap-1'
style={{ pointerEvents: 'none' }}
>
<button
type='button'
style={{ pointerEvents: 'auto' }}
onClick={(e) => {
e.stopPropagation();
handleDownload(task);
}}
className='app-action-button w-7 h-7 rounded-full bg-white/15 hover:bg-brand backdrop-blur-sm flex items-center justify-center text-white transition-colors'
title={t('下载')}
>
<ActionDownload size={13} />
</button> </button>
<button
type='button'
style={{ pointerEvents: 'auto' }}
onClick={(e) => {
e.stopPropagation();
handleCopyPrompt(task.prompt);
}}
className='app-action-button w-7 h-7 rounded-full bg-white/15 hover:bg-brand backdrop-blur-sm flex items-center justify-center text-white transition-colors'
title={t('复制提示词')}
>
<ActionCopy size={13} />
</button>
{onUseAsReference && (
<button
type='button'
style={{ pointerEvents: 'auto' }}
onClick={(e) => {
e.stopPropagation();
onUseAsReference(task);
}}
className='app-action-button w-7 h-7 rounded-full bg-white/15 hover:bg-brand backdrop-blur-sm flex items-center justify-center text-white transition-colors'
title={t('用作参考图')}
>
<ImagePlus size={13} />
</button>
)}
<button
type='button'
style={{ pointerEvents: 'auto' }}
onClick={(e) => {
e.stopPropagation();
onViewDetail(task);
}}
className='app-action-button w-7 h-7 rounded-full bg-white/15 hover:bg-brand backdrop-blur-sm flex items-center justify-center text-white transition-colors'
title={t('详情')}
>
<ActionEye size={13} />
</button>
</div>
)}
</>
) : isSuccess && task.imageUrl && failedImageIds.has(task.id) ? (
// 自动刷新尝试过仍失败 → 失败占位(用户可点菜单"刷新链接"重试)
<div className='flex flex-col items-center justify-center h-full px-2 text-center'>
<AlertCircle size={18} className='text-amber-500 mb-1' />
<Text type='tertiary' className='!text-[10px]'>
{t('图片加载失败')}
</Text>
<Text
type='tertiary'
className='!text-[9px] !text-gray-400 mt-0.5'
>
{t('从菜单点"刷新链接"重试')}
</Text>
</div>
) : isSuccess && !task.imageUrl ? (
<div className='flex flex-col items-center justify-center h-full'>
<AlertCircle size={18} className='text-amber-400 mb-0.5' />
<Text type='tertiary' className='!text-[10px]'>
{t('链接已失效')}
</Text>
</div>
) : isProcessing ? (
<div className='flex flex-col items-center justify-center h-full'>
<div className='w-7 h-7 rounded-full border-2 border-gray-200 border-t-brand animate-spin mb-1' />
<Text type='tertiary' className='!text-[10px]'>
{t('生成中')}
</Text>
</div>
) : isFailed ? (
<div className='flex items-center justify-center h-full gap-1.5'>
<AlertCircle size={14} className='text-rose-500' />
<Text className='!text-[11px] !text-rose-700 dark:!text-rose-300'>
{t('失败')}
</Text>
</div>
) : ( ) : (
<div className='flex flex-col items-center justify-center h-full'> <div className='image-task-placeholder'>
<ImageIcon size={18} className='text-gray-300 mb-0.5' /> <span className='image-task-status-icon' aria-hidden='true'>
<Text type='tertiary' className='!text-[10px]'> {isFailed || isSuccess ? (
{t('等待中')} <AlertCircle size={21} />
</Text> ) : (
</div> <ImageIcon size={21} />
)} )}
</span>
<strong>
{isFailed
? t('失败')
: isSuccess
? t(task.imageUrl ? '图片加载失败' : '链接已失效')
: isProcessing
? t('生成中')
: t('等待中')}
</strong>
{isSuccess && task.imageUrl && (
<span>{t('从菜单点"刷新链接"重试')}</span>
)}
{isFailed && task.errorMessage && (
<Popover
content={
<div className='image-task-error-detail'>
{task.errorMessage}
</div> </div>
}
{/* 底部信息(紧凑/网格模式下省略部分内容) */} trigger='click'
<div position='top'
className='flex flex-col' showArrow
style={{ padding: density === 'grid' ? '6px 8px' : '8px 10px' }}
> >
{/* 时间 + 收藏 */} <button
{density !== 'grid' && ( type='button'
<div className='flex items-center justify-between mb-1'> className='image-task-error'
<Text type='tertiary' className='!text-[10px]'> title={t('点击查看完整错误')}
{formatTime(task.createdAt)}
</Text>
{task.model && (
<Text
type='tertiary'
className='!text-[10px] truncate ml-2 max-w-[60%]'
title={task.model}
> >
{task.model} {task.errorMessage}
</Text> </button>
</Popover>
)} )}
</div> {isFailed && task.refundedQuota > 0 && (
<span>
{t('已退还 {{amount}}', {
amount: renderQuota(task.refundedQuota),
})}
</span>
)} )}
{/* Prompt 预览 */}
{density === 'comfortable' && task.prompt && (
<div
className='text-[11px] text-gray-600 dark:text-gray-300 leading-snug mb-1.5'
style={{
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
wordBreak: 'break-word',
}}
title={task.prompt}
>
{task.prompt}
</div>
)}
{/* 处理中进度条 */}
{isProcessing && ( {isProcessing && (
<div className='mb-1.5'> <div className='image-task-progress'>
<Progress <Progress
percent={parseInt(task.progress) || 0} percent={parseInt(task.progress) || 0}
size='small' size='small'
@@ -1238,64 +983,33 @@ const ImageTaskList = ({
/> />
</div> </div>
)} )}
{/* 失败错误简介 */}
{isFailed && task.errorMessage && (
<Popover
content={
<div
style={{ maxWidth: 300, maxHeight: 200, overflow: 'auto' }}
>
<Text
size='small'
style={{ wordBreak: 'break-word', whiteSpace: 'pre-wrap' }}
>
{task.errorMessage}
</Text>
</div>
}
trigger='click'
position='top'
showArrow
>
<div
className='text-[10px] text-rose-700 dark:text-rose-300 leading-snug mb-1.5 cursor-pointer hover:underline'
style={{
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
wordBreak: 'break-word',
}}
title={t('点击查看完整错误')}
>
{task.errorMessage}
</div>
</Popover>
)}
{/* 失败退款:按任务实际退还额度展示(不写死"不扣费") */}
{isFailed && task.refundedQuota > 0 && (
<div className='text-[10px] text-gray-500 dark:text-gray-400 leading-snug mb-1.5 tabular-nums'>
{t('已退还 {{amount}}', {
amount: renderQuota(task.refundedQuota),
})}
</div> </div>
)} )}
</div>
{/* 操作按钮 */} <div className='image-task-info'>
{density !== 'grid' && ( {density === 'comfortable' && (
<div className='flex gap-1 mt-auto pt-1 border-t border-gray-100 dark:border-neutral-800'> <strong className='image-task-prompt' title={task.prompt}>
{task.prompt || task.model}
</strong>
)}
<div className='image-task-meta'>
<span className='image-task-model' title={task.model}>
{task.model}
</span>
<time dateTime={task.createdAt}>{formatTime(task.createdAt)}</time>
</div>
<div className='image-task-actions'>
{isSuccess && ( {isSuccess && (
<> <>
<Button <Button
icon={<ActionEye size={11} />} icon={<ActionEye size={11} />}
size='small' size='small'
className='flex-1 !rounded-md !text-[10px]' className='image-task-primary-action'
style={{ height: '24px' }} aria-label={t('查看')}
onClick={() => onViewDetail(task)} onClick={() => onViewDetail(task)}
> >
{density === 'comfortable' ? t('查看') : ''} {t('查看')}
</Button> </Button>
<Dropdown <Dropdown
trigger='click' trigger='click'
@@ -1359,12 +1073,8 @@ const ImageTaskList = ({
<Button <Button
icon={<ActionMoreHorizontal size={11} />} icon={<ActionMoreHorizontal size={11} />}
size='small' size='small'
className='!rounded-md' aria-label={t('更多操作')}
style={{ title={t('更多操作')}
height: '24px',
width: '24px',
minWidth: '24px',
}}
/> />
</Dropdown> </Dropdown>
</> </>
@@ -1374,17 +1084,17 @@ const ImageTaskList = ({
<Button <Button
icon={<ActionRotateCcw size={11} />} icon={<ActionRotateCcw size={11} />}
size='small' size='small'
className='flex-1 !rounded-md !text-[10px]' className='image-task-primary-action'
style={{ height: '24px' }} aria-label={t('重试')}
onClick={() => onRetry(task.id)} onClick={() => onRetry(task.id)}
> >
{density === 'comfortable' ? t('重试') : ''} {t('重试')}
</Button> </Button>
<Button <Button
icon={<ActionTrash2 size={11} />} icon={<ActionTrash2 size={11} />}
size='small' size='small'
className='!rounded-md' aria-label={t('删除')}
style={{ height: '24px', width: '24px', minWidth: '24px' }} title={t('删除')}
onClick={() => { onClick={() => {
if (window.confirm(t('确定要删除这个任务吗?'))) if (window.confirm(t('确定要删除这个任务吗?')))
onDelete(task.id); onDelete(task.id);
@@ -1396,20 +1106,19 @@ const ImageTaskList = ({
<Button <Button
icon={<ActionTrash2 size={11} />} icon={<ActionTrash2 size={11} />}
size='small' size='small'
className='w-full !rounded-md !text-[10px]' className='image-task-primary-action'
style={{ height: '24px' }} aria-label={t('取消')}
onClick={() => { onClick={() => {
if (window.confirm(t('确定要取消这个任务吗?'))) if (window.confirm(t('确定要取消这个任务吗?')))
onDelete(task.id); onDelete(task.id);
}} }}
> >
{density === 'comfortable' ? t('取消') : ''} {t('取消')}
</Button> </Button>
)} )}
</div> </div>
)}
</div>
</div> </div>
</Card>
); );
} }
}; };
@@ -7,17 +7,21 @@
--vip-muted: var(--text-secondary); --vip-muted: var(--text-secondary);
--vip-line: var(--border-subtle); --vip-line: var(--border-subtle);
--vip-surface: var(--surface-card); --vip-surface: var(--surface-card);
--vip-accent: var(--ui-color-primary); --vip-accent: var(--brand-accent);
--vip-tint: color-mix(in srgb, var(--ui-color-primary) 10%, transparent); --vip-tint: var(--brand-selection-bg);
--vip-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card)); --vip-fill: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
--vip-danger: var(--ui-color-danger); --vip-danger: var(--ui-color-danger);
--vip-warning: var(--ui-color-warning); --vip-warning: var(--ui-color-warning);
--vip-ring: color-mix(in srgb, var(--ui-color-primary) 55%, transparent); --vip-ring: var(--brand-accent);
position: relative; display: flex;
height: 100%; flex-direction: column;
overflow: auto; width: 100%;
padding: 16px; max-height: 100%;
min-height: 0;
border: 1px solid var(--vip-line);
border-radius: 12px;
background: var(--vip-surface);
} }
.video-input-panel button:focus-visible, .video-input-panel button:focus-visible,
@@ -26,36 +30,35 @@
outline-offset: 2px; outline-offset: 2px;
} }
.vip-collapse-row { .vip-fields {
display: flex; flex: 1;
justify-content: flex-end; min-height: 0;
margin-bottom: 12px; padding: 12px;
overflow: auto;
scrollbar-width: thin;
} }
.vip-collapse-btn { .vip-fields:not([hidden]) {
color: var(--vip-accent) !important; display: grid;
align-content: start;
grid-auto-rows: max-content;
gap: 12px;
} }
.vip-expand-fab { .vip-fields[hidden] {
position: fixed; display: none;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: 100;
} }
.vip-expand-fab .ant-btn { .vip-prompt textarea::placeholder,
border-top-left-radius: 0; textarea.vip-prompt::placeholder {
border-bottom-left-radius: 0; color: var(--vip-muted);
color: var(--ui-color-primary);
} }
.vip-card { .vip-card {
margin-bottom: 12px; padding: 12px;
padding: 14px 16px;
border: 1px solid var(--vip-line); border: 1px solid var(--vip-line);
border-radius: 12px; border-radius: 10px;
background: var(--vip-surface); background: var(--vip-fill);
min-width: 0; min-width: 0;
} }
@@ -79,7 +82,7 @@
height: 26px; height: 26px;
border-radius: 8px; border-radius: 8px;
background: var(--vip-tint); background: var(--vip-tint);
color: var(--vip-accent); color: var(--brand-selection-text);
} }
.vip-card-extra { .vip-card-extra {
@@ -158,6 +161,13 @@
color: var(--vip-danger); color: var(--vip-danger);
} }
.video-input-panel .cp-option-group {
--cp-accent: var(--brand-selection-text);
--cp-accent-tint: var(--brand-selection-bg);
--cp-accent-line: color-mix(in srgb, var(--brand-accent) 45%, transparent);
--cp-ring: var(--brand-accent);
}
.vip-mode-option { .vip-mode-option {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -198,8 +208,8 @@
.vip-advanced { .vip-advanced {
border: 1px solid var(--vip-line); border: 1px solid var(--vip-line);
border-radius: 12px; border-radius: 10px;
background: var(--vip-surface); background: var(--vip-fill);
overflow: hidden; overflow: hidden;
} }
@@ -1,8 +1,8 @@
import { import {
ChevronRight as ActionChevronRight, ChevronDown as ActionChevronDown,
ChevronLeft as ActionChevronLeft, ChevronUp as ActionChevronUp,
} from '@/components/common/icons/ActionIcons'; } from '@/components/common/icons/ActionIcons';
import React from 'react'; import React, { useId } from 'react';
import { import {
Button, Button,
Collapse, Collapse,
@@ -76,13 +76,9 @@ const formatModelPrice = (t, model, resolution) => {
return unit ? `${amount}${t(unit)}` : amount; return unit ? `${amount}${t(unit)}` : amount;
}; };
const VideoInputPanel = ({ const VideoInputPanel = ({ creation, onCollapse, collapsed, scrollRef }) => {
creation,
onCollapse,
collapsed,
collapsible = true,
}) => {
const { t } = useTranslation(); const { t } = useTranslation();
const fieldsId = useId();
const { const {
formData, formData,
setFormData, setFormData,
@@ -109,20 +105,6 @@ const VideoInputPanel = ({
setFormData((prev) => ({ ...prev, [field]: value })); setFormData((prev) => ({ ...prev, [field]: value }));
}; };
// 单列(手机)布局不提供折叠:没有相邻面板可以让位,收起只会留下一片空白,
// 而唯一的恢复入口是一个浮在屏幕左侧垂直中央的裸箭头。
if (collapsed && collapsible) {
return (
<div className='vip-expand-fab'>
<Button
icon={<ActionChevronRight size={20} />}
onClick={onCollapse}
aria-label={t('展开')}
/>
</div>
);
}
const advancedParams = visibleParams.filter( const advancedParams = visibleParams.filter(
(p) => p.placement === 'advanced', (p) => p.placement === 'advanced',
); );
@@ -248,20 +230,34 @@ const VideoInputPanel = ({
entry.labelIndex ? `${t(entry.label)} ${entry.labelIndex}` : t(entry.label); entry.labelIndex ? `${t(entry.label)} ${entry.labelIndex}` : t(entry.label);
return ( return (
<div className='video-input-panel'> <section className='video-input-panel'>
{collapsible && ( <header className='video-panel-header'>
<div className='vip-collapse-row'> <div className='video-panel-heading'>
<SlidersHorizontal size={17} aria-hidden='true' />
<h2>{t('参数设置')}</h2>
</div>
<Button <Button
icon={<ActionChevronLeft size={18} />} icon={
collapsed ? (
<ActionChevronDown size={16} />
) : (
<ActionChevronUp size={16} />
)
}
onClick={onCollapse} onClick={onCollapse}
size='small' size='small'
type='tertiary' type='tertiary'
className='vip-collapse-btn' aria-label={collapsed ? t('展开创作台') : t('收起创作台')}
aria-label={t('收起')} aria-expanded={!collapsed}
aria-controls={fieldsId}
/> />
</div> </header>
)} <div
id={fieldsId}
hidden={collapsed}
ref={scrollRef}
className='vip-fields app-scrollbar'
>
<Section icon={Wand2} title={t('选择模型')}> <Section icon={Wand2} title={t('选择模型')}>
{renderModelSection()} {renderModelSection()}
</Section> </Section>
@@ -336,7 +332,8 @@ const VideoInputPanel = ({
} }
onClearSelection={clearPortraitAsset} onClearSelection={clearPortraitAsset}
/> />
{formData.images?.first_frame?.identityType === 'real_person' ? ( {formData.images?.first_frame?.identityType ===
'real_person' ? (
<Tag color='green' size='small'> <Tag color='green' size='small'>
{t('真人人像')} {t('真人人像')}
</Tag> </Tag>
@@ -348,8 +345,9 @@ const VideoInputPanel = ({
<Section icon={Sparkles} title={t('场景模板')}> <Section icon={Sparkles} title={t('场景模板')}>
<Select <Select
aria-label={t('场景模板')}
placeholder={t('选择场景模板(可选)')} placeholder={t('选择场景模板(可选)')}
value={formData.selectedTemplate} value={formData.selectedTemplate || undefined}
onChange={(value) => updateField('selectedTemplate', value)} onChange={(value) => updateField('selectedTemplate', value)}
style={{ width: '100%' }} style={{ width: '100%' }}
showClear showClear
@@ -371,6 +369,7 @@ const VideoInputPanel = ({
<Section icon={Video} title={t('提示词')}> <Section icon={Video} title={t('提示词')}>
<TextArea <TextArea
aria-label={t('提示词')}
placeholder={t( placeholder={t(
'描述你想要生成的视频内容,例如:一只可爱的猫咪在草地上玩耍', '描述你想要生成的视频内容,例如:一只可爱的猫咪在草地上玩耍',
)} )}
@@ -379,6 +378,7 @@ const VideoInputPanel = ({
autosize={{ minRows: 4, maxRows: 8 }} autosize={{ minRows: 4, maxRows: 8 }}
maxLength={2000} maxLength={2000}
showClear showClear
className='vip-prompt'
/> />
<Text type='tertiary' size='small' className='vip-counter'> <Text type='tertiary' size='small' className='vip-counter'>
{formData.prompt?.length || 0} / 2000 {formData.prompt?.length || 0} / 2000
@@ -423,6 +423,7 @@ const VideoInputPanel = ({
</div> </div>
) : null} ) : null}
</div> </div>
</section>
); );
}; };
@@ -1,66 +1,107 @@
/* 视频预览面板 - 电影感动画背景(增强版) */ .video-preview-panel.ant-card {
display: flex;
/* 动态光晕1 - 缓慢飘动 */ flex-direction: column;
@keyframes videoPreviewFloat1 { min-width: 0;
0%, min-height: 0;
100% { border-color: var(--border-subtle);
transform: translate3d(0, 0, 0); border-radius: 12px;
} background: var(--surface-card);
25% {
transform: translate3d(50px, -30px, 0);
}
50% {
transform: translate3d(80px, 20px, 0);
}
75% {
transform: translate3d(30px, 50px, 0);
}
} }
/* 动态光晕2 - 反向飘动 */ .video-preview-panel > .ant-card-body {
@keyframes videoPreviewFloat2 { display: flex;
0%, flex: 1;
100% { flex-direction: column;
transform: translate3d(0, 0, 0); min-width: 0;
} min-height: 0;
25% { padding: 0;
transform: translate3d(-60px, 40px, 0);
}
50% {
transform: translate3d(-30px, -50px, 0);
}
75% {
transform: translate3d(-70px, -20px, 0);
}
} }
/* 脉动效果 */ .video-preview-header {
@keyframes videoPreviewPulse { flex-wrap: wrap;
0%, }
100% {
opacity: 0.4; .video-preview-actions {
transform: scale(1); display: flex;
flex: 1;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 8px 12px;
min-width: 0;
}
.video-preview-actions .ant-typography {
overflow-wrap: anywhere;
}
.video-generate-button {
font-weight: 600;
}
.video-preview-stage {
flex: 1;
min-height: 0;
overflow: auto;
border-end-start-radius: 11px;
border-end-end-radius: 11px;
}
.video-preview-empty {
--vp-stage: color-mix(in srgb, var(--text-primary) 4%, var(--surface-card));
display: grid;
align-content: center;
justify-items: center;
gap: 10px;
height: calc(100% - 32px);
min-height: 180px;
margin: 16px;
padding: 24px;
border: 1px dashed var(--border-subtle);
border-radius: 10px;
background: var(--vp-stage);
text-align: center;
}
.video-preview-empty-icon {
width: 56px;
height: 56px;
margin-bottom: 4px;
}
.video-preview-empty h3 {
margin: 0;
color: var(--text-primary);
font-size: 18px;
font-weight: 650;
}
.video-preview-empty p {
margin: 0;
color: var(--text-secondary);
font-size: 13px;
line-height: 20px;
}
@media (max-width: 767px) {
.video-preview-header {
align-items: flex-start;
flex-direction: column;
} }
50% {
opacity: 1; .video-preview-actions {
transform: scale(1.1); justify-content: flex-start;
width: 100%;
}
.video-help-button {
margin-inline-start: auto;
}
.video-preview-empty {
height: auto;
min-height: 190px;
margin: 12px;
padding: 16px;
} }
} }
/* 动画类 - GPU 加速 */
.video-preview-glow1 {
animation: videoPreviewFloat1 12s ease-in-out infinite;
will-change: transform;
backface-visibility: hidden;
}
.video-preview-glow2 {
animation: videoPreviewFloat2 15s ease-in-out infinite;
will-change: transform;
backface-visibility: hidden;
}
.video-preview-glow3 {
animation: videoPreviewPulse 6s ease-in-out infinite;
will-change: opacity, transform;
}
@@ -91,7 +91,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '600px', videoMaxHeight: '600px',
buttonSize: 'large', buttonSize: 'large',
titleSize: 4, titleSize: 4,
iconSize: 64,
progressWidth: 120, progressWidth: 120,
}; };
} }
@@ -102,7 +101,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '500px', videoMaxHeight: '500px',
buttonSize: 'default', buttonSize: 'default',
titleSize: 5, titleSize: 5,
iconSize: 56,
progressWidth: 100, progressWidth: 100,
}; };
} }
@@ -113,7 +111,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '400px', videoMaxHeight: '400px',
buttonSize: 'default', buttonSize: 'default',
titleSize: 5, titleSize: 5,
iconSize: 48,
progressWidth: 90, progressWidth: 90,
}; };
} }
@@ -124,7 +121,6 @@ const VideoPreviewPanel = ({
videoMaxHeight: '350px', videoMaxHeight: '350px',
buttonSize: 'small', buttonSize: 'small',
titleSize: 6, titleSize: 6,
iconSize: 40,
progressWidth: 80, progressWidth: 80,
}; };
}; };
@@ -241,28 +237,8 @@ const VideoPreviewPanel = ({
const renderTopBar = () => { const renderTopBar = () => {
// 优先显示从任务列表选择的任务 // 优先显示从任务列表选择的任务
const displayTask = selectedTaskForPlay || currentTask; const displayTask = selectedTaskForPlay || currentTask;
const normalizedStatus = normalizeVideoTaskStatus(displayTask?.status);
const isCompleted = normalizedStatus === 'success';
// 检查是否有视频URL
let _hasVideo = false;
if (displayTask) {
const videoUrl = getVideoURLFromDetail(displayTask);
_hasVideo = isCompleted && !!videoUrl;
}
return ( return (
<div <div className='video-preview-actions'>
style={{
padding: windowWidth > 768 ? '16px 20px' : '12px 16px',
display: 'flex',
alignItems: 'center',
gap: '12px',
backgroundColor: 'var(--ui-color-bg-1)',
borderBottom: '1px solid var(--ui-color-border)',
flexShrink: 0,
}}
>
{needTopUp ? ( {needTopUp ? (
<Button <Button
type='warning' type='warning'
@@ -283,14 +259,7 @@ const VideoPreviewPanel = ({
onClick={isButtonDisabled ? undefined : handleGenerate} onClick={isButtonDisabled ? undefined : handleGenerate}
disabled={isButtonDisabled || submitting} disabled={isButtonDisabled || submitting}
loading={submitting} loading={submitting}
style={{ className='video-generate-button'
fontWeight: 600,
background:
isButtonDisabled || submitting
? undefined
: 'linear-gradient(135deg, var(--ui-color-primary) 0%, var(--ui-color-primary-active, var(--ui-color-primary)) 100%)',
border: 'none',
}}
> >
{submitting {submitting
? t('提交中...') ? t('提交中...')
@@ -344,8 +313,6 @@ const VideoPreviewPanel = ({
</Text> </Text>
)} )}
<div style={{ flex: 1 }} />
<Tooltip <Tooltip
content={ content={
<div style={{ padding: '12px', maxWidth: '300px' }}> <div style={{ padding: '12px', maxWidth: '300px' }}>
@@ -368,11 +335,13 @@ const VideoPreviewPanel = ({
</div> </div>
} }
position='bottomRight' position='bottomRight'
trigger='hover' trigger={['hover', 'focus']}
showArrow={true} showArrow={true}
> >
<Button <Button
icon={<ActionHelpCircle size={18} />} icon={<ActionHelpCircle size={18} />}
className='video-help-button'
aria-label={t('使用提示')}
type='tertiary' type='tertiary'
size={windowWidth > 768 ? 'default' : 'small'} size={windowWidth > 768 ? 'default' : 'small'}
/> />
@@ -702,199 +671,31 @@ const VideoPreviewPanel = ({
); );
} }
// 默认空状态 - 纯CSS电影感动画背景(无网络资源消耗)
return ( return (
<div <div className='video-preview-empty'>
style={{ <span className='video-preview-empty-icon' aria-hidden='true'>
display: 'flex', <Film size={28} />
flexDirection: 'column', </span>
minHeight: config.minHeight, <h3>{t('AI 视频生成')}</h3>
height: '100%', <p>
position: 'relative',
borderRadius: '12px',
overflow: 'hidden',
margin: '16px',
background:
'linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%)',
}}
>
{/* CSS动画背景 - 流动光效(增强版) */}
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
overflow: 'hidden',
pointerEvents: 'none',
}}
>
{/* 动态光晕1 - 紫色 */}
<div
className='video-preview-glow1'
style={{
position: 'absolute',
width: '60%',
height: '60%',
top: '10%',
left: '5%',
background:
'radial-gradient(ellipse at center, color-mix(in srgb, var(--brand-gradient-via) 35%, transparent) 0%, color-mix(in srgb, var(--brand-gradient-via) 10%, transparent) 40%, transparent 70%)',
borderRadius: '50%',
filter: 'blur(40px)',
}}
/>
{/* 动态光晕2 - 橙红色 */}
<div
className='video-preview-glow2'
style={{
position: 'absolute',
width: '50%',
height: '50%',
bottom: '10%',
right: '5%',
background:
'radial-gradient(ellipse at center, rgba(251, 146, 60, 0.3) 0%, rgba(251, 146, 60, 0.1) 40%, transparent 70%)',
borderRadius: '50%',
filter: 'blur(40px)',
}}
/>
{/* 动态光晕3 - 金色中心 */}
<div
className='video-preview-glow3'
style={{
position: 'absolute',
width: '40%',
height: '40%',
top: '30%',
left: '30%',
background:
'radial-gradient(ellipse at center, rgba(251, 191, 36, 0.25) 0%, transparent 60%)',
borderRadius: '50%',
filter: 'blur(30px)',
}}
/>
</div>
{/* 电影宽银幕效果 - 上下黑边 */}
<div
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
height: '6%',
background:
'linear-gradient(180deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
zIndex: 2,
}}
/>
<div
style={{
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
height: '6%',
background:
'linear-gradient(0deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
zIndex: 2,
}}
/>
{/* 中央内容区域 */}
<div
style={{
flex: 1,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: config.padding,
color: 'white',
position: 'relative',
zIndex: 3,
}}
>
<div
style={{
backgroundColor: 'rgba(255, 255, 255, 0.1)',
borderRadius: '50%',
padding: windowWidth > 1024 ? '32px' : '24px',
marginBottom: windowWidth > 768 ? '32px' : '24px',
border: '1px solid rgba(255, 255, 255, 0.2)',
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.3)',
transition: 'transform 0.3s ease',
}}
onMouseEnter={(e) => {
e.currentTarget.style.transform = 'scale(1.05)';
}}
onMouseLeave={(e) => {
e.currentTarget.style.transform = 'scale(1)';
}}
>
<Film
size={config.iconSize}
style={{
color: 'rgba(255, 220, 180, 0.9)',
filter: 'drop-shadow(0 2px 12px rgba(255,200,150,0.4))',
}}
/>
</div>
<Title
heading={config.titleSize}
style={{
marginBottom: '12px',
color: 'rgba(255, 250, 245, 0.95)',
fontWeight: 700,
textShadow: '0 4px 20px rgba(0, 0, 0, 0.6)',
letterSpacing: '3px',
}}
>
{t('AI 视频生成')}
</Title>
<Text
style={{
marginBottom: windowWidth > 768 ? '24px' : '16px',
textAlign: 'center',
fontSize: windowWidth > 768 ? '16px' : '14px',
padding: '0 16px',
color: 'rgba(255, 255, 255, 0.7)',
maxWidth: '500px',
lineHeight: '1.8',
textShadow: '0 2px 8px rgba(0, 0, 0, 0.5)',
}}
>
{formData.mode === 'text2video' {formData.mode === 'text2video'
? t('输入提示词,让 AI 为你创造精彩视频') ? t('输入提示词,让 AI 为你创造精彩视频')
: t('上传图片并输入提示词,生成动态视频')} : t('上传图片并输入提示词,生成动态视频')}
</Text> </p>
</div>
</div> </div>
); );
}; };
return ( return (
<Card <Card className='video-preview-panel'>
style={{ height: '100%', display: 'flex', flexDirection: 'column' }} <header className='video-panel-header video-preview-header'>
styles={{ <div className='video-panel-heading'>
body: { <Film size={17} aria-hidden='true' />
flex: 1, <h2>{t('视频预览')}</h2>
display: 'flex', </div>
flexDirection: 'column',
overflow: 'hidden',
padding: 0,
},
}}
>
{/* 始终显示的顶部操作栏 */}
{renderTopBar()} {renderTopBar()}
</header>
{/* 内容区域 */} <div className='video-preview-stage app-scrollbar'>{renderPreview()}</div>
<div style={{ flex: 1, overflow: 'auto' }}>{renderPreview()}</div>
</Card> </Card>
); );
}; };
@@ -4,8 +4,9 @@ import {
RefreshCw as ActionRefreshCw, RefreshCw as ActionRefreshCw,
Trash2 as ActionTrash2, Trash2 as ActionTrash2,
AlertCircle as ActionAlertCircle, AlertCircle as ActionAlertCircle,
ChevronDown as ActionChevronDown,
} from '@/components/common/icons/ActionIcons'; } from '@/components/common/icons/ActionIcons';
import React, { useState, useEffect } from 'react'; import React, { useState, useId } from 'react';
import { import {
Table, Table,
Button, Button,
@@ -17,8 +18,7 @@ import {
Badge, Badge,
} from '@/components/ui'; } from '@/components/ui';
import { import {
ChevronUp, ListVideo,
ChevronDown,
CheckCircle2, CheckCircle2,
AlertCircle, AlertCircle,
Clock, Clock,
@@ -47,32 +47,7 @@ const VideoTaskQueue = ({
// 8 列合计 1190px 塞进 ~340px 容器、按钮全带文字,实际完全用不了。 // 8 列合计 1190px 塞进 ~340px 容器、按钮全带文字,实际完全用不了。
const isCompact = useIsMobile(); const isCompact = useIsMobile();
const [selectedTasks, setSelectedTasks] = useState([]); const [selectedTasks, setSelectedTasks] = useState([]);
const [windowHeight, setWindowHeight] = useState(window.innerHeight); const queueId = useId();
// 监听窗口高度变化
useEffect(() => {
const handleResize = () => {
setWindowHeight(window.innerHeight);
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
// 计算任务队列高度:不超过屏幕高度的20%(五分之一)
// 同时设置最小高度150px,最大高度300px
const getQueueHeight = () => {
const maxHeightPercent = windowHeight * 0.2; // 屏幕高度的20%
// 手机端工具栏本身会换行占掉 ~100px,再按 20%(844px 屏上仅 169px)会让表格只剩
// 不到 70px,连表头带分页都放不下。窄屏改用更宽松的下限。
const minHeight = isCompact ? 300 : 150;
const maxHeight = isCompact ? 420 : 300;
// 在最小和最大值之间取适当的高度
return Math.max(minHeight, Math.min(maxHeightPercent, maxHeight));
};
const queueHeight = getQueueHeight();
// 状态标签映射 // 状态标签映射
const getStatusTag = (status) => { const getStatusTag = (status) => {
@@ -303,65 +278,30 @@ const VideoTaskQueue = ({
}; };
return ( return (
<> <section className='video-queue'>
{/* 折叠触发器 */} <h2 className='video-queue-heading'>
<div <button
style={{ type='button'
position: 'absolute', className='video-queue-toggle'
bottom: visible ? `${queueHeight}px` : '0', aria-expanded={visible}
left: 0, aria-controls={queueId}
right: 0,
height: '40px',
backgroundColor: 'var(--ui-color-bg-1)',
borderTop: '1px solid var(--ui-color-border)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer',
transition: 'bottom 0.3s',
zIndex: 10,
}}
onClick={() => setVisible(!visible)} onClick={() => setVisible(!visible)}
> >
<Space> <ListVideo size={19} aria-hidden='true' />
{visible ? <ChevronDown size={16} /> : <ChevronUp size={16} />} <span>{t('任务队列')}</span>
<span style={{ fontSize: !isCompact ? '14px' : '12px' }}> <span className='video-queue-count'>{taskStats.total}</span>
{t('任务队列')} ({taskStats.total})
</span>
{taskStats.in_progress > 0 && ( {taskStats.in_progress > 0 && (
<Badge count={taskStats.in_progress} type='danger' /> <Badge count={taskStats.in_progress} type='danger' />
)} )}
</Space> <ActionChevronDown
</div> size={16}
className='video-queue-chevron'
{/* 任务队列抽屉 */} aria-hidden='true'
<div />
style={{ </button>
position: 'absolute', </h2>
bottom: visible ? '0' : `-${queueHeight}px`, <div id={queueId} className='video-queue-content' hidden={!visible}>
left: 0, <div className='video-queue-toolbar'>
right: 0,
height: `${queueHeight}px`,
backgroundColor: 'var(--ui-color-bg-0)',
borderTop: '1px solid var(--ui-color-border)',
transition: 'bottom 0.3s',
display: 'flex',
flexDirection: 'column',
zIndex: 9,
}}
>
{/* 工具栏 */}
<div
style={{
padding: !isCompact ? '12px 16px' : '8px 12px',
borderBottom: '1px solid var(--ui-color-border)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
flexWrap: 'wrap',
gap: '8px',
}}
>
<Space wrap> <Space wrap>
<Button <Button
size={!isCompact ? 'default' : 'small'} size={!isCompact ? 'default' : 'small'}
@@ -427,7 +367,7 @@ const VideoTaskQueue = ({
</div> </div>
{/* 任务表格 */} {/* 任务表格 */}
<div style={{ flex: 1, overflow: 'auto' }}> <div className='video-queue-table app-scrollbar'>
<Table <Table
columns={columns} columns={columns}
dataSource={tasks} dataSource={tasks}
@@ -446,7 +386,7 @@ const VideoTaskQueue = ({
/> />
</div> </div>
</div> </div>
</> </section>
); );
}; };
@@ -0,0 +1,211 @@
.video-workspace {
display: flex;
flex-direction: column;
gap: 20px;
height: 100%;
padding: 24px;
overflow: auto;
}
.video-workspace-heading,
.video-panel-heading {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.video-workspace-icon,
.video-preview-empty-icon {
display: grid;
flex: none;
place-items: center;
width: 46px;
height: 46px;
color: var(--brand-selection-text);
background: var(--brand-selection-bg);
border-radius: 10px;
}
.video-workspace-heading h1 {
margin: 0;
color: var(--text-primary);
font-size: 28px;
font-weight: 650;
line-height: 32px;
}
.video-workspace-heading p {
margin: 4px 0 0;
color: var(--text-secondary);
font-size: 13px;
}
.video-workspace-body {
display: flex;
flex: 1;
flex-direction: column;
gap: 16px;
height: 100%;
min-height: 0;
min-width: 0;
}
.video-workspace-grid {
display: grid;
flex: 1;
grid-template-columns: clamp(312px, 26%, 420px) minmax(0, 1fr);
gap: 16px;
min-height: 310px;
}
.video-workspace-composer {
display: flex;
align-items: flex-start;
min-width: 0;
min-height: 0;
}
.video-panel-header {
display: flex;
flex: none;
align-items: center;
justify-content: space-between;
gap: 12px;
min-height: 57px;
padding: 10px 16px;
border-bottom: 1px solid var(--border-subtle);
}
.video-panel-header:last-child {
border-bottom: 0;
}
.video-panel-heading {
gap: 8px;
color: var(--brand-accent);
}
.video-panel-heading h2 {
margin: 0;
color: var(--text-primary);
font-size: 15px;
font-weight: 600;
line-height: 22px;
}
.video-queue {
flex: none;
min-width: 0;
background: var(--surface-card);
border: 1px solid var(--border-subtle);
border-radius: 12px;
}
.video-queue-heading {
margin: 0;
}
.video-queue-toggle {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
min-height: 52px;
padding: 8px 16px;
border: 0;
border-radius: 11px;
background: transparent;
color: var(--text-primary);
text-align: start;
font: inherit;
font-size: 15px;
font-weight: 600;
cursor: pointer;
}
.video-queue-toggle > svg:first-child {
color: var(--brand-accent);
}
.video-queue-toggle:hover {
background: var(--surface-bg-base);
}
.video-queue-toggle:focus-visible {
outline: 2px solid var(--brand-accent);
outline-offset: -3px;
}
.video-queue-toggle[aria-expanded='true'] {
border-end-start-radius: 0;
border-end-end-radius: 0;
}
.video-queue-count {
min-width: 23px;
padding: 2px 6px;
border-radius: 6px;
background: var(--surface-bg-base);
color: var(--text-secondary);
text-align: center;
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.video-queue-chevron {
margin-inline-start: auto;
color: var(--text-secondary);
}
.video-queue-toggle[aria-expanded='true'] .video-queue-chevron {
transform: rotate(180deg);
}
.video-queue-content {
border-top: 1px solid var(--border-subtle);
}
.video-queue-toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px 16px;
padding: 10px 16px;
border-bottom: 1px solid var(--border-subtle);
}
.video-queue-table {
min-width: 0;
max-height: clamp(120px, 24dvh, 260px);
overflow: auto;
border-end-start-radius: 11px;
border-end-end-radius: 11px;
}
@media (max-width: 1024px) {
.video-workspace {
gap: 16px;
padding: 16px;
}
.video-workspace-body {
flex: none;
height: auto;
}
.video-workspace-grid {
grid-template-columns: minmax(0, 1fr);
min-height: 0;
}
.video-workspace-heading h1 {
font-size: 24px;
line-height: 28px;
}
.video-queue-table {
max-height: 320px;
}
}
@@ -1,31 +1,21 @@
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useRef } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import VideoInputPanel from './Video/VideoInputPanel'; import VideoInputPanel from './Video/VideoInputPanel';
import VideoPreviewPanel from './Video/VideoPreviewPanel'; import VideoPreviewPanel from './Video/VideoPreviewPanel';
import VideoTaskQueue from './Video/VideoTaskQueue'; import VideoTaskQueue from './Video/VideoTaskQueue';
import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration'; import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration';
import { showInfo } from '../../../../helpers'; import { showInfo } from '../../../../helpers';
import './Video/VideoWorkspace.css';
const VideoGenerationTab = () => { const VideoGenerationTab = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(false); const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(false);
const [taskQueueVisible, setTaskQueueVisible] = useState(false); const [taskQueueVisible, setTaskQueueVisible] = useState(false);
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const [selectedTaskForPlay, setSelectedTaskForPlay] = useState(null); const [selectedTaskForPlay, setSelectedTaskForPlay] = useState(null);
// 输入面板容器:再生成回填后滚动到面板顶部 // 输入面板容器:再生成回填后滚动到面板顶部
const inputPanelRef = useRef(null); const inputPanelRef = useRef(null);
const inputScrollRef = useRef(null); const inputScrollRef = useRef(null);
// 监听窗口大小变化
useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
};
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
const creation = useVideoGeneration(); const creation = useVideoGeneration();
const { const {
// 表单数据 // 表单数据
@@ -95,155 +85,24 @@ const VideoGenerationTab = () => {
showInfo(t('已回填原参数,确认后点击生成')); showInfo(t('已回填原参数,确认后点击生成'));
// 等面板展开渲染后再滚动 // 等面板展开渲染后再滚动
requestAnimationFrame(() => { requestAnimationFrame(() => {
inputScrollRef.current?.scrollTo?.({ top: 0, behavior: 'smooth' }); inputScrollRef.current?.scrollTo?.({ top: 0 });
inputPanelRef.current?.scrollIntoView?.({ inputPanelRef.current?.scrollIntoView?.({
behavior: 'smooth',
block: 'start', block: 'start',
}); });
}); });
}; };
// 响应式布局配置 - 两列布局(左侧配置区 + 右侧预览区)
const getLayoutConfig = () => {
// 超大屏幕 (>1920px): 25% - 75%
if (windowWidth > 1920) {
return {
leftWidth: '25%',
centerWidth: '75%',
minLeftWidth: '350px',
minCenterWidth: '800px',
direction: 'row',
};
}
// 大屏幕 (1600-1920px): 28% - 72%
if (windowWidth > 1600) {
return {
leftWidth: '28%',
centerWidth: '72%',
minLeftWidth: '320px',
minCenterWidth: '700px',
direction: 'row',
};
}
// 中等屏幕 (1280-1600px): 32% - 68%
if (windowWidth > 1280) {
return {
leftWidth: '32%',
centerWidth: '68%',
minLeftWidth: '300px',
minCenterWidth: '600px',
direction: 'row',
};
}
// 小屏幕 (1024-1280px): 35% - 65%
if (windowWidth > 1024) {
return {
leftWidth: '35%',
centerWidth: '65%',
minLeftWidth: '280px',
minCenterWidth: '500px',
direction: 'row',
};
}
// 超小屏幕 (<1024px): 单列布局
return {
leftWidth: '100%',
centerWidth: '100%',
minLeftWidth: '100%',
minCenterWidth: '100%',
direction: 'column',
};
};
const layoutConfig = getLayoutConfig();
return ( return (
<div <div className='video-workspace-body'>
style={{ <div className='video-workspace-grid'>
height: '100%', <div ref={inputPanelRef} className='video-workspace-composer'>
display: 'flex',
flexDirection: 'column',
position: 'relative',
overflow: 'hidden',
}}
>
<div
style={{
flex: 1,
overflow: layoutConfig.direction === 'row' ? 'hidden' : 'auto',
display: 'flex',
flexDirection: layoutConfig.direction === 'row' ? 'row' : 'column',
gap: layoutConfig.direction === 'column' ? '16px' : '0',
position: 'relative',
paddingBottom: '40px', // 为任务队列触发器留出空间
}}
>
{/* 左侧:输入区域(区域1) */}
<div
ref={inputPanelRef}
style={{
width:
layoutConfig.direction === 'row'
? layoutConfig.leftWidth
: '100%',
minWidth: layoutConfig.minLeftWidth,
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
// 折叠态不能再预留 500px:面板收起后只剩一个 fixed 定位的浮动箭头,
// 这 500px 会变成页面顶部一整块空白
minHeight:
layoutConfig.direction === 'column' && !leftPanelCollapsed
? '500px'
: 'auto',
flexShrink: layoutConfig.direction === 'row' ? 0 : 1,
backgroundColor: 'var(--ui-color-bg-1)',
borderRight:
layoutConfig.direction === 'row'
? '1px solid var(--ui-color-border)'
: 'none',
borderBottom:
layoutConfig.direction === 'column'
? '1px solid var(--ui-color-border)'
: 'none',
display: 'flex',
flexDirection: 'column',
}}
>
<div
ref={inputScrollRef}
className='app-scrollbar'
style={{
height: '100%',
overflow: 'auto',
paddingBottom: layoutConfig.direction === 'row' ? '16px' : '16px',
}}
>
<VideoInputPanel <VideoInputPanel
creation={creation} creation={creation}
onCollapse={() => setLeftPanelCollapsed(!leftPanelCollapsed)}
collapsed={leftPanelCollapsed} collapsed={leftPanelCollapsed}
collapsible={layoutConfig.direction === 'row'} onCollapse={() => setLeftPanelCollapsed((current) => !current)}
scrollRef={inputScrollRef}
/> />
</div> </div>
</div>
{/* 右侧:预览+生成区域 */}
<div
style={{
flex: 1,
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
minHeight: layoutConfig.direction === 'column' ? '600px' : 'auto',
minWidth: 0,
}}
>
<div
className='app-scrollbar'
style={{
height: '100%',
backgroundColor: 'var(--ui-color-bg-0)',
padding: windowWidth > 768 ? '16px' : '12px',
overflow: 'auto',
}}
>
<VideoPreviewPanel <VideoPreviewPanel
formData={formData} formData={formData}
generating={generating} generating={generating}
@@ -262,19 +121,6 @@ const VideoGenerationTab = () => {
onClearSelectedTask={handleClearSelectedTask} onClearSelectedTask={handleClearSelectedTask}
/> />
</div> </div>
</div>
</div>
{/* 底部:任务队列(区域4) - 使用 absolute 定位,相对于父容器 */}
<div
style={{
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
zIndex: 1000,
}}
>
<VideoTaskQueue <VideoTaskQueue
visible={taskQueueVisible} visible={taskQueueVisible}
setVisible={setTaskQueueVisible} setVisible={setTaskQueueVisible}
@@ -286,7 +132,6 @@ const VideoGenerationTab = () => {
onRegenerate={handleRegenerate} onRegenerate={handleRegenerate}
/> />
</div> </div>
</div>
); );
}; };
@@ -1,6 +1,6 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Video, Sparkles, Clapperboard, Film, Play } from 'lucide-react'; import { Video } from 'lucide-react';
import VideoGenerationTab from './AICreation/VideoGenerationTab'; import VideoGenerationTab from './AICreation/VideoGenerationTab';
import CreationStudio from '../../../components/creation/CreationStudio'; import CreationStudio from '../../../components/creation/CreationStudio';
import { StatusContext } from '../../../context/Status'; import { StatusContext } from '../../../context/Status';
@@ -16,82 +16,18 @@ const VideoGeneration = () => {
} }
return ( return (
<div className='h-full flex flex-col p-6 relative overflow-hidden'> <div className='video-workspace app-scrollbar'>
{/* 背景由父级 ExperienceCenter 的 PageBackground(rich) 统一提供,此处不再渲染 */} <header className='video-workspace-heading'>
<span className='video-workspace-icon' aria-hidden='true'>
{/* Header */} <Video size={22} />
<div className='relative z-10 flex-shrink-0 mb-6'> </span>
<div className='flex items-center gap-4'>
{/* 图标容器 */}
<div className='relative'>
<div className='absolute -inset-2 bg-gradient-to-r from-cyan-500/30 to-blue-500/30 rounded-2xl blur-lg opacity-60' />
<div className='relative p-3 bg-gradient-to-br from-cyan-500 via-blue-500 to-brand-to rounded-2xl shadow-xl shadow-cyan-500/30'>
<Video size={26} className='text-white' />
</div>
<Sparkles
size={16}
className='absolute -top-1 -right-1 text-amber-400 animate-pulse'
/>
{/* 播放动画指示器 */}
<div className='absolute -bottom-1 -left-1 w-5 h-5 rounded-full bg-green-500 flex items-center justify-center shadow-lg shadow-green-500/50'>
<Play size={10} className='text-white ml-0.5' fill='white' />
</div>
</div>
{/* 标题文字 */}
<div> <div>
<h1 className='text-2xl md:text-3xl font-bold flex items-center gap-2'> <h1>{t('视频生成')}</h1>
<span className='bg-clip-text text-transparent bg-gradient-to-r from-cyan-600 via-blue-600 to-brand-to dark:from-cyan-400 dark:via-blue-400 dark:to-brand-to'> <p>{t('使用 AI 创建令人惊叹的视频内容')}</p>
{t('视频生成')}
</span>
</h1>
<p className='text-sm text-gray-500 dark:text-gray-400 mt-1'>
{t('使用 AI 创建令人惊叹的视频内容')}
</p>
</div> </div>
</header>
{/* 右侧装饰标签 */}
<div className='hidden md:flex items-center gap-2 ml-auto'>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-cyan-50 to-teal-50 dark:from-cyan-950/30 dark:to-teal-950/30 border border-cyan-200/50 dark:border-cyan-800/30'>
<Clapperboard size={14} className='text-cyan-500' />
<span className='text-xs font-medium text-cyan-600 dark:text-cyan-400'>
{t('图生视频')}
</span>
</div>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-blue-50 to-brand-to/5 dark:from-blue-950/30 dark:to-brand-to/30 border border-blue-200/50 dark:border-blue-800/30'>
<Film size={14} className='text-blue-500' />
<span className='text-xs font-medium text-blue-600 dark:text-blue-400'>
{t('文生视频')}
</span>
</div>
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-brand-from/5 to-brand-to/5 dark:from-brand-from/30 dark:to-brand-to/30 border border-brand/50 dark:border-brand-deep/30'>
<Sparkles size={14} className='text-brand' />
<span className='text-xs font-medium text-brand-deep dark:text-brand-from'>
{t('多模型支持')}
</span>
</div>
</div>
</div>
</div>
{/* Content */}
<div className='relative z-10 flex-1 min-h-0'>
{/* 卡片装饰边框 */}
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 via-blue-500/20 to-brand-to/20 rounded-[20px] blur-sm opacity-60' />
{/* 内容卡片 */}
<div className='relative h-full bg-white/70 dark:bg-neutral-900/70 backdrop-blur-xl rounded-2xl border border-white/50 dark:border-neutral-800/50 shadow-xl shadow-cyan-500/5 overflow-hidden'>
{/* 顶部装饰线 */}
<div className='absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent' />
{/* 左侧装饰线 */}
<div className='absolute top-0 bottom-0 left-0 w-[2px] bg-gradient-to-b from-transparent via-blue-500/30 to-transparent' />
<VideoGenerationTab /> <VideoGenerationTab />
</div> </div>
</div>
</div>
); );
}; };
+6 -2
View File
@@ -190,9 +190,13 @@ const ExperienceCenter = () => {
* 子组件不再各自渲染背景,避免双层叠加。 * 子组件不再各自渲染背景,避免双层叠加。
* text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。 * text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。
* 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */} * 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */}
{!isTextModel && ( {!isTextModel &&
(!(isVideoGeneration || isImageGeneration) ||
creationStudioEnabled) && (
<PageBackground <PageBackground
variant={isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'} variant={
isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'
}
animate animate
/> />
)} )}
+2 -2
View File
@@ -4,12 +4,12 @@
## 单一表单数据 ## 单一表单数据
首页、关于微词元、预约演示、动态与洞察共用一个配置对象,切换页签保留输入。 首页、关于微元算力、预约演示、动态与洞察共用一个配置对象,切换页签保留输入。
teamMembers 在两个页签共用,不生成不同的副本。原有 11 个字段均必填。 teamMembers 在两个页签共用,不生成不同的副本。原有 11 个字段均必填。
动态与洞察绑定 insights 对象,包含 categories 和 articles,不按页签拆分保存。 动态与洞察绑定 insights 对象,包含 categories 和 articles,不按页签拆分保存。
model.js 定义字段、页签、初始化、标准化和校验规则。 model.js 定义字段、页签、初始化、标准化和校验规则。
保存按首页、关于微词元、预约演示、动态与洞察顺序校验全部字段,错误保存在各表单项内。 保存按首页、关于微元算力、预约演示、动态与洞察顺序校验全部字段,错误保存在各表单项内。
空输入框提示“请输入中文字段名”,选择框提示“请选择中文字段名”,二维码提示“请上传企业微信二维码”。 空输入框提示“请输入中文字段名”,选择框提示“请选择中文字段名”,二维码提示“请上传企业微信二维码”。
每个非当前页签有错误时只显示一条“请完善某页签的配置”警告,不列出全部字段,不自动切换页签。 每个非当前页签有错误时只显示一条“请完善某页签的配置”警告,不列出全部字段,不自动切换页签。
当前页签只显示表单项错误;切换页签后,其他页签的错误状态仍会显示。 当前页签只显示表单项错误;切换页签后,其他页签的错误状态仍会显示。
+3 -3
View File
@@ -14,8 +14,8 @@ export const TABS = [
}, },
{ {
key: 'about', key: 'about',
label: '关于微词元', label: '关于微元算力',
description: '配置官网关于微词元区域展示的团队与服务信息。', description: '配置官网关于微元算力区域展示的团队与服务信息。',
fields: ['teamMembers', 'researchRatio', 'headquarters', 'serviceNetwork'], fields: ['teamMembers', 'researchRatio', 'headquarters', 'serviceNetwork'],
}, },
{ {
@@ -53,7 +53,7 @@ export const FIELDS = {
}, },
teamMembers: { teamMembers: {
label: '团队成员', label: '团队成员',
note: '首页与关于微词元共用', note: '首页与关于微元算力共用',
placeholder: '请输入团队成员数量,例如 50', placeholder: '请输入团队成员数量,例如 50',
metric: { kind: 'integer', suffix: '+' }, metric: { kind: 'integer', suffix: '+' },
}, },
+2 -2
View File
@@ -198,7 +198,7 @@ test('saving marks all fields inline and emits one ordered summary per hidden in
assert.equal(page.warnings.length, 0); assert.equal(page.warnings.length, 0);
assert.deepEqual( assert.deepEqual(
page.messages.map((item) => item.message), page.messages.map((item) => item.message),
['请完善首页的配置', '请完善关于微词元的配置', '请完善预约演示的配置'], ['请完善首页的配置', '请完善关于微元算力的配置', '请完善预约演示的配置'],
); );
page.switchTab('home'); page.switchTab('home');
assert.equal(page.field('paidCustomers').props.error, '请输入付费企业客户'); assert.equal(page.field('paidCustomers').props.error, '请输入付费企业客户');
@@ -408,7 +408,7 @@ test('a shared invalid field still flags its hidden tab exactly once', async ()
await page.save(); await page.save();
assert.deepEqual( assert.deepEqual(
page.messages.map((item) => item.message), page.messages.map((item) => item.message),
['请完善关于微词元的配置'], ['请完善关于微元算力的配置'],
); );
}); });