diff --git a/AGENTS.md b/AGENTS.md index 8e641cc3..2fc4dcf3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -89,6 +89,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd | 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` | | 模型超市 / 技能超市 | `docs/ui/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` | | 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` | +| UI 审查清单 | `docs/ui-review-checklist.md` | | 历史改动与回滚 | `docs/CHANGELOG.md` | | Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 | @@ -122,7 +123,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd - 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。 - 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。 -> 规范版本:v3.5 · 更新:2026-11-18 +> 规范版本:v3.6 · 更新:2026-11-19 ## 10. 工具差异(本节允许不同) diff --git a/CLAUDE.md b/CLAUDE.md index 5031e513..e32c4587 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -89,6 +89,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd | 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` | | 模型超市 / 技能超市 | `docs/ui/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` | | 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` | +| UI 审查清单 | `docs/ui-review-checklist.md` | | 历史改动与回滚 | `docs/CHANGELOG.md` | | Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 | @@ -122,7 +123,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd - 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。 - 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。 -> 规范版本:v3.5 · 更新:2026-11-18 +> 规范版本:v3.6 · 更新:2026-11-19 ## 10. 工具差异(本节允许不同) diff --git a/README.md b/README.md index adff39ea..7e6f22dc 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ monkey-ai-web/ ### 本地 Playwright 登录配置 +全流程 UI 审查使用 [UI 审查清单](docs/ui-review-checklist.md)。`e2e/` 保存本地用例,`.e2e/` 保存分阶段状态、截图、验收报告与会话缓存;均由 Git 忽略。会话缓存不上传、不提交。 + 本机自动化登录入口为 `e2e/auth-login/run.mjs`(本地验收脚本,Git 忽略)。在 `.env.playwright.local` 中配置 `UI_ORG_NAME`、`UI_ORG_USER`、`UI_ORG_PASS`、`UI_PERSONAL_USER`、`UI_PERSONAL_PASS`。该文件只保存测试账号,按用户约定不作 Git 忽略,允许提交;不得把值写入脚本、日志、截图注释或报告。其他凭据与 storageState 仍不入库。运行时由 Node 加载到环境变量: ```powershell diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index da5f6975..85e2da95 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,101 @@ ## 2026-11-19 +### 修复 · 并发请求失败与会话过期提示 + +- **范围**:统一请求工具、登录入口及企业预算的关联查询。 +- **变更**:会话 401 单次处理并取消旧会话的未完成读取;支持按组取消关联读取;合并重复 HTTP 错误和过期提示。 +- **影响**:正常并发与公开请求不受限制;单个权限或服务错误不取消无关请求,也不会批量中断已发出的写入。 +- **回滚**:仅还原本条的请求生命周期、提示和关联查询改动。 +- **关联**:`src/helpers/api.js`、`src/helpers/requestLifecycle.js`、`src/pages/Organization/OrgBudgets.jsx`。 + +### 调整 · 登录与退出不再弹出成功提示 + +- **范围**:个人登录、企业登录、两步验证及顶栏退出登录。 +- **变更**:移除登录成功和退出成功弹窗。 +- **影响**:会话校验、页面跳转、失败提示及密码修改提示保持不变。 +- **回滚**:仅还原本条的成功提示改动。 +- **关联**:`src/helpers/loginFlow.js`、`src/components/auth/TwoFAVerification.jsx`、`src/hooks/common/useHeaderBar.js`。 + +### 修复 · 个人与企业登录回跳错位 + +- **范围**:个人登录、企业登录及同一浏览器切换账号。 +- **变更**:直接登录不再读取旧回跳地址;验证会话账号后才完成登录,拒绝明显不匹配的落点;旧会话的迟到响应不再覆盖新会话;企业账号跳转时不再短暂挂载受限的个人页面并误弹权限提示。 +- **影响**:保留适用的深链参数、锚点和原有权限校验;无有效落点时回到对应入口的默认页面。 +- **回滚**:仅还原本条对应的登录、回跳逻辑和测试。 +- **关联**:`src/App.jsx`、`src/helpers/loginFlow.js`、`src/helpers/data.js`、`src/components/layout/PageLayout.jsx`、`test/unit/post-login-redirect.test.js`。 + +### 调整 · 控制台列表与行操作统一 + +- **范围**:控制台兑换码、会员卡、发票管理,以及控制台、企业中心、用户中心和视频任务队列的多操作列表。 +- **变更**:筛选栅格、列表工具栏、表头、分页与空态按密钥管理收敛;低频行操作统一进入带箭头的“更多”菜单。 +- **影响**:不改变接口、载荷、权限、状态限制及危险操作确认;筛选与菜单适配移动端和亮暗主题;修复兑换码抽屉关闭后快速重新编辑时记录被延时清空的问题。 +- **回滚**:仅还原本条关联的列表、行操作和公共样式改动,不还原其他主题改动。 +- **关联**:`src/components/common/table/TableToolbar.jsx`、`src/components/console/ConsolePrimitives.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`。 + +### 修复 · 云端大脑撰写态左侧对齐 + +- **范围**:`/experience-center/cloud-brain` 专家列表与撰写区布局。 +- **变更**:撰写态由固定宽度居中改为从内容区左侧对齐,编辑区填充剩余空间,消除宽屏左侧与右侧的大块空白。 +- **影响**:仅调整布局样式,保留专家选择、任务填写和主题切换行为;窄屏单列布局不变。 +- **回滚**:还原 `src/pages/CloudBrain/cloud-brain.css` 中 `.brain-expert-layout.is-composing` 规则。 + +### 修复 · 图片生成底部操作区固定布局 + +- **范围**:`/experience-center/image-generation` 参数表单与生成操作区。 +- **变更**:将生成按钮及估价移出参数滚动容器,通过独立 flex 区域贴住表单底边;移除固定 124px 底部占位,操作区使用完整主题表面背景,并兼顾移动端安全区。 +- **影响**:桌面参数独立滚动,末尾参数可完整滚入可视区域;移动端保留自然堆叠与展开、收起行为,生成及估价逻辑不变。 +- **回滚**:仅还原本条涉及的表单滚动结构与操作区 CSS,保留其他主题适配改动。 +- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`。 + +### 修复 · 图片生成表单背景与圆角主题适配 + +- **范围**:`/experience-center/image-generation` 图片生成表单外层、分区与底部生成操作区。 +- **变更**:统一使用主题卡片表面色与边框 token,补齐整块白色背景、连续圆角和底部 sticky 操作区的顶部边界;深色模式自动映射深色表面。 +- **影响**:仅调整视觉层,保留模型选择、提示词、参数、估价和生成逻辑;禁用按钮继续保持不可提交状态。 +- **回滚**:按文件还原 `ImageGenerationForm.jsx`、`ImageGenerationForm.css` 及本条记录。 +- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`。 + +### 调整 · 推广分享弹窗布局与交互 + +- **范围**:顶栏推广入口的链接分享、海报分享及奖励规则入口。 +- **变更**:采用 800px Ant Design 弹窗;链接分享以扫码区与复制区双栏展示,奖励规则收为底部轻量入口;海报预览与模板、导出操作分栏,模板使用带名称的单选控件并支持键盘选择;移动端堆叠,短视口正文限高滚动。 +- **影响**:弹窗主体跟随系统主题色与亮暗模式,保留已有海报模板、分享接口、邀请地址、奖励页路由和 PNG 导出逻辑;邀请码不可用时不展示占位二维码。 +- **回滚**:按文件还原 `src/components/promotion/PromotionPosterModal.jsx` 与 `src/components/promotion/promotion-poster.css`。 +- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md` 第 8、10、15 节。 + +### 修复 · 系统主题色在亮暗模式下的交互对比度 + +- **范围**:共享主题入口、双端侧栏与公告、实底控件及系统设置主题色预览。 +- **变更**:由当前主题色分别派生实底、文字和选中浅底;亮暗模式分别控制亮度与饱和度。同步企业强调色、个人深色页签和设置预览;预览链接示意即时切色,气泡按渐变亮度选用可读文字。 +- **影响**:暗色原型侧栏保持琥珀选中态;默认浅色选中文字微调以达对比度要求。保留原始配置及持久化,成功、警告、错误仍独立配色。 +- **回滚**:按文件回退本条涉及的主题解析、样式桥、消费者和配色单测,不改系统设置数据。 +- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md`、`docs/ui-review-checklist.md`。 + +### 调整 · 新手教程阅读布局与主题适配 + +- **范围**:`/tutorial` 图文、视频教程及关闭入口。 +- **变更**:去除固定阅读高度和嵌套纵向滚动,桌面采用步骤目录与正文双栏、移动目录换行;目录支持滚动同步与焦点定位,代码自动折行;视频列表支持键盘选择;关闭入口使用 Ant Design 文本图标按钮与提示,修复视频空态标题。 +- **影响**:颜色跟随系统主题配置和亮暗主题;保留教程内容、请求、链接、返回逻辑和小程序充值步骤隐藏规则。 +- **回滚**:按文件还原 `src/pages/Tutorial/` 本次修改。 +- **关联**:`docs/ui/GLOBAL_UI_BASELINE.md`、`docs/standards/UI_COMPONENT_STANDARDS.md`。 + +### 调整 · 顶栏右侧工具与账户对齐 + +- **范围**:共享顶栏右侧教程、推广、下载、充值、主题、公告、语言和账户入口。 +- **变更**:统一按钮高度、图标与文字行高和间距;消除链接与公告徽标包装层的行内基线偏移;调整头像、箭头与分隔线居中,桌面专属按钮按移动断点隐藏。 +- **影响**:保留既有权限、配置和操作回调,样式随亮暗主题切换。 +- **回滚**:按文件还原 `src/components/layout/headerbar/ActionButtons.jsx` 与 `src/styles/prototype.css` 顶栏相关段落。 +- **关联**:`docs/ui/GLOBAL_UI_BASELINE.md` 第 4.1 节。 + +### 文档 · 补充双端 UI 审查清单 + +- **范围**:企业端与个人端的 UI 审查、真实操作验收与证据归档。 +- **变更**:登记可复用审查清单,忽略 `.e2e/` 的分阶段本地产物。 +- **影响**:不改变业务、路由、接口或 Playwright 默认配置;验收证据与会话缓存不入库。 +- **回滚**:按文件还原本条涉及的清单、索引与忽略规则;保留既有本地验收证据。 +- **关联**:`docs/ui-review-checklist.md`、`README.md`、`.gitignore`。 + ### 功能 · 恢复服务监控入口并接入超管开关 - **范围**:用户中心桌面侧栏、移动底栏、服务监控路由与面包屑。 diff --git a/docs/README.md b/docs/README.md index 47f5ba07..b30f62a4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,7 +18,7 @@ | 修改企业中心 / 控制台 | `ui/ORG_CENTER_SPEC.md` / `ui/CONSOLE_SPEC.md` | — | | 修改模型超市 / 技能超市 | `ui/MODEL_MARKET_SPEC.md` / `ui/SKILL_MARKET_SPEC.md` | — | | 修改任一表格的列设置 | `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | — | -| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | 对应页面规范的“验收要点” | +| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | `ui-review-checklist.md`、对应页面规范的“验收要点” | | 查改动范围或回滚方式 | `CHANGELOG.md` | — | 每份规范开头都有“何时阅读”和“速查”表,先看速查,需要细节再按章节号读取。 @@ -38,6 +38,7 @@ | `ui/MODEL_MARKET_SPEC.md` | 模型超市 | 约 8KB | | `ui/SKILL_MARKET_SPEC.md` | 技能超市与数据模式 | 约 8KB | | `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | 表格列设置 | 约 4KB | +| `ui-review-checklist.md` | 双端 UI 审查、交互与证据记录清单 | 约 3KB | | `CHANGELOG.md` | 对现状仍有影响的功能与修复记录 | 约 6KB | ## 规则优先级 diff --git a/docs/standards/DEV_STANDARDS.md b/docs/standards/DEV_STANDARDS.md index deda389b..f195f133 100644 --- a/docs/standards/DEV_STANDARDS.md +++ b/docs/standards/DEV_STANDARDS.md @@ -118,7 +118,8 @@ ESLint 规则 `header/header` 要求每个 `.js/.jsx` 顶部带 AGPL 许可证 ### 3.1 规则 - 只用 `import { API } from '@/helpers'`;禁止新建 axios 实例或用 `fetch` 调 `/api`(流式对话 `src/hooks/playground/useApiRequest.jsx` 除外)。 -- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行提示);401 清理会话并跳转 `/org/login?expired=true`。 +- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭,带取消信号或请求组的 GET 不共享);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行处理)。受会话约束的接口首次返回 401 时取消该会话未完成的只读请求,阻止该会话继续发请求,并仅清理、跳转 `/org/login?expired=true` 一次。公开接口或显式 `sessionBound: false` 的请求不参与会话联动。 +- 同一批必须全部成功的只读请求,可传入同一个 `requestGroup: new AbortController()`;首次拒绝的 HTTP 4xx/5xx 取消同组剩余读取。普通失败不取消无关请求,正常并发不限流;已发送的写入不由请求组批量取消。调用方仍须处理 Promise 拒绝,并在 `finally` 清理加载状态。 - 查询参数用 `params` 对象,不手拼查询字符串(手拼不会编码 `&`、`#`、中文)。 - 响应按 `{ success, message, data }` 处理,先判断 `success`;具体字段以接口契约为准。 - 分页参数 `p` 从 1 开始,`page_size` 默认 `ITEMS_PER_PAGE`(10,须与后端一致);后端对 `page_size > 100` 静默截断为 100,需要全量数据时用 `collectPagedItems(fetchPage)`(`src/helpers/paging.js`)。 diff --git a/docs/standards/UI_COMPONENT_STANDARDS.md b/docs/standards/UI_COMPONENT_STANDARDS.md index 51784eac..6b4c9470 100644 --- a/docs/standards/UI_COMPONENT_STANDARDS.md +++ b/docs/standards/UI_COMPONENT_STANDARDS.md @@ -53,9 +53,9 @@ 品牌主题预设在 `src/styles/presets.js`,主题配置与持久化在 `src/helpers/theme.js` 与 `src/context/Theme`;预设 key 不改名。 -组件级配置:`Menu`(项高 42px,选中底 `#fff3df` / `#382b1b`,选中文字 `#a95d07` / `#f2ad41`);`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。 +组件级配置:`Menu` 项高 42px,原型选中底 `#fff3df` / `#382b1b`,选中文字 `#a45a07` / `#f2ad41`;`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。 -暗色主色:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`。系统以 `#d1963a` 作为 `colorPrimary`,其余衍生 token 仍按种子推导;页面需要“品牌强调色”时用 `brandAccentFromToken(colorPrimary, dark)`,浅色与自定义主色返回 `colorPrimary`,默认暗色返回 `#f2ad41`。 +暗色原型:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`;保留该全局主色及原型选中态。系统配置的主题色保留为原始种子,交互色根据当前明暗模式派生:选中背景低浓度着色,选中文字与强调色保证可读;实底按钮的默认、悬停和按压态共享同一前景色。页面复用 `--brand-accent`、`--brand-selection-bg`、`--brand-selection-text`,不自行写固定品牌色;成功、警告、错误继续独立于主色。 ### 2.2 取色方式 @@ -132,6 +132,7 @@ html.dark .km-page { - 行为:搜索与重置都回到第 1 页;重置 = 清空表单 + 以默认条件重新查询;只切换筛选的页签放在筛选卡上方。 - 移动端:用户中心与控制台默认收起,通过“显示 / 隐藏操作项”或“筛选”按钮展开;列设置入口不随筛选收起。 - 控制台使用 `ConsoleSearchBar` + `ConsoleSearchActions`,企业中心使用 `OrgFilterCard`,不要另写网格。 +- 控制台标准列表以 `/console/token` 为参考:使用 `ConsoleCollection`(或通过 `CardPro` 接入),控件走共享筛选栅格(三列、≤ 1100px 两列、≤ 768px 单列),在列表卡内单列工具栏;快捷筛选在左,批量、刷新、新建等列表动作在右。不要把列表动作插进搜索字段区,也不要为了对齐而新增无业务语义的按钮。 ## 5. 表格 @@ -149,7 +150,7 @@ html.dark .km-page { - 每列显式 `width`,长文本 `ellipsis` 并配 `Tooltip`;金额与数量右对齐;时间统一格式,必要时日期与时间分两行。 - 状态列用 `Tag` 或 `Switch`(见第 11 节);启停开关请求中禁用,失败恢复原状态。 -- 操作列放在最后,按钮为 `type='link' size='small'`,危险操作加 `danger`,同一行操作间距 8–10px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`;操作较多时折叠到“更多”下拉。 +- 操作列放在最后,标题固定为“操作”,按钮为 `type='link' size='small'`,同一行操作间距 8px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`。多操作列表以 `/console/commission?view=partners` 为参考:使用 `TableRowActions`,直出 1–2 个高频动作(如“详情”“编辑”),其余放进带下箭头的文字“更多”菜单。菜单点击打开、右对齐,无有效菜单项时不渲染入口;危险项置末、标记 `danger` 并保留业务确认。现有权限、状态限制、禁用项和回调不得因收纳而改变,方向键、Enter、Escape 可操作菜单。 - 三中心表格通过 `CenterActionTable` 统一处理,最后一列存在创建、查看、编辑、测试、详情、删除、添加、设置、配置、弹窗 / 抽屉或请求交互时,列头统一显示“操作”并固定右侧,宽度按按钮 / 交互数量计算。没有操作列但估算列宽超出容器时,从右侧固定末 4 列,列数不足时降为 3、2、1 列。固定列使用不透明底色并保持表头层级;横向滚动条遵循 Ant Design 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。 - 列显隐只在已有列设置的表格中提供,统一使用 `ColumnSettings`(见 `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。 - 三中心表头背景统一由 `center-table.css` 绘制:页面通过 `--center-table-head-bg` 提供色调,公共层在不透明的容器底色上叠加同色填充,普通列与固定列保持一致;页面不再直接覆盖表头 `background`。固定列使用 antd 6 的 `.ant-table-cell-fix` 与原生动态层级,不写死 `z-index`,不使用旧版 `fix-left` / `fix-right` 类名补丁;表头不换行,表头与正文沿用同一列宽和对齐方式。 @@ -160,7 +161,7 @@ html.dark .km-page { | 状态 | 写法 | | --- | --- | | 加载 | `Table loading` | -| 空数据 | `Empty image={Empty.PRESENTED_IMAGE_SIMPLE}`,文案沿用页面原有 | +| 空数据 | 标准列表使用 `TableEmpty`(`ConsoleListTable` 默认接入):保留表头,简单插图 + “暂无数据”在当前可见宽度内居中;加载中不把空态当作查询结果,失败继续走错误提示 | | 批量操作 | `rowSelection={{ selectedRowKeys, onChange }}`,未选中时批量按钮禁用 | ## 6. 分页 diff --git a/docs/ui-review-checklist.md b/docs/ui-review-checklist.md new file mode 100644 index 00000000..47bdfe9a --- /dev/null +++ b/docs/ui-review-checklist.md @@ -0,0 +1,29 @@ +# UI 审查清单 + +> 状态:有效 · 更新:2026-11-19 · 版本:v1.0 + +**何时阅读**:执行双端 UI 审查、视觉回归与真实操作验收时。项目设置、全局基线与对应页面规范优先,本清单不定义新增功能。 + +## 速查 + +- 环境、登录、视口与像素阈值:`ui/GLOBAL_UI_BASELINE.md` 第 6、7 节。 +- 组件与主题判定:`standards/UI_COMPONENT_STANDARDS.md` 与对应页面规范。 +- 只勾选实际验证项;无此控件写“不适用”,权限、数据或环境不足写“未覆盖”并留证,不视为通过。 + +## 检查顺序 + +- [ ] **导航布局**:侧栏展开、折叠、层级、悬停、选中与图标;顶栏 Logo、搜索、通知、头像、主题、语言、环境标识;面包屑;多页签关闭、固定、右键、滚动与回到顶部。 +- [ ] **全局视觉**:背景、渐变、蒙层与其他叠加;边距、栅格、对齐、响应折行;主题与语义色、透明度、深浅映射;字号、字重、行高、截断、等宽数字和脱敏;SVG 基线、线面、尺寸、间距、圆角、边框、分割线与阴影。 +- [ ] **容器**:卡片头、主体与分区,标签页的选中态、下划线、胶囊与位置,折叠面板与分隔线。 +- [ ] **数据区**:表头、单元格、固定列、斑马纹、空态、虚拟滚动、列设置、密度、批量、编辑和拖拽;分页条数、位置、跳转、总数;操作对齐、权限、折叠和危险态;下拉菜单分组、图标及禁用态;标签、徽标、头像、进度、描述、统计、时间线、步骤、结果、JSON、高亮、复制与二维码。 +- [ ] **输入与筛选**:文本、数字、自动补全、搜索、富文本、代码、单复选、组合框、开关、分段、日期时间、级联、树、穿梭、上传、滑块和评分;尺寸、前后缀、清除、计数、下拉空态、多选标签、远程搜索及错误、只读、禁用;标签、必填、校验、栅格、查询重置、展开收起和条件计数。 +- [ ] **操作按钮**:主、次、默认、虚线、文本、链接、图标、危险、幽灵、下拉、分裂;大小、形状、块级、图标间距、点击热区、加载和禁用;按钮组、长文案与多语言折行、工具栏及弹层主操作、权限隐藏和禁用提示;危险二次确认、防重入、键盘焦点、语义色及深浅映射。复用组件和 token。 +- [ ] **浮层与反馈**:弹窗和抽屉的尺寸、位置、结构、遮罩、关闭与二次确认;提示与气泡的定位、箭头、背景、阴影和触发;警告、消息、通知、无权占位及关闭反馈。 +- [ ] **图形**:图表、拓扑、流程的 Canvas、WebGL 或 SVG;容器、DPR、清晰度、坐标轴、网格、图例、标注、配色、提示和动画终态。 +- [ ] **状态**:骨架、加载、空态、失败、禁用、校验、选中;文字与图标能传达状态,空态操作不越权。 +- [ ] **交互**:悬停、键盘焦点、按压、展开收起、表单、弹层、搜索分页、主题语言、导航与多页签;过渡时长、缓动、关键帧、进出场与减少动态效果。真实 CRUD 按基线、创建、复查、编辑、复查、删除、复查执行。 + +## 记录口径 + +- 每项差异记录页面、组件、属性、期望、实际、严重级、截图与建议;只读、真实写入与模拟场景分别记账。 +- 视觉证据注明主题、视口、DPR、语言、字体和数据模式;跨主题像素变化不等于缺陷,只有同条件基线比较可按视觉阈值判定。 diff --git a/docs/ui/GLOBAL_UI_BASELINE.md b/docs/ui/GLOBAL_UI_BASELINE.md index 1460e8bd..c3e3f362 100644 --- a/docs/ui/GLOBAL_UI_BASELINE.md +++ b/docs/ui/GLOBAL_UI_BASELINE.md @@ -1,6 +1,6 @@ # 后台 UI 全局基线 -> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v3.11 +> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-19 · 版本:v3.12 后台外壳与布局基线:顶栏、侧栏、公告、页头与内容边距、登录页,以及原型未定义场景、登录关卡与验收流程。主题与组件样式见 `UI_COMPONENT_STANDARDS.md`。 @@ -51,7 +51,7 @@ - 桌面高 72px、移动 56px,另含 1px 底部分隔线;背景、文字、分隔线跟随双主题变量。 - 主导航:导航项撑满顶栏,左右内边距 24px;2px 主色下划线两端内缩 16px;选中项主色文字,普通项悬停保留正常文字色,键盘焦点可见。不改链接与权限条件。 -- 右侧按钮:主题、公告、语言等图标 16px,工具按钮点击区 34px,账户下拉箭头 10px;`.ui-header-actions` 内图标容器为 inline-flex,使图标与文字垂直居中。 +- 右侧按钮:主题、公告、语言等图标 16px,按钮高度与工具按钮点击区 34px、文字行高 20px,账户头像 32px、下拉箭头 10px;`.ui-header-actions` 内链接、徽标和图标容器为 inline-flex,图标、文字、头像与分隔线垂直居中;桌面专属操作在 768px 以下隐藏。 - 全站共享顶栏不展示未登录用户的“登录 / 注册”按钮,桌面与移动端一致;已登录用户保留头像与账户菜单,登录 / 注册页面及受保护导航的原有鉴权跳转保持不变。 - 主题按钮为 `Button` + `Tooltip`,点击在浅色与深色之间直接切换,不提供下拉或“跟随系统”;沿用现有主题 setter 与持久化,覆盖 `/org/login`、`/login` 与共享顶栏。 - WeyAi 下载按钮复用现有下载配置与权限判定,跳转 `/weyai/download`;使用 antd text 按钮默认悬停背景与 `Tooltip`,不硬编码外部地址。 diff --git a/src/App.jsx b/src/App.jsx index 514ca131..b35713a0 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -130,9 +130,11 @@ const ORG_USER_NAV_PATHS = { keyManagement: ['/key-management', '/user-center/key-management'], userCenter: ['/user-center'], }; +const matchesPathPrefix = (pathname, prefix) => + pathname === prefix || pathname.startsWith(`${prefix}/`); const isOrgAllowedPath = (pathname, extraPrefixes = []) => - [...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some( - (p) => pathname === p || pathname.startsWith(p + '/'), + [...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some((prefix) => + matchesPathPrefix(pathname, prefix), ); // 模型超市旧路径 /pricing → /market。用组件而非静态 , @@ -220,27 +222,38 @@ function App() { // /org,从此无任何路径把平台技能加入企业技能库——技能库与分发页永远为空。 // 顶栏开关的本意是收敛"员工浏览目录",不应连带阉割企业治理能力,故对 // 管理员无条件放行该路由(页面内部仍按 skill_manage 决定是否出现启用按钮)。 - if (isOrgAdmin && !prefixes.includes('/skill-market')) { + if ( + orgMembershipLoaded && + isOrgAdmin && + !prefixes.includes('/skill-market') + ) { prefixes.push('/skill-market'); } return prefixes; - }, [statusState?.status?.HeaderNavModulesOrgUser, isOrgAdmin]); + }, [ + statusState?.status?.HeaderNavModulesOrgUser, + orgMembershipLoaded, + isOrgAdmin, + ]); // 路由级封锁:org_only 员工访问非企业路由一律回到企业空间。 // 仅在企业中心可用时启用,避免企业中心被全局关闭时与其内部回退跳转形成重定向死循环。 - // 企业列表未到位前不做封锁判定:isOrgAdmin 首帧恒 false,此时若直接重定向, - // 硬刷新/收藏夹直达 /skill-market 的 org_only 管理员会在放行判据还没算出来时 - // 就被弹回 /org,而重定向不可逆——之后 isOrgAdmin 变 true 也回不去。 + // 只有技能超市的企业管理员特例需要等待企业列表;等待时也不挂载受限页面。 + const routePath = location.pathname.toLowerCase(); const orgConfined = userState?.user?.org_only_mode === true && - orgMembershipLoaded && isOrgCenterAvailable && - !isOrgAllowedPath(location.pathname, orgUserAllowedPrefixes); + !isOrgAllowedPath(routePath, orgUserAllowedPrefixes); if (orgConfined) { return ( - + {!orgMembershipLoaded && + matchesPathPrefix(routePath, '/skill-market') ? ( + + ) : ( + + )} ); } diff --git a/src/components/analytics/ChannelConsumption.jsx b/src/components/analytics/ChannelConsumption.jsx index 7d44aea2..f0829beb 100644 --- a/src/components/analytics/ChannelConsumption.jsx +++ b/src/components/analytics/ChannelConsumption.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatPercent } from '../../helpers/safeDisplay'; import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js'; import React, { useState } from 'react'; @@ -118,7 +119,7 @@ const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => { width: 80, align: 'right', render: (val) => ( - {(val || 0).toFixed(1)}% + {formatPercent(val || 0, 1)} ), }, ]; diff --git a/src/components/analytics/HighFreqLowCostUsers.jsx b/src/components/analytics/HighFreqLowCostUsers.jsx index ea0eb042..b107dad1 100644 --- a/src/components/analytics/HighFreqLowCostUsers.jsx +++ b/src/components/analytics/HighFreqLowCostUsers.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatUserReference } from '../../helpers/safeDisplay'; import React, { useMemo, useState } from 'react'; import { @@ -113,7 +114,9 @@ const HighFreqLowCostUsers = ({ width: 160, render: (v, row) => (
- {v || row.username || `user_${row.user_id}`} + + {formatUserReference(v || row.username, row.user_id, t('未知用户'))} + {row.username && v && row.username !== v && ( @{row.username} diff --git a/src/components/analytics/ModelDistribution.jsx b/src/components/analytics/ModelDistribution.jsx index cad7ab91..d226685b 100644 --- a/src/components/analytics/ModelDistribution.jsx +++ b/src/components/analytics/ModelDistribution.jsx @@ -21,6 +21,7 @@ import React, { useMemo } from 'react'; import { Card } from '@/components/ui'; import { VChart } from '@visactor/react-vchart'; import { renderQuota } from '../../helpers'; +import { formatPercent } from '../../helpers/safeDisplay'; const ModelDistribution = ({ data, title, icon, t }) => { const pieSpec = useMemo(() => { @@ -119,12 +120,12 @@ const ModelDistribution = ({ data, title, icon, t }) => { {index + 1} - {item.model_name} + {item.model_name || t('未知')} - {item.percent?.toFixed(1)}% + {formatPercent(item.percent, 1)}
))} diff --git a/src/components/analytics/OrgRealtimeUsage.jsx b/src/components/analytics/OrgRealtimeUsage.jsx index 9a7a151b..f9273764 100644 --- a/src/components/analytics/OrgRealtimeUsage.jsx +++ b/src/components/analytics/OrgRealtimeUsage.jsx @@ -17,6 +17,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatPercent } from '../../helpers/safeDisplay'; import React, { useState, useCallback } from 'react'; import { Badge, Empty, Progress, Skeleton, Tag, Tooltip, theme } from 'antd'; import { ArrowDown } from 'lucide-react'; @@ -275,7 +276,7 @@ const OrgRealtimeUsage = ({ className='text-sm font-semibold group-hover:underline' style={{ color: cacheRateColor(rate, token) }} > - {rate.toFixed(1)}% + {formatPercent(rate, 1)} . For commercial licensing, please contact support@quantumnous.com */ +import { formatPercent } from '../../helpers/safeDisplay'; import React from 'react'; import { Card } from '@/components/ui'; @@ -117,7 +118,7 @@ const OverviewCards = ({ overview, loading = false, t }) => { )} {isPositive ? '+' : ''} - {change.toFixed(1)}% + {formatPercent(change, 1)} ); diff --git a/src/components/analytics/RiskControlBanLogs.jsx b/src/components/analytics/RiskControlBanLogs.jsx index ae5ab0f9..9980f06f 100644 --- a/src/components/analytics/RiskControlBanLogs.jsx +++ b/src/components/analytics/RiskControlBanLogs.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatUserReference } from '../../helpers/safeDisplay'; import { Trans } from 'react-i18next'; import React, { useState } from 'react'; @@ -246,7 +247,9 @@ const RiskControlBanLogs = ({
{t('用户:')} - {unbanRow.user_snapshot || `user_${unbanRow.user_id}`}(ID: + {unbanRow.user_snapshot || + formatUserReference('', unbanRow.user_id, t('未知用户'))} + (ID: {unbanRow.user_id})
diff --git a/src/components/analytics/UserRanking.jsx b/src/components/analytics/UserRanking.jsx index 34421ad9..c9127a9c 100644 --- a/src/components/analytics/UserRanking.jsx +++ b/src/components/analytics/UserRanking.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatUserReference } from '../../helpers/safeDisplay'; import { Trans } from 'react-i18next'; import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js'; @@ -104,9 +105,13 @@ const UserRanking = ({ data, title, icon, t }) => {
- {item.display_name || item.username || `User ${item.user_id}`} + {formatUserReference( + item.display_name || item.username, + item.user_id, + t('未知用户'), + )} #{item.user_id} diff --git a/src/components/analytics/UserSurveyStats.jsx b/src/components/analytics/UserSurveyStats.jsx index 68b27268..44779383 100644 --- a/src/components/analytics/UserSurveyStats.jsx +++ b/src/components/analytics/UserSurveyStats.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatPercent } from '../../helpers/safeDisplay'; import React, { useMemo, useState, useEffect, useCallback } from 'react'; import { Card, Spin, Tag, Progress } from '@/components/ui'; @@ -130,7 +131,7 @@ const UserSurveyStats = ({ title, icon, t }) => { }, { key: () => t('占比'), - value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`, + value: (datum) => formatPercent(datum?.percentage || 0, 1), }, ], }, @@ -186,7 +187,7 @@ const UserSurveyStats = ({ title, icon, t }) => { }, { key: () => t('占比'), - value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`, + value: (datum) => formatPercent(datum?.percentage || 0, 1), }, ], }, diff --git a/src/components/analytics/UserTopupRanking.jsx b/src/components/analytics/UserTopupRanking.jsx index 336e17f4..24f354d4 100644 --- a/src/components/analytics/UserTopupRanking.jsx +++ b/src/components/analytics/UserTopupRanking.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatUserReference } from '../../helpers/safeDisplay'; import { Trans } from 'react-i18next'; import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js'; @@ -80,9 +81,9 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
- {text || `User ${record.user_id}`} + {formatUserReference(text, record.user_id, t('未知用户'))} {I18N_TECHNICAL_TEXT.ID} {record.user_id} diff --git a/src/components/analytics/orgReport/ActionCenter.jsx b/src/components/analytics/orgReport/ActionCenter.jsx index f1fabc1f..2a838a57 100644 --- a/src/components/analytics/orgReport/ActionCenter.jsx +++ b/src/components/analytics/orgReport/ActionCenter.jsx @@ -30,6 +30,7 @@ import { } from '@/components/ui'; import { ClipboardList } from 'lucide-react'; import { ChangeText, OrgNameCell, ReasonTags, SectionCard } from './shared'; +import { formatRatioPercent } from '../../../helpers/safeDisplay'; import { daysSince, downloadCsv, @@ -284,7 +285,11 @@ const columnsFor = (tab, cny, t, atRisk) => { {v}/{r.member_count} {r.member_count > 0 ? ( - {Math.min(100, (v / r.member_count) * 100).toFixed(0)}% + {formatRatioPercent( + Math.min(100, Number(v) || 0), + r.member_count, + 0, + )} ) : null} diff --git a/src/components/analytics/orgReport/Overview.jsx b/src/components/analytics/orgReport/Overview.jsx index 066821c5..1b146c19 100644 --- a/src/components/analytics/orgReport/Overview.jsx +++ b/src/components/analytics/orgReport/Overview.jsx @@ -31,6 +31,10 @@ import { } from 'lucide-react'; import { ChangeText, KpiCard, SectionCard } from './shared'; import { formatCny, formatCst, pct, SEGMENTS } from './utils'; +import { + formatPercent, + formatRatioPercent, +} from '../../../helpers/safeDisplay'; // ─── 报表抬头:统计口径 + 数据状态 ───────────────────────────────── export const ReportHeader = ({ report, onExport, t }) => { @@ -209,7 +213,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => { n: (k.active_orgs || 0).toLocaleString(), count: k.active_orgs || 0, }), - sub: `${t('活跃率')} ${pct(k.active_orgs, servingOrgs).toFixed(1)}% · ${t('新增')} ${k.new_orgs || 0}`, + sub: `${t('活跃率')} ${formatRatioPercent(k.active_orgs, servingOrgs)} · ${t('新增')} ${k.new_orgs || 0}`, compare: ( ), @@ -229,7 +233,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => { n: (k.active_members || 0).toLocaleString(), count: k.active_members || 0, }), - sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`, + sub: `${t('渗透率')} ${formatPercent(Math.min(100, pct(k.active_members, k.total_members)))} · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`, tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'), onClick: () => onJump('growth'), }, @@ -277,7 +281,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => { }, { title: t('企业消耗占平台'), - value: `${share.toFixed(1)}%`, + value: formatPercent(share), sub: `${t('个人消耗')} ${formatCny(k.personal_quota, cny)}`, compare: shareDelta === null ? null : ( @@ -341,7 +345,7 @@ export const HealthSegments = ({ report, cny, activeSegment, onSelect, t }) => { {t(meta.label)} - {pct(s.count, totalCount).toFixed(0)}% + {formatPercent(pct(s.count, totalCount), 0)}
diff --git a/src/components/analytics/orgReport/Tables.jsx b/src/components/analytics/orgReport/Tables.jsx index 95bb1702..c786d5f9 100644 --- a/src/components/analytics/orgReport/Tables.jsx +++ b/src/components/analytics/orgReport/Tables.jsx @@ -30,6 +30,7 @@ import { } from '@/components/ui'; import { Search, Table2, UserCog } from 'lucide-react'; import { ChangeText, OrgNameCell, SectionCard } from './shared'; +import { formatPercent } from '../../../helpers/safeDisplay'; import { ALERT_LEVELS, ORG_STATUS, @@ -266,7 +267,7 @@ export const OrgDetailTable = ({ report, filter, setFilter, cny, t }) => { align: 'right', render: (v) => v > 0 ? ( - {v.toFixed(1)}% + {formatPercent(v, 1)} ) : ( — ), @@ -501,8 +502,8 @@ export const exportOrgDetail = (rows, cny, t) => { SEGMENTS[o.segment] ? t(SEGMENTS[o.segment].label) : '', yuan(o.quota), yuan(o.prev_quota), - rate === null ? '' : `${rate.toFixed(1)}%`, - o.share ? `${o.share.toFixed(2)}%` : '', + rate === null ? '' : formatPercent(rate, 1), + o.share ? formatPercent(o.share, 2) : '', o.requests, o.active_members, o.member_count, diff --git a/src/components/analytics/orgReport/shared.jsx b/src/components/analytics/orgReport/shared.jsx index dac50035..86b872e6 100644 --- a/src/components/analytics/orgReport/shared.jsx +++ b/src/components/analytics/orgReport/shared.jsx @@ -21,6 +21,7 @@ import React from 'react'; import { Card, Tag, Tooltip } from '@/components/ui'; import { TrendingDown, TrendingUp } from 'lucide-react'; import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils'; +import { formatPercent } from '../../../helpers/safeDisplay'; export const SectionCard = ({ id, @@ -90,7 +91,7 @@ export const ChangeText = ({ cur, prev, t, size = 'xs', showNew = true }) => { )} {up ? '+' : ''} - {rate.toFixed(1)}% + {formatPercent(rate, 1)} ); }; diff --git a/src/components/analytics/orgReport/utils.js b/src/components/analytics/orgReport/utils.js index 4de61618..23876bcd 100644 --- a/src/components/analytics/orgReport/utils.js +++ b/src/components/analytics/orgReport/utils.js @@ -16,6 +16,8 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../../helpers/safeDisplay'; +import { formatPercent } from '../../../helpers/safeDisplay'; // 企业经营决策报表:口径常量、行动清单派生、要点生成、CSV 导出 @@ -52,7 +54,15 @@ export const formatRate = (rate) => ? '—' : `${rate >= 0 ? '+' : ''}${rate.toFixed(1)}%`; -export const pct = (part, total) => (total > 0 ? (part / total) * 100 : 0); +export const pct = (part, total) => { + const numerator = Number(part); + const denominator = Number(total); + return Number.isFinite(numerator) && + Number.isFinite(denominator) && + denominator > 0 + ? (numerator / denominator) * 100 + : 0; +}; // ─── 时间(报表口径统一为 UTC+8,与浏览器时区无关) ───────────────── const pad = (n) => String(n).padStart(2, '0'); @@ -405,11 +415,11 @@ export const deriveFindings = (report, lists, cny, t) => { ? t( '头部依赖较高:Top5 企业贡献 {{share}} 的企业消耗,需关注大客户稳定性', { - share: `${k.top5_share.toFixed(1)}%`, + share: formatPercent(k.top5_share, 1), }, ) : t('客户结构较分散:Top5 企业贡献 {{share}} 的企业消耗', { - share: `${k.top5_share.toFixed(1)}%`, + share: formatPercent(k.top5_share, 1), }), target: 'tiers', }); @@ -426,7 +436,7 @@ export const deriveFindings = (report, lists, cny, t) => { text: t( '企业成员渗透率 {{rate}},{{count}} 家企业成员活跃率低于 30%,存在增量空间', { - rate: `${Math.min(100, penetration).toFixed(1)}%`, + rate: formatPercent(Math.min(100, penetration), 1), count: lowPen, }, ), @@ -467,4 +477,6 @@ export const downloadCsv = (filename, headers, rows) => { }; export const orgDisplayName = (o, t) => - o.deleted ? `${t('已删除企业')} #${o.org_id}` : o.name || `#${o.org_id}`; + o.deleted + ? `${t('已删除企业')} ${formatIdReference(o.org_id)}` + : o.name || formatIdReference(o.org_id); diff --git a/src/components/auth/AuthLoginTabs.jsx b/src/components/auth/AuthLoginTabs.jsx index 07826d4c..077a247d 100644 --- a/src/components/auth/AuthLoginTabs.jsx +++ b/src/components/auth/AuthLoginTabs.jsx @@ -19,8 +19,9 @@ For commercial licensing, please contact support@quantumnous.com import React from 'react'; import { Button } from 'antd'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, useSearchParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; +import { isSafePostLoginRedirect } from '../../helpers/data'; /** * 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。 @@ -34,6 +35,12 @@ import { useTranslation } from 'react-i18next'; const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => { const { t } = useTranslation(); const navigate = useNavigate(); + const [searchParams] = useSearchParams(); + const redirect = searchParams.get('redirect'); + const loginSearch = + mode === 'login' && isSafePostLoginRedirect(redirect) + ? `?${new URLSearchParams({ redirect })}` + : ''; // 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口 const tabs = @@ -57,7 +64,7 @@ const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => { type={isActive ? 'primary' : 'text'} aria-pressed={isActive} onClick={() => { - if (!isActive) navigate(tab.to); + if (!isActive) navigate(`${tab.to}${loginSearch}`); }} className='flex-1 font-medium' > diff --git a/src/components/auth/LoginForm.jsx b/src/components/auth/LoginForm.jsx index 28d86168..872b0621 100644 --- a/src/components/auth/LoginForm.jsx +++ b/src/components/auth/LoginForm.jsx @@ -220,12 +220,17 @@ const LoginForm = () => { }; }, []); + const redirect = searchParams.get('redirect'); useEffect(() => { - const redirect = searchParams.get('redirect'); - if (redirect) { - savePostLoginRedirect(redirect); - } - if (searchParams.get('expired')) { + savePostLoginRedirect(redirect); + }, [redirect]); + + const expiryShown = useRef(false); + useEffect(() => { + if (!searchParams.get('expired')) { + expiryShown.current = false; + } else if (!expiryShown.current) { + expiryShown.current = true; showError(t('未登录或登录已过期,请重新登录')); const nextParams = new URLSearchParams(searchParams); nextParams.delete('expired'); @@ -234,15 +239,15 @@ const LoginForm = () => { }, [searchParams, setSearchParams, t]); const finishLogin = useCallback( - (data, successMessage) => + (data) => runLoginFlow({ data, userDispatch, navigate, t, - successMessage, + redirect, }), - [navigate, t, userDispatch], + [navigate, redirect, t, userDispatch], ); const onWeChatLoginClicked = () => { diff --git a/src/components/auth/TwoFAVerification.jsx b/src/components/auth/TwoFAVerification.jsx index 58b18835..f792dec7 100644 --- a/src/components/auth/TwoFAVerification.jsx +++ b/src/components/auth/TwoFAVerification.jsx @@ -17,7 +17,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { Trans } from 'react-i18next'; -import { API, showError, showSuccess } from '../../helpers'; +import { API, showError } from '../../helpers'; import { Button, Card, Divider, Form, Typography } from '@/components/ui'; import React, { useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -51,7 +51,6 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => { }); if (res.data.success) { - showSuccess(t('登录成功')); if (onSuccess) { onSuccess(res.data.data); } diff --git a/src/components/common/table/TableToolbar.jsx b/src/components/common/table/TableToolbar.jsx index 217ab56f..d6935ecf 100644 --- a/src/components/common/table/TableToolbar.jsx +++ b/src/components/common/table/TableToolbar.jsx @@ -18,9 +18,41 @@ For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; +import { Button, Dropdown } from 'antd'; import { useTranslation } from 'react-i18next'; +import { ChevronDown } from '../icons/ActionIcons'; import './table-toolbar.css'; +export function TableRowActions({ children, items = [] }) { + const { t } = useTranslation(); + const menuItems = items.filter(Boolean); + if (!children && !menuItems.length) return null; + + return ( +
+ {children} + {menuItems.length > 0 && ( + + + + )} +
+ ); +} + export function TableTitle({ children }) { const { t } = useTranslation(); return ( diff --git a/src/components/common/table/table-toolbar.css b/src/components/common/table/table-toolbar.css index d89d4d83..db39c4c2 100644 --- a/src/components/common/table/table-toolbar.css +++ b/src/components/common/table/table-toolbar.css @@ -1,3 +1,10 @@ +.table-row-actions { + display: inline-flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; +} + .table-toolbar { display: flex; align-items: center; diff --git a/src/components/console/ConsolePrimitives.jsx b/src/components/console/ConsolePrimitives.jsx index c1f32f8f..72e8e0fb 100644 --- a/src/components/console/ConsolePrimitives.jsx +++ b/src/components/console/ConsolePrimitives.jsx @@ -118,6 +118,28 @@ export function ConsoleSearchActions({ ); } +export function ConsoleFilterGrid({ children, onReset, onSearch, loading }) { + return ( +
+
{children}
+ +
+ ); +} + +export function ConsoleFilterField({ label, id, children }) { + return ( +
+ + {children} +
+ ); +} + export const ConsoleForm = forwardRef(function ConsoleForm( { className, layout = 'vertical', ...props }, ref, @@ -167,6 +189,16 @@ export function ConsoleTabs({ className, ...props }) { return ; } +export function ConsoleListTable({ locale, ...props }) { + return ( + , ...locale }} + /> + ); +} + const isFooterButton = (node) => React.isValidElement(node) && (node.type === Button || node.type?.render?.name === 'Button'); diff --git a/src/components/console/console.css b/src/components/console/console.css index 9dc7042f..b4dbc690 100644 --- a/src/components/console/console.css +++ b/src/components/console/console.css @@ -233,6 +233,67 @@ gap: var(--console-space-1); margin-inline-start: auto; } +.console-filter-panel { + width: 100%; +} +.console-page .console-search-card .console-filter-panel.ant-form { + display: block; +} +.console-filter-grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 1rem; + width: 100%; +} +.console-filter-field { + display: flex; + flex-direction: column; + gap: 8px; + min-width: 0; +} +.console-filter-field > label, +.console-page .console-filter-grid .ant-form-item-label > label { + color: var(--console-muted); + font-size: 13px; +} +.console-filter-field > :is(.ant-input-number, .ant-picker) { + width: 100%; +} +.console-filter-panel .console-search-actions { + margin-top: 1rem; +} +.console-table.console-list-table .ant-table-thead > tr > th { + height: 46px; + padding-block: 0; + font-weight: 400; +} +.console-list-tools, +.console-list-quick-filters, +.console-list-tool-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 8px; +} +.console-list-tools { + width: 100%; + gap: 12px 20px; + justify-content: space-between; +} +.console-list-tool-actions { + justify-content: flex-end; + margin-inline-start: auto; +} +@media (max-width: 1100px) { + .console-filter-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +@media (max-width: 768px) { + .console-filter-grid { + grid-template-columns: minmax(0, 1fr); + } +} .console-page .console-table .ant-table-thead > tr > th { --center-table-head-bg: var(--console-fill); color: var(--console-muted); diff --git a/src/components/layout/PageLayout.jsx b/src/components/layout/PageLayout.jsx index 24c1bd0e..4267d177 100644 --- a/src/components/layout/PageLayout.jsx +++ b/src/components/layout/PageLayout.jsx @@ -198,12 +198,20 @@ const PageLayout = () => { return; } + const sessionAPI = API; + const isCurrentSession = () => { + const currentUser = getUserData(); + return ( + sessionAPI === API && currentUser?.id === cachedUser.id && !!currentUser + ); + }; userDispatch({ type: 'auth_start' }); try { - const res = await API.get('/api/user/self', { + const res = await sessionAPI.get('/api/user/self', { skipErrorHandler: true, disableDuplicate: true, }); + if (!isCurrentSession()) return; const { success, data } = res.data; if (success && data) { setUserData(data); @@ -213,6 +221,7 @@ const PageLayout = () => { userDispatch({ type: 'logout' }); } } catch (error) { + if (!isCurrentSession()) return; if (error?.response?.status === 401 || error?.response?.status === 403) { clearUserData(); userDispatch({ type: 'logout' }); diff --git a/src/components/layout/headerbar/ActionButtons.jsx b/src/components/layout/headerbar/ActionButtons.jsx index 11caada1..ccb31c29 100644 --- a/src/components/layout/headerbar/ActionButtons.jsx +++ b/src/components/layout/headerbar/ActionButtons.jsx @@ -146,7 +146,10 @@ const ActionButtons = ({
{/* Tutorial Button - 新手教程按钮 (桌面端显示) */} {isLoggedIn && isButtonVisible('tutorial') && ( - + {!isMobile && t('新手教程')} @@ -157,7 +160,7 @@ const ActionButtons = ({ {isLoggedIn && isButtonVisible('pricing') && ( setPromotionVisible(true)} > {!isMobile && t('推广')} @@ -169,7 +172,7 @@ const ActionButtons = ({ + { copyWithFeedback(affCode, t('邀请码')); }; - // 链接分享模式 - PC友好 const renderLinkMode = () => ( -
- {/* 分享卡片 */} -
- {/* 装饰元素 */} -
-
-
- -
- {/* 平台信息 */} -
-
- -
-
-

- {systemName} -

-

- {posterConfig?.slogan || t('邀请好友,共享AI')} -

-
-
- - {/* 福利说明 */} -
-
- - {t('注册即送额度')} -
-
- - {t('消费返佣')} -
-
- - {/* 二维码(小尺寸) */} -
-
- -
-
-

{t('手机扫码注册')}

-

- {t('邀请码')}:{' '} - - {affCode} - -

-
-
-
-
- - {/* 链接输入框 */} -
- - {t('邀请链接')} - -
-
- +
+
{t('推广分享')}
+ {systemName} + + {posterConfig?.slogan || t('邀请好友,共享AI')} + +
+ } - onClick={handleCopyLink} - className='!bg-gradient-to-r !from-brand-from !to-brand-to !border-0 !rounded-lg' - > - {t('复制')} - - } + size={144} + level='M' + marginSize={2} />
-
- - {/* 邀请码 */} -
- - {t('邀请码')} - -
-
-
- - {affCode} - -
+ {t('手机扫码注册')} +
+ + + {t('注册即送额度')} + + + + {t('消费返佣')} + +
+ +
+
+ +
-
- - {/* 使用说明 */} -
-
- - - {t( - '将链接发送给好友,好友点击即可注册。支持微信、QQ、邮件等任意方式分享。', - )} +
+ + {t('邀请码')} +
+ + {affCode} + + +
-
+ + {t( + '将链接发送给好友,好友点击即可注册。支持微信、QQ、邮件等任意方式分享。', + )} + +
); - // 海报模式 - 移动端友好 const renderPosterMode = () => ( -
- {/* 模板选择 */} -
- - {t('选择模板')} - -
- {DEFAULT_TEMPLATES.map((template) => ( - - ))} -
-
- - {/* 海报预览 */} -
- {/* 装饰元素 */} -
-
- -
-

- {posterConfig?.slogan || t('邀请好友,共享AI')} -

-

+

+
+
+

{posterConfig?.slogan || t('邀请好友,共享AI')}

+

{posterConfig?.sub_slogan || t('注册即可获得免费额度')}

- -

- {systemName} -

- -
+

{systemName}

+
- -

- {t('扫码注册')} +

{t('扫码注册')}

+

+ {t('邀请码')}: {affCode} +

+

+ {posterConfig?.footer_text || t('长按识别二维码,立即体验AI')}

- -
-

- {t('邀请码')}: {affCode} -

-
- -
-
-

- {posterConfig?.footer_text || t('长按识别二维码,立即体验AI')} -

-
- - {/* 隐藏的 canvas 用于导出 */} - - - {/* 操作按钮 */} -
- - -
+
+
+ + {t('选择模板')} + + + setSelectedTemplate( + DEFAULT_TEMPLATES.find( + (item) => item.id === event.target.value, + ), + ) + } + > + {DEFAULT_TEMPLATES.map((template) => ( + + + + {t(template.name)} + + + ))} + +
+
+ + +
+ + {posterConfig?.footer_text || t('长按识别二维码,立即体验AI')} + +
+
); return ( -
- -
- {t('推广分享')} -
- } - visible={visible} + title={t('推广分享')} + open={visible} onCancel={onClose} footer={null} - width={520} + width={800} centered className='promotion-modal' - bodyStyle={{ padding: '0 24px 24px' }} > -
- {loading ? ( -
-
-
-
-
- - {t('加载中...')} - -
- ) : ( - <> - {/* 查看邀请奖励规则 - 顶部显眼横幅 */} -
{ - onClose(); - navigate('/user-center/invite'); - }} - > - {/* 装饰元素 */} -
-
- - {/* 动态光效 */} -
- -
-
-
- -
-
-
- {t('查看邀请奖励规则')} - -
-
- {t('了解返佣比例和奖励详情')} -
-
-
-
- - {t('立即查看')} - - -
-
- - {/* 底部小标签 */} -
- - - {t('消费返佣')} - - - - {t('额度奖励')} - -
-
- - {/* Tab 导航 */} + {loading ? ( +
+ +
+ ) : ( + <> + {affLink ? ( - - - {t('链接分享')} - - } - itemKey='link' - > -
{renderLinkMode()}
-
- - - {t('海报分享')} - - } - itemKey='poster' - > -
{renderPosterMode()}
-
-
- - )} -
+ items={[ + { + key: 'link', + label: ( + + + {t('链接分享')} + + ), + children: renderLinkMode(), + }, + { + key: 'poster', + label: ( + + + {t('海报分享')} + + ), + children: renderPosterMode(), + }, + ]} + /> + ) : ( + + )} + + + )} ); }; diff --git a/src/components/promotion/promotion-poster.css b/src/components/promotion/promotion-poster.css new file mode 100644 index 00000000..26445b98 --- /dev/null +++ b/src/components/promotion/promotion-poster.css @@ -0,0 +1,352 @@ +/* Copyright (C) 2025 QuantumNous */ + +.promotion-modal.ant-modal { + --pm-surface: var(--surface-card); + --pm-muted: var(--surface-bg-base); + --pm-text: var(--text-primary); + --pm-secondary: var(--text-secondary); + --pm-border: var(--border-subtle); + --pm-accent: var(--brand-primary); + --pm-soft: var(--brand-primary-soft); + --pm-qr-surface: #fff; + max-width: calc(100vw - 32px); + padding-block: 24px; +} +.promotion-modal .ant-modal-container { + padding: 28px 32px; + border-radius: 12px; +} +.promotion-modal .ant-modal-header { + margin-bottom: 12px; +} +.promotion-modal .ant-modal-title { + font-size: 20px; + line-height: 28px; +} +.promotion-modal .ant-modal-close { + top: 24px; + right: 24px; +} +.promotion-modal .ant-modal-body { + max-height: calc(100dvh - 160px); + overflow-y: auto; + overscroll-behavior: contain; +} +.promotion-tabs > .ant-tabs-nav { + margin-bottom: 24px; +} +.pm-tab-label { + display: inline-flex; + align-items: center; + gap: 8px; +} +.pm-link-layout { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); + gap: 32px; + align-items: stretch; +} +.pm-invitation-card { + display: flex; + flex-direction: column; + align-items: center; + padding: 28px 20px; + border: 1px solid var(--pm-border); + border-radius: 12px; + background: var(--pm-muted); + text-align: center; + min-width: 0; +} +.pm-eyebrow { + margin-bottom: 12px; + color: var(--pm-accent); + font-size: 12px; + letter-spacing: 0.08em; +} +.pm-invitation-card h4.ant-typography { + margin: 0 0 8px; + font-size: 20px; + overflow-wrap: anywhere; +} +.pm-invitation-card .ant-typography { + max-width: 100%; +} +.pm-qrcode { + padding: 12px; + background: var(--pm-qr-surface); + border-radius: 12px; + margin: 8px 0 16px; +} +.pm-qrcode canvas, +.pm-poster-qr canvas { + display: block; + max-width: 100%; + height: auto; +} +.pm-benefits { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 8px 16px; + margin-top: 24px; + color: var(--pm-secondary); + font-size: 12px; +} +.pm-benefits span { + display: inline-flex; + align-items: center; + gap: 6px; +} +.pm-share-details { + display: flex; + flex-direction: column; + justify-content: center; + gap: 28px; + min-width: 0; + padding-block: 12px; +} +.pm-field { + display: flex; + flex-direction: column; + align-items: stretch; + gap: 12px; + min-width: 0; +} +.pm-field label { + color: var(--pm-text); + font-size: 14px; + font-weight: 600; +} +.pm-field > .ant-btn { + align-self: flex-start; +} +.pm-code-row { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 16px; +} +.promotion-modal .pm-code { + padding: 10px 16px; + color: var(--pm-accent); + background: var(--pm-soft); + border-radius: 8px; + font: + 600 20px/28px Consolas, + monospace; + letter-spacing: 0.06em; + overflow-wrap: anywhere; + min-width: 0; +} +.promotion-modal .pm-share-hint { + margin: 0; + font-size: 13px; + line-height: 1.8; +} +.pm-rewards { + display: flex; + align-items: center; + gap: 14px; + width: 100%; + margin-top: 24px; + padding: 16px; + background: var(--pm-surface); + color: var(--pm-text); + border: 1px solid var(--pm-border); + border-radius: 10px; + font: inherit; + text-align: left; + cursor: pointer; +} +.pm-rewards:hover { + border-color: var(--pm-accent); + background: var(--pm-soft); +} +.pm-rewards-icon { + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + width: 40px; + height: 40px; + border-radius: 8px; + color: var(--pm-accent); + background: var(--pm-soft); +} +.pm-rewards-copy { + display: grid; + gap: 4px; + flex: 1; + min-width: 0; +} +.pm-rewards-copy strong { + font-size: 14px; + font-weight: 600; +} +.pm-rewards-copy > span { + color: var(--pm-secondary); + font-size: 12px; +} +.pm-rewards > svg { + flex-shrink: 0; + color: var(--pm-secondary); +} +.pm-poster-layout { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); + gap: 32px; + align-items: center; +} +.pm-preview-stage { + display: flex; + justify-content: center; + padding: 20px; + border: 1px solid var(--pm-border); + border-radius: 12px; + background: var(--pm-muted); + min-width: 0; +} +.pm-poster { + display: flex; + flex-direction: column; + align-items: center; + width: 240px; + min-width: 0; + aspect-ratio: 375 / 667; + padding: 28px 16px 20px; + background: var(--pm-poster-background); + color: var(--pm-poster-ink); + border-radius: 8px; + text-align: center; +} +.pm-poster h2 { + margin: 0 0 8px; + font-size: 18px; + line-height: 1.5; + color: inherit; +} +.pm-poster p { + margin: 0; + font-size: 12px; + line-height: 1.6; + color: inherit; +} +.pm-poster h3 { + margin: 20px 0; + font-size: 16px; + line-height: 1.5; + color: inherit; +} +.pm-poster-qr { + padding: 8px; + background: var(--pm-qr-surface); + border-radius: 8px; + margin-bottom: 12px; +} +.pm-poster .pm-poster-code { + font-weight: 600; + margin-top: 8px; + overflow-wrap: anywhere; +} +.pm-poster .pm-poster-footer { + margin-top: auto; + padding-top: 20px; + font-size: 10px; +} +.pm-poster-options { + display: grid; + gap: 24px; + min-width: 0; +} +.pm-template-list { + display: grid; + gap: 8px; +} +.promotion-modal .pm-template-list .ant-radio-wrapper { + display: flex; + align-items: center; + margin: 0; + padding: 10px 12px; + border: 1px solid var(--pm-border); + border-radius: 8px; +} +.promotion-modal .pm-template-list .ant-radio-wrapper-checked { + border-color: var(--pm-accent); + background: var(--pm-soft); +} +.pm-template-label { + display: inline-flex; + align-items: center; + gap: 10px; +} +.pm-template-swatch { + display: block; + width: 24px; + height: 24px; + border-radius: 6px; + background: var(--pm-template-background); +} +.pm-poster-actions { + display: grid; + gap: 12px; +} +.pm-loading { + padding-block: 32px; +} +.promotion-modal :is(button, input):focus-visible { + outline: 2px solid var(--pm-accent); + outline-offset: 3px; +} +@media (max-width: 600px) { + .promotion-modal .ant-modal-container { + padding: 20px; + } + .promotion-modal .ant-modal-title { + font-size: 18px; + } + .promotion-modal .ant-modal-close { + top: 18px; + right: 16px; + } + .promotion-modal .ant-modal-body { + max-height: calc(100dvh - 136px); + } + .pm-link-layout, + .pm-poster-layout { + grid-template-columns: minmax(0, 1fr); + gap: 24px; + } + .pm-invitation-card { + padding: 20px 16px; + } + .pm-benefits { + margin-top: 16px; + } + .pm-share-details { + gap: 24px; + padding: 0; + } + .pm-field > .ant-btn { + width: 100%; + } + .pm-preview-stage { + padding: 16px; + } + .pm-template-list { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + .promotion-modal .pm-template-list .ant-radio-wrapper { + padding: 8px; + } + .pm-template-label { + gap: 6px; + font-size: 12px; + } + .pm-template-swatch { + width: 18px; + height: 18px; + } + .pm-rewards { + padding: 12px; + } +} diff --git a/src/components/quality/QualityDetail.jsx b/src/components/quality/QualityDetail.jsx index a631386d..d3620011 100644 --- a/src/components/quality/QualityDetail.jsx +++ b/src/components/quality/QualityDetail.jsx @@ -16,6 +16,8 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../helpers/safeDisplay'; +import { formatUserReference } from '../../helpers/safeDisplay'; import React, { useCallback, useEffect, useRef, useState } from 'react'; import { @@ -82,7 +84,7 @@ export const HopChain = ({ hops, outcome, t }) => { > {t('第 {{n}} 跳', { n: i + 1 })} ·{' '} - {hop.channel_name || `#${hop.channel_id}`} + {hop.channel_name || formatIdReference(hop.channel_id)} {failed ? ( @@ -199,7 +201,7 @@ const QualityDetail = ({ quality, t }) => { width: 130, render: (v, row) => ( - {v || `#${row.user_id}`} + {v || formatUserReference('', row.user_id)} ), }, @@ -212,7 +214,7 @@ const QualityDetail = ({ quality, t }) => { render: (v, row) => row.organization_id ? ( - {v || `#${row.organization_id}`} + {v || formatIdReference(row.organization_id)} ) : ( @@ -240,7 +242,7 @@ const QualityDetail = ({ quality, t }) => { width: 140, render: (v, row) => ( - {row.channel_id ? v || `#${row.channel_id}` : '-'} + {row.channel_id ? v || formatIdReference(row.channel_id) : '-'} ), }, @@ -452,7 +454,9 @@ const QualityDetail = ({ quality, t }) => { {row.channel_name || - (row.channel_id ? `#${row.channel_id}` : '')} + (row.channel_id + ? formatIdReference(row.channel_id) + : '')} {(row.status_code || row.error_code) && ( diff --git a/src/components/quality/QualityFilterBar.jsx b/src/components/quality/QualityFilterBar.jsx index f37e5742..bed1db40 100644 --- a/src/components/quality/QualityFilterBar.jsx +++ b/src/components/quality/QualityFilterBar.jsx @@ -16,6 +16,8 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../helpers/safeDisplay'; +import { formatUserReference } from '../../helpers/safeDisplay'; import { SlidersHorizontal as ActionSlidersHorizontal, @@ -110,7 +112,7 @@ const RemoteSelect = ({ const name = labels.current[String(value)]; opts.unshift({ value: String(value), - label: name ? `${name} (#${value})` : `#${value}`, + label: name ? `${name} (#${value})` : formatIdReference(value), }); } return opts; @@ -193,7 +195,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => { if (filters.user_id) push( 'user_id', - `${isOrg ? t('成员') : t('用户')}: ${nameOf(options.members, filters.user_id) || '#' + filters.user_id}`, + `${isOrg ? t('成员') : t('用户')}: ${nameOf(options.members, filters.user_id) || formatUserReference('', filters.user_id)}`, ); if (filters.token_id) push( diff --git a/src/components/quality/QualityHeatmap.jsx b/src/components/quality/QualityHeatmap.jsx index e406afaf..8f5296ee 100644 --- a/src/components/quality/QualityHeatmap.jsx +++ b/src/components/quality/QualityHeatmap.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../helpers/safeDisplay'; import { Trans } from 'react-i18next'; import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js'; @@ -102,7 +103,9 @@ const QualityHeatmap = ({ quality, t }) => { (row.cells || []).forEach((c) => { byTs[c.ts] = c; }); - const name = names[row.channel_id] || `#${row.channel_id}`; + const name = + names[row.channel_id] || + formatIdReference(row.channel_id); return ( diff --git a/src/components/settings/CustomerServiceSetting.jsx b/src/components/settings/CustomerServiceSetting.jsx index 4f3c34e5..b28940d5 100644 --- a/src/components/settings/CustomerServiceSetting.jsx +++ b/src/components/settings/CustomerServiceSetting.jsx @@ -21,6 +21,7 @@ import { Plus as ActionPlus, Upload as ActionUpload, } from '@/components/common/icons/ActionIcons'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import React, { useState, useEffect, useCallback } from 'react'; import { Card, @@ -31,7 +32,6 @@ import { Select, Tag, Avatar, - Popconfirm, Typography, Space, Banner, @@ -307,28 +307,34 @@ const CustomerServiceSetting = () => { title: t('操作'), dataIndex: 'action', render: (_, record) => ( - - + handleToggleStatus(record), + danger: (record.status === 1 ? 'danger' : 'primary') === 'danger', + }, + { + key: 'delete', + label: t('删除'), + danger: true, + onClick: () => + Modal.confirm({ + title: t('确认删除'), + content: t('确定要删除这个客服吗?'), + okText: t('确认'), + cancelText: t('取消'), + okButtonProps: { danger: true }, + onOk: () => handleDelete(record.id), + }), + }, + ]} + > - handleDelete(record.id)} - > - - - + ), }, ]; diff --git a/src/components/settings/LevelPolicySetting.jsx b/src/components/settings/LevelPolicySetting.jsx index 26b03204..1fcabc01 100644 --- a/src/components/settings/LevelPolicySetting.jsx +++ b/src/components/settings/LevelPolicySetting.jsx @@ -24,6 +24,7 @@ import { ChevronDown as ActionChevronDown, ChevronRight as ActionChevronRight, } from '@/components/common/icons/ActionIcons'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { Card, @@ -989,7 +990,31 @@ const LevelPolicySetting = () => { title: t('操作'), width: 260, render: (_, r) => ( - + duplicateLevel(type, r.code), + title: t('以该等级为模板新建'), + }, + { + key: 'delete', + label: t('删除'), + disabled: deletingCode === `${type}/${r.code}`, + danger: true, + onClick: () => + Modal.confirm({ + title: t('确认删除该等级?'), + content: t('被用户/企业/默认等级引用时会被拒绝'), + okText: t('确认'), + cancelText: t('取消'), + okButtonProps: { danger: true }, + onOk: () => deleteLevel(type, r.code), + }), + }, + ]} + > - - - - deleteLevel(type, r.code)} - > - - - + ), }, ]; diff --git a/src/components/settings/TutorialVideoSetting.jsx b/src/components/settings/TutorialVideoSetting.jsx index b7e0cff9..1be4f83f 100644 --- a/src/components/settings/TutorialVideoSetting.jsx +++ b/src/components/settings/TutorialVideoSetting.jsx @@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import { useEffectEvent } from '../../hooks/common/useEffectEvent'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { @@ -27,7 +28,6 @@ import { Modal, Form, Toast, - Popconfirm, Switch, Tag, Progress, @@ -262,7 +262,29 @@ const TutorialVideoSetting = () => { title: t('操作'), width: 180, render: (_, record) => ( -
+ handleEdit(record), + }, + { + key: 'delete', + label: t('删除'), + danger: true, + onClick: () => + Modal.confirm({ + title: t('确定删除这个视频吗?'), + content: t('删除后将无法恢复'), + okText: t('确认'), + cancelText: t('取消'), + okButtonProps: { danger: true }, + onOk: () => handleDelete(record.id), + }), + }, + ]} + > - - handleDelete(record.id)} - > - - -
+ ), }, ]; diff --git a/src/components/smart-router/ProfileTable.jsx b/src/components/smart-router/ProfileTable.jsx index ce69f107..2d7ea2ac 100644 --- a/src/components/smart-router/ProfileTable.jsx +++ b/src/components/smart-router/ProfileTable.jsx @@ -19,7 +19,8 @@ For commercial licensing, please contact support@quantumnous.com import React, { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { Button, Empty, Popconfirm, Space, Tag, Typography } from 'antd'; +import { Button, Empty, Modal, Space, Tag, Typography } from 'antd'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import { Table } from '@/components/ui'; import { ConsoleAlert as Alert } from '../console/ConsolePrimitives'; import { Plus } from '../common/icons/ActionIcons'; @@ -148,7 +149,37 @@ const ProfileTable = ({ mode, orgId, canWrite = true, emptyHint }) => { fixed: 'right', width: 180, render: (_, r) => ( - + setEditing(r), + }, + canWrite && { + key: 'delete', + label: t('删除'), + danger: true, + onClick: () => + Modal.confirm({ + title: t('确认删除该集合?'), + content: t('使用该虚拟模型名的请求将返回"模型不存在"。'), + okText: t('确认'), + cancelText: t('取消'), + okButtonProps: { danger: true }, + onOk: async () => { + try { + await deleteProfile(mode, orgId, r.id); + showSuccess(t('已删除')); + load(); + } catch (e) { + if (e?.message) showError(e.message); + } + }, + }), + }, + ]} + > - {canWrite && ( - <> - - { - try { - await deleteProfile(mode, orgId, r.id); - showSuccess(t('已删除')); - load(); - } catch (e) { - if (e?.message) showError(e.message); - } - }} - > - - - - )} - + ), }, ]; diff --git a/src/components/table/channels/ChannelsColumnDefs.jsx b/src/components/table/channels/ChannelsColumnDefs.jsx index 1d03871c..1a674b28 100644 --- a/src/components/table/channels/ChannelsColumnDefs.jsx +++ b/src/components/table/channels/ChannelsColumnDefs.jsx @@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com */ import { writeClipboardText } from '../../../helpers/clipboard'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import React, { useState } from 'react'; import { Switch } from 'antd'; import { @@ -729,142 +730,110 @@ export const getChannelsColumns = ({ dataIndex: 'operate', fixed: 'right', render: (text, record, index) => { - if (record.children === undefined) { - const moreMenuItems = [ - { - node: 'item', - name: t('删除'), - type: 'danger', - onClick: async () => { - const content = await buildDeleteConfirmContent(record.id, t); - Modal.confirm({ - title: t('确定是否要删除此渠道?'), - content, - onOk: () => { - (async () => { - await manageChannel(record.id, 'delete', record); - await refresh(); - setTimeout(() => { - if (channels.length === 0 && activePage > 1) { - refresh(activePage - 1); - } - }, 100); - })(); - }, - }); - }, - }, - { - node: 'item', - name: t('复制'), - type: 'tertiary', - onClick: () => { - Modal.confirm({ - title: t('确定是否要复制此渠道?'), - content: t('复制渠道的所有信息'), - onOk: () => copySelectedChannel(record), - }); - }, - }, - ]; - + if (!isRoot()) return null; + if (record.children !== undefined) { return ( - - {isRoot() && ( - <> - - - - - - {record.channel_info?.is_multi_key && ( - - )} - - )} - - ); - } else { - // 标签操作按钮 - return ( - - {isRoot() && ( - <> - - - - - )} - + manageTag(record.key, 'enable'), + }, + { + key: 'disable', + label: t('禁用全部'), + onClick: () => manageTag(record.key, 'disable'), + }, + ]} + > + + ); } + return ( + { + setCurrentTestChannel(record); + setShowModelTestModal(true); + }, + }, + record.channel_info?.is_multi_key && { + key: 'multi-key', + label: t('多密钥管理'), + onClick: () => { + setCurrentMultiKeyChannel(record); + setShowMultiKeyManageModal(true); + }, + }, + { + key: 'copy', + label: t('复制'), + onClick: () => { + Modal.confirm({ + title: t('确定是否要复制此渠道?'), + content: t('复制渠道的所有信息'), + onOk: () => copySelectedChannel(record), + }); + }, + }, + { + key: 'delete', + label: t('删除'), + danger: true, + onClick: async () => { + const content = await buildDeleteConfirmContent(record.id, t); + Modal.confirm({ + title: t('确定是否要删除此渠道?'), + content, + onOk: () => { + (async () => { + await manageChannel(record.id, 'delete', record); + await refresh(); + setTimeout(() => { + if (channels.length === 0 && activePage > 1) { + refresh(activePage - 1); + } + }, 100); + })(); + }, + }); + }, + }, + ]} + > + + + + ); }, }, ]; diff --git a/src/components/table/channels/modals/EditChannelModal.jsx b/src/components/table/channels/modals/EditChannelModal.jsx index 7fcf6d3d..d7860a0b 100644 --- a/src/components/table/channels/modals/EditChannelModal.jsx +++ b/src/components/table/channels/modals/EditChannelModal.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../../../helpers/safeDisplay'; import { I18N_TECHNICAL_TEXT } from '../../../../i18n/technicalText.js'; import { useEffectEvent } from '../../../../hooks/common/useEffectEvent'; @@ -290,11 +291,11 @@ const EditChannelModal = (props) => { if (ch.status !== 1) { return { value: ch.id, - label: `#${ch.id} ${ch.name}${t('(已禁用)')}`, + label: `${formatIdReference(ch.id)} ${ch.name}${t('(已禁用)')}`, disabled: true, }; } - const parts = [`#${ch.id} ${ch.name}`]; + const parts = [`${formatIdReference(ch.id)} ${ch.name}`]; if (ch.group) parts.push(ch.group); if (ch.region) parts.push(ch.region); return { value: ch.id, label: parts.join(' · ') }; @@ -345,7 +346,7 @@ const EditChannelModal = (props) => { .filter((id) => !known.has(id) && id !== channelId) .map((id) => ({ value: id, - label: `#${id}${t('(已删除)')}`, + label: `${formatIdReference(id)}${t('(已删除)')}`, disabled: true, })); return missing.length diff --git a/src/components/table/channels/modals/MultiKeyManageModal.jsx b/src/components/table/channels/modals/MultiKeyManageModal.jsx index f40fe001..55445cdd 100644 --- a/src/components/table/channels/modals/MultiKeyManageModal.jsx +++ b/src/components/table/channels/modals/MultiKeyManageModal.jsx @@ -16,6 +16,7 @@ along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ +import { formatIdReference } from '../../../../helpers/safeDisplay'; import { useEffectEvent } from '../../../../hooks/common/useEffectEvent'; import React, { useState, useEffect } from 'react'; @@ -359,7 +360,7 @@ const MultiKeyManageModal = ({ visible, onCancel, channel, onRefresh }) => { { title: t('索引'), dataIndex: 'index', - render: (text) => `#${text}`, + render: (text) => formatIdReference(text), }, // { // title: t('密钥预览'), diff --git a/src/components/table/models/ModelsColumnDefs.jsx b/src/components/table/models/ModelsColumnDefs.jsx index 7f858402..6cc159b7 100644 --- a/src/components/table/models/ModelsColumnDefs.jsx +++ b/src/components/table/models/ModelsColumnDefs.jsx @@ -18,9 +18,10 @@ For commercial licensing, please contact support@quantumnous.com */ import { Copy as ActionCopy } from '@/components/common/icons/ActionIcons'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import React from 'react'; import { Button as AntButton, Tooltip as AntTooltip } from 'antd'; -import { Button, Space, Tag, Modal, Tooltip } from '@/components/ui'; +import { Button, Tag, Modal, Tooltip } from '@/components/ui'; import { timestamp2string, getLobeHubIcon, @@ -239,64 +240,57 @@ const renderOperations = ( setDetailModel, ) => { return ( - + + manageModel( + record.id, + record.status === 1 ? 'disable' : 'enable', + record, + ), + }, + { + key: 'delete', + label: t('删除'), + danger: true, + onClick: () => { + Modal.confirm({ + title: t('确定是否要删除此模型?'), + content: t('此修改将不可逆'), + onOk: () => { + (async () => { + await manageModel(record.id, 'delete', record); + await refresh(); + })(); + }, + }); + }, + }, + ] + : [] + } + > {isRoot() && ( - <> - {record.status === 1 ? ( - - ) : ( - - )} - - - - - + )} - + ); }; diff --git a/src/components/table/redemptions/RedemptionsActions.jsx b/src/components/table/redemptions/RedemptionsActions.jsx index 93847b68..c8e7ca9f 100644 --- a/src/components/table/redemptions/RedemptionsActions.jsx +++ b/src/components/table/redemptions/RedemptionsActions.jsx @@ -38,37 +38,21 @@ const RedemptionsActions = ({ }; return ( -
- {isAdmin() && ( - - )} - - {isAdmin() && ( - )} + {isAdmin() && ( + + )}
); }; diff --git a/src/components/table/redemptions/RedemptionsColumnDefs.jsx b/src/components/table/redemptions/RedemptionsColumnDefs.jsx index 39e60d70..c85892eb 100644 --- a/src/components/table/redemptions/RedemptionsColumnDefs.jsx +++ b/src/components/table/redemptions/RedemptionsColumnDefs.jsx @@ -18,8 +18,8 @@ For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; -import { Tag, Button, Space, Popover, Dropdown } from '@/components/ui'; -import { IconMore } from '@/components/ui/icons'; +import { Tag, Button, Popover } from '@/components/ui'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import { renderQuota, timestamp2string, @@ -144,46 +144,42 @@ export const getRedemptionsColumns = ({ }, }, { - title: '', + title: t('操作'), dataIndex: 'operate', fixed: 'right', - width: 205, + width: 215, render: (text, record) => { - // Create dropdown menu items for more operations - const moreMenuItems = [ - { - node: 'item', - name: t('删除'), - type: 'danger', - onClick: () => { - showDeleteRedemptionModal(record); - }, - }, - ]; - - if (record.status === REDEMPTION_STATUS.UNUSED && !isExpired(record)) { + const moreMenuItems = []; + if (isAdmin() && !isExpired(record)) { + const unused = record.status === REDEMPTION_STATUS.UNUSED; moreMenuItems.push({ - node: 'item', - name: t('禁用'), - type: 'warning', - onClick: () => { - manageRedemption(record.id, REDEMPTION_ACTIONS.DISABLE, record); - }, - }); - } else if (!isExpired(record)) { - moreMenuItems.push({ - node: 'item', - name: t('启用'), - type: 'secondary', - onClick: () => { - manageRedemption(record.id, REDEMPTION_ACTIONS.ENABLE, record); - }, + key: 'toggle-status', + label: unused ? t('禁用') : t('启用'), disabled: record.status === REDEMPTION_STATUS.USED, + onClick: () => + manageRedemption( + record.id, + unused ? REDEMPTION_ACTIONS.DISABLE : REDEMPTION_ACTIONS.ENABLE, + record, + ), + }); + } + moreMenuItems.unshift({ + key: 'copy', + label: t('复制'), + onClick: () => copyText(record.key), + }); + if (isAdmin()) { + moreMenuItems.push({ + key: 'delete', + label: t('删除'), + danger: true, + onClick: () => showDeleteRedemptionModal(record), }); } return ( - + - - {isAdmin() && ( - <> - - - )} - + ); }, }, diff --git a/src/components/table/redemptions/RedemptionsFilters.jsx b/src/components/table/redemptions/RedemptionsFilters.jsx index e608771f..9aea445a 100644 --- a/src/components/table/redemptions/RedemptionsFilters.jsx +++ b/src/components/table/redemptions/RedemptionsFilters.jsx @@ -51,28 +51,24 @@ const RedemptionsFilters = ({ onSubmit={searchRedemptions} allowEmpty={true} autoComplete='off' - layout='horizontal' + layout='vertical' trigger='change' stopValidateWithError={false} - className='w-full' + className='console-filter-panel' > -
-
- } - placeholder={t('关键字(id或者名称)')} - showClear - pure - size='small' - /> -
- + } + label={t('搜索关键字')} + placeholder={t('关键字(id或者名称)')} + showClear />
+ ); }; diff --git a/src/components/table/redemptions/RedemptionsTable.jsx b/src/components/table/redemptions/RedemptionsTable.jsx index 963116ec..027fb30d 100644 --- a/src/components/table/redemptions/RedemptionsTable.jsx +++ b/src/components/table/redemptions/RedemptionsTable.jsx @@ -18,12 +18,8 @@ For commercial licensing, please contact support@quantumnous.com */ import React, { useMemo, useState } from 'react'; -import { Empty } from '@/components/ui'; +import TableEmpty from '../../common/table/TableEmpty'; import CardTable from '../../common/ui/CardTable'; -import { - IllustrationNoResult, - IllustrationNoResultDark, -} from '../../common/illustrations'; import { getRedemptionsColumns } from './RedemptionsColumnDefs'; import DeleteRedemptionModal from './modals/DeleteRedemptionModal'; @@ -101,17 +97,8 @@ const RedemptionsTable = (redemptionsData) => { loading={loading} rowSelection={rowSelection} onRow={handleRow} - empty={ - } - darkModeImage={ - - } - description={t('搜索无结果')} - style={{ padding: 30 }} - /> - } - className='rounded-xl overflow-hidden' + empty={} + className='console-list-table overflow-hidden' size='middle' /> diff --git a/src/components/table/redemptions/index.jsx b/src/components/table/redemptions/index.jsx index 33928f42..3b48ba9c 100644 --- a/src/components/table/redemptions/index.jsx +++ b/src/components/table/redemptions/index.jsx @@ -82,15 +82,13 @@ const RedemptionsPage = () => { /> } type='type1' - descriptionArea={ - - } actionsArea={ -
+
+ { @@ -327,7 +321,6 @@ const renderOperations = ( const name = Object.keys(item)[0]; if (!name) continue; chatsArray.push({ - node: 'item', key: i, name, value: item[name], @@ -340,87 +333,70 @@ const renderOperations = ( } return ( - - - - - - - - - {record.status === 1 ? ( - - ) : ( - - )} - - - - - + ); }; diff --git a/src/components/table/users/UsersColumnDefs.jsx b/src/components/table/users/UsersColumnDefs.jsx index 4ef9f422..36a3ff23 100644 --- a/src/components/table/users/UsersColumnDefs.jsx +++ b/src/components/table/users/UsersColumnDefs.jsx @@ -26,10 +26,9 @@ import { Progress, Popover, Typography, - Dropdown, } from '@/components/ui'; import { Switch } from 'antd'; -import { IconMore } from '@/components/ui/icons'; +import { TableRowActions } from '@/components/common/table/TableToolbar'; import { renderGroup, renderNumber, @@ -256,50 +255,48 @@ const renderOperations = ( if (canChangeRole) { moreMenu.push( { - node: 'item', - name: t('提升'), + key: 'promote', + label: t('提升'), onClick: () => showPromoteModal(record), }, { - node: 'item', - name: t('降级'), + key: 'demote', + label: t('降级'), onClick: () => showDemoteModal(record), }, - { node: 'divider' }, + { type: 'divider' }, ); } moreMenu.push({ - node: 'item', - name: t('邀请记录'), + key: 'invitations', + label: t('邀请记录'), onClick: () => showInvitedUsersModal(record), }); if (canManage) { moreMenu.push( - { node: 'divider' }, + { type: 'divider' }, { - node: 'item', - name: t('重置 Passkey'), + key: 'reset-passkey', + label: t('重置 Passkey'), onClick: () => showResetPasskeyModal(record), }, { - node: 'item', - name: t('重置 2FA'), + key: 'reset-2fa', + label: t('重置 2FA'), onClick: () => showResetTwoFAModal(record), }, - { node: 'divider' }, + { type: 'divider' }, { - node: 'item', - name: t('注销'), - type: 'danger', + key: 'delete', + label: t('注销'), + danger: true, onClick: () => showDeleteModal(record), }, ); } return ( - // wrap 保留:移动端 CardTable 把按钮放进 ~280px 的卡片行里,Semi Space 默认 - // wrap:false 时溢出会被 .ant-card{overflow:hidden} 裁掉(不是滚动,是永久看不到) - + {canManage && ( <> - - - )} - {(record.status === INVOICE_STATUS.APPROVED || - record.status === INVOICE_STATUS.INVOICING) && ( - - )} - {record.status === INVOICE_STATUS.FAILED && ( - <> - - - - )} -
+ > + {t('详情')} + + ), }, ]; return (
- {/* 筛选区:标题与筛选项同行 */} - -
- } - placeholder={t('搜索抬头/税号/订单号/用户')} - value={keyword} - onChange={setKeyword} - onEnterPress={handleSearch} - style={{ width: 240 }} - /> - } + placeholder={t('搜索抬头/税号/订单号/用户')} + value={keyword} + onChange={setKeyword} + onEnterPress={handleSearch} + /> + + +