feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
适用于本仓库,不要重复加载全文。
|
||||
|
||||
## 双中心侧栏与容器附件对齐(2026-11-06)
|
||||
|
||||
企业中心 `/org/*` 与用户中心 `/user-center/*` 菜单页共用 `src/styles/center-layout.css`:侧栏展开 216px、收起 64px,菜单行高 42px、行距 6px、图标 16px / 1.5px 线宽;企业信息区使用无底框 LayoutGrid、企业名与身份 12px。折叠入口显示“收起导航”。内容外壳通过 `min-width: 0` 防止表格挤压;桌面顶部 / 横向 / 底部仍为 30 / 36 / 36px,移动为 16 / 16 / 24px;工作区块间距 `--uc-layout-gap: 18px`。桌面滚动区保留稳定槽位并补足设计图 16px 留白,滚动条本身仍走全局 6px;移动不补额外留白。菜单权限、名称与业务数据取原数据源。附件图 1 是本轮视觉标准;本地验收产物位于忽略目录 `report/layout-alignment/`,不做生产测试。
|
||||
|
||||
## 技能超市真实 API 恢复状态(2026-11-05)
|
||||
|
||||
`/skill-market` 已按用户口令恢复真实 API,默认入口为 `src/pages/SkillMarket/LiveSkillMarket.jsx`;仅显式设置 `VITE_SKILL_MARKET_MOCK=true` 才进入本地演示,当前开发 / 生产环境均未开启该覆盖。共享 `view/*`、`skill-market.css`、`catalogData.js` 保留 Hero、详情按钮居中、独立滚动侧栏、技能范围、多标签 OR、已选标签、搜索、重置及本地分页。红框本地演示提示和恢复样例数据按钮不在真实模式挂载,mock CRUD 与缓存不参与真实账号业务,绝不导入后端。请求载荷与权限保持原样,详情见 `docs/ui/SKILL_MARKET_MOCK.md`。后续重复发送恢复口令时核验此状态即可,不回退现有 UI 或其他页面。
|
||||
@@ -82,7 +86,7 @@
|
||||
4. 面包屑:新页面须在 `UserCenterBreadcrumb.jsx` 的 `pageTitles` 登记 `路径 → 标题`,显示“用户中心 / 当前页面”;无副标题文案的页面可只传 `title`,不要为凑规格新增未翻译文案。
|
||||
5. 滚动条:全站统一滑块 `#8b8b8b`、hover `#636363`、宽高 6px、圆角 3px、轨道透明,值由 `src/styles/tokens.css` 的 `--brand-scroll` / `--brand-scroll-hover`(浅深色同值)提供,规则集中在 `src/index.css` 全局 `*::-webkit-scrollbar*`;模型超市侧栏用 `--mm-scroll-thumb(-hover)`(同值)。禁止在页面 CSS 或内联样式里再设置 `scrollbar-width` / `scrollbar-color`(Chrome 121+ 设置后会忽略 `::-webkit-scrollbar`,hover 色失效;标准属性只在 `@supports not selector(::-webkit-scrollbar)` 内给 Firefox),也不得单独给滑块配色。
|
||||
6. 验证:改动后逐页(桌面 1920×1000 / 移动 393×851,浅深色)核对左右边距、面包屑顶距、标题与副标题字号间距一致,滚动条静止与 hover 颜色;运行 `npm run eslint`、`npm run lint`、`npm test -- --test-concurrency=1`、`git diff --check`。
|
||||
7. 企业端(`/org/*`)同样适用:内容边距走 `.uc-page`(普通页)或 `src/styles/org-page.css`(功能页 `.org-*-page` / `.knowledge-page`,`.org-workbench` 同),不得再用 `p-4 sm:p-6 lg:p-8` 或各页 16/24/32px。普通页头一律 `OrgPageHeader`(内部复用 `UserCenterPageHeader`),面包屑为“企业中心 / 当前页面”,由 `OrgBreadcrumb`(`pages/Organization/components/`)按路径末段取侧栏菜单名,未登记(随角色变化或非侧栏页)的页面用标题兜底;带 hero 的功能页(专家、技能、Connector、效能、质量、审计、知识等)在 hero 内首个 `div` 顶部放 `<OrgBreadcrumb />`,卡片底/边框与标题字号由 `org-page.css` 统一为无卡片的 28px/650 标题 + 14px 副标题,操作区与指引入口保留。新增企业页须同时登记 `OrgBreadcrumb` 的路径映射。
|
||||
7. 企业端(`/org/*`)同样适用:内容边距走 `.uc-page`(普通页)或 `src/styles/org-page.css`(功能页 `.org-*-page` / `.knowledge-page`,`.org-workbench` 同),不得再用 `p-4 sm:p-6 lg:p-8` 或各页 16/24/32px。普通页头一律 `OrgPageHeader`(内部复用 `UserCenterPageHeader`),面包屑统一两级:组织管理、额度与治理、财务与日志、系统设置分组下显示“分组 / 当前页面”,其他页面显示“企业中心 / 当前页面”(由 `orgPageGroups` 登记,2026-11-06 用户追加要求),由 `OrgBreadcrumb`(`pages/Organization/components/`)按路径末段取侧栏菜单名,未登记(随角色变化或非侧栏页)的页面用标题兜底;带 hero 的功能页(专家、技能、Connector、效能、质量、审计、知识等)在 hero 内首个 `div` 顶部放 `<OrgBreadcrumb />`,卡片底/边框与标题字号由 `org-page.css` 统一为无卡片的 28px/650 标题 + 14px 副标题,操作区与指引入口保留。新增企业页须同时登记 `OrgBreadcrumb` 的路径映射。
|
||||
|
||||
## 用户中心二次回归约定(/user-center/* + /key-management,2026-11-04)
|
||||
|
||||
@@ -99,6 +103,17 @@
|
||||
- 暗色主色跟随在线原型实测:Ant 暗色算法对种子 `#f2ad41` 推导出 `#d1963a`(悬停 `#e8ba65`)。`prototypeTheme` 保持 colorPrimary = `--brand-primary`(`#d1963a`),仅在暗色且主色等于该值时用 `#f2ad41` 种子推导其余令牌;`presets.js` ocean.dark 与 `tokens.css` 暗色品牌变量同步(含 hover / soft / scroll / 渐变 / accent,`bg-glow` 不变)。保留 `#f2ad41`:侧栏选中项(文字 `#f2ad41`、底 `#382b1b`)与使用记录页签选中文字 / 下划线(`--ur-tab-accent`,原型实测)。
|
||||
- 数据看板页头 / hero(原型 `.dashboard-hero` 实测):副标题“追踪每一次模型调用,让用量与成本清晰可见。”14/22px、标题 34px / 43.07px / -1px、页头与指标 16px、操作区上内边距 8px;时间粒度由图标 + 文字改为 Ant `Select`(92×34,值与选项来自 `dataExportDefaultTime` / `timeOptions`,`onChange` 复用 `handleInputChange` 与筛选弹窗同源,新粒度在下一次刷新 / 筛选加载时生效,不新增请求);hero 装饰迁入 `.uc-dashboard-hero` 图层(高 `--uc-hero-h`=315px / 移动 460px,原型渐变、网格线、60px 底部渐隐,暗色 `--uc-hero-*`),插画 630×310、`right:4%`、`top:17px`、不透明度浅 .82 / 暗 .64 + `brightness(.83) saturate(.8)`,移动 330×210、`right:-65px`、`top:10px`、.18;移动端操作区右对齐、间距 6px。
|
||||
|
||||
## 企业中心单页约定(/org/*,2026-11-06)
|
||||
|
||||
详细数值、映射表与判定见 `docs/ui/ORG_CENTER_SPEC.md`;本节与 `AGENTS.md` / `CLAUDE.md` 同节同步维护,改造记录见 `docs/UI_MIGRATION.md`“企业中心按在线原型对齐(2026-11-06)”。
|
||||
|
||||
1. 范围与依据:视觉唯一基准为在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(SPA、URL 保持 `/`,深色用“切换至暗色主题”),只作视觉依据,不作业务 / 路由 / 数据依据。目标页(仅 UI):工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”“组织架构”“角色管理”按用户特殊规定跳过(不采集 / 不比较 / 不修改),共享组件改动须保持其渲染不变。
|
||||
2. 目录:样式 `src/styles/org-center.css`(`.org-center .oc-page` 作用域,页面类 `.oc-workbench` / `.oc-dashboard` / `.oc-recharge` / `.oc-personal-settings` / `.oc-company-settings`,Portal 用 `.oc-dialog` / `.oc-key-drawer`);通用块 `pages/Organization/components/OrgListCard.jsx`(`OrgListCard` / `OrgFilterCard` / `OrgRowActions`);面包屑分组登记在 `OrgBreadcrumb` 的 `orgPageGroups`(上述四组含角色专属页面均登记)。
|
||||
3. 组件映射:列表 → `OrgListCard`(卡头标题 + 刷新 / 主操作)+ Ant `Table`(`showTotal`,不加尺寸切换);筛选 → `OrgFilterCard` 三列 + 重置 / 搜索;状态按钮组 / 自绘页签 → Ant `Tabs.oc-list-tabs`(只切筛选时加 `.oc-tabs-nav-only`,原 `lazyRender=false` 的页签保留 `forceRender`);行操作 → 无图标 link 按钮(危险加 `danger`);启停 → `Switch`(onChange 走原处理函数,项目复用 DELETE 停用与编辑 PUT 启用,预算复用编辑 PUT 并透传行内原始额度、周期和超限动作;其他无行内启停列表保留只读 Tag);Tag `bordered={false}`,非预设色改 `gold` / `purple`;预算中心两条旧 Banner → `.oc-policy` 固定文案说明条;企业密钥创建 / 编辑 → 560px `OrgSideSheet`;个人设置 → 资料头 + 头像设置 / 个人资料 / 通知设置三页签(复用 `ui-personal-*`、`AvatarSection`、`SectionHeader`);企业设置 → 设置卡内页签 + 区块头(刷新 / 保存设置)。
|
||||
4. Token:不新增 ConfigProvider / 主题状态 / 存储 key;颜色只写在 `--oc-*` 变量(浅色为原型实测,深色写在 `html.dark` 下),规则只引用变量;`--oc-brand` 浅 `#b96508` / 深 `#f2ad41`(原型 `--brand`),Ant 组件颜色仍由 `UiThemeProvider` 决定。
|
||||
5. 规范例外与保留差异:页头沿用“带侧栏页面统一规格”(比原型矮约 6px);原型有、系统无对应功能(员工筛选卡、列设置、导出、在职 / 离职、分组列、订单号搜索、发票入口、绘图与视频)不补建;充值档位 / 折扣、额度与列表数据差异记为业务差异;不点击真实支付。
|
||||
6. 验收:`e2e/org-center/login.mjs`(A 企业名 + 下一步 / B 记忆企业直登,凭据经 `UI_ORG_NAME` / `UI_ORG_USER` / `UI_ORG_PASS`)→ `proto-capture.mjs` / `capture-system.mjs`(`OC_THEMES`、`OC_PAGES`、`OC_STATES`、`OC_LABEL=after|before`)→ `compare.mjs`(整页 ≤0.5%、组件 ≤0.2%,P3 ≤2%、P2 ≤10%、P1 >10%)→ `routes.mjs`(路由核定)→ `report.mjs`(`report/visual-regression.html`)→ `e2e/org-center-ui.spec.js`(`toHaveScreenshot()` 建基线后不带 update 复跑,写请求 0)→ `logout.mjs`(UI 退出)。1920×1080、DPR 1、zh-CN、Asia/Shanghai、reducedMotion、离屏有头 Chrome,`CONCURRENCY` 从 1 起;截图、trace、video、storageState、报告只在 Git 忽略的 `report/`。
|
||||
|
||||
适用于本项目的开发、验收、测试与页面比对。
|
||||
|
||||
## 工具选择
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
适用于本仓库,不要重复加载全文。
|
||||
|
||||
## 双中心侧栏与容器附件对齐(2026-11-06)
|
||||
|
||||
企业中心 `/org/*` 与用户中心 `/user-center/*` 菜单页共用 `src/styles/center-layout.css`:侧栏展开 216px、收起 64px,菜单行高 42px、行距 6px、图标 16px / 1.5px 线宽;企业信息区使用无底框 LayoutGrid、企业名与身份 12px。折叠入口显示“收起导航”。内容外壳通过 `min-width: 0` 防止表格挤压;桌面顶部 / 横向 / 底部仍为 30 / 36 / 36px,移动为 16 / 16 / 24px;工作区块间距 `--uc-layout-gap: 18px`。桌面滚动区保留稳定槽位并补足设计图 16px 留白,滚动条本身仍走全局 6px;移动不补额外留白。菜单权限、名称与业务数据取原数据源。附件图 1 是本轮视觉标准;本地验收产物位于忽略目录 `report/layout-alignment/`,不做生产测试。
|
||||
|
||||
## 技能超市真实 API 恢复状态(2026-11-05)
|
||||
|
||||
`/skill-market` 已按用户口令恢复真实 API,默认入口为 `src/pages/SkillMarket/LiveSkillMarket.jsx`;仅显式设置 `VITE_SKILL_MARKET_MOCK=true` 才进入本地演示,当前开发 / 生产环境均未开启该覆盖。共享 `view/*`、`skill-market.css`、`catalogData.js` 保留 Hero、详情按钮居中、独立滚动侧栏、技能范围、多标签 OR、已选标签、搜索、重置及本地分页。红框本地演示提示和恢复样例数据按钮不在真实模式挂载,mock CRUD 与缓存不参与真实账号业务,绝不导入后端。请求载荷与权限保持原样,详情见 `docs/ui/SKILL_MARKET_MOCK.md`。后续重复发送恢复口令时核验此状态即可,不回退现有 UI 或其他页面。
|
||||
@@ -82,7 +86,7 @@
|
||||
4. 面包屑:新页面须在 `UserCenterBreadcrumb.jsx` 的 `pageTitles` 登记 `路径 → 标题`,显示“用户中心 / 当前页面”;无副标题文案的页面可只传 `title`,不要为凑规格新增未翻译文案。
|
||||
5. 滚动条:全站统一滑块 `#8b8b8b`、hover `#636363`、宽高 6px、圆角 3px、轨道透明,值由 `src/styles/tokens.css` 的 `--brand-scroll` / `--brand-scroll-hover`(浅深色同值)提供,规则集中在 `src/index.css` 全局 `*::-webkit-scrollbar*`;模型超市侧栏用 `--mm-scroll-thumb(-hover)`(同值)。禁止在页面 CSS 或内联样式里再设置 `scrollbar-width` / `scrollbar-color`(Chrome 121+ 设置后会忽略 `::-webkit-scrollbar`,hover 色失效;标准属性只在 `@supports not selector(::-webkit-scrollbar)` 内给 Firefox),也不得单独给滑块配色。
|
||||
6. 验证:改动后逐页(桌面 1920×1000 / 移动 393×851,浅深色)核对左右边距、面包屑顶距、标题与副标题字号间距一致,滚动条静止与 hover 颜色;运行 `npm run eslint`、`npm run lint`、`npm test -- --test-concurrency=1`、`git diff --check`。
|
||||
7. 企业端(`/org/*`)同样适用:内容边距走 `.uc-page`(普通页)或 `src/styles/org-page.css`(功能页 `.org-*-page` / `.knowledge-page`,`.org-workbench` 同),不得再用 `p-4 sm:p-6 lg:p-8` 或各页 16/24/32px。普通页头一律 `OrgPageHeader`(内部复用 `UserCenterPageHeader`),面包屑为“企业中心 / 当前页面”,由 `OrgBreadcrumb`(`pages/Organization/components/`)按路径末段取侧栏菜单名,未登记(随角色变化或非侧栏页)的页面用标题兜底;带 hero 的功能页(专家、技能、Connector、效能、质量、审计、知识等)在 hero 内首个 `div` 顶部放 `<OrgBreadcrumb />`,卡片底/边框与标题字号由 `org-page.css` 统一为无卡片的 28px/650 标题 + 14px 副标题,操作区与指引入口保留。新增企业页须同时登记 `OrgBreadcrumb` 的路径映射。
|
||||
7. 企业端(`/org/*`)同样适用:内容边距走 `.uc-page`(普通页)或 `src/styles/org-page.css`(功能页 `.org-*-page` / `.knowledge-page`,`.org-workbench` 同),不得再用 `p-4 sm:p-6 lg:p-8` 或各页 16/24/32px。普通页头一律 `OrgPageHeader`(内部复用 `UserCenterPageHeader`),面包屑统一两级:组织管理、额度与治理、财务与日志、系统设置分组下显示“分组 / 当前页面”,其他页面显示“企业中心 / 当前页面”(由 `orgPageGroups` 登记,2026-11-06 用户追加要求),由 `OrgBreadcrumb`(`pages/Organization/components/`)按路径末段取侧栏菜单名,未登记(随角色变化或非侧栏页)的页面用标题兜底;带 hero 的功能页(专家、技能、Connector、效能、质量、审计、知识等)在 hero 内首个 `div` 顶部放 `<OrgBreadcrumb />`,卡片底/边框与标题字号由 `org-page.css` 统一为无卡片的 28px/650 标题 + 14px 副标题,操作区与指引入口保留。新增企业页须同时登记 `OrgBreadcrumb` 的路径映射。
|
||||
|
||||
## 用户中心二次回归约定(/user-center/* + /key-management,2026-11-04)
|
||||
|
||||
@@ -99,6 +103,17 @@
|
||||
- 暗色主色跟随在线原型实测:Ant 暗色算法对种子 `#f2ad41` 推导出 `#d1963a`(悬停 `#e8ba65`)。`prototypeTheme` 保持 colorPrimary = `--brand-primary`(`#d1963a`),仅在暗色且主色等于该值时用 `#f2ad41` 种子推导其余令牌;`presets.js` ocean.dark 与 `tokens.css` 暗色品牌变量同步(含 hover / soft / scroll / 渐变 / accent,`bg-glow` 不变)。保留 `#f2ad41`:侧栏选中项(文字 `#f2ad41`、底 `#382b1b`)与使用记录页签选中文字 / 下划线(`--ur-tab-accent`,原型实测)。
|
||||
- 数据看板页头 / hero(原型 `.dashboard-hero` 实测):副标题“追踪每一次模型调用,让用量与成本清晰可见。”14/22px、标题 34px / 43.07px / -1px、页头与指标 16px、操作区上内边距 8px;时间粒度由图标 + 文字改为 Ant `Select`(92×34,值与选项来自 `dataExportDefaultTime` / `timeOptions`,`onChange` 复用 `handleInputChange` 与筛选弹窗同源,新粒度在下一次刷新 / 筛选加载时生效,不新增请求);hero 装饰迁入 `.uc-dashboard-hero` 图层(高 `--uc-hero-h`=315px / 移动 460px,原型渐变、网格线、60px 底部渐隐,暗色 `--uc-hero-*`),插画 630×310、`right:4%`、`top:17px`、不透明度浅 .82 / 暗 .64 + `brightness(.83) saturate(.8)`,移动 330×210、`right:-65px`、`top:10px`、.18;移动端操作区右对齐、间距 6px。
|
||||
|
||||
## 企业中心单页约定(/org/*,2026-11-06)
|
||||
|
||||
详细数值、映射表与判定见 `docs/ui/ORG_CENTER_SPEC.md`;本节与 `AGENTS.md` / `CLAUDE.md` 同节同步维护,改造记录见 `docs/UI_MIGRATION.md`“企业中心按在线原型对齐(2026-11-06)”。
|
||||
|
||||
1. 范围与依据:视觉唯一基准为在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(SPA、URL 保持 `/`,深色用“切换至暗色主题”),只作视觉依据,不作业务 / 路由 / 数据依据。目标页(仅 UI):工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”“组织架构”“角色管理”按用户特殊规定跳过(不采集 / 不比较 / 不修改),共享组件改动须保持其渲染不变。
|
||||
2. 目录:样式 `src/styles/org-center.css`(`.org-center .oc-page` 作用域,页面类 `.oc-workbench` / `.oc-dashboard` / `.oc-recharge` / `.oc-personal-settings` / `.oc-company-settings`,Portal 用 `.oc-dialog` / `.oc-key-drawer`);通用块 `pages/Organization/components/OrgListCard.jsx`(`OrgListCard` / `OrgFilterCard` / `OrgRowActions`);面包屑分组登记在 `OrgBreadcrumb` 的 `orgPageGroups`(上述四组含角色专属页面均登记)。
|
||||
3. 组件映射:列表 → `OrgListCard`(卡头标题 + 刷新 / 主操作)+ Ant `Table`(`showTotal`,不加尺寸切换);筛选 → `OrgFilterCard` 三列 + 重置 / 搜索;状态按钮组 / 自绘页签 → Ant `Tabs.oc-list-tabs`(只切筛选时加 `.oc-tabs-nav-only`,原 `lazyRender=false` 的页签保留 `forceRender`);行操作 → 无图标 link 按钮(危险加 `danger`);启停 → `Switch`(onChange 走原处理函数,项目复用 DELETE 停用与编辑 PUT 启用,预算复用编辑 PUT 并透传行内原始额度、周期和超限动作;其他无行内启停列表保留只读 Tag);Tag `bordered={false}`,非预设色改 `gold` / `purple`;预算中心两条旧 Banner → `.oc-policy` 固定文案说明条;企业密钥创建 / 编辑 → 560px `OrgSideSheet`;个人设置 → 资料头 + 头像设置 / 个人资料 / 通知设置三页签(复用 `ui-personal-*`、`AvatarSection`、`SectionHeader`);企业设置 → 设置卡内页签 + 区块头(刷新 / 保存设置)。
|
||||
4. Token:不新增 ConfigProvider / 主题状态 / 存储 key;颜色只写在 `--oc-*` 变量(浅色为原型实测,深色写在 `html.dark` 下),规则只引用变量;`--oc-brand` 浅 `#b96508` / 深 `#f2ad41`(原型 `--brand`),Ant 组件颜色仍由 `UiThemeProvider` 决定。
|
||||
5. 规范例外与保留差异:页头沿用“带侧栏页面统一规格”(比原型矮约 6px);原型有、系统无对应功能(员工筛选卡、列设置、导出、在职 / 离职、分组列、订单号搜索、发票入口、绘图与视频)不补建;充值档位 / 折扣、额度与列表数据差异记为业务差异;不点击真实支付。
|
||||
6. 验收:`e2e/org-center/login.mjs`(A 企业名 + 下一步 / B 记忆企业直登,凭据经 `UI_ORG_NAME` / `UI_ORG_USER` / `UI_ORG_PASS`)→ `proto-capture.mjs` / `capture-system.mjs`(`OC_THEMES`、`OC_PAGES`、`OC_STATES`、`OC_LABEL=after|before`)→ `compare.mjs`(整页 ≤0.5%、组件 ≤0.2%,P3 ≤2%、P2 ≤10%、P1 >10%)→ `routes.mjs`(路由核定)→ `report.mjs`(`report/visual-regression.html`)→ `e2e/org-center-ui.spec.js`(`toHaveScreenshot()` 建基线后不带 update 复跑,写请求 0)→ `logout.mjs`(UI 退出)。1920×1080、DPR 1、zh-CN、Asia/Shanghai、reducedMotion、离屏有头 Chrome,`CONCURRENCY` 从 1 起;截图、trace、video、storageState、报告只在 Git 忽略的 `report/`。
|
||||
|
||||
进入项目先阅读根目录 `AGENTS.md` 和 `docs/UI_MIGRATION.md`,改个人端用户中心页面再读 `docs/ui/UI_SPEC.md`。本文件与 `AGENTS.md` 同时维护;二者对 UI 的约束一致。原型:`http://192.168.0.161:8888`(个人端用户中心以 `原型图.zip` 为准,见上节;模型超市以原型站“模型超市”页为准,改该页先读 `docs/ui/MARKET_SPEC.md`)。
|
||||
|
||||
## 目录
|
||||
|
||||
+53
-1
@@ -1,5 +1,27 @@
|
||||
# 后台 UI 改造记录
|
||||
|
||||
## 双中心侧栏与容器按附件对齐(2026-11-06)
|
||||
|
||||
- 本轮附件图 1 为视觉标准,图 2 红框为重点;统一 `/org/*` 与 `/user-center/*` 菜单页面的共享容器及侧栏。
|
||||
- 新增 `src/styles/center-layout.css`,企业信息改为无底框网格图标、12px 名称 / 身份;侧栏 216 / 64px,菜单 42px 行高、6px 间距、16px 细线图标,收起按钮去除描边并显示“收起导航”。用户中心沿用 Ant Menu 并共享尺寸与颜色。
|
||||
- `user-center.css` 统一滚动区域的稳定槽位与桌面设计留白;两中心外层补 `min-w-0`,防止宽表格挤压内容。页面继续读取统一 30 / 36 / 36px、移动 16 / 16 / 24px 变量;功能页面主区块使用 18px 间距,合并页签按内容边距对齐,工作台移动端底距恢复统一变量。
|
||||
- 权限、菜单可见性、路由、请求与业务数据沿用现有实现;不新增主题状态或存储项。本地只读验收与截图保存在忽略目录 `report/layout-alignment/`,不进行生产环境测试。
|
||||
- 回归修复:消费记录加载骨架改为在表格卡片正文内横向滚动;密钥页 Joyride 设置 `disableScrollParentFix`,避免其将尚未溢出的宿主滚动容器改成 `overflow: initial`,保证空列表与长列表宽度一致。
|
||||
- 个人数据看板移除重复的内部滚动区,复用用户中心宿主滚动条,避免卡片可用宽度额外减少 6px。
|
||||
|
||||
## 企业中心按在线原型对齐(/org/*,2026-11-06)
|
||||
|
||||
范围:`TARGET_PATH=/org/*`、`SCOPE=target`,登录后侧栏展开 33 条子路由,目标 12 页(工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置)全部“仅 UI”;“我的 AI 能力”“组织架构”“角色管理”按用户特殊规定跳过(不采集 / 不比较 / 不修改);其余为重定向 / 账号不可见 / 范围外,清单与原因见 `report/target-pages.md`。视觉基准为在线原型“企业中心”,规范见 `docs/ui/ORG_CENTER_SPEC.md`,入口约定见 AGENTS.md / CLAUDE.md“企业中心单页约定”。
|
||||
|
||||
- 通用:新增 `src/styles/org-center.css`(`.org-center .oc-page` 作用域,颜色只在 `--oc-*` 变量,深色在 `html.dark`)与 `OrgListCard` / `OrgFilterCard` / `OrgRowActions`;页头操作移入列表卡头;状态按钮组 / 自绘页签 → Ant `Tabs`(原预渲染页签保留 `forceRender`);行操作 → 无图标 link;启停 → `Switch`(原处理函数);Tag 无边框,非预设色 `amber` / `violet` → `gold` / `purple`(修复审批“待审批”标签不可见);面包屑按原型增加分组(只登记目标页);目标页 OrgModal / OrgSideSheet 遮罩按原型 `rgba(0,0,0,.3)` + `blur(4px)`。
|
||||
- 预算中心:移除表格上方两条旧提示栏(“预算实时拦截未生效”“引擎急停”+ cap 说明),按原型 `.eb-policy` 新增说明条,固定文案“预算只设置「最多能花多少」的上限,不增加企业真实额度池;提额仅提高上限。”。旧栏专用的 `Banner` 引用、`enforcementEnabled` / `engineEnabled` 状态与 4 个文案键经全仓检索无其他引用后删除;`/api/org/budget` 请求与列表解析不变。
|
||||
- 个人设置:新增“个人资料”“通知设置”页签,与“头像设置”组成原型三页签;旧内容重新归纳(头像 → 头像设置;昵称 / 登录密码 / 个人配额 → 个人资料;配额预警通知 → 通知设置;企业 / 角色 / 部门 → 资料头卡)。复用用户中心 `ui-personal-*`、`AvatarSection`、`SectionHeader`;`OrgAvatarSection.jsx` 经检索无引用后删除。无新增接口 / 数据流 / 状态 / 路由。
|
||||
- 其他页:工作台(标签化身份、额度 / 密钥 / 用量 / 最近申请卡)、数据看板(`.ea-hero` 页头 + 企业额度 / 组织概况、分析区汇总条 / 趋势 Segmented / 分布、明细页签并入成员用量)、员工管理(页签 + 员工列表卡、首尾列固定、备注独立列)、密钥管理(密钥框、显隐 / 复制、创建 / 编辑改 560px 抽屉)、企业充值(企业钱包 + 充值工作区 + 订单卡 + 记录,修复改前档位卡样式缺失)、消耗明细(统计卡、页签、三列筛选卡)、审计日志(筛选卡 + 操作记录卡)、企业设置(设置卡内页签 + 区块头刷新 / 保存设置、两列表单、复制图标按钮)。逐页修改与剩余差异归类见 `report/visual-regression.html`。
|
||||
- 组件映射:`Banner` → `.oc-policy`;`OrgPanel` / 页头按钮 → `OrgListCard`;`RadioGroup` / 自绘 Tabs → Ant `Tabs`;描边小按钮 → link;`Tag` 色板 → Ant 预设色;`OrgModal`(密钥创建 / 编辑)→ `OrgSideSheet`;`OrgAvatarSection` → `AvatarSection`;`InfoRow` → 设置行 / `Card`;`NotifyChannelForm` 结构改为渠道下拉 + 浅底详情框(值 / 回调契约不变,仅个人设置与企业设置使用);`OrgScopedLimitButtons` 新增 `variant='link'`(组织架构仍为默认描边)。
|
||||
- 遮罩与弹窗:目标页 OrgModal / OrgSideSheet 遮罩按原型(antd 6 默认)`rgba(0,0,0,.3)` + `blur(4px)`;密钥创建 / 编辑抽屉表单按原型重排(过期单选按钮、自定义才显示日期、高级设置折叠,新增仅视图的选中态,载荷不变);工作台提额弹窗不显示必填星号(规则不变)、说明改为字段 extra、申请理由显示 0 / 200 计数(原已限长 200)。
|
||||
- 验证:真实 UI 登录 A(企业名 + 下一步)/ B(记忆企业)均进入 `/org/workbench`,接口错误 0;原型 / 系统同序列采集(1920×1080、DPR 1、zh-CN、reducedMotion、浅深,系统 24 组 0 错误、非 GET 0、trace / video 在 `report/`);路由核定 33 条非 GET 0;比较按 DIFF_THRESHOLD(整页 ≤0.5%、组件 ≤0.2%,未放宽)12 页均**未达阈值**:整页 0.49%–8.51%(最差 P2,无 P1;改前对照 30 组中 27 组下降,企业充值 12.6% → 2.3%),组件 20 通过 / 110 P3 / 155 P2 / 17 P1(16 项为面包屑 18px 行高规范例外,1 项为暗色看板组织概况数据 / 进度色),其余为 mock 与真实数据、规范例外或系统无对应功能,已逐项归类,不宣称像素一致。`e2e/org-center-ui.spec.js` 建基线 30/30,有意改动后仅重建看板 2 张,不带 update 复跑 32/32(含 8 条只读交互,写请求 0);`npm test` 256/256;全仓 ESLint 13 错误 / 169 警告与基线一致(改动文件 0 错误);Prettier 561 个既有问题文件(改动文件中仅 HEAD 即未格式化的 `OrgScopedLimitButtons.jsx`);临时目录构建通过;`git diff --check` 通过;结束 UI 退出成功。内存全程绿线(已用峰值 45.2%),无降载 / 暂停 / 重试。证据与报告在 Git 忽略的 `report/`(`visual-regression.html`、`visual-regression-quick-*.html`、`target-pages.md`、`resources/memory.jsonl`)。
|
||||
- 风险:审计“提示词记录”接口 `success:false`(后端提示词库未配置,非 UI);页头统一规格比原型矮约 6px(规范例外);未做真实支付 / 密钥增改 / 预算保存 / 审批 / 提额提交(只验证打开、校验、取消);“组织架构”文案键未登记 9 个语言包(用户在制改名,未改);antd 5 与原型 antd 6 其余默认样式差异保留。
|
||||
|
||||
## 技能超市恢复真实 API(2026-11-05)
|
||||
|
||||
已按用户指令将 `src/pages/SkillMarket/index.jsx` 默认入口恢复为 `LiveSkillMarket.jsx`;仅 `VITE_SKILL_MARKET_MOCK=true` 显式开启历史演示。开发 / 生产环境文件及当前终端没有该覆盖项,无需重启环境变量;入口代码热更新后已实际验证真实请求。红框中的本地演示、浏览器保存说明和恢复样例按钮不再挂载,本地新增 / 编辑 / 删除不进入真实页面。旧浏览器 mock 缓存被忽略,不迁移至后端。
|
||||
@@ -106,7 +128,7 @@ mock 与 live 共享完整目录的前端筛选及分页逻辑。live 沿用 `/a
|
||||
|
||||
导航:按后续标注将密钥管理从桌面/移动主导航移除,在用户中心侧栏使用记录下方及移动底部导航增加入口;LayoutGrid、ScrollText、KeyRound、Wallet、UserRound 对齐图标语义与线宽,头像菜单沿用密钥管理跳转。保留 /key-management URL 与原模块鉴权/PrivateRoute,只把路由内容包装进 UserCenter keyManagementMode;密钥页 embedded 分支不重复背景和顶部占位,增加用户中心面包屑,原 API 与操作回调不改。此为用户明确要求的导航宿主调整,不新增业务权限或新路由。
|
||||
|
||||
导航实测:真实个人 UI 登录,侧栏入口顺序、进入后侧栏保留/选中、刷新保持、头像菜单入口、顶栏无密钥入口、移动底部入口,以及双主题桌面/移动截图通过;非 GET /api/ 请求 0,pageerror 0,结束 UI 退出。客服与导航证据分别为 logs/header-nav/customer-*、key-nav-*(Git 忽略)。串行单元测试及局部静态检查见本轮交付;未执行构建、全量 lint 或企业登录/权限矩阵验收,不宣称像素阈值验收通过。
|
||||
导航实测:真实个人 UI 登录,侧栏入口顺序、进入后侧栏保留/选中、刷新保持、头像菜单入口、顶栏无密钥入口、移动底部入口,以及双主题桌面/移动截图通过;非 GET /api/ 请求 0,pageerror 0,结束 UI 退出。客服与导航证据分别为 logs/header-nav/customer-_、key-nav-_(Git 忽略)。串行单元测试及局部静态检查见本轮交付;未执行构建、全量 lint 或企业登录/权限矩阵验收,不宣称像素阈值验收通过。
|
||||
|
||||
## 系统公告弹窗与移动适配(2026-11-04)
|
||||
|
||||
@@ -517,3 +539,33 @@ mock 与 live 共享完整目录的前端筛选及分页逻辑。live 沿用 `/a
|
||||
- 原型与真实配置、数据和页面结构存在差异,已列出剩余视觉差异;当前结果不能标记为全站像素级对齐或全部真实业务验收完成。
|
||||
- 真实后台存在请求频率限制;后续采集优先 SPA 导航并在同一页面切换主题,出现 429 时记录并降低采集频率,不能改服务端限流或把错误页当作空数据通过。
|
||||
- 全量 lint 的原有错误与格式差异继续单列;不得为交付绿灯顺带调整业务 Hook 或批量重排不相关文件。构建的既有大 chunk 告警记录为后续独立性能任务。
|
||||
|
||||
## 企业侧栏移除菜单搜索(2026-11-06)
|
||||
|
||||
- 按用户对 `/org/workbench` 的截图要求,移除共享 `OrgSidebar` 的搜索输入框、收起态放大镜入口、搜索状态、菜单过滤、高亮和搜索空态;企业端共用此侧栏的页面同步生效。
|
||||
- 保留菜单权限、分组折叠、当前路由高亮、导航与移动端共用侧栏;不新增文案。
|
||||
- 复用既有真实 UI 登录会话,在 `dev.log` 的 Local 地址验证工作台;离屏有头 Chrome 检查浅深色下展开/收起无搜索入口、分组折叠、工作台与数据看板跳转及高亮,移动视口检查无搜索输入框,结束经 UI 退出。页面运行错误 0,退出前非 GET API 请求 0。记录保存在忽略目录 `report/sidebar-remove-browser.json`。
|
||||
- `npm test -- --test-concurrency=1`:256/256 通过;变更组件 ESLint、Prettier 与 `git diff --check` 通过。全仓 ESLint 仍有其他文件的 14 个错误、184 个警告;全仓 Prettier 报告 561 个文件格式差异,未批量修复。按用户要求未执行生产构建。
|
||||
|
||||
## 控制台系统设置页签崩溃修复(2026-11-06)
|
||||
|
||||
- 在 `/login` 通过个人登录进入管理员后台后,访问 `/console/setting` 并切换至 `ratio`,复现 `TypeError: showTotal is not a function`。调用栈来自可视化倍率表格与未设置倍率模型表格的分页,顶层 `ChunkErrorBoundary` 捕获后替换整个应用,导致导航无法继续使用。
|
||||
- 根因是旧组件支持 `pagination.showTotal: true`,Ant Design 只接受总数渲染函数;独立 `Pagination` 已处理布尔值,但共享 `Table` 没有转换。隐藏子页签预渲染及列表数据是否存在影响触发时机,因此表现为有概率挂起。
|
||||
- `src/components/ui/pagination.js` 提供统一 `paginationShowTotal`,`Table` 与独立 `Pagination` 共用;保留自定义函数、关闭总数展示、原分页回调与接口。未修改登录、路由、权限、设置保存或错误边界。
|
||||
- 在已跟踪的 `tests/users-pagination.test.js` 增加 9 项真实 Ant Design 服务端渲染回归,覆盖两种分页的布尔总数、自定义函数与范围参数、隐藏总数和关闭表格分页。
|
||||
- 离屏有头 Chrome 使用真实后台数据完成 18 个顶层页签的三轮切换(54 次),点击检查 23 个子页签,包含更多菜单入口;另验证定价页刷新、浏览器前进/后退、侧栏切页后返回。深色补测定价、内容防护、模型相关、系统设置在 1920px 与 393px 的 8 个场景。运行错误 0、失败 API 响应 0、设置验证期间非 GET API 请求 0,结束经 UI 退出。账号无教程视频,未验证视频预览弹窗。
|
||||
- 全量单元测试 265/265 通过,变更文件 ESLint、Prettier 与 `git diff --check` 通过;全仓 ESLint 和格式检查的其他文件遗留问题单列在忽略目录 `report/settings-eslint.log`、`report/settings-prettier.log`。复现与浏览器结果为 `report/settings-probe.json`、`report/settings-regression.json`、`report/settings-extra.json`,不提交会话和验收产物。按用户要求未执行生产构建。
|
||||
|
||||
## 企业中心追加交互(2026-11-06)
|
||||
|
||||
- 企业密钥管理:按追加设计补充分组列,直接展示列表已有 group(auto 显示智能熔断,缺失显示 -);调整表头顺序、列宽、对齐及复制图标颜色,新增当前页面列设置(至少保留一列、刷新恢复默认)。沿用原显隐、复制、模型抽屉、创建编辑、删除确认、启停接口与角色权限。本地模拟 API 浏览器检查覆盖上述功能、管理员 / 成员及暗色移动布局,未执行生产测试。
|
||||
|
||||
- 模型明细滚动调整:按后续截图要求移除表格局部纵向滚动和固定表头,表格随页面自然展开,与成员用量一致;保留每页 10 条的前端分页及窄屏横向滚动,翻页不增加请求。
|
||||
|
||||
- 数据看板后续调整:顶部“企业运行正常”及右侧动态企业名(复用 `orgInfo.name`);多维分析工具组使用原生 Ant 控件,尺寸 132/86/34×34px、间距 8px;模型明细改为前端每页 10 条分页和局部表体滚动,翻页零请求,筛选或数据更新回第一页。本地模拟测试覆盖桌面/移动、浅深主题、长企业名、16 条数据分页 10/6、3 条数据单页、筛选和原有刷新调用。
|
||||
|
||||
- 数据看板:剩余额度下增加充足 / 偏低 / 已用尽提示;充足色 #438568,橙 / 红使用相近的暗色调;剩余占比 20% 为偏低边界,原始值判定,文案补齐 9 种语言。
|
||||
- 项目管理:状态改为启用 / 禁用开关,移除操作列停用;复用现有 DELETE 停用(保留确认)、编辑 PUT 启用;请求中锁定开关,失败保留原状态。
|
||||
- 预算中心:状态开关复用 PUT /api/org/budget,透传行主体、原始额度、周期、自定义天数及超限动作,只改变 status;主体已删除时不可切换。
|
||||
- 导航:组织管理、额度与治理、财务与日志、系统设置统一“分组 / 页面”两级面包屑;概览页保留“企业中心 / 页面”。本轮用户要求覆盖这些分组全部页面。
|
||||
- 验证:本地模拟 API 浏览器测试覆盖项目启停 / 取消 / 失败、预算启停 / 失败 / 字段保留 / 已删除主体、浅深主题桌面及移动额度状态与实际颜色;无生产写入。产物在忽略目录 report/。
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# 企业中心(/org/*)在线原型对齐规范
|
||||
|
||||
本文件是企业中心目标页的详细规格;入口约定见 `AGENTS.md` / `CLAUDE.md`“企业中心单页约定(/org/*)”,改造记录见 `docs/UI_MIGRATION.md`“企业中心按在线原型对齐(2026-11-06)”。
|
||||
|
||||
## 1. 范围与依据
|
||||
|
||||
- 视觉唯一基准:在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(SPA,URL 保持 `/`,无需登录;深色用“切换至暗色主题”)。原型只作视觉依据,不作业务 / 路由 / 数据依据。
|
||||
- 目标页(`TARGET_PATH=/org/*`,按登录后侧栏展开):工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置。
|
||||
- 跳过(特殊规定,不采集 / 不比较 / 不修改):我的 AI 能力、组织架构、角色管理(系统无对应路由)。共享组件改动必须保持这些页面渲染不变(例:`OrgScopedLimitButtons` 新增 `variant='link'`,默认描边按钮留给组织架构;面包屑分组只登记目标页)。
|
||||
- 仅 UI:只对齐背景、字体、图标、表格、表单、卡片、Tab、搜索条件、操作列、弹窗、按钮、颜色、文字、间距与已有交互反馈;不新增功能,不改请求 / 载荷 / 状态 / 路由 / 权限 / 触发条件。原型有而系统无的功能(列设置齿轮、CSV 导出、尺寸切换分页、新建员工 / 分配角色 / 离职等员工操作、角色管理、在职 / 已离职筛选、订单号搜索、分组列、发票入口)不补建,记为“原型有、系统无对应功能”。例外:企业密钥管理的分组列与列设置按 2026-11-06 用户追加要求实现,其他页面不据此新增。
|
||||
|
||||
## 2. 作用域与 token
|
||||
|
||||
- 目标页根节点追加 `.oc-page`(与 `.uc-page` 并存);样式集中在 `src/styles/org-center.css`,全部规则以 `.org-center .oc-page`(或页面类 `.oc-workbench` / `.oc-dashboard` / `.oc-recharge` / `.oc-personal-settings` / `.oc-company-settings`)限定;Portal 弹窗用 `.oc-dialog`。
|
||||
- 颜色只写在变量中,规则只引用变量;浅色为原型实测,深色写在 `html.dark` 下:
|
||||
|
||||
| 变量 | 浅色 | 深色 | 来源 |
|
||||
| ------------------ | ----------------------------- | ----------------------------- | -------------------------------------- |
|
||||
| `--oc-text` | `--text-primary`(#263247) | `--text-primary`(#e6ebf3) | 原型 `--text` |
|
||||
| `--oc-muted` | `--text-secondary`(#7e8998) | `--text-secondary`(#8e9aaa) | 原型 `--muted` |
|
||||
| `--oc-border` | `--border-subtle`(#e9edf2) | `--border-subtle`(#2b333f) | 原型 `--border` |
|
||||
| `--oc-soft` | #fafbfc | #202732 | 原型 `--soft` |
|
||||
| `--oc-brand` | #b96508 | #f2ad41 | 原型 `--brand`(Ant 主色仍为 #d1963a) |
|
||||
| `--oc-page-bg` | #f8fafc | `--surface-bg-base` | 原型 `.main` 背景 |
|
||||
| `--oc-card-shadow` | `0 3px 18px #25354a03` | 同左 | 原型 `.ee-list-card` |
|
||||
|
||||
- 不新增 ConfigProvider / 主题状态 / 存储 key;Ant 组件颜色由现有 `UiThemeProvider` token 决定。标签统一 `bordered={false}`(等价原型 antd 6 默认 filled),非 antd 预设色(如 `amber`、`violet`)改为 `gold` / `purple`。
|
||||
|
||||
## 3. 页头与通用块
|
||||
|
||||
- 页头沿用“带侧栏页面统一规格”:`OrgPageHeader`(面包屑 12/18px、距顶 30px、与标题 24px;标题 28/32px/650;副标题 14/22px)。原型为 26px / 20px 行高 / 标题 39.2px 行高 / 副标题 13px,整体比原型矮约 6px——记为“规范例外(用户 2026-11-04 统一规格)”。`.oc-page` 内 `--uc-heading` / `--uc-subtitle` 取原型 `--text` / `--muted`。
|
||||
- 面包屑(2026-11-06 用户追加要求):组织管理、额度与治理、财务与日志、系统设置分组页为“分组 / 页面”,其他页面为“企业中心 / 页面”;`OrgBreadcrumb` 的 `orgPageGroups` 覆盖四组全部页面,含组织架构、角色专属页和 Agent 任务审计。
|
||||
- 页头不放操作按钮;操作移入卡头(原型 `.ee-list-toolbar`)。
|
||||
- `OrgListCard`(`components/OrgListCard.jsx`):Ant `Card.oc-list-card`,正文 24px;卡头 h2 15px/600 + 工具区 8px;表格 13px、表头 12px/500 次文字色浅底、行上下 17px;分页 `showTotal`“共 N 条”(不加尺寸切换)。
|
||||
- `OrgFilterCard`:三列网格 16px、表单竖排标签 13px 次文字色、操作右对齐(重置 / 搜索)。筛选取值与生效时机沿用原页面(审计“选择即筛选”,“搜索”= 以当前条件重新查询)。
|
||||
- `OrgRowActions`:link 按钮 13px/24px、无内边距、间距 10px;危险操作 `danger` link;不带图标。
|
||||
- 列表页签 `.oc-list-tabs`(原型 `.platform-list-tabs`):导航 44px、页签 12px 0、间距 28px、选中 / 悬停 `--oc-brand`、2px 下划线;只切换筛选时加 `.oc-tabs-nav-only` 隐藏内容区。原 Tabs 预渲染全部页签(`lazyRender=false`)的页面改用 Ant Tabs 时保留 `forceRender`,请求时机不变。
|
||||
- 状态开关:原有启停操作的列表(密钥、员工)用 `Switch size=small`(启用 / 禁用),`onChange` 仍调原处理函数;项目、预算按用户追加要求改为同款开关;项目禁用保留原确认与 DELETE,启用复用编辑 PUT;预算复用编辑 PUT 并携带主体、原始额度、周期、自定义周期天数、超限动作和目标状态,主体已删除时禁用开关。请求中禁用重复操作,失败保留原状态。
|
||||
- 弹窗 / 抽屉:遮罩按原型(antd 6 默认)`rgba(0,0,0,.3)` + `blur(4px)`,浅深一致;规则为 `body:has(.org-center .oc-page)` 下含 `.org-modal` / `.org-sidesheet` 的遮罩,宿主公告、客服与跳过页不受影响。表单按原型竖排、`requiredMark={false}`(校验规则不变),字段说明用 Form.Item `extra`。
|
||||
- 密钥创建 / 编辑抽屉(`OrgKeyForm`):名称 / 归属项目 / 密钥分组 / 过期时间(`Radio.Group.oc-key-expiry`:间距 6px、圆角 6px、描边 `#d9dfe6`,深浅同值;仅“自定义”显示日期选择)/ `Collapse` 高级设置(`forceRender`;额度设置 + `Divider` + 访问限制,小标题 14px/700/下距 18px);正文 24px,说明 12px / 1.8;页脚贴底。选中态 `expiryPreset` 只用于视图,取值仍走原 `setExpiredTime`。
|
||||
|
||||
## 4. 页面映射(原型 → 系统)
|
||||
|
||||
| 页面 | 原型结构 | 系统实现 | 保留差异 |
|
||||
| -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
|
||||
| 工作台 | `.ew-hero` 标签 / `.ew-stats` / `.ew-middle`(额度 + 密钥)/ `.ew-usage` / `.ew-requests` | `OrgHero` 标签化身份、`oc-wb-*` 卡片;数据与提额 / 昵称 / 改密回调不变 | 额度周期标签放在重置卡;最近申请无分页 |
|
||||
| 数据看板 | `.ea-hero`(健康 / 标题 / 操作 / 企业额度 + 组织概况)→ `.ea-analysis` → `.ea-details` 页签 | `oc-dash-*` hero + `OrgAnalyticsPanel`(汇总条、趋势 Segmented、分布、明细页签,成员用量明细并入页签) | 企业名复用 orgInfo.name;“成员用量”= 切换页签并页内定位;时间范围保留 7/30/90 天 |
|
||||
| 员工管理 | 页签 + 筛选卡 + 员工列表 | 页签(员工权限 / 员工账号)+ 员工列表卡;首列 / 操作列固定;备注独立列(原就地编辑);状态 Switch | 无筛选卡 / 在职离职页签 / 角色多标签;操作为系统既有(配额 / 模型 / 分组 / 权限 / 移除) |
|
||||
| 项目管理 | 项目列表卡 | `OrgListCard` + link 操作(模型 / 分组 / 成员 / 密钥 / 编辑) | 状态为启用 / 禁用开关,操作列不再显示停用 |
|
||||
| 预算中心 | `.eb-policy` + 预算列表卡 | 新说明条 `.oc-policy`(固定文案)替换两条旧 Banner;列宽 300/110/260/120/120/130 | 无分页、状态为启用 / 禁用开关 |
|
||||
| 审批中心 | 状态页签 + 申请列表卡 | 页签回调 `setStatusFilter`;拒绝弹窗竖排表单项 | — |
|
||||
| 密钥管理 | 密钥列表卡(`.km-secret`)+ 创建 / 编辑抽屉(`.km-editor-drawer`) | 密钥框 + 显隐 / 复制 text 按钮、可用模型 link、状态 Switch、绝对时间;创建 / 编辑改为 560px `OrgSideSheet`(表单与回调不变) | 分组展示现有 group 字段;列设置仅控制当前页面显示;抽屉字段为系统既有字段 |
|
||||
| 企业充值 | RechargeLayoutC:企业钱包 + 工作区(额度卡 / 自定义 / 支付方式)+ 订单卡 + 记录 | `oc-rc-*`;`AmountCard` 复用;订单卡“立即充值”与点击支付方式同为 `handlePreTopUp` | 档位 / 标签 / 折扣徽标为后台配置;无订单号搜索与发票入口 |
|
||||
| 消耗明细 | `.eex-stats` + 页签 + 筛选卡 + 列表卡 | 同结构;查询改名“搜索”(同 `handleSearch`) | 无“绘图与视频”页签、分组列 |
|
||||
| 审计日志 | 页签 + 筛选卡(操作类型)+ 操作记录卡 | 同结构;“提示词记录”页签沿用原显隐 | 详情分隔符沿用系统格式 |
|
||||
| 个人设置 | `.ps-profile` + `.ps-workspace` 页签(头像设置 / 个人资料 / 通知设置) | 复用用户中心 `.ui-personal-*`、`AvatarSection`、`SectionHeader`;个人资料 = 昵称 / 密码设置行 + 个人配额卡;企业身份并入资料头 | 昵称为弹窗修改(原型行内) |
|
||||
| 企业设置 | `.ps-workspace` 页签 + 每页签区块头(刷新 / 保存设置) | 同结构;刷新 / 保存按钮并入区块头;复制为 14px 无内边距图标按钮(原型 Typography copyable) | 保留系统独有“数据安全”“危险区域”页签 |
|
||||
|
||||
## 5. 判定与验收
|
||||
|
||||
- 采集:`e2e/org-center/proto-capture.mjs`(原型)/ `capture-system.mjs`(系统,复用 `report/auth/org-storage.json`);1920×1080、DPR 1、zh-CN、Asia/Shanghai、reducedMotion + 注入关闭动画、浅 / 深;系统侧关闭会话级公告栏(sessionStorage,仅测试浏览器)并 Esc 关闭公告弹窗。
|
||||
- 比较:`compare.mjs`(pixelmatch 等价 + SSIM + pHash,整页遮罩宿主顶栏 / 侧栏 / 滚动条带 / 客服浮钮);整页因 mock 与真实数据不同只作信息值;组件按两侧 DOM 树对应类名裁剪;阈值整页 ≤0.5%、组件 ≤0.2%(P3 ≤2%、P2 ≤10%、P1 >10%),不放宽。报告 `report/visual-regression.html`。
|
||||
- 本地回归:`e2e/org-center-ui.spec.js` 以 `toHaveScreenshot()` 建基线后不带 update 复跑(本地基线 ≠ 原型像素一致)。
|
||||
- 只读验收非 GET `/api/` 为 0;登录使用真实 UI(A:企业名 + 下一步;B:记忆企业后的登录名 + 密码),结束 UI 退出。
|
||||
|
||||
### 2026-11-06 追加交互
|
||||
|
||||
- 企业数据看板剩余额度下方增加状态提示:剩余占比 >20% 为“可用额度充足”(#438568),0<占比≤20% 为“可用额度偏低”(#9c6b25),剩余≤0 为“可用额度已用尽”(#b34c4c);数据缺失或无效时隐藏。占比使用未取整原始值,仅控制提示,不改变计费或拦截。新增文案覆盖 9 个语言包。
|
||||
- 数据看板顶部正常提示为“企业运行正常”;右侧企业名由父页面已加载的 `orgInfo.name` 传入,无值时隐藏,长名称换行,不新增接口。
|
||||
- 多维用量分析操作组使用原生 Ant Select / Button 和全局 token:维度 132px、时间 86px、刷新 34px,统一 34px 高、8px 间距,保留原筛选与刷新请求逻辑。
|
||||
- 模型明细使用已加载数据做前端分页,每页 10 条,非空数据均展示底部分页;翻页不请求接口,维度、时间或数据更新时回到第一页。按用户后续要求移除表体局部纵向滚动,与成员用量一致随页面自然展开;仅保留窄屏横向滚动,成员用量分页保持原逻辑。
|
||||
- 本轮只在本地组件及拦截 API 的模拟环境验证,不进行生产测试。
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"dev": "node scripts/dev.mjs",
|
||||
"build": "vite build",
|
||||
"test": "node --test",
|
||||
"test:e2e": "playwright test",
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// esbuild runs in Go, so NODE_OPTIONS cannot control its heap or parallelism.
|
||||
process.env.GOMEMLIMIT ||= '512MiB';
|
||||
process.env.GOMAXPROCS ||= '2';
|
||||
|
||||
// Set Go's environment before Vite starts its esbuild service.
|
||||
await import('../node_modules/vite/bin/vite.js');
|
||||
@@ -30,7 +30,7 @@ const TIERS = [
|
||||
{ tier: 5, name: '通用交互层', areas: ['hooks', 'components/table', 'components/customer-service', 'pages/Log', 'pages/Task', 'pages/Subscription', 'components/membership', 'pages/Tutorial', 'pages/Docs', 'pages/About', 'pages/PrivacyPolicy', 'pages/UserAgreement', 'pages/Status'] },
|
||||
{ tier: 6, name: '企业侧', areas: ['pages/Organization', 'pages/ExpertPlatform', 'pages/SkillPlatform', 'pages/ExperienceCenterAudit'] },
|
||||
{ tier: 7, name: '管理/运营后台', areas: ['pages/Setting', 'components/settings', 'pages/AdminOrganizations', 'pages/AdminInvoice', 'pages/AdminOrder', 'pages/Channel', 'pages/Model', 'pages/Redemption', 'pages/Monitoring', 'pages/MonitorCenter', 'pages/ServiceDashboard', 'pages/Analytics', 'pages/User', 'components/analytics', 'components/dashboard'] },
|
||||
{ tier: 8, name: '分佣/合作伙伴', areas: ['pages/CommissionConsole', 'pages/MyCommission', 'pages/PartnerPortal', 'components/promotion'] },
|
||||
{ tier: 8, name: '提成/合作伙伴', areas: ['pages/MyCommission', 'pages/PartnerPortal', 'components/promotion'] },
|
||||
];
|
||||
const TIER_OTHER = 9; // 源码中有引用但未归入上表的区域
|
||||
const TIER_DEAD = 99; // 源码已无引用的历史 key(en.json 里还在,为「一一对应」保留)
|
||||
|
||||
+1
-15
@@ -20,7 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { lazy, Suspense, useContext, useMemo } from 'react';
|
||||
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
||||
import Loading from './components/common/ui/Loading';
|
||||
import { AuthRedirect, PrivateRoute, AdminRoute, RootRoute } from './helpers';
|
||||
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
|
||||
import NotFound from './pages/NotFound';
|
||||
import Forbidden from './pages/Forbidden';
|
||||
import { StatusContext } from './context/Status';
|
||||
@@ -55,7 +55,6 @@ const LoginForm = lazy(() => import('./components/auth/LoginForm'));
|
||||
const OrgLogin = lazy(() => import('./pages/OrgLogin'));
|
||||
const PartnerPortal = lazy(() => import('./pages/PartnerPortal'));
|
||||
const PartnerConsole = lazy(() => import('./pages/PartnerPortal/Console'));
|
||||
const CommissionConsole = lazy(() => import('./pages/CommissionConsole'));
|
||||
const MyCommission = lazy(() => import('./pages/MyCommission'));
|
||||
const OrgRegister = lazy(() => import('./pages/OrgRegister'));
|
||||
const RegisterForm = lazy(() => import('./components/auth/RegisterForm'));
|
||||
@@ -335,19 +334,6 @@ function App() {
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/commission'
|
||||
element={
|
||||
/* 分佣管理为 Root 专属:侧边栏一直用 isRoot() 隐藏该入口,后端结算/销售/成本/
|
||||
伙伴管理各路由组也已全部 Root 收口。这里把路由守卫对齐,避免 role=10 直接
|
||||
输 URL 进到一个读得到、写按钮全 403 的半残页面。 */
|
||||
<RootRoute>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<CommissionConsole />
|
||||
</Suspense>
|
||||
</RootRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/experience-center-audit'
|
||||
element={
|
||||
|
||||
@@ -218,7 +218,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
title: t('企业活跃成员'),
|
||||
value: `${(k.active_members || 0).toLocaleString()} ${t('人')}`,
|
||||
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
tip: t('本期通过企业令牌产生调用的去重成员数(按自然日统计)'),
|
||||
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
||||
onClick: () => onJump('growth'),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ export const REASONS = {
|
||||
never_used: {
|
||||
label: '开通未使用',
|
||||
color: 'violet',
|
||||
action: '引导创建令牌、完成首次调用',
|
||||
action: '引导创建密钥、完成首次调用',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ const CardTable = ({
|
||||
|
||||
// ===== 移动端多选支持 =====
|
||||
// 移动端卡片分支此前完全没有消费 rowSelection,导致调用方的 selectedKeys 永远是空数组,
|
||||
// 令牌/兑换码/渠道/模型/管理员令牌五个页面的批量操作在手机上全是死按钮
|
||||
// 密钥/兑换码/渠道/模型/管理员密钥五个页面的批量操作在手机上全是死按钮
|
||||
// (点了只提示「请至少选择一个」,渠道页甚至会对空集合弹出删除确认)。
|
||||
// 这里补上:兼容 Semi 的受控(传 selectedRowKeys)与非受控(只传 onChange)两种用法。
|
||||
const rowSelection =
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { DatePicker, Form, Input, Modal, Select } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import './user-dashboard-filter.css';
|
||||
|
||||
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
const UserDashboardFilterModal = ({
|
||||
searchModalVisible,
|
||||
handleSearchConfirm,
|
||||
handleCloseModal,
|
||||
isAdminUser,
|
||||
inputs,
|
||||
dataExportDefaultTime,
|
||||
timeOptions,
|
||||
handleInputChange,
|
||||
t,
|
||||
}) => (
|
||||
<Modal
|
||||
open={searchModalVisible}
|
||||
title={t('筛选数据')}
|
||||
width={520}
|
||||
className='uc-dashboard-filter-modal'
|
||||
onCancel={handleCloseModal}
|
||||
onOk={handleSearchConfirm}
|
||||
okText={t('查询')}
|
||||
cancelText={t('取消')}
|
||||
maskClosable
|
||||
>
|
||||
<Form layout='vertical' requiredMark={false}>
|
||||
<Form.Item label={t('时间范围')} htmlFor='dashboard-filter-range'>
|
||||
<DatePicker.RangePicker
|
||||
id='dashboard-filter-range'
|
||||
aria-label={t('时间范围')}
|
||||
showTime
|
||||
format={DATE_FORMAT}
|
||||
allowClear={false}
|
||||
value={[dayjs(inputs.start_timestamp), dayjs(inputs.end_timestamp)]}
|
||||
onChange={(_, dateStrings) => {
|
||||
// Keep the existing query hook's local date-string contract.
|
||||
handleInputChange(dateStrings[0], 'start_timestamp');
|
||||
handleInputChange(dateStrings[1], 'end_timestamp');
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('时间粒度')} htmlFor='dashboard-filter-granularity'>
|
||||
<Select
|
||||
id='dashboard-filter-granularity'
|
||||
value={dataExportDefaultTime}
|
||||
options={timeOptions}
|
||||
onChange={(value) =>
|
||||
handleInputChange(value, 'data_export_default_time')
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
{isAdminUser && (
|
||||
<Form.Item label={t('用户名称')} htmlFor='dashboard-filter-username'>
|
||||
<Input
|
||||
id='dashboard-filter-username'
|
||||
value={inputs.username}
|
||||
placeholder={t('可选值')}
|
||||
onChange={(event) =>
|
||||
handleInputChange(event.target.value, 'username')
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
export default UserDashboardFilterModal;
|
||||
@@ -0,0 +1,15 @@
|
||||
.uc-dashboard-filter-modal .ant-modal-body {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-picker-range {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.uc-dashboard-filter-modal .ant-modal-footer {
|
||||
margin-top: 0;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import React, { useContext, useEffect, useMemo, useState } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { getLucideIcon } from '../../helpers/render';
|
||||
import { ChevronLeft } from 'lucide-react';
|
||||
import { ChevronDown, ChevronLeft } from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { useSidebar } from '../../hooks/common/useSidebar';
|
||||
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
import SkeletonWrapper from './components/SkeletonWrapper';
|
||||
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
|
||||
|
||||
import { Nav, Divider, Button } from '@/components/ui';
|
||||
import { Nav, Button } from '@/components/ui';
|
||||
|
||||
const routerMap = {
|
||||
home: '/',
|
||||
@@ -58,7 +58,6 @@ const routerMap = {
|
||||
personal: '/console/personal',
|
||||
monitor: '/console/monitor',
|
||||
analytics: '/console/analytics',
|
||||
commission: '/console/commission',
|
||||
'my-commission': '/console/my-commission',
|
||||
partner: '/console/partner',
|
||||
organizations: '/console/organizations',
|
||||
@@ -97,6 +96,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
const [selectedKeys, setSelectedKeys] = useState(['home']);
|
||||
const [chatItems, setChatItems] = useState([]);
|
||||
const [openedKeys, setOpenedKeys] = useState([]);
|
||||
const [foldedGroups, setFoldedGroups] = useState([]);
|
||||
const location = useLocation();
|
||||
const [routerMapState, setRouterMapState] = useState(routerMap);
|
||||
|
||||
@@ -112,7 +112,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
: 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('令牌管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'token',
|
||||
to: '/token',
|
||||
},
|
||||
@@ -210,12 +210,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
to: '/console/analytics',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('分佣管理'),
|
||||
itemKey: 'commission',
|
||||
to: '/console/commission',
|
||||
className: isRoot() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('渠道管理'),
|
||||
itemKey: 'channel',
|
||||
@@ -247,7 +241,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
},
|
||||
{
|
||||
text: t('秘钥管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'admin-token',
|
||||
to: '/console/token',
|
||||
className: isAdmin() ? '' : 'tableHiddle',
|
||||
@@ -320,10 +314,6 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
// 分佣管理:新增模块不在 sidebar 配置注册表内,绕过 isModuleVisible(Root 硬门控)
|
||||
if (item.itemKey === 'commission') {
|
||||
return isRoot();
|
||||
}
|
||||
// 系统设置入口:被下放了至少一个 tab 的普通管理员强制可见
|
||||
// (需绕过 isModuleVisible,因为 GetSelf 默认对普通管理员置 admin.setting=false)。
|
||||
// root 及其它情况仍走原有 isModuleVisible 逻辑,保留 root 自行隐藏该入口的能力。
|
||||
@@ -459,6 +449,35 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
// 选中高亮颜色(统一)
|
||||
const SELECTED_COLOR = 'var(--ui-color-primary)';
|
||||
|
||||
const renderGroup = (key, label, items) => {
|
||||
const folded = foldedGroups.includes(key);
|
||||
return (
|
||||
<Nav.Group
|
||||
itemKey={key}
|
||||
folded={folded}
|
||||
text={
|
||||
<button
|
||||
type='button'
|
||||
className='sidebar-group-toggle'
|
||||
aria-expanded={!folded}
|
||||
onClick={() =>
|
||||
setFoldedGroups((previous) =>
|
||||
previous.includes(key)
|
||||
? previous.filter((group) => group !== key)
|
||||
: [...previous, key],
|
||||
)
|
||||
}
|
||||
>
|
||||
<span className='truncate'>{label}</span>
|
||||
<ChevronDown size={13} className={folded ? '-rotate-90' : ''} />
|
||||
</button>
|
||||
}
|
||||
>
|
||||
{items}
|
||||
</Nav.Group>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染自定义菜单项
|
||||
const renderNavItem = (item) => {
|
||||
// 跳过隐藏的项目
|
||||
@@ -546,7 +565,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
width: forceExpanded
|
||||
? 'var(--sidebar-width)'
|
||||
: 'var(--sidebar-current-width)',
|
||||
background: 'var(--ui-color-bg-0)',
|
||||
background: 'var(--surface-sidebar)',
|
||||
}}
|
||||
>
|
||||
<SkeletonWrapper
|
||||
@@ -596,52 +615,35 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
|
||||
}}
|
||||
>
|
||||
{/* 聊天区域 */}
|
||||
{hasSectionVisibleModules('chat') && (
|
||||
<div className='sidebar-section'>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('聊天')}</div>
|
||||
)}
|
||||
{chatMenuItems.map((item) => renderSubItem(item))}
|
||||
</div>
|
||||
{hasSectionVisibleModules('chat') &&
|
||||
renderGroup(
|
||||
'chat-group',
|
||||
t('聊天'),
|
||||
chatMenuItems.map(renderSubItem),
|
||||
)}
|
||||
|
||||
{/* 控制台区域 */}
|
||||
{hasSectionVisibleModules('console') && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('控制台')}</div>
|
||||
)}
|
||||
{workspaceItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
{hasSectionVisibleModules('console') &&
|
||||
renderGroup(
|
||||
'console-group',
|
||||
t('控制台'),
|
||||
workspaceItems.map(renderNavItem),
|
||||
)}
|
||||
|
||||
{/* 个人中心区域 */}
|
||||
{hasSectionVisibleModules('personal') && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('个人中心')}</div>
|
||||
)}
|
||||
{financeItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
{hasSectionVisibleModules('personal') &&
|
||||
renderGroup(
|
||||
'personal-group',
|
||||
t('个人中心'),
|
||||
financeItems.map(renderNavItem),
|
||||
)}
|
||||
|
||||
{/* 管理员区域:按角色、权限下放及菜单配置过滤。 */}
|
||||
{isAdmin() && (
|
||||
<>
|
||||
<Divider className='sidebar-divider' />
|
||||
<div>
|
||||
{!collapsed && (
|
||||
<div className='sidebar-group-label'>{t('管理员')}</div>
|
||||
)}
|
||||
{adminItems.map((item) => renderNavItem(item))}
|
||||
</div>
|
||||
</>
|
||||
{isAdmin() &&
|
||||
renderGroup(
|
||||
'admin-group',
|
||||
t('管理员'),
|
||||
adminItems.map(renderNavItem),
|
||||
)}
|
||||
</Nav>
|
||||
</SkeletonWrapper>
|
||||
|
||||
@@ -90,7 +90,7 @@ const UserArea = ({
|
||||
isActionVisible('userSettings') &&
|
||||
isTopNavModuleVisible('userCenter') &&
|
||||
isSidebarModuleVisible('userCenter', 'settings');
|
||||
// 「秘钥管理快捷入口」由 rightActions.keyManagement 单独控制(运营设置→顶栏管理)。
|
||||
// 「密钥管理快捷入口」由 rightActions.keyManagement 单独控制(运营设置→顶栏管理)。
|
||||
// 个人用户的 /user-center/key-management 路由不依赖顶栏模块是否显示,故顶栏导航隐藏该模块时
|
||||
// 头像菜单仍保留入口;企业员工只有在其顶栏模块放开时路由才被放行,继续联动判断。
|
||||
const showKeyManagement =
|
||||
|
||||
@@ -195,7 +195,7 @@ const SSEViewer = ({ sseData }) => {
|
||||
)}
|
||||
{item.parsed.usage && (
|
||||
<Badge
|
||||
count={`${t('令牌')}: ${item.parsed.usage.prompt_tokens || 0}/${item.parsed.usage.completion_tokens || 0}`}
|
||||
count={`${t('密钥')}: ${item.parsed.usage.prompt_tokens || 0}/${item.parsed.usage.completion_tokens || 0}`}
|
||||
type='tertiary'
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -175,7 +175,7 @@ const QualityBreakdown = ({ quality, t }) => {
|
||||
if (dim === 'error')
|
||||
return row.key !== 'service_error' && (row.key || row.key2);
|
||||
if (row.key === '' || row.key === '__unknown__') return false;
|
||||
// 渠道 / 企业 / 用户 / 令牌的 0 表示"无",筛选参数里 0 等于不过滤
|
||||
// 渠道 / 企业 / 用户 / 密钥的 0 表示"无",筛选参数里 0 等于不过滤
|
||||
if (['channel', 'org', 'user', 'token'].includes(dim) && row.key === '0')
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -343,7 +343,7 @@ const QualityDetail = ({ quality, t }) => {
|
||||
)}
|
||||
{row.token_name && (
|
||||
<span>
|
||||
{t('令牌')}: {row.token_name}
|
||||
{t('密钥')}: {row.token_name}
|
||||
</span>
|
||||
)}
|
||||
{!isOrg && row.group && (
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
const splitList = (v) => (v ? String(v).split(',').filter(Boolean) : []);
|
||||
|
||||
/**
|
||||
* 远程搜索下拉(企业 / 用户 / 令牌)。选中项的名称缓存在本地,
|
||||
* 远程搜索下拉(企业 / 用户 / 密钥)。选中项的名称缓存在本地,
|
||||
* 即使结果列表被新的搜索替换,已选值仍能显示名称而非裸 ID。
|
||||
*/
|
||||
const RemoteSelect = ({
|
||||
@@ -88,7 +88,7 @@ const RemoteSelect = ({
|
||||
[quality.get, type, extraKey],
|
||||
);
|
||||
|
||||
// 联动条件(如令牌随用户)变化后清空候选,下次展开时按新条件重新搜索
|
||||
// 联动条件(如密钥随用户)变化后清空候选,下次展开时按新条件重新搜索
|
||||
useEffect(() => {
|
||||
seq.current += 1;
|
||||
setList([]);
|
||||
@@ -193,7 +193,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
if (filters.token_id)
|
||||
push(
|
||||
'token_id',
|
||||
`${t('令牌')}: ${nameOf(options.tokens, filters.token_id) || '#' + filters.token_id}`,
|
||||
`${t('密钥')}: ${nameOf(options.tokens, filters.token_id) || '#' + filters.token_id}`,
|
||||
);
|
||||
if (filters.path) push('path', `${t('接口')}: ${filters.path}`);
|
||||
if (filters.error_code)
|
||||
@@ -415,7 +415,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
extra={
|
||||
filters.user_id ? { user_id: filters.user_id } : undefined
|
||||
}
|
||||
placeholder={t('全部令牌(输入名称搜索)')}
|
||||
placeholder={t('全部密钥(输入名称搜索)')}
|
||||
onChange={(v) => setFilters({ token_id: v })}
|
||||
/>
|
||||
)}
|
||||
@@ -425,7 +425,7 @@ const QualityFilterBar = ({ quality, t, onOpenDetail }) => {
|
||||
quality={quality}
|
||||
type='token'
|
||||
value={filters.token_id}
|
||||
placeholder={t('全部令牌(输入名称搜索)')}
|
||||
placeholder={t('全部密钥(输入名称搜索)')}
|
||||
onChange={(v) => setFilters({ token_id: v })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -102,7 +102,7 @@ export const QualityMetaNotice = ({ meta, scope, t }) => {
|
||||
if (meta.detail_available === false) {
|
||||
notes.push({
|
||||
tone: 'warn',
|
||||
text: t('日志表尚未完成质量字段升级,明细与按用户 / 令牌分析暂不可用'),
|
||||
text: t('日志表尚未完成质量字段升级,明细与按用户 / 密钥分析暂不可用'),
|
||||
});
|
||||
}
|
||||
if (notes.length === 0) return null;
|
||||
|
||||
@@ -61,7 +61,7 @@ export const PLATFORM_DIMS = [
|
||||
{ value: 'error', label: '错误码', filterKey: 'error_code' },
|
||||
{ value: 'path', label: '接口', filterKey: 'path' },
|
||||
{ value: 'user', label: '用户', filterKey: 'user_id' },
|
||||
{ value: 'token', label: '令牌', filterKey: 'token_id' },
|
||||
{ value: 'token', label: '密钥', filterKey: 'token_id' },
|
||||
];
|
||||
|
||||
export const ORG_DIMS = [
|
||||
@@ -69,7 +69,7 @@ export const ORG_DIMS = [
|
||||
{ value: 'dept', label: '部门', filterKey: 'dept_id' },
|
||||
{ value: 'project', label: '项目', filterKey: 'project_id' },
|
||||
{ value: 'user', label: '成员', filterKey: 'user_id' },
|
||||
{ value: 'token', label: '令牌', filterKey: 'token_id' },
|
||||
{ value: 'token', label: '密钥', filterKey: 'token_id' },
|
||||
{ value: 'error', label: '错误码', filterKey: 'error_code' },
|
||||
];
|
||||
|
||||
@@ -100,7 +100,7 @@ export const ALERT_DIM_TYPES = [
|
||||
export const QUALITY_ERROR_TEXT = {
|
||||
window_invalid: '时间范围无效,请重新选择',
|
||||
window_too_wide:
|
||||
'按用户 / 令牌或交叉条件筛选时,时间范围最长 7 天,请缩小范围',
|
||||
'按用户 / 密钥或交叉条件筛选时,时间范围最长 7 天,请缩小范围',
|
||||
detail_window_too_wide: '明细查询时间范围最长 31 天,请缩小范围',
|
||||
invalid_dimension: '不支持的分析维度',
|
||||
unsupported_dimension: '当前筛选条件下不支持该维度',
|
||||
@@ -113,7 +113,7 @@ export const QUALITY_ERROR_TEXT = {
|
||||
invalid_path: '接口参数过长',
|
||||
invalid_error_code: '错误码参数过长',
|
||||
org_required: '缺少企业上下文,请重新进入企业中心',
|
||||
token_not_in_org: '该令牌不属于本企业',
|
||||
token_not_in_org: '该密钥不属于本企业',
|
||||
invalid_keyword: '搜索关键词过长',
|
||||
invalid_type: '搜索类型无效',
|
||||
request_trace_params_required: '缺少请求 ID,无法查看链路',
|
||||
@@ -135,8 +135,8 @@ export const QUALITY_ERROR_TEXT = {
|
||||
};
|
||||
|
||||
export const DEGRADE_TEXT = {
|
||||
user_or_token_filter: '按用户 / 令牌筛选,已改为直接统计调用日志',
|
||||
user_or_token_dimension: '按用户 / 令牌维度分析,已改为直接统计调用日志',
|
||||
user_or_token_filter: '按用户 / 密钥筛选,已改为直接统计调用日志',
|
||||
user_or_token_dimension: '按用户 / 密钥维度分析,已改为直接统计调用日志',
|
||||
cross_dimension: '当前筛选组合超出预聚合范围,已改为直接统计调用日志',
|
||||
path_ignored: '直查日志时不支持按接口筛选,接口条件未生效',
|
||||
heatmap_requires_single_dimension:
|
||||
|
||||
@@ -71,7 +71,7 @@ const ChatsSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 聊天设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsChats options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -423,6 +423,7 @@ const CustomerServiceSetting = () => {
|
||||
|
||||
{/* 新建/编辑弹窗 */}
|
||||
<Modal
|
||||
rootClassName='settings-form-dialog'
|
||||
title={editingAgent ? t('编辑客服') : t('添加客服')}
|
||||
visible={modalVisible}
|
||||
onOk={handleSubmit}
|
||||
|
||||
@@ -146,27 +146,27 @@ const DashboardSetting = () => {
|
||||
</Modal>
|
||||
|
||||
{/* 数据看板设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsDataDashboard options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* 系统公告管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsAnnouncements options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* API信息管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsAPIInfo options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* 常见问答管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsFAQ options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
|
||||
{/* Uptime Kuma 监控设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsUptimeKuma options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -73,7 +73,7 @@ const DrawingSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 绘图设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsDrawing options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -113,7 +113,7 @@ const GroupModelDiscountEditor = ({
|
||||
maxTagCount={3}
|
||||
showClear
|
||||
size='small'
|
||||
style={{ minWidth: 320 }}
|
||||
style={{ width: 320, maxWidth: '100%' }}
|
||||
placeholder={t('搜索并选择模型(可多选)')}
|
||||
optionList={selectableModels.map((m) => ({ label: m, value: m }))}
|
||||
value={pendingModels}
|
||||
@@ -954,7 +954,7 @@ const LevelPolicySetting = () => {
|
||||
content={
|
||||
<div style={{ maxWidth: 360 }}>
|
||||
{t(
|
||||
'该等级用户在市场页与令牌创建中看不到这些分组,也无法显式选用',
|
||||
'该等级用户在市场页与密钥创建中看不到这些分组,也无法显式选用',
|
||||
)}
|
||||
{rest > 0 && (
|
||||
<div style={{ marginTop: 4 }}>
|
||||
@@ -1374,7 +1374,7 @@ const LevelPolicySetting = () => {
|
||||
searchPosition='dropdown'
|
||||
maxTagCount={3}
|
||||
showClear
|
||||
style={{ minWidth: 340, flex: 1 }}
|
||||
style={{ minWidth: 0, flex: '1 1 340px' }}
|
||||
placeholder={t('搜索并选择模型(可多选)')}
|
||||
value={overrideModels}
|
||||
onChange={setOverrideModels}
|
||||
@@ -1491,7 +1491,7 @@ const LevelPolicySetting = () => {
|
||||
'折扣系数 <=1 表示打折,在分组倍率基础上相乘,对该个人等级用户计费生效;留空表示该分组不打折。',
|
||||
)}{' '}
|
||||
{t(
|
||||
'「隐藏」开启后:该等级用户在市场页、令牌创建下拉中看不到该分组,显式选用的令牌在调用时会被拒绝(403);auto 路由也会绕开。例外:分组等于用户自身分组(企业为作用域默认分组)的令牌不受影响,避免误配切断存量流量(用户分组事后迁移则豁免随之失效)。',
|
||||
'「隐藏」开启后:该等级用户在市场页、密钥创建下拉中看不到该分组,显式选用的密钥在调用时会被拒绝(403);auto 路由也会绕开。例外:分组等于用户自身分组(企业为作用域默认分组)的密钥不受影响,避免误配切断存量流量(用户分组事后迁移则豁免随之失效)。',
|
||||
)}{' '}
|
||||
{t(
|
||||
'点击「模型折扣」列可展开分组行,为指定模型单独设置折扣系数——命中的模型直接按覆盖系数计费(替换分组折扣,不叠乘)。',
|
||||
|
||||
@@ -106,27 +106,27 @@ const ModelSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 模型分类管理 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingModelCategory />
|
||||
</Card>
|
||||
{/* OpenAI */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingGlobalModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Gemini */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingGeminiModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Claude */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingClaudeModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Image pricing */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingImagePricing options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* Video */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingVideoModel options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -61,14 +61,13 @@ const NotifyChannelForm = ({
|
||||
const patch = (fields) => onChange?.({ ...v, ...fields });
|
||||
|
||||
const Label = ({ children }) => (
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5'>
|
||||
{children}
|
||||
</label>
|
||||
<label className='oc-notify-label'>{children}</label>
|
||||
);
|
||||
|
||||
// 原型:渠道下拉(≤360px)+ 浅底详情框承载各渠道字段(竖排标签)
|
||||
return (
|
||||
<div className='space-y-4'>
|
||||
<div className='max-w-xs'>
|
||||
<div className='oc-notify-form'>
|
||||
<div className='oc-notify-field oc-notify-channel'>
|
||||
<Label>{t('通知渠道')}</Label>
|
||||
<Select
|
||||
value={type}
|
||||
@@ -84,8 +83,9 @@ const NotifyChannelForm = ({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='oc-notify-details'>
|
||||
{type === 'email' && (
|
||||
<div className='max-w-md'>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('通知邮箱')}</Label>
|
||||
<Input
|
||||
value={v.notification_email || ''}
|
||||
@@ -97,8 +97,8 @@ const NotifyChannelForm = ({
|
||||
)}
|
||||
|
||||
{type === 'webhook' && (
|
||||
<div className='max-w-md space-y-3'>
|
||||
<div>
|
||||
<>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Webhook 地址')}</Label>
|
||||
<Input
|
||||
value={v.webhook_url || ''}
|
||||
@@ -107,7 +107,7 @@ const NotifyChannelForm = ({
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('接口凭证')}</Label>
|
||||
<Input
|
||||
value={v.webhook_secret || ''}
|
||||
@@ -116,11 +116,11 @@ const NotifyChannelForm = ({
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{type === 'bark' && (
|
||||
<div className='max-w-md'>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Bark 推送地址')}</Label>
|
||||
<Input
|
||||
value={v.bark_url || ''}
|
||||
@@ -132,8 +132,8 @@ const NotifyChannelForm = ({
|
||||
)}
|
||||
|
||||
{type === 'gotify' && (
|
||||
<div className='max-w-md space-y-3'>
|
||||
<div>
|
||||
<>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Gotify 服务器地址')}</Label>
|
||||
<Input
|
||||
value={v.gotify_url || ''}
|
||||
@@ -142,15 +142,15 @@ const NotifyChannelForm = ({
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>{t('Gotify 应用令牌')}</Label>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('Gotify 应用密钥')}</Label>
|
||||
<Input
|
||||
value={v.gotify_token || ''}
|
||||
onChange={(val) => patch({ gotify_token: val })}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='oc-notify-field'>
|
||||
<Label>{t('消息优先级')}</Label>
|
||||
<InputNumber
|
||||
value={v.gotify_priority ?? 0}
|
||||
@@ -161,9 +161,10 @@ const NotifyChannelForm = ({
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -230,59 +230,59 @@ const OperationSetting = () => {
|
||||
{errorBanner}
|
||||
<ProgressiveSettingsSections loading={loading}>
|
||||
{/* 通用设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsGeneral options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 语言与地区 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsLanguage options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 主题色配置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsTheme options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 顶栏模块管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsHeaderNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 企业员工顶栏管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsOrgUserNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 左侧边栏模块管理(管理员) */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsSidebarModulesAdmin options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 屏蔽词过滤设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsSensitiveWords options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 日志设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsLog options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 监控设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsMonitoring options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 兜底渠道设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsFallback options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 技能注入(网关直连)设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsSkillInject options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 服务大盘监控设置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsDashboardMonitor />
|
||||
</div>
|
||||
{/* 额度设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsCreditLimit options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 跑马灯设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsMarquee options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 体验中心设置 */}
|
||||
|
||||
@@ -270,28 +270,28 @@ const PaymentSetting = () => {
|
||||
return (
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsGeneralPayment options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGateway options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayStripe options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayPayPal options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentGatewayCreem options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentWechat options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsPaymentAlipay options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<SettingsNuonuoInvoice options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -78,7 +78,7 @@ const RateLimitSetting = () => {
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* AI请求速率限制 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<RequestRateLimit options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
</Spin>
|
||||
|
||||
@@ -98,7 +98,7 @@ const RatioSetting = () => {
|
||||
return (
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 模型倍率设置以及可视化编辑器 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<Card className='settings-section'>
|
||||
<Tabs type='card'>
|
||||
<Tabs.TabPane tab={t('模型倍率设置')} itemKey='model'>
|
||||
<ModelRatioSettings options={inputs} refresh={onRefresh} />
|
||||
|
||||
@@ -1875,7 +1875,7 @@ const SystemSetting = () => {
|
||||
)}
|
||||
{/* WeyAi 账号接入配置:仅超级管理员可见(后端同样按 root-only 校验) */}
|
||||
{isLoaded && isRoot() && (
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<div className='settings-section'>
|
||||
<SettingsWeyAi />
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -473,7 +473,7 @@ const AccountManagement = ({
|
||||
<div className='py-4'>
|
||||
<div className='space-y-6'>
|
||||
<Space vertical className='w-full'>
|
||||
{/* 系统访问令牌 */}
|
||||
{/* 系统访问密钥 */}
|
||||
<Card className='!rounded-xl w-full'>
|
||||
<div className='flex flex-col sm:flex-row items-start sm:justify-between gap-4'>
|
||||
<div className='flex items-start w-full sm:w-auto'>
|
||||
@@ -482,10 +482,10 @@ const AccountManagement = ({
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<Typography.Title heading={6} className='mb-1'>
|
||||
{t('系统访问令牌')}
|
||||
{t('系统访问密钥')}
|
||||
</Typography.Title>
|
||||
<Typography.Text type='tertiary' className='text-sm'>
|
||||
{t('用于API调用的身份验证令牌,请妥善保管')}
|
||||
{t('用于API调用的身份验证密钥,请妥善保管')}
|
||||
</Typography.Text>
|
||||
{systemToken && (
|
||||
<div className='mt-3'>
|
||||
@@ -508,7 +508,7 @@ const AccountManagement = ({
|
||||
className='!bg-slate-600 hover:!bg-slate-700 w-full sm:w-auto'
|
||||
icon={<IconKey />}
|
||||
>
|
||||
{systemToken ? t('重新生成') : t('生成令牌')}
|
||||
{systemToken ? t('重新生成') : t('生成密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -240,7 +240,7 @@ const NotificationSettings = ({
|
||||
description: t('数据管理和日志查看'),
|
||||
modules: [
|
||||
{ key: 'detail', title: t('数据看板'), description: t('系统数据统计') },
|
||||
{ key: 'token', title: t('令牌管理'), description: t('API令牌管理') },
|
||||
{ key: 'token', title: t('密钥管理'), description: t('API密钥管理') },
|
||||
{ key: 'log', title: t('使用日志'), description: t('API使用记录') },
|
||||
{
|
||||
key: 'midjourney',
|
||||
@@ -628,19 +628,19 @@ const NotificationSettings = ({
|
||||
|
||||
<Form.Input
|
||||
field='gotifyToken'
|
||||
label={t('Gotify应用令牌')}
|
||||
placeholder={t('请输入Gotify应用令牌')}
|
||||
label={t('Gotify应用密钥')}
|
||||
placeholder={t('请输入Gotify应用密钥')}
|
||||
onChange={(val) => handleFormChange('gotifyToken', val)}
|
||||
prefix={<IconKey />}
|
||||
extraText={t(
|
||||
'在Gotify服务器创建应用后获得的令牌,用于发送通知',
|
||||
'在Gotify服务器创建应用后获得的密钥,用于发送通知',
|
||||
)}
|
||||
showClear
|
||||
rules={[
|
||||
{
|
||||
required:
|
||||
notificationSettings.warningType === 'gotify',
|
||||
message: t('请输入Gotify应用令牌'),
|
||||
message: t('请输入Gotify应用密钥'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
@@ -675,7 +675,7 @@ const NotificationSettings = ({
|
||||
<div>
|
||||
2.{' '}
|
||||
{t(
|
||||
'复制应用的令牌(Token)并填写到上方的应用令牌字段',
|
||||
'复制应用的密钥(Token)并填写到上方的应用密钥字段',
|
||||
)}
|
||||
</div>
|
||||
<div>3. {t('填写Gotify服务器的完整URL地址')}</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Input as AntInput, Segmented } from 'antd';
|
||||
import { Segmented } from 'antd';
|
||||
import { Button, Input } from '@/components/ui';
|
||||
import { Check } from 'lucide-react';
|
||||
import {
|
||||
@@ -58,9 +58,6 @@ const AvatarSection = ({
|
||||
avatarSettings.avatarType === USER_AVATAR_TYPES.CUSTOM &&
|
||||
!avatarSettings.customAvatarUrl?.trim();
|
||||
|
||||
// 与 getInitialAvatarDataUrl 相同的首字取法,仅用于展示,不进入保存载荷
|
||||
const initialText = username ? username[0].toUpperCase() : '';
|
||||
|
||||
return (
|
||||
<section className='ui-avatar-section'>
|
||||
<SectionHeader
|
||||
@@ -135,13 +132,6 @@ const AvatarSection = ({
|
||||
)}
|
||||
{avatarSettings.avatarType === USER_AVATAR_TYPES.INITIAL && (
|
||||
<div className='ui-avatar-field'>
|
||||
<div className='ui-avatar-field-label'>{t('显示文字')}</div>
|
||||
<AntInput
|
||||
readOnly
|
||||
value={initialText}
|
||||
className='ui-avatar-text-input'
|
||||
aria-label={t('显示文字')}
|
||||
/>
|
||||
<p className='ui-avatar-help'>
|
||||
{t('根据用户名自动生成简洁文字头像')}
|
||||
</p>
|
||||
|
||||
@@ -178,7 +178,7 @@ const SidebarSection = ({ t }) => {
|
||||
gradient: 'from-emerald-500 to-teal-500',
|
||||
modules: [
|
||||
{ key: 'detail', title: t('数据看板'), description: t('系统数据统计') },
|
||||
{ key: 'token', title: t('令牌管理'), description: t('API令牌管理') },
|
||||
{ key: 'token', title: t('密钥管理'), description: t('API密钥管理') },
|
||||
{ key: 'log', title: t('使用日志'), description: t('API使用记录') },
|
||||
{
|
||||
key: 'midjourney',
|
||||
|
||||
@@ -207,7 +207,7 @@ export const getAdminTokensColumns = ({
|
||||
render: (text, record) => renderUserCell(text, record, t),
|
||||
},
|
||||
{
|
||||
title: t('秘钥名称'),
|
||||
title: t('密钥名称'),
|
||||
dataIndex: 'name',
|
||||
render: (text) => (
|
||||
<span className='truncate inline-block max-w-[160px]' title={text}>
|
||||
@@ -216,7 +216,7 @@ export const getAdminTokensColumns = ({
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('秘钥'),
|
||||
title: t('密钥'),
|
||||
dataIndex: 'key',
|
||||
render: renderKey,
|
||||
},
|
||||
|
||||
@@ -29,7 +29,7 @@ const AdminTokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='flex items-center gap-2 text-brand'>
|
||||
<IconKey />
|
||||
<Text>{t('秘钥管理')}</Text>
|
||||
<Text>{t('密钥管理')}</Text>
|
||||
<Tag color='orange' shape='circle' size='small'>
|
||||
{t('管理员')}
|
||||
</Tag>
|
||||
|
||||
@@ -61,7 +61,7 @@ const AdminTokensFilters = ({
|
||||
<Form.Input
|
||||
field='keyword'
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('秘钥名称 / Key 片段')}
|
||||
placeholder={t('密钥名称 / Key 片段')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
|
||||
@@ -21,16 +21,16 @@ import React from 'react';
|
||||
import { Modal, Banner } from '@/components/ui';
|
||||
|
||||
const actionMeta = {
|
||||
enable: { title: '批量启用', danger: false, hint: '将选中秘钥批量启用' },
|
||||
enable: { title: '批量启用', danger: false, hint: '将选中密钥批量启用' },
|
||||
disable: {
|
||||
title: '批量禁用',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量禁用,用户将无法使用',
|
||||
hint: '将选中密钥批量禁用,用户将无法使用',
|
||||
},
|
||||
delete: {
|
||||
title: '批量删除',
|
||||
danger: true,
|
||||
hint: '将选中秘钥批量删除,操作不可恢复',
|
||||
hint: '将选中密钥批量删除,操作不可恢复',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ const AdminBatchActionModal = ({
|
||||
okText={t('确认执行')}
|
||||
>
|
||||
<div className='space-y-2'>
|
||||
<div>{t('共选中 {{count}} 个秘钥', { count })}</div>
|
||||
<div>{t('共选中 {{count}} 个密钥', { count })}</div>
|
||||
<Banner
|
||||
type={meta.danger ? 'danger' : 'info'}
|
||||
description={t(meta.hint)}
|
||||
|
||||
@@ -28,7 +28,7 @@ const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('确定要删除此秘钥吗?')}
|
||||
title={t('确定要删除此密钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
@@ -41,14 +41,14 @@ const AdminDeleteTokenModal = ({ visible, onCancel, onConfirm, token, t }) => {
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,删除将影响企业内多用户的使用',
|
||||
'该密钥属于企业 Token,删除将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
<div>{t('删除后将无法恢复,且会立即终止使用此秘钥的所有调用')}</div>
|
||||
<div>{t('删除后将无法恢复,且会立即终止使用此密钥的所有调用')}</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
{t('密钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
|
||||
@@ -35,7 +35,7 @@ const statusMeta = {
|
||||
};
|
||||
|
||||
/**
|
||||
* 管理员编辑秘钥弹窗
|
||||
* 管理员编辑密钥弹窗
|
||||
* 允许修改:name / group / unlimited_quota / remain_quota / expired_time
|
||||
* 不修改:
|
||||
* - status —— 启用/禁用走专用按钮,避免在编辑路径上绕过状态校验
|
||||
@@ -136,7 +136,7 @@ const AdminEditTokenModal = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('编辑秘钥')}
|
||||
title={t('编辑密钥')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
@@ -155,7 +155,7 @@ const AdminEditTokenModal = ({
|
||||
<Text strong>
|
||||
{token.display_name || token.username || '—'}
|
||||
</Text>{' '}
|
||||
(ID: {token.user_id}) {t('的秘钥')}
|
||||
(ID: {token.user_id}) {t('的密钥')}
|
||||
<Tag
|
||||
color={curStatusMeta.color}
|
||||
shape='circle'
|
||||
@@ -172,7 +172,7 @@ const AdminEditTokenModal = ({
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'该秘钥属于企业 Token,修改额度或过期时间将影响企业内多用户的使用',
|
||||
'该密钥属于企业 Token,修改额度或过期时间将影响企业内多用户的使用',
|
||||
)}
|
||||
closeIcon={null}
|
||||
className='!mt-2'
|
||||
@@ -190,10 +190,10 @@ const AdminEditTokenModal = ({
|
||||
>
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('秘钥名称')}
|
||||
placeholder={t('给秘钥起个名字')}
|
||||
label={t('密钥名称')}
|
||||
placeholder={t('给密钥起个名字')}
|
||||
maxLength={30}
|
||||
rules={[{ required: true, message: t('请输入秘钥名称') }]}
|
||||
rules={[{ required: true, message: t('请输入密钥名称') }]}
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
|
||||
@@ -35,7 +35,7 @@ const AdminEnableDisableTokenModal = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={isDisable ? t('确定要禁用此秘钥吗?') : t('确定要启用此秘钥吗?')}
|
||||
title={isDisable ? t('确定要禁用此密钥吗?') : t('确定要启用此密钥吗?')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
@@ -44,11 +44,11 @@ const AdminEnableDisableTokenModal = ({
|
||||
<div className='space-y-1'>
|
||||
<div>
|
||||
{isDisable
|
||||
? t('禁用后用户将无法使用此秘钥调用 API')
|
||||
: t('启用后用户即可重新使用此秘钥')}
|
||||
? t('禁用后用户将无法使用此密钥调用 API')
|
||||
: t('启用后用户即可重新使用此密钥')}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('秘钥名称')}:{token.name || '—'}
|
||||
{t('密钥名称')}:{token.name || '—'}
|
||||
</Text>
|
||||
<br />
|
||||
<Text type='tertiary' size='small'>
|
||||
|
||||
@@ -79,7 +79,7 @@ const PricingGroups = ({
|
||||
|
||||
return (
|
||||
<MarketFilterGroup
|
||||
title={title === undefined ? t('可用令牌分组') : title}
|
||||
title={title === undefined ? t('可用密钥分组') : title}
|
||||
items={items}
|
||||
activeValue={filterGroup}
|
||||
onChange={setFilterGroup}
|
||||
|
||||
@@ -56,6 +56,7 @@ const ModelDetailSideSheet = ({
|
||||
title={t('模型详情')}
|
||||
open={visible}
|
||||
onClose={onClose}
|
||||
maskClosable
|
||||
width={isMobile ? '100%' : 820}
|
||||
rootClassName='mm-detail-drawer mm-theme'
|
||||
rootStyle={themeStyle}
|
||||
|
||||
@@ -39,7 +39,7 @@ const TokensActions = ({
|
||||
// Handle copy selected tokens with options
|
||||
const handleCopySelectedTokens = () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
setShowCopyModal(true);
|
||||
@@ -48,7 +48,7 @@ const TokensActions = ({
|
||||
// Handle delete selected tokens with confirmation
|
||||
const handleDeleteSelectedTokens = () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
setShowDeleteModal(true);
|
||||
@@ -74,7 +74,7 @@ const TokensActions = ({
|
||||
}}
|
||||
size='small'
|
||||
>
|
||||
{t('添加令牌')}
|
||||
{t('添加密钥')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -83,7 +83,7 @@ const TokensActions = ({
|
||||
onClick={handleCopySelectedTokens}
|
||||
size='small'
|
||||
>
|
||||
{t('复制所选令牌')}
|
||||
{t('复制所选密钥')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
@@ -92,7 +92,7 @@ const TokensActions = ({
|
||||
onClick={handleDeleteSelectedTokens}
|
||||
size='small'
|
||||
>
|
||||
{t('删除所选令牌')}
|
||||
{t('删除所选密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ const renderOperations = (
|
||||
size='small'
|
||||
onClick={() => {
|
||||
Modal.confirm({
|
||||
title: t('确定是否要删除此令牌?'),
|
||||
title: t('确定是否要删除此密钥?'),
|
||||
content: t('此修改将不可逆'),
|
||||
onOk: () => {
|
||||
(async () => {
|
||||
|
||||
@@ -29,7 +29,7 @@ const TokensDescription = ({ compactMode, setCompactMode, t }) => {
|
||||
<div className='flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full'>
|
||||
<div className='flex items-center text-blue-500'>
|
||||
<Key size={16} className='mr-2' />
|
||||
<Text>{t('令牌管理')}</Text>
|
||||
<Text>{t('密钥管理')}</Text>
|
||||
</div>
|
||||
|
||||
<CompactModeToggle
|
||||
|
||||
@@ -55,7 +55,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
? (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌/g, labelReplace)
|
||||
? result.replace(/密钥/g, labelReplace)
|
||||
: result;
|
||||
}
|
||||
: originalT;
|
||||
@@ -145,7 +145,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
{key
|
||||
? t('请选择模型。')
|
||||
: t('选择模型后可一键填充当前选中令牌(或本页第一个令牌)。')}
|
||||
: t('选择模型后可一键填充当前选中密钥(或本页第一个密钥)。')}
|
||||
</div>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Select
|
||||
@@ -235,7 +235,7 @@ function TokensPage({ labelReplace } = {}) {
|
||||
? tokens[0]
|
||||
: null;
|
||||
if (!token) {
|
||||
Toast.warning(t('没有可用令牌用于填充'));
|
||||
Toast.warning(t('没有可用密钥用于填充'));
|
||||
return;
|
||||
}
|
||||
apiKeyToUse = 'sk-' + token.key;
|
||||
|
||||
@@ -43,7 +43,7 @@ const CopyTokensModal = ({ visible, onCancel, selectedKeys, copyText, t }) => {
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('复制令牌')}
|
||||
title={t('复制密钥')}
|
||||
icon={null}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
|
||||
@@ -29,14 +29,14 @@ const DeleteTokensModal = ({
|
||||
}) => {
|
||||
return (
|
||||
<Modal
|
||||
title={t('批量删除令牌')}
|
||||
title={t('批量删除密钥')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onConfirm}
|
||||
type='warning'
|
||||
>
|
||||
<div>
|
||||
{t('确定要删除所选的 {{count}} 个令牌吗?', {
|
||||
{t('确定要删除所选的 {{count}} 个密钥吗?', {
|
||||
count: selectedKeys.length,
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -95,9 +95,9 @@ const EditTokenDrawer = ({
|
||||
<Drawer
|
||||
open={open}
|
||||
onClose={onCancel}
|
||||
title={isEdit ? t('编辑令牌') : t('创建令牌')}
|
||||
title={isEdit ? t('编辑密钥') : t('创建密钥')}
|
||||
width={isMobile ? '100%' : 560}
|
||||
maskClosable={false}
|
||||
maskClosable
|
||||
forceRender
|
||||
rootClassName='km-edit-drawer'
|
||||
footer={
|
||||
@@ -108,7 +108,7 @@ const EditTokenDrawer = ({
|
||||
loading={loading}
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
>
|
||||
{isEdit ? t('保存') : t('创建令牌')}
|
||||
{isEdit ? t('保存') : t('创建密钥')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
@@ -126,13 +126,13 @@ const EditTokenDrawer = ({
|
||||
<Form.Input
|
||||
field='name'
|
||||
label={t('名称')}
|
||||
placeholder={t('请输入令牌名称')}
|
||||
placeholder={t('请输入密钥名称')}
|
||||
rules={[{ required: true, message: t('请输入名称') }]}
|
||||
/>
|
||||
{groups.length > 0 ? (
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('令牌分组')}
|
||||
label={t('密钥分组')}
|
||||
placeholder={t('选择分组,默认为用户分组')}
|
||||
optionList={groups}
|
||||
renderOptionItem={renderGroupOption}
|
||||
@@ -142,7 +142,7 @@ const EditTokenDrawer = ({
|
||||
) : (
|
||||
<Form.Select
|
||||
field='group'
|
||||
label={t('令牌分组')}
|
||||
label={t('密钥分组')}
|
||||
placeholder={t('管理员未设置用户可选分组')}
|
||||
disabled
|
||||
style={{ width: '100%' }}
|
||||
|
||||
@@ -60,7 +60,7 @@ const EditTokenModal = (props) => {
|
||||
? (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌/g, props.labelReplace)
|
||||
? result.replace(/密钥/g, props.labelReplace)
|
||||
: result;
|
||||
}
|
||||
: originalT;
|
||||
@@ -365,7 +365,7 @@ const EditTokenModal = (props) => {
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(t('令牌更新成功!'));
|
||||
showSuccess(t('密钥更新成功!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
} else {
|
||||
@@ -393,7 +393,7 @@ const EditTokenModal = (props) => {
|
||||
}
|
||||
}
|
||||
if (successCount > 0) {
|
||||
showSuccess(t('令牌创建成功,请在列表页面点击复制获取令牌!'));
|
||||
showSuccess(t('密钥创建成功,请在列表页面点击复制获取密钥!'));
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
}
|
||||
@@ -464,10 +464,10 @@ const EditTokenModal = (props) => {
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-base font-semibold text-gray-800 dark:text-gray-100'>
|
||||
{isEdit ? t('编辑令牌') : t('创建令牌')}
|
||||
{isEdit ? t('编辑密钥') : t('创建密钥')}
|
||||
</h2>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{isEdit ? t('修改令牌配置') : t('快速创建访问令牌')}
|
||||
{isEdit ? t('修改密钥配置') : t('快速创建访问密钥')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -506,16 +506,16 @@ const EditTokenModal = (props) => {
|
||||
<Form.Input
|
||||
field='name'
|
||||
noLabel
|
||||
placeholder={t('请输入令牌名称')}
|
||||
placeholder={t('请输入密钥名称')}
|
||||
rules={[{ required: true, message: t('请输入名称') }]}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 秘钥分组 */}
|
||||
{/* 密钥分组 */}
|
||||
<div>
|
||||
<FieldLabel icon={Layers} iconColor='text-brand'>
|
||||
{t('令牌分组')}
|
||||
{t('密钥分组')}
|
||||
</FieldLabel>
|
||||
{groups.length > 0 ? (
|
||||
<Form.Select
|
||||
@@ -664,7 +664,7 @@ const EditTokenModal = (props) => {
|
||||
<Form.Switch
|
||||
field='unlimited_quota'
|
||||
label={t('无限额度')}
|
||||
extraText={t('开启后令牌不限制使用额度')}
|
||||
extraText={t('开启后密钥不限制使用额度')}
|
||||
/>
|
||||
|
||||
{!values.unlimited_quota && (
|
||||
@@ -755,7 +755,7 @@ const EditTokenModal = (props) => {
|
||||
icon={<Check size={16} />}
|
||||
loading={loading}
|
||||
>
|
||||
{isEdit ? t('保存修改') : t('创建令牌')}
|
||||
{isEdit ? t('保存修改') : t('创建密钥')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
|
||||
@@ -504,7 +504,7 @@ export const getLogsColumns = ({
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.TOKEN,
|
||||
title: t('令牌'),
|
||||
title: t('密钥'),
|
||||
dataIndex: 'token_name',
|
||||
render: (text, record, index) => {
|
||||
return record.type === 0 || record.type === 2 || record.type === 5 ? (
|
||||
|
||||
@@ -259,7 +259,7 @@ const LogsFilters = ({
|
||||
field='token_name'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Key} />}
|
||||
placeholder={t('令牌名称')}
|
||||
placeholder={t('密钥名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
|
||||
@@ -96,7 +96,7 @@ const FIELD_DEFS = [
|
||||
},
|
||||
{
|
||||
id: 'tokenName',
|
||||
label: '令牌名称',
|
||||
label: '密钥名称',
|
||||
width: 16,
|
||||
value: (r) => r.token_name || '',
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import './payment-confirm.css';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Tag as AntTag } from 'antd';
|
||||
import { Modal, Typography, Skeleton } from '@/components/ui';
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/* 充值确认弹窗(原型未定义):Ant Design 默认弹窗 + 统一规范的语义行列表 */
|
||||
.payment-confirm-rows {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin: 16px 0;
|
||||
padding: 16px 0;
|
||||
border-block: 1px solid var(--border-subtle);
|
||||
}
|
||||
.payment-confirm-rows > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
.payment-confirm-rows dt {
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.payment-confirm-rows dd {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.payment-confirm-amount {
|
||||
color: var(--ui-color-primary);
|
||||
font-size: 20px;
|
||||
}
|
||||
.payment-confirm-discount {
|
||||
color: var(--ui-color-success);
|
||||
}
|
||||
.payment-confirm-method .ant-typography {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.payment-confirm-modal .ant-modal-content {
|
||||
border-radius: 12px;
|
||||
padding: 20px 24px;
|
||||
}
|
||||
.payment-confirm-modal .ant-modal-footer {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.payment-confirm-rows {
|
||||
gap: 12px;
|
||||
margin: 18px 0;
|
||||
padding: 18px 0;
|
||||
}
|
||||
.payment-confirm-rows dt {
|
||||
line-height: 20px;
|
||||
}
|
||||
.payment-confirm-rows dd {
|
||||
font-size: 13px;
|
||||
}
|
||||
.payment-confirm-method {
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
@@ -109,7 +109,17 @@ export const Form = forwardRef(function Form(
|
||||
? 'inline'
|
||||
: 'vertical'
|
||||
}
|
||||
labelCol={labelWidth ? { flex: labelWidth } : undefined}
|
||||
labelCol={
|
||||
props.labelCol ??
|
||||
(labelWidth
|
||||
? {
|
||||
flex: `0 0 ${typeof labelWidth === 'number' ? `${labelWidth}px` : labelWidth}`,
|
||||
}
|
||||
: undefined)
|
||||
}
|
||||
wrapperCol={
|
||||
props.wrapperCol ?? (labelWidth ? { flex: '1 1 0' } : undefined)
|
||||
}
|
||||
labelAlign={labelAlign}
|
||||
onFinish={onSubmit}
|
||||
onFinishFailed={onSubmitFail}
|
||||
|
||||
@@ -20,7 +20,8 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { forwardRef } from 'react';
|
||||
import * as Ant from 'antd';
|
||||
import { controlSize, placement } from './controls';
|
||||
import { paginationEvents } from './pagination';
|
||||
import { paginationEvents, paginationShowTotal } from './pagination';
|
||||
import { overlayMaskClosable } from './overlayPolicy';
|
||||
|
||||
export * from './controls';
|
||||
export { Form, withField } from './form';
|
||||
@@ -124,7 +125,7 @@ export const Space = ({ spacing, vertical, size, ...props }) => (
|
||||
<Ant.Space
|
||||
{...props}
|
||||
direction={vertical ? 'vertical' : 'horizontal'}
|
||||
size={spacing ?? size}
|
||||
size={spacing === 'medium' ? 'middle' : (spacing ?? size)}
|
||||
/>
|
||||
);
|
||||
export const Divider = ({ margin, align, layout, style, ...props }) => (
|
||||
@@ -271,6 +272,7 @@ export function Table({
|
||||
current: pagination.currentPage ?? pagination.current,
|
||||
pageSizeOptions:
|
||||
pagination.pageSizeOpts ?? pagination.pageSizeOptions,
|
||||
showTotal: paginationShowTotal(pagination.showTotal),
|
||||
...paginationEvents(pagination),
|
||||
}
|
||||
: false
|
||||
@@ -301,7 +303,7 @@ export function Pagination({
|
||||
})}
|
||||
pageSizeOptions={pageSizeOpts ?? props.pageSizeOptions}
|
||||
size={size === 'small' ? 'small' : 'default'}
|
||||
showTotal={showTotal === true ? (total) => `${total}` : showTotal}
|
||||
showTotal={paginationShowTotal(showTotal)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -516,6 +518,7 @@ function modalProps({
|
||||
}) {
|
||||
return {
|
||||
...props,
|
||||
maskClosable: overlayMaskClosable(props.maskClosable),
|
||||
open: visible,
|
||||
title: header === null ? null : (props.title ?? header),
|
||||
keyboard: closeOnEsc,
|
||||
@@ -556,6 +559,7 @@ export const SideSheet = ({
|
||||
}) => (
|
||||
<Ant.Drawer
|
||||
{...props}
|
||||
maskClosable={overlayMaskClosable(props.maskClosable)}
|
||||
open={visible}
|
||||
onClose={onCancel}
|
||||
keyboard={closeOnEsc}
|
||||
@@ -681,6 +685,7 @@ export const Dropdown = Object.assign(
|
||||
|
||||
const NavItem = ({ children }) => children;
|
||||
const NavSub = ({ children }) => children;
|
||||
const NavGroup = ({ children }) => children;
|
||||
export const Nav = Object.assign(
|
||||
function Nav({
|
||||
children,
|
||||
@@ -701,6 +706,21 @@ export const Nav = Object.assign(
|
||||
return React.Children.toArray(nodes).flatMap((child, index) => {
|
||||
if (!React.isValidElement(child)) return [];
|
||||
const p = child.props;
|
||||
if (child.type === NavGroup) {
|
||||
const children = items(p.children, `${prefix}${p.itemKey}-`);
|
||||
if (children.length === 0) return [];
|
||||
// Collapsed menus keep their icon tooltips without group headings.
|
||||
if (isCollapsed) return children;
|
||||
return [
|
||||
{
|
||||
type: 'group',
|
||||
key: p.itemKey,
|
||||
label: p.text,
|
||||
className: p.className,
|
||||
children: p.folded ? [] : children,
|
||||
},
|
||||
];
|
||||
}
|
||||
if (child.type === NavItem || child.type === NavSub) {
|
||||
const label = renderWrapper
|
||||
? renderWrapper({ itemElement: <span>{p.text}</span>, props: p })
|
||||
@@ -736,5 +756,5 @@ export const Nav = Object.assign(
|
||||
/>
|
||||
);
|
||||
},
|
||||
{ Item: NavItem, Sub: NavSub },
|
||||
{ Item: NavItem, Sub: NavSub, Group: NavGroup },
|
||||
);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// Shared overlays also serve admin pages; apply the personal-page policy only
|
||||
// when rendering an overlay or opening an imperative confirmation on these routes.
|
||||
export function overlayMaskClosable(
|
||||
configured,
|
||||
pathname = globalThis.window?.location?.pathname ?? '',
|
||||
) {
|
||||
const scoped =
|
||||
pathname === '/market' ||
|
||||
pathname === '/market/' ||
|
||||
pathname === '/skill-market' ||
|
||||
pathname === '/skill-market/' ||
|
||||
pathname === '/user-center' ||
|
||||
pathname.startsWith('/user-center/');
|
||||
return scoped ? true : configured;
|
||||
}
|
||||
@@ -17,6 +17,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// Legacy pagination accepts a boolean; Ant Design calls a renderer when enabled.
|
||||
export const paginationShowTotal = (showTotal) =>
|
||||
showTotal === true ? (total) => `${total}` : showTotal;
|
||||
|
||||
// Preserve the existing callback sequence while Ant Design owns presentation.
|
||||
export function paginationEvents({
|
||||
currentPage,
|
||||
|
||||
@@ -193,7 +193,7 @@ export const CHANNEL_OPTIONS = [
|
||||
},
|
||||
{
|
||||
// Tezign(特赞)视频网关(seedance 2.0);value 对应后端 ChannelTypeTezignVideo=58
|
||||
// 密钥格式:上游 Bearer 令牌(sk-gw-...)
|
||||
// 密钥格式:上游 Bearer 密钥(sk-gw-...)
|
||||
value: 58,
|
||||
color: 'orange',
|
||||
label: 'Tezign 视频',
|
||||
|
||||
@@ -70,7 +70,7 @@ export async function finishLogin({
|
||||
showSuccess(message);
|
||||
}
|
||||
// org_only(仅企业资源)用户默认落企业空间,与 AuthRedirect 一致:默认落地页
|
||||
// (秘钥管理)挂载即调用被 BlockOrgOnlyMode 拦截的 /api/token,会先弹报错再被
|
||||
// (密钥管理)挂载即调用被 BlockOrgOnlyMode 拦截的 /api/token,会先弹报错再被
|
||||
// orgConfined 踢回 /org;企业中心整体关闭时 orgConfined 不生效,会一直停在报错页
|
||||
const defaultRedirect =
|
||||
verifiedUser.org_only_mode === true ? '/org' : undefined;
|
||||
|
||||
@@ -122,7 +122,7 @@ export const useAdminTokensData = () => {
|
||||
);
|
||||
|
||||
// 注意:不能像 users hook 那样用 `list[i].key = list[i].id`,
|
||||
// 因为 Token 的 key 字段本身有意义(脱敏后的秘钥),覆盖会破坏列表展示
|
||||
// 因为 Token 的 key 字段本身有意义(脱敏后的密钥),覆盖会破坏列表展示
|
||||
// 改为在 Table 上用 rowKey='id'
|
||||
const setListFormat = (list) => {
|
||||
setTokens(list);
|
||||
@@ -219,7 +219,7 @@ export const useAdminTokensData = () => {
|
||||
// 批量管理
|
||||
const batchManageTokens = async (ids, action) => {
|
||||
if (!ids || ids.length === 0) {
|
||||
showError(t('请先选择秘钥'));
|
||||
showError(t('请先选择密钥'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -30,7 +30,7 @@ export function useTokenKeys(id) {
|
||||
const loadAllData = async () => {
|
||||
const fetchedKeys = await fetchTokenKeys();
|
||||
if (fetchedKeys.length === 0) {
|
||||
showError('当前没有可用的启用令牌,请确认是否有令牌处于启用状态!');
|
||||
showError('当前没有可用的启用密钥,请确认是否有密钥处于启用状态!');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/console/token';
|
||||
}, 1500); // 延迟 1.5 秒后跳转
|
||||
|
||||
@@ -107,7 +107,7 @@ export const useNavigation = (
|
||||
|
||||
const allLinks = [
|
||||
{
|
||||
text: t('秘钥管理'),
|
||||
text: t('密钥管理'),
|
||||
itemKey: 'keyManagement',
|
||||
to: '/user-center/key-management',
|
||||
requireAuth: getHeaderModuleRequireAuth(modules, 'keyManagement'),
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { API } from '../../helpers';
|
||||
import { parsePayPalQuote } from '../../helpers/paypalPayment';
|
||||
|
||||
// Bind quotes to the exact selection and coalesce preview/confirmation requests.
|
||||
export default function usePayPalQuote(endpoint, body, enabled, orgId) {
|
||||
const key = JSON.stringify([endpoint, body, orgId]);
|
||||
const currentKey = useRef(key);
|
||||
currentKey.current = key;
|
||||
const pending = useRef(null);
|
||||
const [result, setResult] = useState(null);
|
||||
const [loadingKey, setLoadingKey] = useState(null);
|
||||
|
||||
const setQuote = (quote) => setResult({ key, quote });
|
||||
const refresh = useCallback(() => {
|
||||
if (pending.current?.key === key) return pending.current.promise;
|
||||
const [url, payload, organization] = JSON.parse(key);
|
||||
setLoadingKey(key);
|
||||
setResult(null);
|
||||
const promise = API.post(
|
||||
url,
|
||||
payload,
|
||||
organization === undefined || organization === null
|
||||
? undefined
|
||||
: { headers: { 'X-Org-Id': String(organization) } },
|
||||
)
|
||||
.then((response) => {
|
||||
if (!response.data.success) throw new Error(response.data.message);
|
||||
const quote = parsePayPalQuote(response);
|
||||
if (currentKey.current !== key) return null;
|
||||
setResult({ key, quote });
|
||||
return quote;
|
||||
})
|
||||
.finally(() => {
|
||||
if (pending.current?.promise === promise) pending.current = null;
|
||||
setLoadingKey((previous) => (previous === key ? null : previous));
|
||||
});
|
||||
pending.current = { key, promise };
|
||||
return promise;
|
||||
}, [key]);
|
||||
|
||||
useEffect(() => {
|
||||
if (enabled) refresh().catch(() => {});
|
||||
}, [enabled, refresh]);
|
||||
|
||||
return {
|
||||
quote: result?.key === key ? result.quote : null,
|
||||
setQuote,
|
||||
loading: enabled && loadingKey === key,
|
||||
refresh,
|
||||
};
|
||||
}
|
||||
@@ -258,7 +258,7 @@ export const useTokensData = (openFluentNotification) => {
|
||||
// Batch delete tokens
|
||||
const batchDeleteTokens = async () => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请先选择要删除的令牌!'));
|
||||
showError(t('请先选择要删除的密钥!'));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
@@ -267,7 +267,7 @@ export const useTokensData = (openFluentNotification) => {
|
||||
const res = await API.post('/api/token/batch', { ids });
|
||||
if (res?.data?.success) {
|
||||
const count = res.data.data || 0;
|
||||
showSuccess(t('已删除 {{count}} 个令牌!', { count }));
|
||||
showSuccess(t('已删除 {{count}} 个密钥!', { count }));
|
||||
await refresh();
|
||||
setTimeout(() => {
|
||||
if (tokens.length === 0 && activePage > 1) {
|
||||
@@ -287,12 +287,12 @@ export const useTokensData = (openFluentNotification) => {
|
||||
// Batch copy tokens
|
||||
const batchCopyTokens = (copyType) => {
|
||||
if (selectedKeys.length === 0) {
|
||||
showError(t('请至少选择一个令牌!'));
|
||||
showError(t('请至少选择一个密钥!'));
|
||||
return;
|
||||
}
|
||||
|
||||
Modal.info({
|
||||
title: t('复制令牌'),
|
||||
title: t('复制密钥'),
|
||||
icon: null,
|
||||
content: t('请选择你的复制方式'),
|
||||
footer: (
|
||||
|
||||
+212
-182
File diff suppressed because it is too large
Load Diff
+218
-182
File diff suppressed because it is too large
Load Diff
+211
-181
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+227
-192
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+210
-180
File diff suppressed because it is too large
Load Diff
+214
-184
File diff suppressed because it is too large
Load Diff
+209
-179
File diff suppressed because it is too large
Load Diff
+84
-20
@@ -16,8 +16,8 @@
|
||||
/* ==================== 全局基础样式 ==================== */
|
||||
:root {
|
||||
/* Sidebar 宽度变量 */
|
||||
--sidebar-width: 180px;
|
||||
--sidebar-width-collapsed: 60px;
|
||||
--sidebar-width: 216px;
|
||||
--sidebar-width-collapsed: 64px;
|
||||
--sidebar-current-width: var(--sidebar-width);
|
||||
|
||||
/* 统一配色变量 - 亮色模式 */
|
||||
@@ -189,6 +189,51 @@ code {
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
-ms-overflow-style: none;
|
||||
padding: 4px 12px 8px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-group + .ant-menu-item-group {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-group-list {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item,
|
||||
.sidebar-nav .ant-menu-submenu-title {
|
||||
width: 100%;
|
||||
height: 46px;
|
||||
line-height: 46px;
|
||||
margin: 0 0 6px;
|
||||
padding-inline: 12px !important;
|
||||
border-radius: 8px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-icon.sidebar-icon-container {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-right: 0;
|
||||
color: var(--ui-color-text-1);
|
||||
}
|
||||
|
||||
.sidebar-nav .sidebar-icon-container svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.sidebar-nav .ant-menu-item-selected {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar-nav.ant-menu-inline-collapsed {
|
||||
padding-inline: 8px;
|
||||
}
|
||||
|
||||
.sidebar-nav.ant-menu-inline-collapsed .ant-menu-item,
|
||||
.sidebar-nav.ant-menu-inline-collapsed .ant-menu-submenu-title {
|
||||
padding-inline: 9px !important;
|
||||
}
|
||||
|
||||
.sidebar-nav::-webkit-scrollbar {
|
||||
@@ -237,20 +282,44 @@ code {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* 分割线样式 */
|
||||
.sidebar-divider {
|
||||
margin: 4px 8px;
|
||||
opacity: 0.15;
|
||||
/* 分组标签样式 */
|
||||
.sidebar-nav .ant-menu-item-group-title {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* 分组标签样式 */
|
||||
.sidebar-group-label {
|
||||
padding: 4px 15px 8px;
|
||||
.sidebar-group-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
padding: 4px 8px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--ui-color-text-2);
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
line-height: 16px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
opacity: 0.8;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle:hover {
|
||||
background: var(--ui-color-fill-0);
|
||||
color: var(--ui-color-text-1);
|
||||
}
|
||||
|
||||
.sidebar-group-toggle:focus-visible {
|
||||
outline: 2px solid var(--ui-color-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.sidebar-group-toggle svg {
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
/* 底部折叠按钮 */
|
||||
@@ -286,11 +355,6 @@ code {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
/* 侧边栏区域容器 */
|
||||
.sidebar-section {
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
/* ==================== 聊天界面样式 ==================== */
|
||||
|
||||
/* 用户消息气泡样式 - 主题渐变 */
|
||||
@@ -454,7 +518,7 @@ code {
|
||||
|
||||
/* 深色模式下的筛选弹窗 */
|
||||
|
||||
/* ==================== 编辑令牌弹窗 ==================== */
|
||||
/* ==================== 编辑密钥弹窗 ==================== */
|
||||
|
||||
/* ==================== 协议预览弹窗(服务协议/隐私政策) ==================== */
|
||||
|
||||
@@ -1190,9 +1254,9 @@ html.dark .model-select-dropdown {
|
||||
|
||||
/* ==================== 注册/登录表单紧凑样式 ==================== */
|
||||
|
||||
/* ==================== 系统访问令牌 Input 深色模式优化 ==================== */
|
||||
/* ==================== 系统访问密钥 Input 深色模式优化 ==================== */
|
||||
|
||||
/* 深色模式下的系统令牌输入框 */
|
||||
/* 深色模式下的系统密钥输入框 */
|
||||
|
||||
/* 前缀图标颜色 */
|
||||
|
||||
@@ -1307,7 +1371,7 @@ body[theme-mode='dark'] .app-card {
|
||||
* 中性可读正文,圆角与全站统一。
|
||||
* ==================================================================== */
|
||||
/* 表头/单元格精修 —— ⚠️ 同样只作用域到 .app-card 内的表格(与上面透明规则一致)。
|
||||
* 故意不全局:后台数据表(渠道/用户/模型/兑换码/秘钥等)大量自带列渲染与表头样式,
|
||||
* 故意不全局:后台数据表(渠道/用户/模型/兑换码/密钥等)大量自带列渲染与表头样式,
|
||||
* 全局 !important 会盖掉它们的设计意图。仅用户端日志表(已用 .app-card 包裹)吃这套。 */
|
||||
/* 表头:极淡冷调底(跟品牌色 4%)+ 克制细线 + 次级文字色 —— 云控制台轻表头 */
|
||||
/* ⚠️ 例外:固定表头列同样需不透明遮罩 —— 同色相但叠在不透明 surface-card 上
|
||||
|
||||
@@ -33,6 +33,7 @@ import './styles/org.css';
|
||||
import './styles/prototype.css';
|
||||
import './styles/user-center.css';
|
||||
import './styles/org-page.css';
|
||||
import './styles/center-layout.css';
|
||||
import { applyThemeFromCache } from './helpers/theme';
|
||||
import { installChunkReloadHandlers } from './helpers/chunkReload';
|
||||
import ChunkErrorBoundary from './components/common/ChunkErrorBoundary';
|
||||
|
||||
@@ -214,7 +214,7 @@ const gatewayReasonHints = [
|
||||
],
|
||||
[
|
||||
/额度|quota|insufficient[_ ]?(balance|credit|quota)|欠费/i,
|
||||
'账户或令牌额度不足,请充值后重试。',
|
||||
'账户或密钥额度不足,请充值后重试。',
|
||||
],
|
||||
[
|
||||
/rate.?limit|too many requests|429|请求过于频繁/i,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@
|
||||
|
||||
底部功能区:
|
||||
|
||||
- ✅ 秘钥管理(复用令牌管理)
|
||||
- ✅ 密钥管理(复用密钥管理)
|
||||
|
||||
### 3. 功能组件
|
||||
|
||||
@@ -51,7 +51,7 @@ web/src/pages/ExperienceCenter/
|
||||
├── TextModel.jsx # 大模型体验(复用Playground)
|
||||
├── ImageGeneration.jsx # 语音合成(占位)
|
||||
├── VideoGeneration.jsx # 视频生成(占位)
|
||||
└── KeyManagement.jsx # 秘钥管理(复用Token)
|
||||
└── KeyManagement.jsx # 密钥管理(复用Token)
|
||||
```
|
||||
|
||||
## 访问方式
|
||||
|
||||
@@ -181,7 +181,7 @@ const ExperienceCenter = () => {
|
||||
{/* 统一页面背景层 —— 除 text-model 外,ExperienceCenter 是其子页面的唯一背景来源,
|
||||
* 子组件不再各自渲染背景,避免双层叠加。
|
||||
* text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。
|
||||
* 沉浸式生成页(视频/图片)用 rich 大光球,秘钥管理(Token 列表)用 subtle。 */}
|
||||
* 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */}
|
||||
{!isTextModel && (
|
||||
<PageBackground
|
||||
variant={isVideoGeneration || isImageGeneration ? 'rich' : 'subtle'}
|
||||
|
||||
@@ -284,7 +284,7 @@ const Home = () => {
|
||||
},
|
||||
{
|
||||
icon: <Key size={28} className='text-rose-400' />,
|
||||
title: t('令牌管理'),
|
||||
title: t('密钥管理'),
|
||||
desc: t('精细化的 API Key 权限控制与额度限制'),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ const COLUMN_WIDTHS = {
|
||||
// 列设置:只控制本页表格列的显示,不持久化、不改请求。
|
||||
const COLUMN_OPTIONS = [
|
||||
{ value: 'name', label: '名称' },
|
||||
{ value: 'key', label: '令牌' },
|
||||
{ value: 'key', label: '密钥' },
|
||||
{ value: 'group', label: '分组' },
|
||||
{ value: 'status', label: '状态' },
|
||||
{ value: 'expired_time', label: '过期时间' },
|
||||
@@ -117,11 +117,11 @@ const KeyTable = ({
|
||||
key: 'name',
|
||||
dataIndex: 'name',
|
||||
render: (name) => (
|
||||
<span className='km-name'>{name || t('未命名令牌')}</span>
|
||||
<span className='km-name'>{name || t('未命名密钥')}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('令牌'),
|
||||
title: t('密钥'),
|
||||
key: 'key',
|
||||
render: (_, token) => {
|
||||
const shown = !!showKeys[token.id];
|
||||
@@ -130,22 +130,22 @@ const KeyTable = ({
|
||||
<code className='km-key-code'>
|
||||
sk-{shown ? token.key : KEY_MASK}
|
||||
</code>
|
||||
<Tooltip title={shown ? t('隐藏令牌') : t('显示令牌')}>
|
||||
<Tooltip title={shown ? t('隐藏密钥') : t('显示密钥')}>
|
||||
<Button
|
||||
type='text'
|
||||
size='small'
|
||||
aria-label={shown ? t('隐藏令牌') : t('显示令牌')}
|
||||
aria-label={shown ? t('隐藏密钥') : t('显示密钥')}
|
||||
aria-pressed={shown}
|
||||
icon={shown ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||
onClick={() => onToggleShowKey(token.id)}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title={t('复制令牌')}>
|
||||
<Tooltip title={t('复制密钥')}>
|
||||
<Button
|
||||
type='text'
|
||||
size='small'
|
||||
className='km-copy-btn tour-copy-btn'
|
||||
aria-label={t('复制令牌')}
|
||||
aria-label={t('复制密钥')}
|
||||
icon={<Copy size={16} />}
|
||||
onClick={() => onCopy('sk-' + token.key)}
|
||||
/>
|
||||
@@ -346,12 +346,12 @@ const ModelsDrawer = ({ visible, onClose, token, t }) => {
|
||||
const loadModels = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
// 如果秘钥有模型限制,使用限制的模型列表
|
||||
// 如果密钥有模型限制,使用限制的模型列表
|
||||
if (token.model_limits_enabled && token.model_limits) {
|
||||
const limitedModels = token.model_limits.split(',').filter(Boolean);
|
||||
setModels(limitedModels);
|
||||
} else {
|
||||
// 否则获取该秘钥所属分组下的可用模型
|
||||
// 否则获取该密钥所属分组下的可用模型
|
||||
const groupValue = token.group || token.groups;
|
||||
// 如果分组为 auto 或空,获取用户所有分组的模型
|
||||
const apiUrl =
|
||||
@@ -401,16 +401,17 @@ const ModelsDrawer = ({ visible, onClose, token, t }) => {
|
||||
title={t('可用模型列表')}
|
||||
open={visible}
|
||||
onClose={onClose}
|
||||
maskClosable
|
||||
placement='right'
|
||||
width={440}
|
||||
rootClassName='km-models-drawer'
|
||||
>
|
||||
<dl className='km-models-info'>
|
||||
<dt>{t('令牌名称')}</dt>
|
||||
<dd>{token?.name || t('未命名令牌')}</dd>
|
||||
<dt>{t('密钥名称')}</dt>
|
||||
<dd>{token?.name || t('未命名密钥')}</dd>
|
||||
{token?.group ? (
|
||||
<>
|
||||
<dt>{t('令牌分组')}</dt>
|
||||
<dt>{t('密钥分组')}</dt>
|
||||
<dd>{token.group === 'auto' ? t('智能熔断') : token.group}</dd>
|
||||
</>
|
||||
) : null}
|
||||
@@ -501,11 +502,11 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
t: originalT,
|
||||
} = tokensData;
|
||||
|
||||
// 设计图统一称“密钥”:沿用原 令牌 文案键,仅替换显示词。
|
||||
// 设计图统一称“密钥”:沿用原 密钥 文案键,仅替换显示词。
|
||||
const t = (key, options) => {
|
||||
const result = originalT(key, options);
|
||||
return typeof result === 'string'
|
||||
? result.replace(/令牌|秘钥/g, '密钥')
|
||||
? result.replace(/密钥|密钥/g, '密钥')
|
||||
: result;
|
||||
};
|
||||
|
||||
@@ -525,23 +526,23 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
userState?.user?.group,
|
||||
);
|
||||
|
||||
// 判断是否有秘钥
|
||||
// 判断是否有密钥
|
||||
const hasKeys = tokens.length > 0;
|
||||
|
||||
// 新手引导步骤 - 根据是否有秘钥动态调整
|
||||
// 新手引导步骤 - 根据是否有密钥动态调整
|
||||
const tourSteps = hasKeys
|
||||
? [
|
||||
// 有秘钥时:完整引导
|
||||
// 有密钥时:完整引导
|
||||
{
|
||||
target: '.tour-create-btn',
|
||||
content: (
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>✨</span>
|
||||
<span className='font-semibold'>{t('创建秘钥')}</span>
|
||||
<span className='font-semibold'>{t('创建密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击这里创建新秘钥,设置名称和使用额度')}
|
||||
{t('点击这里创建新密钥,设置名称和使用额度')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -555,13 +556,13 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>📋</span>
|
||||
<span className='font-semibold'>{t('秘钥卡片')}</span>
|
||||
<span className='font-semibold'>{t('密钥卡片')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('每张卡片展示秘钥的状态、名称和剩余额度')}
|
||||
{t('每张卡片展示密钥的状态、名称和剩余额度')}
|
||||
</div>
|
||||
<div className='mt-2 text-xs text-gray-400'>
|
||||
💡 {t('绿色状态点表示秘钥已启用')}
|
||||
💡 {t('绿色状态点表示密钥已启用')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -573,10 +574,10 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>📋</span>
|
||||
<span className='font-semibold'>{t('复制秘钥')}</span>
|
||||
<span className='font-semibold'>{t('复制密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击复制完整秘钥(sk-xxx 格式)')}
|
||||
{t('点击复制完整密钥(sk-xxx 格式)')}
|
||||
</div>
|
||||
<div className='mt-2 p-2 bg-gray-100 dark:bg-neutral-800 rounded text-xs font-mono'>
|
||||
sk-xxxxxxxxxxxxxxxx
|
||||
@@ -592,10 +593,10 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div>
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>⚙️</span>
|
||||
<span className='font-semibold'>{t('管理秘钥')}</span>
|
||||
<span className='font-semibold'>{t('管理密钥')}</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('编辑秘钥名称、额度、过期时间等设置')}
|
||||
{t('编辑密钥名称、额度、过期时间等设置')}
|
||||
</div>
|
||||
<div className='mt-3 text-xs text-gray-400'>
|
||||
💡 {t('点击右上角问号可随时重新查看引导')}
|
||||
@@ -607,7 +608,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
},
|
||||
]
|
||||
: [
|
||||
// 没有秘钥时:简化引导,只显示创建按钮
|
||||
// 没有密钥时:简化引导,只显示创建按钮
|
||||
{
|
||||
target: '.tour-create-btn',
|
||||
content: (
|
||||
@@ -615,14 +616,14 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='flex items-center gap-2 mb-2'>
|
||||
<span className='text-lg'>🚀</span>
|
||||
<span className='font-semibold'>
|
||||
{t('开始创建您的第一个秘钥')}
|
||||
{t('开始创建您的第一个密钥')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('点击这里创建秘钥,创建后可用于调用 API 服务')}
|
||||
{t('点击这里创建密钥,创建后可用于调用 API 服务')}
|
||||
</div>
|
||||
<div className='mt-3 p-2 bg-brand/5 dark:bg-brand-deep/20 rounded-lg text-xs text-brand-deep dark:text-brand-from'>
|
||||
💡 {t('创建秘钥后,可再次点击右上角问号查看完整操作指引')}
|
||||
💡 {t('创建密钥后,可再次点击右上角问号查看完整操作指引')}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -668,7 +669,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
const action = token.status === 1 ? 'disable' : 'enable';
|
||||
Modal.confirm({
|
||||
title: t(
|
||||
action === 'disable' ? '确定要禁用此秘钥吗?' : '确定要启用此秘钥吗?',
|
||||
action === 'disable' ? '确定要禁用此密钥吗?' : '确定要启用此密钥吗?',
|
||||
),
|
||||
onOk: () => manageToken(token.id, action, token),
|
||||
});
|
||||
@@ -676,7 +677,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
|
||||
const handleDelete = (token) => {
|
||||
Modal.confirm({
|
||||
title: t('确定要删除此秘钥吗?'),
|
||||
title: t('确定要删除此密钥吗?'),
|
||||
content: t('删除后将无法恢复'),
|
||||
okType: 'danger',
|
||||
onOk: async () => {
|
||||
@@ -744,6 +745,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
showCloseButton
|
||||
hideBackButton={false}
|
||||
disableCloseOnEsc={false}
|
||||
disableScrollParentFix
|
||||
disableOverlayClose={false}
|
||||
scrollToFirstStep
|
||||
scrollOffset={100}
|
||||
@@ -848,7 +850,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='km-content uc-page relative'>
|
||||
<UserCenterPageHeader
|
||||
title={t('密钥管理')}
|
||||
subtitle={t('管理模型调用的访问令牌')}
|
||||
subtitle={t('管理模型调用的访问密钥')}
|
||||
extra={
|
||||
<>
|
||||
{tutorialButtonVisible ? (
|
||||
@@ -877,13 +879,13 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
<div className='km-panels'>
|
||||
<Card className='km-card km-search-card tour-search-input'>
|
||||
<label className='km-search-label' htmlFor='km-search-input'>
|
||||
{t('令牌查询')}
|
||||
{t('密钥查询')}
|
||||
</label>
|
||||
<div className='km-search-row'>
|
||||
<Input
|
||||
id='km-search-input'
|
||||
className='km-search-input'
|
||||
placeholder={t('搜索令牌名称、Key 或分组')}
|
||||
placeholder={t('搜索密钥名称、Key 或分组')}
|
||||
value={searchValue}
|
||||
onChange={(event) => setSearchValue(event.target.value)}
|
||||
onPressEnter={() => setSearchValue(searchValue)}
|
||||
@@ -902,14 +904,14 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
|
||||
<Card className='km-card km-list-card'>
|
||||
<div className='km-list-head'>
|
||||
<h2>{t('令牌列表')}</h2>
|
||||
<h2>{t('密钥列表')}</h2>
|
||||
<div className='km-list-actions'>
|
||||
<Button
|
||||
type='link'
|
||||
className='km-contact-link'
|
||||
onClick={openCustomerService}
|
||||
>
|
||||
{t('创建令牌后不知道怎么用?联系客服')}
|
||||
{t('创建密钥后不知道怎么用?联系客服')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
@@ -917,7 +919,7 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
className='tour-create-btn'
|
||||
onClick={handleCreate}
|
||||
>
|
||||
{t('创建令牌')}
|
||||
{t('创建密钥')}
|
||||
</Button>
|
||||
<Popover
|
||||
trigger='click'
|
||||
@@ -944,8 +946,8 @@ const KeyManagement = ({ embedded = false }) => {
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
searchValue
|
||||
? t('未找到匹配的令牌')
|
||||
: t('暂无令牌,点击上方按钮创建')
|
||||
? t('未找到匹配的密钥')
|
||||
: t('暂无密钥,点击上方按钮创建')
|
||||
}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ html.dark .km-page {
|
||||
.km-panels {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
gap: var(--uc-layout-gap);
|
||||
}
|
||||
|
||||
/* 卡片:查询卡为 Ant Design 默认描边;列表卡描边 #e6e9ef + 极浅投影(设计图可见),圆角 10px,内边距 24px */
|
||||
|
||||
+117
-101
@@ -20,20 +20,13 @@ import React, { useEffect, useState } from 'react';
|
||||
import { getQuotaPerUnit } from '../../helpers';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RefreshCw, ScrollText } from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
Select,
|
||||
Button,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Tabs,
|
||||
TabPane,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, ScrollText, Search } from 'lucide-react';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import { Table, Select, Button, Tag, Tooltip } from '@/components/ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { useOrgAuditLogs } from '../../hooks/org/useOrgData';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import OrgPromptRecords from './OrgPromptRecords';
|
||||
import {
|
||||
@@ -62,14 +55,14 @@ const memberStatusMap = {
|
||||
};
|
||||
|
||||
const targetTypeLabels = {
|
||||
token: '令牌',
|
||||
token: '密钥',
|
||||
member: '成员',
|
||||
organization: '企业',
|
||||
invitation: '邀请',
|
||||
};
|
||||
|
||||
const targetTypeColors = {
|
||||
token: 'violet',
|
||||
token: 'purple',
|
||||
member: 'blue',
|
||||
organization: 'green',
|
||||
invitation: 'orange',
|
||||
@@ -95,9 +88,9 @@ const actionConfig = {
|
||||
accept_invitation: { label: '接受邀请', color: 'green' },
|
||||
cancel_invitation: { label: '取消邀请', color: 'grey' },
|
||||
|
||||
create_token: { label: '创建令牌', color: 'green' },
|
||||
update_token: { label: '更新令牌', color: 'blue' },
|
||||
delete_token: { label: '删除令牌', color: 'red' },
|
||||
create_token: { label: '创建密钥', color: 'green' },
|
||||
update_token: { label: '更新密钥', color: 'blue' },
|
||||
delete_token: { label: '删除密钥', color: 'red' },
|
||||
|
||||
admin_create_org: { label: '管理员创建企业', color: 'cyan' },
|
||||
admin_update_org: { label: '管理员更新企业', color: 'cyan' },
|
||||
@@ -134,7 +127,7 @@ const detailKeyLabels = {
|
||||
allow_ips: 'IP白名单',
|
||||
group: '分组',
|
||||
max_members: '最大成员数',
|
||||
max_tokens: '最大令牌数',
|
||||
max_tokens: '最大密钥数',
|
||||
default_member_quota: '新成员默认额度上限',
|
||||
cycle_quota: '周期额度',
|
||||
cycle_quota_delta: '周期额度增量',
|
||||
@@ -289,10 +282,10 @@ const OrgAudit = ({ orgId }) => {
|
||||
{ value: 'update_member_status', label: t('更新状态') },
|
||||
{ value: 'update_member_model_limits', label: t('更新模型限制') },
|
||||
{ value: 'update_member_admin_permissions', label: t('更新管理员权限') },
|
||||
// 令牌操作
|
||||
{ value: 'create_token', label: t('创建令牌') },
|
||||
{ value: 'update_token', label: t('更新令牌') },
|
||||
{ value: 'delete_token', label: t('删除令牌') },
|
||||
// 密钥操作
|
||||
{ value: 'create_token', label: t('创建密钥') },
|
||||
{ value: 'update_token', label: t('更新密钥') },
|
||||
{ value: 'delete_token', label: t('删除密钥') },
|
||||
// 管理员操作
|
||||
{ value: 'admin_create_org', label: t('管理员创建企业') },
|
||||
{ value: 'admin_update_org', label: t('管理员更新企业') },
|
||||
@@ -301,24 +294,21 @@ const OrgAudit = ({ orgId }) => {
|
||||
{ value: 'admin_update_status', label: t('管理员更新状态') },
|
||||
];
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseAudit(130/170/110/500/150,scroll.x 1140);标签为无边框 filled
|
||||
const columns = [
|
||||
{
|
||||
title: t('操作者'),
|
||||
dataIndex: 'operator_name',
|
||||
width: 120,
|
||||
render: (name, record) => (
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{name || `User#${record.operator_id}`}
|
||||
</span>
|
||||
),
|
||||
width: 130,
|
||||
render: (name, record) => name || `User#${record.operator_id}`,
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
title: t('操作类型'),
|
||||
dataIndex: 'action',
|
||||
width: 170,
|
||||
render: (action, record) => {
|
||||
const config = actionConfig[action];
|
||||
if (!config) return <Tag size='small'>{action}</Tag>;
|
||||
if (!config) return <Tag bordered={false}>{action}</Tag>;
|
||||
// 建企业时配的初始额度复用 admin_adjust_quota(供预警取"加额时刻"),
|
||||
// 但它不是二次人工调额,按 detail.source 区分展示
|
||||
let label = config.label;
|
||||
@@ -333,7 +323,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Tag size='small' color={config.color} type='light'>
|
||||
<Tag color={config.color} bordered={false}>
|
||||
{t(label)}
|
||||
</Tag>
|
||||
);
|
||||
@@ -342,9 +332,9 @@ const OrgAudit = ({ orgId }) => {
|
||||
{
|
||||
title: t('目标类型'),
|
||||
dataIndex: 'target_type',
|
||||
width: 90,
|
||||
width: 110,
|
||||
render: (type) => (
|
||||
<Tag size='small' color={targetTypeColors[type] || 'grey'} type='ghost'>
|
||||
<Tag color={targetTypeColors[type] || 'grey'} bordered={false}>
|
||||
{t(targetTypeLabels[type] || type)}
|
||||
</Tag>
|
||||
),
|
||||
@@ -352,49 +342,43 @@ const OrgAudit = ({ orgId }) => {
|
||||
{
|
||||
title: t('详情'),
|
||||
dataIndex: 'detail',
|
||||
width: 500,
|
||||
render: (detail, record) => {
|
||||
if (!detail)
|
||||
return <span className='text-gray-400 dark:text-gray-500'>-</span>;
|
||||
if (!detail) return <span className='oc-muted'>-</span>;
|
||||
let text = detail;
|
||||
try {
|
||||
const obj = JSON.parse(detail);
|
||||
const text = formatDetail(record.action, obj, t, quotaPerUnit);
|
||||
if (text.length > 60) {
|
||||
text = formatDetail(
|
||||
record.action,
|
||||
JSON.parse(detail),
|
||||
t,
|
||||
quotaPerUnit,
|
||||
);
|
||||
} catch {
|
||||
// detail 非 JSON 时原样展示
|
||||
}
|
||||
return (
|
||||
<Tooltip
|
||||
content={text}
|
||||
position='topLeft'
|
||||
style={{ maxWidth: 400 }}
|
||||
>
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400 cursor-default truncate block max-w-xs'>
|
||||
<Tooltip content={text} position='topLeft' style={{ maxWidth: 400 }}>
|
||||
<span className='oc-audit-detail' tabIndex={0}>
|
||||
{text}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
{text}
|
||||
</span>
|
||||
);
|
||||
} catch {
|
||||
return (
|
||||
<span className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
{detail}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: 140,
|
||||
width: 150,
|
||||
render: (v) =>
|
||||
v ? (
|
||||
<Tooltip content={new Date(v * 1000).toLocaleString('zh-CN')}>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
<time
|
||||
className='oc-audit-time'
|
||||
dateTime={new Date(v * 1000).toISOString()}
|
||||
tabIndex={0}
|
||||
>
|
||||
{formatRelativeTime(v, t)}
|
||||
</span>
|
||||
</time>
|
||||
</Tooltip>
|
||||
) : (
|
||||
'-'
|
||||
@@ -402,69 +386,101 @@ const OrgAudit = ({ orgId }) => {
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('审计日志')}
|
||||
subtitle={t('查看企业操作记录')}
|
||||
actions={
|
||||
activeTab === 'operations' ? (
|
||||
const refresh = () => fetch(page, 20, actionFilter);
|
||||
// 选择即筛选(原交互):与原页头 Select 的 onChange 相同
|
||||
const applyAction = (v) => {
|
||||
setActionFilter(v ?? '');
|
||||
setPage(1);
|
||||
};
|
||||
|
||||
const operations = (
|
||||
<>
|
||||
<OrgFilterCard
|
||||
className='oc-audit-filter'
|
||||
actions={
|
||||
<>
|
||||
{/* 重置 = 选择“全部操作”;搜索 = 以当前筛选重新查询(同“刷新”) */}
|
||||
<Button onClick={() => applyAction('')}>{t('重置')}</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => fetch(page, 20, actionFilter)}
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={refresh}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('操作类型')}>
|
||||
<Select
|
||||
value={actionFilter}
|
||||
onChange={applyAction}
|
||||
optionList={actionOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t('全部操作')}
|
||||
filter
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={t('操作记录')}
|
||||
tools={
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={refresh}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Select
|
||||
value={actionFilter}
|
||||
onChange={(v) => {
|
||||
setActionFilter(v);
|
||||
setPage(1);
|
||||
}}
|
||||
optionList={actionOptions}
|
||||
style={{ width: 200 }}
|
||||
placeholder={t('筛选操作')}
|
||||
filter
|
||||
/>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
|
||||
<Tabs
|
||||
type='line'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
className='mt-2'
|
||||
>
|
||||
<TabPane tab={t('操作审计')} itemKey='operations'>
|
||||
<OrgPanel bodyClassName='overflow-x-auto' className='mt-4'>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1140 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
showSizeChanger: false,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={
|
||||
<OrgStateBlock icon={ScrollText} title={t('暂无审计日志')} />
|
||||
}
|
||||
empty={<OrgStateBlock icon={ScrollText} title={t('暂无审计日志')} />}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</TabPane>
|
||||
</OrgListCard>
|
||||
</>
|
||||
);
|
||||
|
||||
{promptArchiveEnabled && canViewPromptRecords && (
|
||||
<TabPane tab={t('提示词记录')} itemKey='prompt-records'>
|
||||
<OrgPromptRecords key={orgId} orgId={orgId} />
|
||||
</TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
return (
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader title={t('审计日志')} subtitle={t('查看企业操作记录')} />
|
||||
|
||||
{/* 原型 platform-list-tabs;“提示词记录”页签沿用原 feature flag + 权限显隐 */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'operations', label: t('操作审计'), children: operations },
|
||||
...(promptArchiveEnabled && canViewPromptRecords
|
||||
? [
|
||||
{
|
||||
key: 'prompt-records',
|
||||
label: t('提示词记录'),
|
||||
// 原 Tabs 预渲染全部页签(lazyRender=false),保持提示词记录随页面挂载、请求时机不变
|
||||
forceRender: true,
|
||||
children: <OrgPromptRecords key={orgId} orgId={orgId} />,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,8 +16,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -25,10 +32,9 @@ import {
|
||||
Toast,
|
||||
Tag,
|
||||
Progress,
|
||||
Banner,
|
||||
Popconfirm,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Plus, Pencil, Trash2 } from 'lucide-react';
|
||||
import { RefreshCw, Plus } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError } from '../../helpers';
|
||||
import {
|
||||
@@ -38,7 +44,7 @@ import {
|
||||
getQuotaInputUnit,
|
||||
} from '../../helpers/render';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
@@ -48,7 +54,7 @@ const subjectTypeLabel = (t, st) =>
|
||||
department: t('部门'),
|
||||
project: t('项目'),
|
||||
member: t('成员'),
|
||||
token: t('令牌'),
|
||||
token: t('密钥'),
|
||||
org: t('企业'),
|
||||
})[st] || st;
|
||||
|
||||
@@ -65,11 +71,9 @@ const cycleLabel = (t, c) =>
|
||||
const OrgBudgets = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState([]);
|
||||
// null=未知(接口未返回该字段的旧后端),true/false=预算 cap 是否真正在扣费链路生效
|
||||
const [enforcementEnabled, setEnforcementEnabled] = useState(null);
|
||||
// 未生效的细分原因:平台级引擎急停(engine=false) vs 企业未开「预算实时拦截」
|
||||
const [engineEnabled, setEngineEnabled] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatingBudgetId, setUpdatingBudgetId] = useState(null);
|
||||
const updatingBudgetRef = useRef(false);
|
||||
const [depts, setDepts] = useState([]);
|
||||
const [projects, setProjects] = useState([]);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -96,29 +100,17 @@ const OrgBudgets = ({ orgId }) => {
|
||||
API.get('/api/org/project', { headers: getOrgHeaders(orgId) }),
|
||||
]);
|
||||
if (b.data.success) {
|
||||
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组
|
||||
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组。
|
||||
// enforcement/engine 两个字段原只驱动表格上方旧提示栏,提示栏按原型移除后不再读取。
|
||||
const payload = b.data.data;
|
||||
if (Array.isArray(payload)) {
|
||||
setList(payload || []);
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
} else {
|
||||
setList(payload?.items || []);
|
||||
setEnforcementEnabled(payload?.enforcement_enabled ?? null);
|
||||
setEngineEnabled(payload?.engine_enabled ?? null);
|
||||
}
|
||||
setList(Array.isArray(payload) ? payload || [] : payload?.items || []);
|
||||
} else {
|
||||
showError(b.data.message);
|
||||
// 拉取失败回到「未知」,避免 Banner 停留在陈旧状态
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
}
|
||||
if (d.data.success) setDepts(d.data.data || []);
|
||||
if (p.data.success) setProjects(p.data.data || []);
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
setEnforcementEnabled(null);
|
||||
setEngineEnabled(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -128,7 +120,7 @@ const OrgBudgets = ({ orgId }) => {
|
||||
fetchAll();
|
||||
}, [fetchAll]);
|
||||
|
||||
// 主体名称与存在性优先取后端 subject_* 字段(覆盖成员/令牌,且能区分「已删除」与「已停用」);
|
||||
// 主体名称与存在性优先取后端 subject_* 字段(覆盖成员/密钥,且能区分「已删除」与「已停用」);
|
||||
// 旧后端未返回时回落到本地部门/项目列表匹配。
|
||||
const subjectOf = useCallback(
|
||||
(r) => {
|
||||
@@ -156,7 +148,7 @@ const OrgBudgets = ({ orgId }) => {
|
||||
disabled: p?.status === 2,
|
||||
};
|
||||
}
|
||||
// 旧后端下成员/令牌无从解析,按存在处理,避免误标「已删除」
|
||||
// 旧后端下成员/密钥无从解析,按存在处理,避免误标「已删除」
|
||||
return { name: `#${r.subject_id}`, exists: true, disabled: false };
|
||||
},
|
||||
[depts, projects],
|
||||
@@ -252,6 +244,52 @@ const OrgBudgets = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleStatusChange = async (record, enabled) => {
|
||||
if (
|
||||
updatingBudgetRef.current ||
|
||||
(record.status === 1) === enabled ||
|
||||
!subjectOf(record).exists
|
||||
)
|
||||
return;
|
||||
updatingBudgetRef.current = true;
|
||||
setUpdatingBudgetId(record.id);
|
||||
try {
|
||||
// Reuse the edit upsert contract with raw quotas, without currency conversion.
|
||||
const res = await API.put(
|
||||
'/api/org/budget',
|
||||
{
|
||||
subject_type: record.subject_type,
|
||||
subject_id: record.subject_id,
|
||||
cycle_type: record.cycle_type,
|
||||
cycle_quota: record.cycle_quota,
|
||||
total_quota: record.total_quota,
|
||||
custom_cycle_days: record.custom_cycle_days || 0,
|
||||
over_limit_action: record.over_limit_action,
|
||||
status: enabled ? 1 : 2,
|
||||
},
|
||||
{ headers: getOrgHeaders(orgId), skipErrorHandler: true },
|
||||
);
|
||||
if (res.data.success) {
|
||||
Toast.success({
|
||||
content: t('状态已更新'),
|
||||
key: `org-budget-status-${orgId}-${record.id}`,
|
||||
});
|
||||
setList((items) =>
|
||||
items.map((item) =>
|
||||
item.id === record.id ? { ...item, status: enabled ? 1 : 2 } : item,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
updatingBudgetRef.current = false;
|
||||
setUpdatingBudgetId(null);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async (record) => {
|
||||
try {
|
||||
const res = await API.delete(`/api/org/budget/${record.id}`, {
|
||||
@@ -268,30 +306,32 @@ const OrgBudgets = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseBudget(300/110/260/120/120/130,scroll.x 1040);取值与判定沿用原逻辑
|
||||
const columns = [
|
||||
{
|
||||
title: t('主体'),
|
||||
width: 300,
|
||||
render: (_, r) => {
|
||||
const subj = subjectOf(r);
|
||||
return (
|
||||
<span>
|
||||
<Tag color='blue' size='small'>
|
||||
<div className='oc-budget-subject'>
|
||||
<Tag color='gold' bordered={false}>
|
||||
{subjectTypeLabel(t, r.subject_type)}
|
||||
</Tag>{' '}
|
||||
<span className={subj.exists ? '' : 'text-gray-400 line-through'}>
|
||||
</Tag>
|
||||
<span className={subj.exists ? '' : 'oc-muted line-through'}>
|
||||
{subj.name}
|
||||
</span>{' '}
|
||||
</span>
|
||||
{!subj.exists && (
|
||||
<Tag color='red' size='small'>
|
||||
<Tag color='red' bordered={false}>
|
||||
{t('主体已删除')}
|
||||
</Tag>
|
||||
)}
|
||||
{subj.exists && subj.disabled && (
|
||||
<Tag color='grey' size='small'>
|
||||
<Tag color='grey' bordered={false}>
|
||||
{t('已停用')}
|
||||
</Tag>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -299,31 +339,32 @@ const OrgBudgets = ({ orgId }) => {
|
||||
title: t('周期'),
|
||||
dataIndex: 'cycle_type',
|
||||
render: (v) => cycleLabel(t, v),
|
||||
width: 90,
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: t('周期用量 / cap'),
|
||||
width: 220,
|
||||
title: t('周期用量 / 上限'),
|
||||
width: 260,
|
||||
render: (_, r) => {
|
||||
if (!r.cycle_quota)
|
||||
return <span className='text-xs text-gray-400'>{t('不限')}</span>;
|
||||
return <span className='oc-budget-unlimited'>{t('不限')}</span>;
|
||||
const pct = Math.min(
|
||||
100,
|
||||
Math.round((r.used_in_cycle / r.cycle_quota) * 100),
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<div className='oc-budget-usage'>
|
||||
<Progress
|
||||
percent={pct}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={pct >= 90 ? 'var(--ui-color-danger)' : undefined}
|
||||
/>
|
||||
<span className='text-xs text-gray-500'>
|
||||
<span>
|
||||
{renderQuota(r.used_in_cycle, 2)}
|
||||
{r.reserved_in_cycle > 0
|
||||
? ` (+${renderQuota(r.reserved_in_cycle, 2)} ${t('预留')})`
|
||||
: ''}
|
||||
{' / '}
|
||||
<i>/</i>
|
||||
{renderQuota(r.cycle_quota, 2)}
|
||||
</span>
|
||||
</div>
|
||||
@@ -333,36 +374,37 @@ const OrgBudgets = ({ orgId }) => {
|
||||
{
|
||||
title: t('超限动作'),
|
||||
dataIndex: 'over_limit_action',
|
||||
// 90px 是按中文两字标签定的,泰语最短的地道说法 "เมื่อเกินขีดจำกัด" 也要 ~150px;
|
||||
// 这一列没有更短的译法,只能让列让位(其余列头已在 kt_overrides_th.json 收敛用词)
|
||||
width: 150,
|
||||
// 原型 120px;表头 nowrap,较长译文(如泰语)由表格自动撑开列宽,不截断
|
||||
width: 120,
|
||||
render: () => t('拦截'),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
render: (v) => (
|
||||
<Tag color={v === 1 ? 'green' : 'grey'}>
|
||||
{v === 1 ? t('启用') : t('停用')}
|
||||
</Tag>
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<Switch
|
||||
size='small'
|
||||
checked={v === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
aria-label={`${subjectOf(record).name} ${t('状态')}`}
|
||||
loading={updatingBudgetId === record.id}
|
||||
disabled={updatingBudgetId !== null || !subjectOf(record).exists}
|
||||
onChange={(checked) => handleStatusChange(record, checked)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 160,
|
||||
width: 130,
|
||||
render: (_, r) => {
|
||||
const subj = subjectOf(r);
|
||||
return (
|
||||
<div className='flex gap-1'>
|
||||
<OrgRowActions>
|
||||
{/* 主体已删除的孤儿行改不了(后端 upsert 会因主体不存在报错),只留删除 */}
|
||||
{subj.exists && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Pencil size={14} />}
|
||||
onClick={() => openEdit(r)}
|
||||
>
|
||||
<Button type='link' onClick={() => openEdit(r)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
@@ -373,31 +415,36 @@ const OrgBudgets = ({ orgId }) => {
|
||||
)}
|
||||
onConfirm={() => handleDelete(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
>
|
||||
<Button type='link' danger>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('预算中心')}
|
||||
subtitle={t('部门 / 项目 / 成员的额度上限')}
|
||||
actions={
|
||||
subtitle={t('管理部门、项目与成员的额度上限')}
|
||||
/>
|
||||
|
||||
{/* 原型 .eb-policy 说明条:替换原“预算实时拦截未生效”警告与 cap 说明两条 Banner */}
|
||||
<div className='oc-policy' role='note'>
|
||||
{t(
|
||||
'预算只设置「最多能花多少」的上限,不增加企业真实额度池;提额仅提高上限。',
|
||||
)}
|
||||
</div>
|
||||
|
||||
<OrgListCard
|
||||
title={t('预算列表')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={fetchAll}
|
||||
>
|
||||
@@ -405,51 +452,27 @@ const OrgBudgets = ({ orgId }) => {
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<Plus size={14} />}
|
||||
icon={<Plus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('配置预算')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{enforcementEnabled === false && (
|
||||
<Banner
|
||||
type='warning'
|
||||
closeIcon={null}
|
||||
description={
|
||||
engineEnabled === false
|
||||
? t(
|
||||
'预算引擎已被平台全局急停:所有企业的预算拦截与用量统计均暂停,恢复需平台管理员开启系统开关,与本企业配置无关。',
|
||||
)
|
||||
: t(
|
||||
'预算实时拦截当前未生效:这里的配置只会被保存,不会拦截超额调用,也不会累计用量统计。请联系平台管理员开启本企业的「预算实时拦截」功能。',
|
||||
)
|
||||
}
|
||||
className='mb-4'
|
||||
/>
|
||||
)}
|
||||
<Banner
|
||||
type='info'
|
||||
closeIcon={null}
|
||||
description={t(
|
||||
'预算只设置「最多能花多少」的上限(cap),不增加企业真实额度池;提额仅提高上限。',
|
||||
)}
|
||||
className='mb-4'
|
||||
/>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1040 }}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
<OrgModal
|
||||
className='oc-dialog oc-budget-dialog'
|
||||
width={560}
|
||||
title={editing ? t('编辑预算') : t('配置预算')}
|
||||
visible={modalVisible}
|
||||
onOk={submit}
|
||||
@@ -459,11 +482,11 @@ const OrgBudgets = ({ orgId }) => {
|
||||
>
|
||||
<Form getFormApi={setFormApi}>
|
||||
{editing ? (
|
||||
<div className='mb-3'>
|
||||
<Tag color='blue' size='small'>
|
||||
<div className='oc-budget-edit-subject'>
|
||||
<Tag color='gold' bordered={false}>
|
||||
{subjectTypeLabel(t, editing.subject_type)}
|
||||
</Tag>{' '}
|
||||
{subjectOf(editing).name}
|
||||
</Tag>
|
||||
<strong>{subjectOf(editing).name}</strong>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -28,28 +28,24 @@ import { timestamp2string } from '../../helpers/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
BarChart2,
|
||||
Users,
|
||||
Key,
|
||||
Wallet,
|
||||
TrendingUp,
|
||||
ArrowRight,
|
||||
ShieldCheck,
|
||||
Crown,
|
||||
Shield,
|
||||
PiggyBank,
|
||||
Flame,
|
||||
Coins,
|
||||
RefreshCw,
|
||||
Search,
|
||||
FileText,
|
||||
CreditCard,
|
||||
Activity,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
Avatar as AntAvatar,
|
||||
Card as AntCard,
|
||||
Tag as AntTag,
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import {
|
||||
Progress,
|
||||
Table,
|
||||
Tag,
|
||||
Button,
|
||||
DatePicker,
|
||||
Input,
|
||||
@@ -60,14 +56,14 @@ import { useOrgDashboard, useOrgQuota } from '../../hooks/org/useOrgData';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import { API, showError } from '../../helpers';
|
||||
import Loading from '../../components/common/ui/Loading';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgAnalyticsPanel from './components/OrgAnalyticsPanel';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import '../../styles/org-center.css';
|
||||
import OrgSideSheet from './components/OrgSideSheet';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import { getOrgQuotaAvailability } from './orgQuotaAvailability';
|
||||
|
||||
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||||
|
||||
@@ -108,7 +104,7 @@ const isFeatureEnabled = (flags, key) => {
|
||||
// 状态配置
|
||||
const getStatusConfig = (status, t) => {
|
||||
const map = {
|
||||
1: { label: t('正常'), tagLabel: t('运行正常'), color: 'green' },
|
||||
1: { label: t('正常'), tagLabel: t('企业运行正常'), color: 'green' },
|
||||
2: { label: t('冻结'), tagLabel: t('已被冻结'), color: 'red' },
|
||||
3: { label: t('欠费'), tagLabel: t('额度不足'), color: 'orange' },
|
||||
};
|
||||
@@ -363,7 +359,20 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
// 原型 .ea-budget-primary strong small:货币符号缩小为独立 small,数值格式仍来自 renderQuota
|
||||
const renderBudgetAmount = (quota) => {
|
||||
const text = String(renderQuota(quota, 2) ?? '');
|
||||
const m = text.match(/^([^\d\-−]+)(.*)$/);
|
||||
if (!m) return text;
|
||||
return (
|
||||
<>
|
||||
<small>{m[1].trim()}</small>
|
||||
{m[2]}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
@@ -398,140 +407,88 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
{
|
||||
title: t('成员'),
|
||||
dataIndex: 'display_name',
|
||||
width: 200,
|
||||
render: (text, record) => (
|
||||
<div className='flex items-center gap-2.5'>
|
||||
<div className='flex-shrink-0 w-8 h-8 rounded-full bg-brand/10 text-brand flex items-center justify-center text-xs font-semibold'>
|
||||
{(text || record.username || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div className='min-w-0'>
|
||||
width: 170,
|
||||
render: (text, record) => {
|
||||
const name = text || record.username;
|
||||
return (
|
||||
<div className='oc-ea-member'>
|
||||
<AntAvatar size={28}>
|
||||
{(name || '?').charAt(0).toUpperCase()}
|
||||
</AntAvatar>
|
||||
{isAdmin ? (
|
||||
<div
|
||||
className='font-medium text-brand-deep truncate text-sm cursor-pointer hover:text-brand hover:underline transition-colors'
|
||||
<button
|
||||
type='button'
|
||||
className='oc-ea-member-link'
|
||||
onClick={() => handleViewMemberUsage(record)}
|
||||
>
|
||||
{text || record.username}
|
||||
</div>
|
||||
{name}
|
||||
</button>
|
||||
) : (
|
||||
<div className='font-medium text-gray-900 dark:text-white truncate text-sm'>
|
||||
{text || record.username}
|
||||
</div>
|
||||
<span>{name}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('角色'),
|
||||
dataIndex: 'role',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
width: 132,
|
||||
render: (role) => {
|
||||
const config = {
|
||||
owner: { label: t('所有者'), color: 'red', icon: Crown },
|
||||
admin: { label: t('管理员'), color: 'blue', icon: ShieldCheck },
|
||||
dept_admin: {
|
||||
label: t('部门管理员'),
|
||||
color: 'cyan',
|
||||
icon: ShieldCheck,
|
||||
},
|
||||
super_admin: {
|
||||
label: t('超级管理员'),
|
||||
color: 'violet',
|
||||
icon: ShieldCheck,
|
||||
},
|
||||
member: { label: t('成员'), color: 'grey', icon: Shield },
|
||||
owner: { label: t('所有者'), color: 'volcano' },
|
||||
admin: { label: t('管理员'), color: 'geekblue' },
|
||||
dept_admin: { label: t('部门管理员'), color: 'cyan' },
|
||||
super_admin: { label: t('超级管理员'), color: 'purple' },
|
||||
member: { label: t('成员'), color: 'default' },
|
||||
};
|
||||
const c = config[role] || config.member;
|
||||
return (
|
||||
<div className='flex items-center justify-center gap-1'>
|
||||
<c.icon
|
||||
size={12}
|
||||
className={
|
||||
role === 'owner'
|
||||
? 'text-amber-500'
|
||||
: role === 'admin' ||
|
||||
role === 'dept_admin' ||
|
||||
role === 'super_admin'
|
||||
? 'text-brand-deep'
|
||||
: 'text-gray-400 dark:text-gray-500'
|
||||
}
|
||||
/>
|
||||
<Tag size='small' color={c.color}>
|
||||
{c.label}
|
||||
</Tag>
|
||||
</div>
|
||||
);
|
||||
return <AntTag color={c.color}>{c.label}</AntTag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('周期内已用'),
|
||||
dataIndex: 'quota_used_in_period',
|
||||
width: 120,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
render: (v, record) =>
|
||||
isPeriodicQuotaPeriod(record.quota_period) ? (
|
||||
<span className='text-gray-700 dark:text-gray-300 font-medium'>
|
||||
{renderQuota(safeQuotaNumber(v), 2)}
|
||||
</span>
|
||||
) : (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>—</span>
|
||||
),
|
||||
isPeriodicQuotaPeriod(record.quota_period)
|
||||
? renderQuota(safeQuotaNumber(v), 2)
|
||||
: '—',
|
||||
},
|
||||
{
|
||||
title: t('总已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 120,
|
||||
width: 130,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-gray-700 dark:text-gray-300 font-medium'>
|
||||
{renderQuota(safeQuotaNumber(v), 2)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => renderQuota(safeQuotaNumber(v), 2),
|
||||
},
|
||||
{
|
||||
title: t('额度上限 / 周期'),
|
||||
dataIndex: 'quota_limit',
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v, record) => {
|
||||
const quotaLimit = safeQuotaNumber(v);
|
||||
return quotaLimit > 0 ? (
|
||||
<div className='text-right'>
|
||||
<div className='text-gray-700 dark:text-gray-300'>
|
||||
<div className='oc-ea-limit'>
|
||||
{renderQuota(quotaLimit, 2)}
|
||||
</div>
|
||||
<div
|
||||
className={`text-[11px] ${
|
||||
isPeriodicQuotaPeriod(record.quota_period)
|
||||
? 'text-gray-400 dark:text-gray-500'
|
||||
: 'text-amber-500'
|
||||
}`}
|
||||
>
|
||||
<small>
|
||||
{quotaPeriodLimitLabel(t, record.quota_period)}
|
||||
{!isPeriodicQuotaPeriod(record.quota_period) &&
|
||||
` · ${t('不重置')}`}
|
||||
</div>
|
||||
</small>
|
||||
</div>
|
||||
) : (
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{t('不限')}
|
||||
</span>
|
||||
t('不限')
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('使用进度'),
|
||||
width: 160,
|
||||
width: 150,
|
||||
render: (_, record) => {
|
||||
const quotaLimit = safeQuotaNumber(record.quota_limit);
|
||||
if (quotaLimit <= 0) {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>
|
||||
-
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (quotaLimit <= 0) return '—';
|
||||
// 周期模式按「周期内已用 / 上限」;终身模式按「总已用 / 上限」。
|
||||
const usedForProgress = isPeriodicQuotaPeriod(record.quota_period)
|
||||
? safeQuotaNumber(record.quota_used_in_period)
|
||||
@@ -541,17 +498,11 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
Math.round((usedForProgress / quotaLimit) * 100),
|
||||
);
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<Progress
|
||||
percent={percent}
|
||||
size='small'
|
||||
style={{ width: 100 }}
|
||||
stroke={usageStrokeColor(percent)}
|
||||
/>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 w-8 text-right'>
|
||||
{percent}%
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -559,6 +510,22 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
[t, isAdmin, handleViewMemberUsage],
|
||||
);
|
||||
|
||||
// “成员用量”按钮:切换到成员用量明细并在页内定位(不发请求)
|
||||
const membersAnchorRef = useRef(null);
|
||||
const [detailTab, setDetailTab] = useState('models');
|
||||
const showMembers = () => {
|
||||
setDetailTab('members');
|
||||
window.setTimeout(() => {
|
||||
const reduce = window.matchMedia?.(
|
||||
'(prefers-reduced-motion: reduce)',
|
||||
)?.matches;
|
||||
membersAnchorRef.current?.scrollIntoView({
|
||||
behavior: reduce ? 'auto' : 'smooth',
|
||||
block: 'start',
|
||||
});
|
||||
}, 60);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
fetch();
|
||||
fetchQuota();
|
||||
@@ -578,7 +545,7 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
? Math.min(100, Math.round((usedQuota / totalQuota) * 100))
|
||||
: 0;
|
||||
|
||||
// 成员/令牌容量占用率:与其他使用进度共用同一套阈值语义色
|
||||
// 成员/密钥容量占用率:与其他使用进度共用同一套阈值语义色
|
||||
const memberPercent =
|
||||
data?.max_members > 0
|
||||
? Math.min(
|
||||
@@ -595,9 +562,10 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
: 0;
|
||||
|
||||
const statusConfig = getStatusConfig(data?.status, t);
|
||||
const quotaAvailability = getOrgQuotaAvailability(data);
|
||||
|
||||
// 成员明细对账:成员合计(终身已用)与企业池已用(org.UsedQuota)通常不相等,
|
||||
// 差额为「未归属」消费(令牌未绑定成员 / 管理员直接使用 / 成员跟踪前的历史),
|
||||
// 差额为「未归属」消费(密钥未绑定成员 / 管理员直接使用 / 成员跟踪前的历史),
|
||||
// 显式列出避免用户误以为成员明细加总应等于顶部「已用额度」。
|
||||
const memberQuotaRows = quotaData?.member_quotas || [];
|
||||
const memberQuotaPage = Number(quotaData?.member_page || 1);
|
||||
@@ -615,207 +583,23 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
const poolUsedQuota = Number(quotaData?.used_quota ?? data?.used_quota ?? 0);
|
||||
const unattributedQuota = Math.max(0, poolUsedQuota - memberUsedSum);
|
||||
|
||||
return (
|
||||
<div className='uc-page space-y-6'>
|
||||
{/* Header */}
|
||||
<OrgPageHeader
|
||||
icon={BarChart2}
|
||||
title={t('企业概览')}
|
||||
subtitle={t(
|
||||
'聚合企业额度、组织规模与成员消耗,和个人工作台保持职责分离',
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
icon={<CreditCard size={14} />}
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => navigate('/org/recharge')}
|
||||
>
|
||||
{t('立即充值')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => {
|
||||
fetch();
|
||||
fetchQuota(memberQuotaPage, memberQuotaPageSize);
|
||||
}}
|
||||
loading={loading || quotaLoading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
const statusTone = data?.status === 1 ? 'ok' : data?.status ? 'warn' : 'none';
|
||||
|
||||
{/* 统计卡片 - 三列 */}
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-4'>
|
||||
<StatCard
|
||||
icon={Users}
|
||||
title={t('企业成员')}
|
||||
value={data?.member_count ?? 0}
|
||||
tone='brand'
|
||||
loading={loading}
|
||||
subtitle={
|
||||
data?.max_members > 0
|
||||
? `${t('上限')}: ${data.max_members}`
|
||||
: t('不限')
|
||||
}
|
||||
extra={
|
||||
data?.max_members > 0 && (
|
||||
<Progress
|
||||
percent={memberPercent}
|
||||
size='small'
|
||||
stroke={usageStrokeColor(memberPercent)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
icon={Key}
|
||||
title={t('企业令牌')}
|
||||
value={data?.token_count ?? 0}
|
||||
tone='amber'
|
||||
loading={loading}
|
||||
subtitle={
|
||||
data?.max_tokens > 0
|
||||
? `${t('上限')}: ${data.max_tokens}`
|
||||
: t('不限')
|
||||
}
|
||||
extra={
|
||||
data?.max_tokens > 0 && (
|
||||
<Progress
|
||||
percent={tokenPercent}
|
||||
size='small'
|
||||
stroke={usageStrokeColor(tokenPercent)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
icon={TrendingUp}
|
||||
title={t('企业状态')}
|
||||
value={statusConfig.label}
|
||||
tone='sky'
|
||||
loading={loading}
|
||||
extra={
|
||||
data && (
|
||||
<Tag
|
||||
size='small'
|
||||
color={statusConfig.color}
|
||||
type='light'
|
||||
className='mt-0.5'
|
||||
>
|
||||
{statusConfig.tagLabel}
|
||||
</Tag>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 额度使用详情 - 全宽 */}
|
||||
<OrgPanel icon={Wallet} title={t('额度使用详情')} padding='p-5'>
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-4'>
|
||||
{/* 总额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-gray-50/80 dark:bg-neutral-800/50 border border-gray-100 dark:border-neutral-700/50'>
|
||||
<div className='p-2 rounded-lg bg-brand/10'>
|
||||
<Coins size={16} className='text-brand-deep' />
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('总额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-gray-900 dark:text-white'>
|
||||
{data ? renderQuota(totalQuota, 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 已用额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-orange-50/80 dark:bg-orange-900/10 border border-orange-100 dark:border-orange-800/30'>
|
||||
<div className='p-2 rounded-lg bg-orange-100 dark:bg-orange-900/30'>
|
||||
<Flame
|
||||
size={16}
|
||||
className='text-orange-600 dark:text-orange-400'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('已用额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-orange-600 dark:text-orange-400'>
|
||||
{data ? renderQuota(usedQuota, 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* 剩余额度 */}
|
||||
<div className='flex items-center gap-3 p-4 rounded-xl bg-emerald-50/80 dark:bg-emerald-900/10 border border-emerald-100 dark:border-emerald-800/30'>
|
||||
<div className='p-2 rounded-lg bg-emerald-100 dark:bg-emerald-900/30'>
|
||||
<PiggyBank
|
||||
size={16}
|
||||
className='text-emerald-600 dark:text-emerald-400'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div className='text-xs font-medium text-gray-400 dark:text-gray-500 mb-0.5'>
|
||||
{t('剩余额度')}
|
||||
</div>
|
||||
<div className='text-lg font-bold text-emerald-600 dark:text-emerald-400'>
|
||||
{data ? renderQuota(Number(data.quota || 0), 2) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 使用率进度条 */}
|
||||
<div className='mt-5 pt-4 border-t border-gray-100 dark:border-neutral-800'>
|
||||
<div className='flex items-center justify-between mb-2'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400'>
|
||||
{t('使用率(累计)')}
|
||||
</span>
|
||||
<span
|
||||
className='text-sm font-semibold'
|
||||
style={{ color: usageStrokeColor(usedPercent) }}
|
||||
>
|
||||
{usedPercent}%
|
||||
</span>
|
||||
</div>
|
||||
<div className='w-full h-3 bg-gray-100 dark:bg-neutral-800 rounded-full overflow-hidden'>
|
||||
{/* 渐变由同一语义色的浅调 → 本色构成(单色相),
|
||||
不再引入第二色相(旧 emerald→teal 与用量分析的 teal 系列色撞车) */}
|
||||
<div
|
||||
className='h-full rounded-full transition-all duration-1000 ease-out'
|
||||
style={{
|
||||
width: `${Math.max(usedPercent, 0)}%`,
|
||||
background: `linear-gradient(90deg, color-mix(in srgb, ${usageStrokeColor(usedPercent)} 72%, #fff) 0%, ${usageStrokeColor(usedPercent)} 100%)`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 成员用量明细 */}
|
||||
<OrgPanel
|
||||
icon={Users}
|
||||
title={t('成员用量明细')}
|
||||
padding='p-5'
|
||||
bodyClassName='overflow-x-auto'
|
||||
actions={
|
||||
<Link
|
||||
to='/org/members'
|
||||
className='flex items-center gap-1 text-xs text-brand-deep hover:text-brand transition-colors'
|
||||
>
|
||||
const memberUsageCard = (
|
||||
<AntCard className='oc-ea-detail-card oc-ea-members'>
|
||||
<div className='oc-ea-table-toolbar'>
|
||||
<h2>{t('成员用量明细')}</h2>
|
||||
<Link to='/org/members' className='oc-ea-view-all'>
|
||||
{t('查看全部')}
|
||||
<ArrowRight size={12} />
|
||||
</Link>
|
||||
}
|
||||
>
|
||||
</div>
|
||||
<Table
|
||||
columns={memberColumns}
|
||||
dataSource={memberQuotaRows}
|
||||
loading={quotaLoading}
|
||||
rowKey='member_id'
|
||||
scroll={{ x: 860 }}
|
||||
pagination={
|
||||
memberQuotaTotal > memberQuotaPageSize
|
||||
? {
|
||||
@@ -824,59 +608,197 @@ const OrgDashboard = ({ orgId, orgRole, featureFlags }) => {
|
||||
total: memberQuotaTotal,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}
|
||||
: false
|
||||
}
|
||||
size='small'
|
||||
empty={<OrgStateBlock icon={Users} title={t('暂无成员数据')} />}
|
||||
/>
|
||||
{memberQuotaRows.length > 0 && (
|
||||
<div className='mt-3 pt-3 border-t border-gray-100 dark:border-neutral-800 flex flex-wrap items-center gap-x-6 gap-y-1 text-xs'>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('成员合计已用')}:
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(memberUsedSum, 2)}
|
||||
</span>
|
||||
</span>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('企业池已用')}:
|
||||
<span className='font-medium text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(poolUsedQuota, 2)}
|
||||
<div className='oc-ea-member-total'>
|
||||
<span>
|
||||
{t('成员合计已用')}
|
||||
<strong>{renderQuota(memberUsedSum, 2)}</strong>
|
||||
</span>
|
||||
<span>
|
||||
{t('企业池已用')}
|
||||
<strong>{renderQuota(poolUsedQuota, 2)}</strong>
|
||||
</span>
|
||||
{unattributedQuota > 0 && (
|
||||
<Tooltip
|
||||
content={t(
|
||||
'企业池已用包含未绑定到具体成员的消费(如管理员直接使用、令牌未分配成员、成员跟踪前的历史数据),因此成员合计通常小于企业池已用。',
|
||||
'企业池已用包含未绑定到具体成员的消费(如管理员直接使用、密钥未分配成员、成员跟踪前的历史数据),因此成员合计通常小于企业池已用。',
|
||||
)}
|
||||
>
|
||||
<span className='text-amber-600 dark:text-amber-400 cursor-help'>
|
||||
{t('未归属差额')}:
|
||||
<span className='font-medium'>
|
||||
{renderQuota(unattributedQuota, 2)}
|
||||
</span>
|
||||
<span className='oc-ea-unattributed'>
|
||||
{t('未归属差额')}
|
||||
<strong>{renderQuota(unattributedQuota, 2)}</strong>
|
||||
</span>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
);
|
||||
|
||||
{showAnalytics && (
|
||||
<div className='space-y-3'>
|
||||
<div className='flex items-center gap-2 px-1'>
|
||||
<Activity size={16} className='text-brand-deep' />
|
||||
return (
|
||||
<div className='uc-page oc-page oc-dashboard'>
|
||||
<div className='oc-dash-breadcrumb'>
|
||||
<OrgBreadcrumb current={t('数据看板')} />
|
||||
</div>
|
||||
|
||||
{/* 企业概况(原型 .ea-hero) */}
|
||||
<header className='oc-dash-hero'>
|
||||
<div className={`oc-dash-health is-${statusTone}`}>
|
||||
<span>
|
||||
<i aria-hidden='true' />
|
||||
{statusConfig.tagLabel}
|
||||
</span>
|
||||
{orgName && <div className='oc-dash-org-name'>{orgName}</div>}
|
||||
</div>
|
||||
<div className='oc-dash-heading'>
|
||||
<div>
|
||||
<div className='font-semibold text-gray-950 dark:text-white'>
|
||||
{t('多维用量分析')}
|
||||
<h1>{t('企业数据看板')}</h1>
|
||||
<p>{t('掌握企业额度、组织规模与模型消耗')}</p>
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
{t('管理员专属经营数据,避免与个人工作台重复展示')}
|
||||
<div className='oc-dash-actions'>
|
||||
<Button onClick={showMembers}>{t('成员用量')}</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => {
|
||||
fetch();
|
||||
fetchQuota(memberQuotaPage, memberQuotaPageSize);
|
||||
}}
|
||||
loading={loading || quotaLoading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{isAdmin && (
|
||||
<Button
|
||||
icon={<Wallet size={16} />}
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => navigate('/org/recharge')}
|
||||
>
|
||||
{t('立即充值')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className='oc-dash-overview'>
|
||||
<AntCard className='oc-dash-budget'>
|
||||
<div className='oc-dash-budget-heading'>
|
||||
<h2>{t('企业额度')}</h2>
|
||||
<span>{t('累计额度使用情况')}</span>
|
||||
</div>
|
||||
<div className='oc-dash-budget-primary'>
|
||||
<span>{t('剩余额度')}</span>
|
||||
<strong>
|
||||
{data ? renderBudgetAmount(Number(data.quota || 0)) : '-'}
|
||||
</strong>
|
||||
{quotaAvailability && (
|
||||
<div
|
||||
className={`oc-dash-budget-availability is-${quotaAvailability.type}`}
|
||||
role='status'
|
||||
>
|
||||
<Typography.Text type={quotaAvailability.type}>
|
||||
{t(quotaAvailability.label)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className='oc-dash-budget-secondary'>
|
||||
<div>
|
||||
<span>{t('总额度')}</span>
|
||||
<strong>{data ? renderQuota(totalQuota, 2) : '-'}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('已用额度')}</span>
|
||||
<strong>{data ? renderQuota(usedQuota, 2) : '-'}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className='oc-dash-budget-progress'>
|
||||
<div>
|
||||
<span>{t('累计使用率')}</span>
|
||||
<strong style={{ color: usageStrokeColor(usedPercent) }}>
|
||||
{usedPercent}%
|
||||
</strong>
|
||||
</div>
|
||||
<Progress
|
||||
percent={usedPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(usedPercent)}
|
||||
/>
|
||||
</div>
|
||||
</AntCard>
|
||||
|
||||
<div className='oc-dash-org'>
|
||||
<div>
|
||||
<span>
|
||||
<Users size={16} />
|
||||
{t('企业成员')}
|
||||
</span>
|
||||
<strong>
|
||||
{data?.member_count ?? 0}
|
||||
<small>
|
||||
{data?.max_members > 0
|
||||
? `/ ${Number(data.max_members).toLocaleString()}`
|
||||
: `/ ${t('不限')}`}
|
||||
</small>
|
||||
</strong>
|
||||
{data?.max_members > 0 && (
|
||||
<Progress
|
||||
percent={memberPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(memberPercent)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<span>
|
||||
<Key size={16} />
|
||||
{t('企业密钥')}
|
||||
</span>
|
||||
<strong>
|
||||
{data?.token_count ?? 0}
|
||||
<small>
|
||||
{data?.max_tokens > 0
|
||||
? `/ ${Number(data.max_tokens).toLocaleString()}`
|
||||
: `/ ${t('不限')}`}
|
||||
</small>
|
||||
</strong>
|
||||
{data?.max_tokens > 0 && (
|
||||
<Progress
|
||||
percent={tokenPercent}
|
||||
size='small'
|
||||
showInfo={false}
|
||||
stroke={usageStrokeColor(tokenPercent)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className='oc-dash-status'>
|
||||
<span>
|
||||
<Activity size={16} />
|
||||
{t('企业状态')}
|
||||
</span>
|
||||
<strong>{statusConfig.label}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<OrgAnalyticsPanel orgId={orgId} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{showAnalytics ? (
|
||||
<OrgAnalyticsPanel
|
||||
orgId={orgId}
|
||||
memberUsage={memberUsageCard}
|
||||
detailTab={detailTab}
|
||||
onDetailTabChange={setDetailTab}
|
||||
detailsRef={membersAnchorRef}
|
||||
/>
|
||||
) : (
|
||||
<div ref={membersAnchorRef}>{memberUsageCard}</div>
|
||||
)}
|
||||
|
||||
{/* 成员用量明细抽屉 */}
|
||||
|
||||
@@ -242,7 +242,7 @@ const OrgDepartments = ({ orgId }) => {
|
||||
<div className='uc-page'>
|
||||
<OrgPageHeader
|
||||
icon={Network}
|
||||
title={t('部门管理')}
|
||||
title={t('组织架构')}
|
||||
subtitle={t('组织架构与部门预算')}
|
||||
actions={
|
||||
<>
|
||||
|
||||
+191
-232
@@ -21,20 +21,20 @@ import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
RefreshCw,
|
||||
Receipt,
|
||||
Coins,
|
||||
Wallet,
|
||||
Zap,
|
||||
Activity,
|
||||
BarChart3,
|
||||
Download,
|
||||
Trophy,
|
||||
Search,
|
||||
} from 'lucide-react';
|
||||
import { Card as AntCard, Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Select,
|
||||
Button,
|
||||
DatePicker,
|
||||
Input,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Checkbox,
|
||||
Radio,
|
||||
RadioGroup,
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
useOrgMemberRanking,
|
||||
} from '../../hooks/org/useOrgData';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import StatCard from './components/OrgStatCard';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import {
|
||||
API,
|
||||
@@ -58,13 +58,6 @@ import {
|
||||
timestamp2string,
|
||||
} from '../../helpers';
|
||||
|
||||
// ========== 排名徽标颜色 ==========
|
||||
const rankColors = {
|
||||
1: 'from-yellow-400 to-yellow-500',
|
||||
2: 'from-gray-300 to-gray-400',
|
||||
3: 'from-orange-400 to-orange-500',
|
||||
};
|
||||
|
||||
// ========== 缓存 Token 解析(来自 other JSON 字段)==========
|
||||
function getCacheTokens(record) {
|
||||
const other = getLogOther(record.other);
|
||||
@@ -609,86 +602,71 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
];
|
||||
}, [appliedFilters, canViewTeamUsage, isAdmin, members, t]);
|
||||
|
||||
// ========== 日志表格列 ==========
|
||||
// ========== 日志表格列(宽度与渲染对齐原型 EnterpriseExpenses)==========
|
||||
const logColumns = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: t('时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: 170,
|
||||
width: 185,
|
||||
render: (v) => (v ? timestamp2string(v) : '-'),
|
||||
},
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'username',
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{record.display_name || v || '-'}
|
||||
</span>
|
||||
),
|
||||
width: 105,
|
||||
ellipsis: true,
|
||||
render: (v, record) => record.display_name || v || '-',
|
||||
},
|
||||
{
|
||||
title: t('模型'),
|
||||
dataIndex: 'model_name',
|
||||
width: 180,
|
||||
width: 175,
|
||||
ellipsis: true,
|
||||
render: (v) => (
|
||||
<code className='text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-neutral-800 rounded'>
|
||||
{v || '-'}
|
||||
</code>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-model'>{v || '-'}</span>,
|
||||
},
|
||||
{
|
||||
title: t('Token 名称'),
|
||||
title: t('密钥名称'),
|
||||
dataIndex: 'token_name',
|
||||
width: 120,
|
||||
width: 235,
|
||||
ellipsis: true,
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{v || '-'}
|
||||
</span>
|
||||
),
|
||||
render: (v) => v || '-',
|
||||
},
|
||||
{
|
||||
title: t('提示 / 补全'),
|
||||
width: 130,
|
||||
width: 165,
|
||||
render: (_, record) => (
|
||||
<div className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
<span title='Prompt'>{record.prompt_tokens || 0}</span>
|
||||
<span className='mx-1 text-gray-300 dark:text-gray-600'>/</span>
|
||||
<span title='Completion'>{record.completion_tokens || 0}</span>
|
||||
</div>
|
||||
<span className='oc-number'>
|
||||
<span title='Prompt'>{record.prompt_tokens || 0}</span>{' '}
|
||||
<span className='oc-muted' title='Completion'>
|
||||
/ {record.completion_tokens || 0}
|
||||
</span>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('缓存 / 缓存创建'),
|
||||
width: 130,
|
||||
width: 180,
|
||||
render: (_, record) => (
|
||||
<div className='text-xs text-gray-600 dark:text-gray-400'>
|
||||
<span title={t('缓存 Tokens')}>{getCacheTokens(record)}</span>
|
||||
<span className='mx-1 text-gray-300 dark:text-gray-600'>/</span>
|
||||
<span title={t('缓存创建 Tokens')}>
|
||||
{getCacheCreationTokens(record)}
|
||||
<span className='oc-number'>
|
||||
<span title={t('缓存 Tokens')}>{getCacheTokens(record)}</span>{' '}
|
||||
<span className='oc-muted' title={t('缓存创建 Tokens')}>
|
||||
/ {getCacheCreationTokens(record)}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('消耗额度'),
|
||||
dataIndex: 'quota',
|
||||
width: 110,
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-orange-600 dark:text-orange-400 font-medium text-sm'>
|
||||
{renderQuota(v, 6)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-cost'>{renderQuota(v, 6)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('耗时'),
|
||||
dataIndex: 'use_time',
|
||||
width: 80,
|
||||
width: 90,
|
||||
align: 'right',
|
||||
render: (v) => (v ? `${v}s` : '-'),
|
||||
},
|
||||
@@ -696,82 +674,76 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
[t],
|
||||
);
|
||||
|
||||
// ========== 排行榜表格列 ==========
|
||||
// ========== 排行榜表格列(原型 90/200/190/150/160)==========
|
||||
const rankingColumns = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: '#',
|
||||
width: 60,
|
||||
render: (_, __, index) => {
|
||||
const rank = index + 1;
|
||||
const gradient = rankColors[rank];
|
||||
return gradient ? (
|
||||
<div
|
||||
className={`inline-flex items-center justify-center w-7 h-7 rounded-full bg-gradient-to-br ${gradient} text-white text-xs font-bold shadow-sm`}
|
||||
>
|
||||
{rank}
|
||||
</div>
|
||||
) : (
|
||||
<div className='inline-flex items-center justify-center w-7 h-7 rounded-full bg-gray-200 dark:bg-neutral-700 text-gray-600 dark:text-gray-300 text-xs font-medium'>
|
||||
{rank}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
title: t('排名'),
|
||||
width: 90,
|
||||
render: (_, __, index) => (
|
||||
<span className={`oc-exp-rank oc-exp-rank-${index + 1}`}>
|
||||
{index + 1}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('成员'),
|
||||
dataIndex: 'username',
|
||||
width: 160,
|
||||
render: (v, record) => (
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='w-7 h-7 rounded-full bg-brand/10 text-brand flex items-center justify-center text-xs font-semibold flex-shrink-0'>
|
||||
{(record.display_name || v || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<span className='text-sm text-gray-700 dark:text-gray-300 truncate'>
|
||||
{record.display_name || v || '-'}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
width: 200,
|
||||
render: (v, record) => record.display_name || v || '-',
|
||||
},
|
||||
{
|
||||
title: t('消耗额度'),
|
||||
dataIndex: 'quota',
|
||||
width: 130,
|
||||
width: 190,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-orange-600 dark:text-orange-400 font-semibold text-sm'>
|
||||
{renderQuota(v, 6)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-exp-cost'>{renderQuota(v, 6)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('请求数'),
|
||||
dataIndex: 'requests',
|
||||
width: 100,
|
||||
width: 150,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{formatNumber(v)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-number'>{formatNumber(v)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('Token 数'),
|
||||
dataIndex: 'tokens',
|
||||
width: 120,
|
||||
width: 160,
|
||||
align: 'right',
|
||||
render: (v) => (
|
||||
<span className='text-sm text-gray-600 dark:text-gray-400'>
|
||||
{formatNumber(v)}
|
||||
</span>
|
||||
),
|
||||
render: (v) => <span className='oc-number'>{formatNumber(v)}</span>,
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
const statItems = [
|
||||
{
|
||||
key: 'quota',
|
||||
icon: Wallet,
|
||||
label: t('总消耗额度'),
|
||||
value: statLoading ? '...' : renderQuota(stat.quota, 2),
|
||||
},
|
||||
{
|
||||
key: 'rpm',
|
||||
icon: Zap,
|
||||
label: stat.has_time_range ? t('平均 RPM') : t('RPM(需选时间范围)'),
|
||||
value: statLoading ? '...' : stat.has_time_range ? String(stat.rpm) : '—',
|
||||
},
|
||||
{
|
||||
key: 'tpm',
|
||||
icon: BarChart3,
|
||||
label: stat.has_time_range ? t('平均 TPM') : t('TPM(需选时间范围)'),
|
||||
value: statLoading
|
||||
? '...'
|
||||
: stat.has_time_range
|
||||
? formatNumber(stat.tpm)
|
||||
: '—',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
{/* 标题栏 */}
|
||||
<OrgPageHeader
|
||||
title={canViewTeamUsage ? t('消耗明细') : t('我的消耗明细')}
|
||||
@@ -782,16 +754,107 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
? t('查看所负责部门成员的 API 消耗记录')
|
||||
: t('查看自己的 API 调用明细')
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 统计卡片(原型 .eex-stats) */}
|
||||
<div className='oc-exp-stats'>
|
||||
{statItems.map(({ key, icon: Icon, label, value }, i) => (
|
||||
<AntCard key={key} className={`oc-exp-stat oc-exp-stat-${i}`}>
|
||||
<span className='oc-exp-stat-icon'>
|
||||
<Icon size={20} />
|
||||
</span>
|
||||
<div>
|
||||
<span>{label}</span>
|
||||
<strong>{value}</strong>
|
||||
</div>
|
||||
</AntCard>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 页签:明细日志 / 成员排行(原型 platform-list-tabs,只切换下方表格) */}
|
||||
<AntTabs
|
||||
className='oc-list-tabs oc-tabs-nav-only'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'logs', label: t('明细日志') },
|
||||
...(canViewTeamUsage
|
||||
? [{ key: 'ranking', label: t('成员排行') }]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* 筛选栏(原型 .ee-filter-card / .eex-filter-grid) */}
|
||||
<OrgFilterCard
|
||||
className='oc-exp-filter'
|
||||
actions={
|
||||
<>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<Button
|
||||
icon={<Download size={14} />}
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('成员')}>
|
||||
{canViewTeamUsage ? (
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
/>
|
||||
) : (
|
||||
<div className='oc-exp-self'>{t('仅本人')}</div>
|
||||
)}
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('时间范围')}>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('模型名称')}>
|
||||
<Input
|
||||
placeholder={t('请输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={activeTab === 'ranking' ? t('成员排行') : t('明细日志')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={() => setExportModalVisible(true)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => handleSearch(true)}
|
||||
loading={loading}
|
||||
>
|
||||
@@ -799,121 +862,43 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
<div className='grid grid-cols-1 sm:grid-cols-3 gap-3 mb-4'>
|
||||
<StatCard
|
||||
compact
|
||||
tone='brand'
|
||||
icon={Coins}
|
||||
label={t('总消耗额度')}
|
||||
value={statLoading ? '...' : renderQuota(stat.quota, 2)}
|
||||
/>
|
||||
<StatCard
|
||||
compact
|
||||
tone='rose'
|
||||
icon={Zap}
|
||||
label={stat.has_time_range ? t('平均 RPM') : t('RPM(需选时间范围)')}
|
||||
value={
|
||||
statLoading ? '...' : stat.has_time_range ? String(stat.rpm) : '—'
|
||||
}
|
||||
/>
|
||||
<StatCard
|
||||
compact
|
||||
tone='sky'
|
||||
icon={Activity}
|
||||
label={stat.has_time_range ? t('平均 TPM') : t('TPM(需选时间范围)')}
|
||||
value={
|
||||
statLoading
|
||||
? '...'
|
||||
: stat.has_time_range
|
||||
? formatNumber(stat.tpm)
|
||||
: '—'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 筛选栏 */}
|
||||
<div className='flex flex-wrap items-end gap-3 mb-4 p-4 rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-xs)]'>
|
||||
{canViewTeamUsage ? (
|
||||
<div className='min-w-[160px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('成员')}
|
||||
</div>
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: 180 }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className='min-w-[160px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('成员')}
|
||||
</div>
|
||||
<div className='h-8 px-3 inline-flex items-center rounded-md border border-gray-200 dark:border-neutral-700 bg-gray-50/80 dark:bg-neutral-800/70 text-sm text-gray-600 dark:text-gray-300'>
|
||||
{t('仅本人')}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className='min-w-[280px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('时间范围')}
|
||||
</div>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
density='compact'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: 320 }}
|
||||
/>
|
||||
</div>
|
||||
<div className='min-w-[140px]'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1'>
|
||||
{t('模型名称')}
|
||||
</div>
|
||||
<Input
|
||||
placeholder={t('输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
style={{ width: 180 }}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
theme='solid'
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
{activeTab === 'ranking' && canViewTeamUsage ? (
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
pagination={false}
|
||||
scroll={{ x: 790 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Trophy
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无排行数据')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Tabs: 明细日志 / 成员排行 */}
|
||||
<div className='rounded-xl border border-[var(--border-subtle)] bg-[var(--surface-card)] shadow-[var(--elevation-xs)] p-4'>
|
||||
<Tabs activeKey={activeTab} onChange={setActiveTab}>
|
||||
<TabPane tab={t('明细日志')} itemKey='logs'>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
columns={logColumns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1285 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
@@ -929,34 +914,8 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
{canViewTeamUsage && (
|
||||
<TabPane tab={t('成员排行')} itemKey='ranking'>
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
pagination={false}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Trophy
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无排行数据')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</TabPane>
|
||||
)}
|
||||
</Tabs>
|
||||
</div>
|
||||
</OrgListCard>
|
||||
|
||||
{/* 导出弹窗:汇总 / 按用户 + 字段选择 */}
|
||||
<OrgModal
|
||||
|
||||
@@ -33,13 +33,13 @@ import {
|
||||
RefreshCw,
|
||||
UserPlus,
|
||||
Upload as UploadIcon,
|
||||
KeyRound,
|
||||
IdCard,
|
||||
} from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import DeptTreeSelect from './components/DeptTreeSelect';
|
||||
import {
|
||||
@@ -383,16 +383,15 @@ const OrgMemberAccounts = ({
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
width: 260,
|
||||
render: (_, r) => {
|
||||
const managed = r.created_by_org_id === r.organization_id;
|
||||
const canReset = managed || isSuperAdmin;
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
<OrgRowActions>
|
||||
{deptEnabled && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setDeptAssignFor(r);
|
||||
setDeptAssignVal(r.department_id || 0);
|
||||
@@ -413,22 +412,11 @@ const OrgMemberAccounts = ({
|
||||
}
|
||||
onConfirm={() => resetPassword(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<KeyRound size={14} />}
|
||||
>
|
||||
{t('重置密码')}
|
||||
</Button>
|
||||
<Button type='link'>{t('重置密码')}</Button>
|
||||
</Popconfirm>
|
||||
) : (
|
||||
<Tooltip content={t('个人平台账号,请由本人通过找回密码修改')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
disabled
|
||||
icon={<KeyRound size={14} />}
|
||||
>
|
||||
<Button type='link' disabled>
|
||||
{t('重置密码')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
@@ -441,25 +429,32 @@ const OrgMemberAccounts = ({
|
||||
)}
|
||||
onConfirm={() => offboard(r.id)}
|
||||
>
|
||||
<Button size='small' theme='light' type='danger'>
|
||||
<Button type='link' danger>
|
||||
{t('离职回收')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 原型员工列表工具区:刷新 / 新建员工(主按钮)/ CSV 导入;回调不变
|
||||
const actions = (
|
||||
<>
|
||||
<Button theme='light' icon={<RefreshCw size={14} />} onClick={fetchAll}>
|
||||
<Button icon={<RefreshCw size={16} />} onClick={fetchAll}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<UploadIcon size={14} />}
|
||||
theme='solid'
|
||||
icon={<UserPlus size={16} />}
|
||||
onClick={() => setCreateVisible(true)}
|
||||
>
|
||||
{t('创建员工账号')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<UploadIcon size={16} />}
|
||||
onClick={() => {
|
||||
setImportResult(null);
|
||||
setImportFile(null);
|
||||
@@ -468,38 +463,12 @@ const OrgMemberAccounts = ({
|
||||
>
|
||||
{t('CSV 导入')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<UserPlus size={14} />}
|
||||
onClick={() => setCreateVisible(true)}
|
||||
>
|
||||
{t('创建员工账号')}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={embedded ? 'space-y-4' : 'uc-page'}>
|
||||
{embedded ? (
|
||||
<div className='flex items-start justify-between gap-3 flex-wrap rounded-2xl border border-dashed border-brand/25 bg-brand/5 p-4 dark:border-brand/25 dark:bg-brand/10'>
|
||||
<div className='flex items-start gap-3'>
|
||||
<span className='inline-flex h-10 w-10 items-center justify-center rounded-2xl bg-white text-brand-deep shadow-sm dark:bg-white/10 dark:text-brand-from'>
|
||||
<IdCard size={18} />
|
||||
</span>
|
||||
<div>
|
||||
<div className='font-semibold text-gray-950 dark:text-white'>
|
||||
{t('员工账号')}
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('集中管理员工登录、批量导入、重置密码与离职回收')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2 flex-wrap justify-end'>
|
||||
{actions}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className={embedded ? 'oc-member-accounts' : 'uc-page'}>
|
||||
{!embedded && (
|
||||
<OrgPageHeader
|
||||
icon={IdCard}
|
||||
title={t('员工账号')}
|
||||
@@ -518,6 +487,21 @@ const OrgMemberAccounts = ({
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{embedded ? (
|
||||
<OrgListCard title={t('员工账号')} tools={actions}>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
rowKey='id'
|
||||
/>
|
||||
</OrgListCard>
|
||||
) : (
|
||||
<OrgPanel padding='p-2'>
|
||||
<Table
|
||||
columns={columns}
|
||||
@@ -527,6 +511,7 @@ const OrgMemberAccounts = ({
|
||||
rowKey='id'
|
||||
/>
|
||||
</OrgPanel>
|
||||
)}
|
||||
|
||||
{/* 创建账号 */}
|
||||
<OrgModal
|
||||
|
||||
@@ -18,17 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Users,
|
||||
Trash2,
|
||||
Settings,
|
||||
Ban,
|
||||
CheckCircle,
|
||||
RefreshCw,
|
||||
Layers,
|
||||
Pencil,
|
||||
ShieldCheck,
|
||||
} from 'lucide-react';
|
||||
import { Users, RefreshCw, Layers, Pencil, ShieldCheck } from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -38,8 +28,6 @@ import {
|
||||
Popconfirm,
|
||||
Toast,
|
||||
Tooltip,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Switch,
|
||||
} from '@/components/ui';
|
||||
import { useOrgMembers } from '../../hooks/org/useOrgMembers';
|
||||
@@ -48,6 +36,8 @@ import { renderQuota } from '../../helpers/render';
|
||||
import QuotaInput from '../../components/common/ui/QuotaInput';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { Alert as AntAlert, Tabs as AntTabs } from 'antd';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import OrgMemberAccounts from './OrgMemberAccounts';
|
||||
|
||||
@@ -323,46 +313,22 @@ const OrgMembers = ({
|
||||
[editingRemarkValue, updateMemberRemark, updateMemberInList, t],
|
||||
);
|
||||
|
||||
// 格式化加入时间
|
||||
// 格式化加入时间:原型显示绝对日期 YYYY/MM/DD(同一时间戳,仅格式化方式变化)
|
||||
const formatJoinTime = (timestamp) => {
|
||||
if (!timestamp) return '-';
|
||||
const date = new Date(timestamp * 1000);
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays === 0) return t('今天');
|
||||
if (diffDays === 1) return t('昨天');
|
||||
if (diffDays < 30) return `${diffDays} ${t('天前')}`;
|
||||
|
||||
return date.toLocaleDateString('zh-CN', {
|
||||
return new Date(timestamp * 1000).toLocaleDateString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
const memberColumns = [
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'display_name',
|
||||
width: 240,
|
||||
render: (text, record) => {
|
||||
// 列与渲染对齐原型 EnterpriseEmployees:首列 / 操作列固定,状态用 Switch(onChange 走原 handleStatusChange),
|
||||
// 备注独立成列(沿用原就地编辑交互),操作为 link 按钮
|
||||
const renderRemark = (record) => {
|
||||
const isEditingRemark = editingRemarkId === record.id;
|
||||
if (canWrite && isEditingRemark) {
|
||||
return (
|
||||
<div className='flex items-center gap-2.5'>
|
||||
<div className='flex-shrink-0 w-8 h-8 rounded-full bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center text-white text-xs font-bold'>
|
||||
{(text || record.username || '?').charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div className='min-w-0 flex-1'>
|
||||
<div className='font-medium text-gray-900 dark:text-white truncate'>
|
||||
{text || record.username}
|
||||
</div>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 truncate'>
|
||||
{record.email}
|
||||
</div>
|
||||
{/* 备注区域 */}
|
||||
{canWrite && isEditingRemark ? (
|
||||
<Input
|
||||
size='small'
|
||||
value={editingRemarkValue}
|
||||
@@ -370,7 +336,6 @@ const OrgMembers = ({
|
||||
placeholder={t('Enter 保存,Esc 取消')}
|
||||
maxLength={100}
|
||||
autoFocus
|
||||
style={{ marginTop: 4 }}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
@@ -383,14 +348,16 @@ const OrgMembers = ({
|
||||
}}
|
||||
onBlur={() => handleRemarkSave(record.id)}
|
||||
/>
|
||||
) : canWrite ? (
|
||||
<Tooltip
|
||||
content={
|
||||
record.remark ? t('点击编辑备注') : t('点击添加备注')
|
||||
);
|
||||
}
|
||||
if (canWrite) {
|
||||
return (
|
||||
<Tooltip
|
||||
content={record.remark ? t('点击编辑备注') : t('点击添加备注')}
|
||||
>
|
||||
<div
|
||||
className='flex items-center gap-1 mt-0.5 cursor-pointer'
|
||||
<button
|
||||
type='button'
|
||||
className='oc-member-remark'
|
||||
onClick={() => {
|
||||
const current = record.remark || '';
|
||||
editingRemarkIdRef.current = record.id;
|
||||
@@ -399,40 +366,47 @@ const OrgMembers = ({
|
||||
setEditingRemarkValue(current);
|
||||
}}
|
||||
>
|
||||
<Pencil
|
||||
size={10}
|
||||
className='text-gray-300 dark:text-gray-500 flex-shrink-0'
|
||||
/>
|
||||
{record.remark ? (
|
||||
<span className='text-xs text-amber-600 dark:text-amber-400 truncate max-w-[160px]'>
|
||||
{record.remark}
|
||||
</span>
|
||||
<span>{record.remark}</span>
|
||||
) : (
|
||||
<span className='text-xs text-gray-300 dark:text-gray-500 italic'>
|
||||
{t('添加备注')}
|
||||
</span>
|
||||
<span className='oc-muted'>{t('添加备注')}</span>
|
||||
)}
|
||||
</div>
|
||||
<Pencil size={12} aria-hidden />
|
||||
</button>
|
||||
</Tooltip>
|
||||
) : record.remark ? (
|
||||
<div className='text-xs text-amber-600 dark:text-amber-400 truncate mt-0.5'>
|
||||
{record.remark}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
}
|
||||
return record.remark || '-';
|
||||
};
|
||||
|
||||
const memberColumns = [
|
||||
{
|
||||
title: t('用户'),
|
||||
dataIndex: 'display_name',
|
||||
width: 180,
|
||||
fixed: 'left',
|
||||
render: (text, record) => (
|
||||
<div className='oc-member-identity'>
|
||||
<strong>{text || record.username}</strong>
|
||||
{record.email && <span>{record.email}</span>}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('角色'),
|
||||
dataIndex: 'role',
|
||||
width: 110,
|
||||
width: 150,
|
||||
render: (role, record) => {
|
||||
if (role === 'owner') return <Tag color='red'>{t('所有者')}</Tag>;
|
||||
if (role === 'owner')
|
||||
return (
|
||||
<Tag color='blue' bordered={false}>
|
||||
{t('所有者')}
|
||||
</Tag>
|
||||
);
|
||||
if (!canWrite) {
|
||||
return (
|
||||
<Tag
|
||||
bordered={false}
|
||||
color={
|
||||
role === 'admin'
|
||||
? 'blue'
|
||||
@@ -454,7 +428,7 @@ const OrgMembers = ({
|
||||
size='small'
|
||||
value={role}
|
||||
onChange={(v) => handleRoleChange(record.id, v)}
|
||||
style={{ width: 100 }}
|
||||
style={{ width: 120 }}
|
||||
>
|
||||
<Select.Option value='admin'>{t('Admin')}</Select.Option>
|
||||
<Select.Option value='dept_admin'>{t('Dept Admin')}</Select.Option>
|
||||
@@ -466,24 +440,18 @@ const OrgMembers = ({
|
||||
{
|
||||
title: t('已用额度'),
|
||||
dataIndex: 'used_quota',
|
||||
width: 100,
|
||||
render: (v) => (
|
||||
<span className='text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(v, 2)}
|
||||
</span>
|
||||
),
|
||||
width: 120,
|
||||
align: 'right',
|
||||
render: (v) => <span className='oc-number'>{renderQuota(v, 2)}</span>,
|
||||
},
|
||||
{
|
||||
title: t('额度上限'),
|
||||
dataIndex: 'quota_limit',
|
||||
width: 120,
|
||||
align: 'right',
|
||||
render: (v, record) => {
|
||||
if (!(v > 0)) {
|
||||
return (
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{t('不限')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-number'>{t('不限')}</span>;
|
||||
}
|
||||
const periodic = ['daily', 'weekly', 'monthly'].includes(
|
||||
record.quota_period,
|
||||
@@ -497,15 +465,11 @@ const OrgMembers = ({
|
||||
? t('每月')
|
||||
: t('终身·不重置');
|
||||
return (
|
||||
<div>
|
||||
<div className='text-gray-700 dark:text-gray-300'>
|
||||
{renderQuota(v, 2)}
|
||||
</div>
|
||||
<div
|
||||
className={`text-[11px] ${periodic ? 'text-gray-400 dark:text-gray-500' : 'text-amber-500'}`}
|
||||
>
|
||||
<div className='oc-member-limit'>
|
||||
<span className='oc-number'>{renderQuota(v, 2)}</span>
|
||||
<small className={periodic ? '' : 'is-lifetime'}>
|
||||
{periodLabel}
|
||||
</div>
|
||||
</small>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@@ -513,38 +477,27 @@ const OrgMembers = ({
|
||||
{
|
||||
title: t('模型限制'),
|
||||
dataIndex: 'model_limits_enabled',
|
||||
width: 90,
|
||||
render: (enabled, record) => (
|
||||
<span
|
||||
className={
|
||||
enabled
|
||||
? 'text-brand-deep dark:text-brand-from text-xs'
|
||||
: 'text-gray-400 dark:text-gray-500 text-xs'
|
||||
}
|
||||
>
|
||||
{enabled
|
||||
? `${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
: t('不限')}
|
||||
</span>
|
||||
width: 110,
|
||||
render: (enabled, record) =>
|
||||
enabled ? (
|
||||
`${record.model_limits.split(',').filter(Boolean).length} ${t('个模型')}`
|
||||
) : (
|
||||
<span className='oc-muted'>{t('不限')}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('分组'),
|
||||
dataIndex: 'groups',
|
||||
width: 120,
|
||||
width: 175,
|
||||
render: (_, record) => {
|
||||
const groups = parseMemberGroups(record);
|
||||
if (!groups.length) {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500'>
|
||||
{t('继承企业')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-muted'>{t('无(继承企业)')}</span>;
|
||||
}
|
||||
return (
|
||||
<div className='flex flex-wrap gap-1'>
|
||||
<div className='oc-tags'>
|
||||
{groups.map((g) => (
|
||||
<Tag key={g} size='small' color='blue'>
|
||||
<Tag key={g} color='blue' bordered={false}>
|
||||
{g}
|
||||
</Tag>
|
||||
))}
|
||||
@@ -552,25 +505,50 @@ const OrgMembers = ({
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('备注'),
|
||||
dataIndex: 'remark',
|
||||
width: 165,
|
||||
render: (_, record) => renderRemark(record),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 80,
|
||||
render: (status) => (
|
||||
<Tag color={status === 1 ? 'green' : 'red'}>
|
||||
{status === 1 ? t('正常') : t('禁用')}
|
||||
</Tag>
|
||||
),
|
||||
width: 92,
|
||||
render: (status, record) => {
|
||||
const locked = !canWrite || record.role === 'owner';
|
||||
return (
|
||||
<Tooltip
|
||||
content={
|
||||
record.role === 'owner'
|
||||
? t('所有者不可操作')
|
||||
: status === 1
|
||||
? t('禁用后该成员将无法使用企业资源')
|
||||
: t('启用该成员的企业访问权限')
|
||||
}
|
||||
>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={status === 1}
|
||||
checkedText={t('启用')}
|
||||
uncheckedText={t('禁用')}
|
||||
disabled={locked}
|
||||
aria-label={`${record.display_name || record.username || ''}${t('状态')}`}
|
||||
onChange={(checked) =>
|
||||
handleStatusChange(record.id, checked ? 1 : 2)
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('加入时间'),
|
||||
dataIndex: 'joined_at',
|
||||
width: 100,
|
||||
width: 125,
|
||||
render: (v) => (
|
||||
<Tooltip content={v ? new Date(v * 1000).toLocaleString('zh-CN') : '-'}>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 cursor-default'>
|
||||
{formatJoinTime(v)}
|
||||
</span>
|
||||
<span className='oc-number'>{formatJoinTime(v)}</span>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
@@ -580,23 +558,18 @@ const OrgMembers = ({
|
||||
if (canWrite) {
|
||||
memberColumns.push({
|
||||
title: t('操作'),
|
||||
width: 360,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
render: (_, record) => {
|
||||
if (record.role === 'owner') {
|
||||
return (
|
||||
<span className='text-xs text-gray-400 dark:text-gray-500 italic'>
|
||||
{t('所有者不可操作')}
|
||||
</span>
|
||||
);
|
||||
return <span className='oc-muted'>{t('所有者不可操作')}</span>;
|
||||
}
|
||||
const isSelf = Number(record.user_id) === currentUserId;
|
||||
return (
|
||||
<div className='flex items-center gap-1.5 flex-wrap'>
|
||||
<OrgRowActions>
|
||||
<Tooltip content={t('设置该成员的个人额度上限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Settings size={14} />}
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setQuotaMemberId(record.id);
|
||||
setQuotaMemberName(
|
||||
@@ -612,9 +585,7 @@ const OrgMembers = ({
|
||||
</Tooltip>
|
||||
<Tooltip content={t('设置该成员可用的模型范围')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Layers size={14} />}
|
||||
type='link'
|
||||
onClick={async () => {
|
||||
setModelLimitsMemberId(record.id);
|
||||
setModelLimitsMemberName(
|
||||
@@ -657,9 +628,7 @@ const OrgMembers = ({
|
||||
}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Layers size={14} />}
|
||||
type='link'
|
||||
disabled={isSelf}
|
||||
onClick={() => {
|
||||
if (isSelf) return;
|
||||
@@ -677,9 +646,7 @@ const OrgMembers = ({
|
||||
{orgRole === 'owner' && record.role === 'admin' && (
|
||||
<Tooltip content={t('设置该管理员的细粒度权限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<ShieldCheck size={14} />}
|
||||
type='link'
|
||||
onClick={() => {
|
||||
setPermMemberId(record.id);
|
||||
setPermMemberName(
|
||||
@@ -708,45 +675,17 @@ const OrgMembers = ({
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{record.status === 1 ? (
|
||||
<Tooltip content={t('禁用后该成员将无法使用企业资源')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='warning'
|
||||
icon={<Ban size={14} />}
|
||||
onClick={() => handleStatusChange(record.id, 2)}
|
||||
>
|
||||
{t('禁用')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip content={t('启用该成员的企业访问权限')}>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='primary'
|
||||
icon={<CheckCircle size={14} />}
|
||||
onClick={() => handleStatusChange(record.id, 1)}
|
||||
>
|
||||
{t('启用')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip content={t('从企业中移除该成员')}>
|
||||
<Popconfirm
|
||||
title={t('确定移除该成员?移除后该成员将失去企业访问权限。')}
|
||||
onConfirm={() => handleRemove(record.id)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
/>
|
||||
<Button type='link' danger>
|
||||
{t('移除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -754,27 +693,39 @@ const OrgMembers = ({
|
||||
|
||||
const memberListContent = (
|
||||
<>
|
||||
{/* 管理员提示:当只有一个成员时显示 */}
|
||||
{/* 管理员提示:当只有一个成员时显示(原型无此状态 → Ant Design Alert 默认样式) */}
|
||||
{canWrite &&
|
||||
!loading &&
|
||||
members.length === 1 &&
|
||||
members[0]?.role === 'owner' && (
|
||||
<div className='mb-4 p-4 rounded-2xl bg-amber-50/80 border border-amber-200/70 text-amber-900 dark:bg-amber-500/10 dark:border-amber-500/20 dark:text-amber-100'>
|
||||
<p className='text-sm'>
|
||||
💡{' '}
|
||||
{t(
|
||||
<AntAlert
|
||||
className='oc-block-gap'
|
||||
type='info'
|
||||
showIcon
|
||||
message={t(
|
||||
'当前企业仅有您一位成员。成员可使用企业代码自助加入,或由系统管理员创建成员账号后即可在此管理成员角色、额度上限和访问权限。',
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
/>
|
||||
)}
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
<OrgListCard
|
||||
title={t('员工列表')}
|
||||
tools={
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => fetch(page)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
columns={memberColumns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1500 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
@@ -790,49 +741,49 @@ const OrgMembers = ({
|
||||
pageSize: 20,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
icon={Users}
|
||||
title={t('员工管理')}
|
||||
subtitle={t('成员权限、额度配额与托管账号生命周期')}
|
||||
actions={
|
||||
showMemberList && (
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => fetch(page)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
{showMemberList && showAccounts ? (
|
||||
<OrgPanel>
|
||||
<Tabs type='button' activeKey={activeTab} onChange={setActiveTab}>
|
||||
<TabPane tab={t('员工权限')} itemKey='members'>
|
||||
<div className='pt-4'>{memberListContent}</div>
|
||||
</TabPane>
|
||||
<TabPane tab={t('员工账号')} itemKey='accounts'>
|
||||
<div className='pt-4'>
|
||||
// 原型 platform-list-tabs;原 Tabs 预渲染全部页签(lazyRender=false),员工账号页签保持随页面挂载
|
||||
<AntTabs
|
||||
className='oc-list-tabs'
|
||||
activeKey={activeTab}
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{
|
||||
key: 'members',
|
||||
label: t('员工权限'),
|
||||
forceRender: true,
|
||||
children: memberListContent,
|
||||
},
|
||||
{
|
||||
key: 'accounts',
|
||||
label: t('员工账号'),
|
||||
forceRender: true,
|
||||
children: (
|
||||
<OrgMemberAccounts
|
||||
orgId={orgId}
|
||||
orgRole={orgRole}
|
||||
embedded
|
||||
featureFlags={featureFlags}
|
||||
/>
|
||||
</div>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</OrgPanel>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : showMemberList ? (
|
||||
memberListContent
|
||||
) : showAccounts ? (
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { Button, Empty, Tag } from '@/components/ui';
|
||||
import { Button, Card, Empty, Tag, Typography } from 'antd';
|
||||
import { Cable, LockKeyhole } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers/api';
|
||||
@@ -26,8 +26,14 @@ import {
|
||||
PageGuideDrawer,
|
||||
PageGuideTrigger,
|
||||
} from '../../components/common/PageGuide';
|
||||
import './org-connectors.css';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import './org-my-capabilities.css';
|
||||
|
||||
const confirmationLabels = {
|
||||
never: '无需确认',
|
||||
write: '写操作前确认',
|
||||
always: '每次调用都确认',
|
||||
};
|
||||
|
||||
const OrgMyConnectors = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -109,33 +115,58 @@ const OrgMyConnectors = ({ orgId }) => {
|
||||
],
|
||||
});
|
||||
return (
|
||||
<main className='org-connector-page'>
|
||||
<header className='org-connector-hero'>
|
||||
<div>
|
||||
<OrgBreadcrumb current={t('我的业务系统授权')} />
|
||||
<h1>{t('我的业务系统授权')}</h1>
|
||||
<p>{t('查看专家在任务中可代表你调用的业务系统、方法和确认策略。')}</p>
|
||||
</div>
|
||||
<div className='org-connector-actions'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
</div>
|
||||
</header>
|
||||
<main className='uc-page org-capabilities-page'>
|
||||
<OrgPageHeader
|
||||
title={t('我的业务系统授权')}
|
||||
subtitle={t('查看专家在任务中可代表你调用的业务系统、方法和确认策略。')}
|
||||
actions={<PageGuideTrigger guide={guide} />}
|
||||
/>
|
||||
<PageGuideDrawer guide={guide} />
|
||||
{loadError ? (
|
||||
<Empty title={t('授权列表加载失败')} description={loadError} />
|
||||
) : items.length === 0 ? (
|
||||
<Card>
|
||||
<Empty
|
||||
title={t('当前没有 Connector 授权')}
|
||||
description={t('管理员发布授权并覆盖到你后会显示在这里。')}
|
||||
description={
|
||||
<>
|
||||
<Typography.Text>{t('授权列表加载失败')}</Typography.Text>
|
||||
<Typography.Paragraph type='secondary'>
|
||||
{loadError}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : items.length === 0 ? (
|
||||
<Card>
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
<>
|
||||
<Typography.Text>
|
||||
{t('当前没有 Connector 授权')}
|
||||
</Typography.Text>
|
||||
<Typography.Paragraph type='secondary'>
|
||||
{t('管理员发布授权并覆盖到你后会显示在这里。')}
|
||||
</Typography.Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : (
|
||||
<section className='org-connector-grid'>
|
||||
<section className='org-capability-grid'>
|
||||
{items.map((item) => (
|
||||
<article className='org-connector-card' key={item.grant.id}>
|
||||
<div className='org-connector-card-top'>
|
||||
<span className='org-connector-icon'>
|
||||
<Card className='org-capability-card' key={item.grant.id}>
|
||||
<div className='org-capability-card-head'>
|
||||
<span className='org-capability-icon'>
|
||||
<Cable size={20} />
|
||||
</span>
|
||||
<div className='org-capability-card-name'>
|
||||
<Typography.Title level={5}>
|
||||
{item.connector_name}
|
||||
</Typography.Title>
|
||||
<Typography.Text type='secondary'>
|
||||
{item.definition_name}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<Tag
|
||||
color={
|
||||
item.grant.access_level === 'write' ? 'orange' : 'green'
|
||||
@@ -144,23 +175,29 @@ const OrgMyConnectors = ({ orgId }) => {
|
||||
{item.grant.access_level}
|
||||
</Tag>
|
||||
</div>
|
||||
<h3>{item.connector_name}</h3>
|
||||
<p>{item.definition_name}</p>
|
||||
<div className='org-connector-tags'>
|
||||
<div className='org-capability-methods'>
|
||||
{item.methods.map((method) => (
|
||||
<Tag key={method}>{method}</Tag>
|
||||
))}
|
||||
</div>
|
||||
<p>
|
||||
<LockKeyhole size={14} /> {t('确认策略')}:{' '}
|
||||
{item.grant.confirmation_policy}
|
||||
</p>
|
||||
<div className='org-capability-confirmation'>
|
||||
<LockKeyhole size={14} aria-hidden='true' />
|
||||
<Typography.Text type='secondary'>
|
||||
{t('确认策略')}:{' '}
|
||||
{t(
|
||||
confirmationLabels[item.grant.confirmation_policy] ||
|
||||
item.grant.confirmation_policy,
|
||||
)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div className='org-capability-card-footer'>
|
||||
<Button disabled={!item.revocable}>
|
||||
{item.revocable
|
||||
? t('撤销个人委托')
|
||||
: t('企业服务账号由管理员管理')}
|
||||
</Button>
|
||||
</article>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
|
||||
@@ -18,25 +18,36 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Switch, Toast, Typography } from '@/components/ui';
|
||||
import { LockKeyhole } from 'lucide-react';
|
||||
import { Card, Empty, Switch, Tag, Tooltip, Typography } from 'antd';
|
||||
import { Toast } from '@/components/ui';
|
||||
import { Link2, LockKeyhole, Sparkles } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers';
|
||||
import {
|
||||
AssignmentModeTag,
|
||||
ScopeSourceBadge,
|
||||
SkillEmptyGuide,
|
||||
} from '../../components/skill';
|
||||
import {
|
||||
usePageGuide,
|
||||
PageGuideDrawer,
|
||||
PageGuideTrigger,
|
||||
} from '../../components/common/PageGuide';
|
||||
import './org-skills.css';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import './org-my-capabilities.css';
|
||||
|
||||
const { Title, Paragraph, Text } = Typography;
|
||||
|
||||
const modes = {
|
||||
required_locked: { label: '必需锁定', color: 'warning' },
|
||||
default_on: { label: '默认开启', color: 'processing' },
|
||||
recommended: { label: '推荐', color: 'success' },
|
||||
optional: { label: '可选', color: 'default' },
|
||||
};
|
||||
const scopes = {
|
||||
org: '企业',
|
||||
department: '部门',
|
||||
dept: '部门',
|
||||
project: '项目',
|
||||
role: '角色',
|
||||
member: '成员',
|
||||
};
|
||||
|
||||
const OrgMySkills = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const headers = useMemo(() => ({ 'X-Org-Id': String(orgId) }), [orgId]);
|
||||
@@ -114,67 +125,93 @@ const OrgMySkills = ({ orgId }) => {
|
||||
],
|
||||
});
|
||||
return (
|
||||
<main className='org-skills-page'>
|
||||
<header className='org-skills-hero'>
|
||||
<div>
|
||||
<OrgBreadcrumb current={t('我的技能')} />
|
||||
<Title heading={3}>{t('我的技能')}</Title>
|
||||
<Paragraph>
|
||||
{t(
|
||||
<main className='uc-page org-capabilities-page'>
|
||||
<OrgPageHeader
|
||||
title={t('我的技能')}
|
||||
subtitle={t(
|
||||
'这里展示与任务运行时相同的有效能力集,以及每项技能为什么对你生效。',
|
||||
)}
|
||||
</Paragraph>
|
||||
</div>
|
||||
<div className='org-skills-hero-actions'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
</div>
|
||||
</header>
|
||||
actions={<PageGuideTrigger guide={guide} />}
|
||||
/>
|
||||
<PageGuideDrawer guide={guide} />
|
||||
{items.length === 0 ? (
|
||||
<SkillEmptyGuide
|
||||
title={t('当前没有可用技能')}
|
||||
description={t('企业管理员启用并分发后会显示在这里。')}
|
||||
<Card>
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
<>
|
||||
<Text>{t('当前没有可用技能')}</Text>
|
||||
<Paragraph type='secondary'>
|
||||
{t('企业管理员启用并分发后会显示在这里。')}
|
||||
</Paragraph>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Card>
|
||||
) : (
|
||||
<section className='org-my-skills'>
|
||||
<section className='org-capability-grid'>
|
||||
{items
|
||||
.filter((item) => item.mode !== 'forbidden')
|
||||
.map((item) => {
|
||||
const locked = item.mode === 'required_locked';
|
||||
const mode = modes[item.mode] || {
|
||||
label: item.mode,
|
||||
color: 'default',
|
||||
};
|
||||
return (
|
||||
<article key={item.skill_id}>
|
||||
<div>
|
||||
<span className='org-my-skill-title'>
|
||||
{locked && <LockKeyhole size={16} />}
|
||||
<Text strong>
|
||||
{item.customization?.display_name || item.canonical_id}
|
||||
</Text>
|
||||
<AssignmentModeTag mode={item.mode} />
|
||||
<Card key={item.skill_id} className='org-capability-card'>
|
||||
<div className='org-capability-card-head'>
|
||||
<span className='org-capability-icon'>
|
||||
<Sparkles size={20} />
|
||||
</span>
|
||||
<Paragraph>
|
||||
<div className='org-capability-card-name'>
|
||||
<Title level={5}>
|
||||
{item.customization?.display_name || item.canonical_id}
|
||||
</Title>
|
||||
<Text type='secondary'>v#{item.version_id}</Text>
|
||||
</div>
|
||||
<Tag
|
||||
color={mode.color}
|
||||
icon={locked ? <LockKeyhole size={12} /> : undefined}
|
||||
>
|
||||
{t(mode.label)}
|
||||
</Tag>
|
||||
</div>
|
||||
<Paragraph
|
||||
type='secondary'
|
||||
className='org-capability-description'
|
||||
>
|
||||
{item.customization?.description_zh ||
|
||||
item.customization?.usage_boundary ||
|
||||
t('企业已审核的方法能力')}
|
||||
</Paragraph>
|
||||
<div className='org-my-skill-sources'>
|
||||
<div className='org-capability-sources'>
|
||||
{(item.sources || []).map((source) => (
|
||||
<ScopeSourceBadge
|
||||
<Tooltip
|
||||
key={source.id}
|
||||
source={`${source.scope_type}:${source.scope_id || source.scope_value || 'all'}`}
|
||||
detail={`${source.mode} / ${source.activation}`}
|
||||
/>
|
||||
title={`${t(modes[source.mode]?.label || source.mode)} / ${source.activation}`}
|
||||
>
|
||||
<Tag icon={<Link2 size={12} />}>
|
||||
{t(scopes[source.scope_type] || source.scope_type)} ·{' '}
|
||||
{source.scope_id || source.scope_value || t('全部')}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Text type='tertiary'>v#{item.version_id}</Text>
|
||||
<div className='org-capability-card-footer'>
|
||||
<Text type='secondary'>
|
||||
{t(item.enabled ? '已启用' : '已停用')}
|
||||
</Text>
|
||||
<Switch
|
||||
aria-label={
|
||||
item.customization?.display_name || item.canonical_id
|
||||
}
|
||||
disabled={locked}
|
||||
checked={item.enabled}
|
||||
onChange={(enabled) => choose(item, enabled)}
|
||||
/>
|
||||
</div>
|
||||
</article>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
|
||||
@@ -19,22 +19,14 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
Button,
|
||||
InputNumber,
|
||||
Spin,
|
||||
Tabs,
|
||||
TabPane,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import {
|
||||
Bell,
|
||||
Building2,
|
||||
KeyRound,
|
||||
Pencil,
|
||||
UserRound,
|
||||
UserCog,
|
||||
Wallet,
|
||||
} from 'lucide-react';
|
||||
Avatar as AntAvatar,
|
||||
Card as AntCard,
|
||||
Progress as AntProgress,
|
||||
Tabs as AntTabs,
|
||||
Tag as AntTag,
|
||||
} from 'antd';
|
||||
import { Button, InputNumber, Spin, Typography } from '@/components/ui';
|
||||
import { UserCog } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import {
|
||||
showError,
|
||||
@@ -44,13 +36,16 @@ import {
|
||||
USER_AVATAR_TYPES,
|
||||
getAvatarPresetById,
|
||||
getDefaultAvatarPresetId,
|
||||
getUserAvatarUrl,
|
||||
} from '../../helpers';
|
||||
import { renderQuota } from '../../helpers/render';
|
||||
import { UserContext } from '../../context/User';
|
||||
import NotifyChannelForm from '../../components/settings/NotifyChannelForm';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import OrgAvatarSection from './components/OrgAvatarSection';
|
||||
import AvatarSection from '../../components/settings/personal/sections/AvatarSection';
|
||||
import SectionHeader from '../../components/settings/personal/components/SectionHeader';
|
||||
import '../../components/settings/personal/personal-settings.css';
|
||||
import '../../styles/org-center.css';
|
||||
import OrgNicknameModal from './components/OrgNicknameModal';
|
||||
import OrgPasswordModal from './components/OrgPasswordModal';
|
||||
|
||||
@@ -82,20 +77,6 @@ const quotaPeriodHint = (t, period) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 信息行:label + 右侧内容(个人资料/企业身份卡片共用)
|
||||
const InfoRow = ({ label, children, last = false }) => (
|
||||
<div
|
||||
className={`flex items-center justify-between gap-3 py-3 ${
|
||||
last ? '' : 'border-b border-[var(--border-subtle)]'
|
||||
}`}
|
||||
>
|
||||
<Text type='tertiary' className='flex-shrink-0'>
|
||||
{label}
|
||||
</Text>
|
||||
<div className='flex items-center gap-2 min-w-0'>{children}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
/*
|
||||
* 成员个人设置页(/org/personal-settings,全员可见)。
|
||||
* 企业中心是独立空间:改密/昵称走企业端接口,通知为企业维度的成员配额预警,
|
||||
@@ -302,8 +283,12 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
),
|
||||
);
|
||||
// 进度条随用量升温:正常品牌色,≥80% 转琥珀,≥95% 转红,给成员用尽预警
|
||||
const quotaBarClass =
|
||||
usedPct >= 95 ? 'bg-red-500' : usedPct >= 80 ? 'bg-amber-500' : 'bg-brand';
|
||||
const quotaBarColor =
|
||||
usedPct >= 95
|
||||
? 'var(--ui-color-danger)'
|
||||
: usedPct >= 80
|
||||
? 'var(--ui-color-warning)'
|
||||
: 'var(--oc-brand)';
|
||||
const displayName =
|
||||
member.display_name ||
|
||||
userState?.user?.display_name ||
|
||||
@@ -318,142 +303,81 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<OrgPageHeader
|
||||
icon={UserCog}
|
||||
title={t('个人设置')}
|
||||
subtitle={t('管理你的头像、昵称、密码与通知偏好')}
|
||||
/>
|
||||
|
||||
<Tabs type='line' className='mt-2'>
|
||||
<TabPane tab={t('个人资料')} itemKey='profile'>
|
||||
{/* 头像设置上移至页面上半部分,作为视觉锚点,保存走企业端接口 */}
|
||||
<div className='mt-4'>
|
||||
<OrgAvatarSection
|
||||
t={t}
|
||||
userState={userState}
|
||||
avatarSettings={avatarSettings}
|
||||
handleAvatarSettingChange={handleAvatarSettingChange}
|
||||
saveAvatarSettings={saveAvatarSettings}
|
||||
saving={savingAvatar}
|
||||
// 个人资料页签(原型 profile 面板):昵称 / 密码设置行 + 个人配额卡;企业身份信息归入资料头卡
|
||||
const profilePanel = (
|
||||
<div className='oc-ps-panel'>
|
||||
<SectionHeader
|
||||
title={t('基本资料')}
|
||||
description={t('管理企业内展示的个人信息')}
|
||||
/>
|
||||
<div className='ui-settings-rows'>
|
||||
<div className='ui-settings-row'>
|
||||
<div className='ui-settings-row-text'>
|
||||
<h3>{t('昵称管理')}</h3>
|
||||
<p>
|
||||
{t('当前昵称:')}
|
||||
{displayName || t('未设置')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 基本资料 / 企业身份 / 个人配额:三栏均分,卡片等高,避免高度失衡 */}
|
||||
<div className='mt-4 grid grid-cols-1 lg:grid-cols-3 gap-4'>
|
||||
{/* 基本资料:昵称 + 登录密码(复用工作台同款弹窗与企业端接口) */}
|
||||
<OrgPanel title={t('基本资料')} icon={UserRound} padding='px-5 py-2'>
|
||||
<InfoRow label={t('昵称')}>
|
||||
<Text className='truncate'>{displayName || t('未设置')}</Text>
|
||||
<Button
|
||||
theme='light'
|
||||
size='small'
|
||||
icon={<Pencil size={13} />}
|
||||
onClick={() => setNickModal(true)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('登录密码')} last>
|
||||
<Text type='tertiary'>••••••••</Text>
|
||||
<Button
|
||||
theme='light'
|
||||
size='small'
|
||||
icon={<KeyRound size={13} />}
|
||||
onClick={() => setPwdModal(true)}
|
||||
>
|
||||
{t('修改密码')}
|
||||
</Button>
|
||||
</InfoRow>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 企业身份只读信息(数据源 /api/org/me/summary,与工作台一致) */}
|
||||
<OrgPanel title={t('企业身份')} icon={Building2} padding='px-5 py-2'>
|
||||
<InfoRow label={t('所属企业')}>
|
||||
<Text className='truncate'>
|
||||
{summary?.organization?.name || '-'}
|
||||
</Text>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('我的角色')}>
|
||||
<span className='inline-flex items-center rounded-full bg-brand/10 text-brand px-2.5 py-0.5 text-xs font-medium'>
|
||||
{roleLabel(t, member.role)}
|
||||
</span>
|
||||
</InfoRow>
|
||||
<InfoRow label={t('所属部门')} last>
|
||||
<Text className='truncate'>
|
||||
{member.department_name || t('未分配')}
|
||||
</Text>
|
||||
</InfoRow>
|
||||
</OrgPanel>
|
||||
|
||||
{/* 个人配额:成员高频关注项,抽成带进度条的重点块 */}
|
||||
<OrgPanel title={t('个人配额')} icon={Wallet} padding='p-5'>
|
||||
<div className='ui-settings-row-actions'>
|
||||
<Button onClick={() => setNickModal(true)}>{t('修改昵称')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className='ui-settings-row'>
|
||||
<div className='ui-settings-row-text'>
|
||||
<h3>{t('密码管理')}</h3>
|
||||
<p>{t('定期更改密码可以提高账户安全性')}</p>
|
||||
</div>
|
||||
<div className='ui-settings-row-actions'>
|
||||
<Button onClick={() => setPwdModal(true)}>{t('修改密码')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='oc-ps-info-grid'>
|
||||
<AntCard size='small' title={t('个人配额')}>
|
||||
{quotaLimit > 0 ? (
|
||||
<div>
|
||||
<div className='flex items-end justify-between gap-3'>
|
||||
<div className='min-w-0'>
|
||||
<div className='text-xs text-[var(--text-secondary)]'>
|
||||
{t('剩余可用')}
|
||||
<>
|
||||
<div className='oc-ps-quota'>
|
||||
<span>{t('剩余可用')}</span>
|
||||
<strong>{renderQuota(remainQuota)}</strong>
|
||||
</div>
|
||||
<div className='mt-0.5 text-2xl font-semibold text-[var(--text-primary)] truncate'>
|
||||
{renderQuota(remainQuota)}
|
||||
</div>
|
||||
</div>
|
||||
<div className='shrink-0 text-right text-xs text-gray-500 dark:text-gray-400 leading-relaxed'>
|
||||
<div>
|
||||
{t('已用')} {renderQuota(usedQuota)}
|
||||
</div>
|
||||
<div>
|
||||
{t('总额')} {renderQuota(quotaLimit)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='mt-3 h-2 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-white/[0.08]'>
|
||||
<div
|
||||
className={`h-full rounded-full transition-all duration-300 ${quotaBarClass}`}
|
||||
style={{ width: `${usedPct}%` }}
|
||||
<AntProgress
|
||||
percent={usedPct}
|
||||
showInfo={false}
|
||||
strokeColor={quotaBarColor}
|
||||
/>
|
||||
</div>
|
||||
<div className='mt-2 flex items-center justify-between text-xs'>
|
||||
<span className='text-gray-500 dark:text-gray-400'>
|
||||
{t('已用')} {usedPct}%
|
||||
<div className='oc-ps-quota-meta'>
|
||||
<span>
|
||||
{t('已用')} {renderQuota(usedQuota)} / {t('总额')}{' '}
|
||||
{renderQuota(quotaLimit)}({usedPct}%)
|
||||
</span>
|
||||
{isPeriodic && (
|
||||
<span className='text-brand font-medium'>
|
||||
{quotaPeriodHint(t, myQuota.quota_period)}
|
||||
</span>
|
||||
<span>{quotaPeriodHint(t, myQuota.quota_period)}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className='flex items-center gap-2 py-1.5'>
|
||||
<span className='inline-flex items-center rounded-full bg-brand/10 text-brand px-2.5 py-0.5 text-xs font-medium'>
|
||||
<div className='oc-ps-unlimited'>
|
||||
<AntTag color='gold' bordered={false}>
|
||||
{t('不限额')}
|
||||
</span>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('企业未对你设置配额上限')}
|
||||
</Text>
|
||||
</AntTag>
|
||||
<span>{t('企业未对你设置配额上限')}</span>
|
||||
</div>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</AntCard>
|
||||
</div>
|
||||
</TabPane>
|
||||
</div>
|
||||
);
|
||||
|
||||
<TabPane
|
||||
tab={t('通知设置')}
|
||||
itemKey='notify'
|
||||
disabled={isSuperAdminView}
|
||||
>
|
||||
<OrgPanel
|
||||
// 通知设置页签(原型 notice 面板):渠道表单 + 预警阈值;保存回调不变
|
||||
const notifyPanel = (
|
||||
<div className='oc-ps-panel'>
|
||||
<SectionHeader
|
||||
title={t('配额预警通知')}
|
||||
subtitle={t(
|
||||
description={t(
|
||||
'企业分配给你的额度即将用尽或已用尽时,通过以下渠道提醒你',
|
||||
)}
|
||||
icon={Bell}
|
||||
padding='p-5'
|
||||
className='mt-4'
|
||||
actions={
|
||||
extra={
|
||||
<Button
|
||||
theme='solid'
|
||||
loading={savingNotify}
|
||||
@@ -462,18 +386,16 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
{t('保存通知设置')}
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
/>
|
||||
<div className='oc-ps-notice-form'>
|
||||
<NotifyChannelForm
|
||||
value={notifyValue}
|
||||
onChange={setNotifyValue}
|
||||
channels={['email', 'webhook']}
|
||||
emailPlaceholder={t('必填,用于接收预警通知')}
|
||||
/>
|
||||
|
||||
<div className='mt-5 pt-4 border-t border-[var(--border-subtle)]'>
|
||||
<label className='block text-sm font-medium text-[var(--text-primary)] mb-2'>
|
||||
{t('预警阈值')}
|
||||
</label>
|
||||
<div className='oc-ps-threshold'>
|
||||
<label>{t('预警阈值')}</label>
|
||||
{quotaLimit > 0 ? (
|
||||
<>
|
||||
<InputNumber
|
||||
@@ -483,14 +405,12 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
step={1000}
|
||||
style={{ width: '100%', maxWidth: 260 }}
|
||||
/>
|
||||
<div className='mt-2'>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('剩余额度低于该值时提醒,0 表示关闭')}
|
||||
{Number(alertThreshold) > 0 &&
|
||||
` · ${t('约合')} ${renderQuota(Number(alertThreshold))}`}
|
||||
{` · ${t('当前剩余')} ${renderQuota(remainQuota)}`}
|
||||
</Text>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Text type='tertiary'>
|
||||
@@ -498,9 +418,94 @@ const OrgPersonalSettings = ({ orgId }) => {
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
</OrgPanel>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page oc-page ui-personal-settings oc-personal-settings'>
|
||||
<OrgPageHeader
|
||||
icon={UserCog}
|
||||
title={t('个人设置')}
|
||||
subtitle={t('管理你的头像、昵称、密码与通知偏好')}
|
||||
/>
|
||||
|
||||
{/* 资料头卡(原型 .ps-profile):头像 / 昵称 / 角色 / 企业 · 部门 + 配额概览,数据源 /api/org/me/summary */}
|
||||
<AntCard className='ui-personal-profile'>
|
||||
<div className='ui-profile-identity'>
|
||||
<span className='ui-profile-avatar'>
|
||||
<AntAvatar
|
||||
shape='square'
|
||||
size={54}
|
||||
src={getUserAvatarUrl(userState?.user)}
|
||||
>
|
||||
{(displayName || '?').slice(0, 2).toUpperCase()}
|
||||
</AntAvatar>
|
||||
</span>
|
||||
<div className='ui-profile-meta'>
|
||||
<div className='ui-profile-name'>
|
||||
<strong>{displayName || t('未设置')}</strong>
|
||||
<AntTag color='gold' bordered={false}>
|
||||
{roleLabel(t, member.role)}
|
||||
</AntTag>
|
||||
</div>
|
||||
<div className='ui-profile-sub'>
|
||||
<span>{summary?.organization?.name || '-'}</span>
|
||||
<span aria-hidden='true'>·</span>
|
||||
<span>{member.department_name || t('部门未分配')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='ui-profile-stats'>
|
||||
<div>
|
||||
<span>{t('剩余配额')}</span>
|
||||
<strong>
|
||||
{quotaLimit > 0 ? renderQuota(remainQuota) : t('不限额')}
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('已用额度')}</span>
|
||||
<strong>{renderQuota(usedQuota)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</AntCard>
|
||||
|
||||
{/* 设置卡(原型 .ps-workspace):头像设置 / 个人资料 / 通知设置 */}
|
||||
<AntCard className='ui-personal-content'>
|
||||
<AntTabs
|
||||
defaultActiveKey='avatar'
|
||||
items={[
|
||||
{
|
||||
key: 'avatar',
|
||||
label: t('头像设置'),
|
||||
forceRender: true,
|
||||
children: (
|
||||
<AvatarSection
|
||||
t={t}
|
||||
userState={userState}
|
||||
avatarSettings={avatarSettings}
|
||||
handleAvatarSettingChange={handleAvatarSettingChange}
|
||||
saveAvatarSettings={saveAvatarSettings}
|
||||
savingAvatarSettings={savingAvatar}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'profile',
|
||||
label: t('个人资料'),
|
||||
forceRender: true,
|
||||
children: profilePanel,
|
||||
},
|
||||
{
|
||||
key: 'notify',
|
||||
label: t('通知设置'),
|
||||
disabled: isSuperAdminView,
|
||||
forceRender: true,
|
||||
children: notifyPanel,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</AntCard>
|
||||
|
||||
<OrgNicknameModal
|
||||
visible={nickModal}
|
||||
|
||||
@@ -18,6 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Switch } from 'antd';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
@@ -27,11 +28,11 @@ import {
|
||||
Tag,
|
||||
Select,
|
||||
} from '@/components/ui';
|
||||
import { RefreshCw, Plus, Users } from 'lucide-react';
|
||||
import { RefreshCw, Plus } from 'lucide-react';
|
||||
import { API } from '../../helpers/api';
|
||||
import { showError, collectPagedItems } from '../../helpers';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import OrgScopedLimitButtons from './components/OrgScopedLimitButtons';
|
||||
|
||||
@@ -42,6 +43,7 @@ const OrgProjects = ({ orgId }) => {
|
||||
const { t } = useTranslation();
|
||||
const [list, setList] = useState([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [updatingProjectId, setUpdatingProjectId] = useState(null);
|
||||
const [members, setMembers] = useState([]); // 企业全部成员(用于成员选择)
|
||||
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
@@ -53,7 +55,7 @@ const OrgProjects = ({ orgId }) => {
|
||||
const [addMemberIds, setAddMemberIds] = useState([]); // 支持一次添加多个成员
|
||||
const [addMemberRole, setAddMemberRole] = useState('project_member');
|
||||
|
||||
const [tokenModal, setTokenModal] = useState(null); // 当前管理令牌的项目
|
||||
const [tokenModal, setTokenModal] = useState(null); // 当前管理密钥的项目
|
||||
const [orgTokens, setOrgTokens] = useState([]);
|
||||
|
||||
const fetchList = useCallback(async () => {
|
||||
@@ -158,19 +160,34 @@ const OrgProjects = ({ orgId }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDisable = async (record) => {
|
||||
const handleStatusChange = async (record, enabled) => {
|
||||
if (updatingProjectId !== null) return;
|
||||
setUpdatingProjectId(record.id);
|
||||
try {
|
||||
const res = await API.delete(`/api/org/project/${record.id}`, {
|
||||
headers: getOrgHeaders(orgId),
|
||||
});
|
||||
const url = `/api/org/project/${record.id}`;
|
||||
const config = { headers: getOrgHeaders(orgId) };
|
||||
const res = enabled
|
||||
? await API.put(
|
||||
url,
|
||||
{ code: record.code, name: record.name, status: 1 },
|
||||
config,
|
||||
)
|
||||
: await API.delete(url, config);
|
||||
if (res.data.success) {
|
||||
Toast.success(t('项目已停用'));
|
||||
fetchList();
|
||||
Toast.success(t('项目已更新'));
|
||||
setList((items) =>
|
||||
items.map((item) =>
|
||||
item.id === record.id ? { ...item, status: enabled ? 1 : 2 } : item,
|
||||
),
|
||||
);
|
||||
await fetchList();
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
} finally {
|
||||
setUpdatingProjectId(null);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -287,104 +304,116 @@ const OrgProjects = ({ orgId }) => {
|
||||
}));
|
||||
}, [members, projectMembers]);
|
||||
|
||||
// 列宽与渲染对齐原型 EnterpriseProjects(150/350/120/140/300,scroll.x 1060);
|
||||
const columns = [
|
||||
{ title: t('项目编码'), dataIndex: 'code' },
|
||||
{ title: t('项目名称'), dataIndex: 'name' },
|
||||
{
|
||||
title: t('项目编码'),
|
||||
dataIndex: 'code',
|
||||
width: 150,
|
||||
render: (v) => <span className='oc-number'>{v}</span>,
|
||||
},
|
||||
{ title: t('项目名称'), dataIndex: 'name', width: 350 },
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (v) => (
|
||||
<Tag color={v === 1 ? 'green' : 'grey'}>
|
||||
{v === 1 ? t('启用') : t('停用')}
|
||||
</Tag>
|
||||
width: 120,
|
||||
render: (v, record) => (
|
||||
<Popconfirm
|
||||
title={t('确认停用该项目?')}
|
||||
content={t('停用后保留历史,不再接受新调用绑定')}
|
||||
disabled={v !== 1 || updatingProjectId !== null}
|
||||
onConfirm={() => handleStatusChange(record, false)}
|
||||
>
|
||||
<Switch
|
||||
size='small'
|
||||
checked={v === 1}
|
||||
checkedChildren={t('启用')}
|
||||
unCheckedChildren={t('禁用')}
|
||||
aria-label={`${record.name} ${t('状态')}`}
|
||||
loading={updatingProjectId === record.id}
|
||||
disabled={updatingProjectId !== null}
|
||||
onChange={(checked) => {
|
||||
if (checked) handleStatusChange(record, true);
|
||||
}}
|
||||
/>
|
||||
</Popconfirm>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('到期时间'),
|
||||
dataIndex: 'expired_at',
|
||||
width: 120,
|
||||
width: 140,
|
||||
render: (v) => (v ? new Date(v * 1000).toLocaleDateString() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 420,
|
||||
width: 300,
|
||||
render: (_, record) => (
|
||||
<div className='flex items-center gap-2 flex-wrap'>
|
||||
<OrgRowActions>
|
||||
<OrgScopedLimitButtons
|
||||
orgId={orgId}
|
||||
record={record}
|
||||
apiBase='/api/org/project'
|
||||
scopeLabel='项目'
|
||||
onSaved={fetchList}
|
||||
variant='link'
|
||||
/>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
icon={<Users size={14} />}
|
||||
onClick={() => openMembers(record)}
|
||||
>
|
||||
<Button type='link' onClick={() => openMembers(record)}>
|
||||
{t('成员')}
|
||||
</Button>
|
||||
<Button size='small' theme='light' onClick={() => openTokens(record)}>
|
||||
{t('令牌')}
|
||||
<Button type='link' onClick={() => openTokens(record)}>
|
||||
{t('密钥')}
|
||||
</Button>
|
||||
<Button size='small' theme='light' onClick={() => openEdit(record)}>
|
||||
<Button type='link' onClick={() => openEdit(record)}>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
{record.status === 1 && (
|
||||
<Popconfirm
|
||||
title={t('确认停用该项目?')}
|
||||
content={t('停用后保留历史,不再接受新调用绑定')}
|
||||
onConfirm={() => handleDisable(record)}
|
||||
>
|
||||
<Button size='small' theme='light' type='danger'>
|
||||
{t('停用')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</div>
|
||||
</OrgRowActions>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page'>
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('项目管理')}
|
||||
subtitle={t('项目成员与项目预算')}
|
||||
actions={
|
||||
subtitle={t('管理项目成员、模型范围与密钥归属')}
|
||||
/>
|
||||
|
||||
<OrgListCard
|
||||
title={t('项目列表')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
theme='light'
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={fetchList}
|
||||
>
|
||||
<Button icon={<RefreshCw size={16} />} onClick={fetchList}>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
icon={<Plus size={14} />}
|
||||
icon={<Plus size={16} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建项目')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<OrgPanel padding='p-2'>
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
pagination={{ pageSize: 15, showSizeChanger: false }}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
}}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1060 }}
|
||||
/>
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
{/* 项目创建/编辑 */}
|
||||
<OrgModal
|
||||
className='oc-dialog'
|
||||
width={560}
|
||||
title={editing ? t('编辑项目') : t('新建项目')}
|
||||
visible={modalVisible}
|
||||
onOk={handleSubmit}
|
||||
@@ -420,6 +449,8 @@ const OrgProjects = ({ orgId }) => {
|
||||
|
||||
{/* 项目成员管理 */}
|
||||
<OrgModal
|
||||
className='oc-dialog oc-dialog-table'
|
||||
width={760}
|
||||
title={`${t('项目成员')} - ${memberModal?.name || ''}`}
|
||||
visible={!!memberModal}
|
||||
onCancel={() => setMemberModal(null)}
|
||||
@@ -489,17 +520,18 @@ const OrgProjects = ({ orgId }) => {
|
||||
/>
|
||||
</OrgModal>
|
||||
|
||||
{/* 项目令牌绑定 */}
|
||||
{/* 项目密钥绑定 */}
|
||||
<OrgModal
|
||||
title={`${t('项目令牌')} - ${tokenModal?.name || ''}`}
|
||||
className='oc-dialog oc-dialog-table'
|
||||
title={`${t('项目密钥')} - ${tokenModal?.name || ''}`}
|
||||
visible={!!tokenModal}
|
||||
onCancel={() => setTokenModal(null)}
|
||||
footer={null}
|
||||
width={560}
|
||||
width={760}
|
||||
>
|
||||
<Table
|
||||
columns={[
|
||||
{ title: t('令牌'), dataIndex: 'name' },
|
||||
{ title: t('密钥'), dataIndex: 'name' },
|
||||
{
|
||||
title: t('当前归属'),
|
||||
dataIndex: 'project_id',
|
||||
|
||||
@@ -118,7 +118,7 @@ const PromptCallDetails = ({ orgId, groupKey }) => {
|
||||
{calls.length >= 200 ? '+' : ''})
|
||||
<span className='ml-2 font-normal text-gray-400 dark:text-gray-500'>
|
||||
{t(
|
||||
'明细为该提示词的全部调用;跨 30 分钟统计桶或多令牌时,条数可能多于本行调用次数',
|
||||
'明细为该提示词的全部调用;跨 30 分钟统计桶或多密钥时,条数可能多于本行调用次数',
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user