Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a62c80aea1 | |||
| 06ef5f3f77 | |||
| cd6eae5ed9 | |||
| 7e89edda5b | |||
| 2c43dd9cb1 | |||
| 6e41115d40 | |||
| 1e7780bdce | |||
| 5a9d6ae3cb | |||
| 3a0d9e15cd | |||
| 04cf3324a3 | |||
| a811793825 | |||
| 9576ba674a | |||
| 870b51d054 | |||
| ed693a450a | |||
| 49515f4ef3 | |||
| f896495048 | |||
| a532b860c8 | |||
| dd4da99f1d | |||
| 437a0345e8 | |||
| 9b9e98a6b4 | |||
| 574b6efa1e | |||
| 45979985fe | |||
| 4cd894b7ae | |||
| 09e1d7cf7f | |||
| 2ae4a625b5 | |||
| 031e22ee49 | |||
| ef67244aea | |||
| 436195a229 | |||
| 46aaa44a77 | |||
| ab79dfd357 | |||
| 461f0c577a | |||
| 72e7fe1072 | |||
| d90319f43a | |||
| 9145ed5834 | |||
| 94ac3db60c | |||
| 2aa9d73325 | |||
| 605cff1d58 | |||
| 04cc45bbb7 | |||
| 7908ed53a3 | |||
| 9b6eb1c7c4 | |||
| f88a404fab | |||
| 074c4422f9 | |||
| f8c451b7b8 | |||
| ff93660768 | |||
| b6a859bcad | |||
| 5610fdc273 | |||
| db3dba1e96 | |||
| 737c353d84 | |||
| d878f0db21 | |||
| 67969a041d | |||
| ef3f405190 | |||
| e154b31b99 | |||
| 3dc2624e00 | |||
| 822d26c0dd | |||
| 923e27de08 | |||
| 19fd943660 | |||
| 28b71237df | |||
| 0fe6151153 | |||
| 7b7616b3fa | |||
| 7802020982 | |||
| 2889fee300 | |||
| cb74c2b310 | |||
| d40d88d292 | |||
| 67719540ba | |||
| c604a8ff9c | |||
| 4ffe9dadbf | |||
| ed9820e6a6 | |||
| 5463a0c772 | |||
| 85214b308a | |||
| cfb9f85c90 | |||
| 635351f539 | |||
| 5c0849e82b | |||
| 54b3e0cc21 | |||
| d3404996fd | |||
| b0860467d5 | |||
| a075732cb4 | |||
| fc09e2307a | |||
| 43048626a6 | |||
| 15192c433b | |||
| 1fd4e084b6 | |||
| 29bf03b770 | |||
| 0ac883ea62 | |||
| 87d2c2894b | |||
| 399a3d7907 | |||
| d14a517fdc | |||
| 2e6fe73939 | |||
| b8659d0a9a | |||
| f9dd9297b8 | |||
| 3ffba4ac6c | |||
| 7b9cc0ba40 | |||
| 26c9b367a5 | |||
| 5f48bfda12 | |||
| 67d08b69c2 | |||
| ae190663f0 | |||
| de1c1de1ab | |||
| edb74f1223 |
-106
@@ -1,106 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: { browser: true, es2021: true, node: true },
|
||||
parserOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: { jsx: true },
|
||||
},
|
||||
settings: {
|
||||
react: { version: 'detect' },
|
||||
},
|
||||
plugins: ['header', 'react-hooks', 'react', 'unused-imports'],
|
||||
ignorePatterns: [
|
||||
'dist/**',
|
||||
'node_modules/**',
|
||||
'logs/**',
|
||||
'report/**',
|
||||
'playwright-report/**',
|
||||
'test-results/**',
|
||||
'blob-report/**',
|
||||
'src/assets/brand-icons/*.js',
|
||||
],
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
rules: {
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
group: [
|
||||
'@radix-ui/*',
|
||||
'@floating-ui/*',
|
||||
'@lobehub/ui',
|
||||
'@lobehub/ui/*',
|
||||
'@lobehub/icons',
|
||||
'@lobehub/icons/*',
|
||||
'@douyinfe/semi-*',
|
||||
'@headlessui/*',
|
||||
'@mui/*',
|
||||
'@chakra-ui/*',
|
||||
'leva',
|
||||
'leva/*',
|
||||
'antd-style',
|
||||
'react-layout-kit',
|
||||
],
|
||||
message:
|
||||
'Use antd public APIs or the audited local brand SVG assets. Preserve legacy components/ui callback contracts.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
'header/header': [
|
||||
2,
|
||||
'block',
|
||||
[
|
||||
'',
|
||||
'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',
|
||||
'',
|
||||
],
|
||||
],
|
||||
'no-multiple-empty-lines': ['error', { max: 1 }],
|
||||
|
||||
// ===== 防线:杜绝“用了未定义/未导入标识符”导致的运行时崩溃(本次线上事故根因)=====
|
||||
// 让规则识别 JSX 中使用到的组件/React,避免误报。
|
||||
'react/jsx-uses-vars': 'error',
|
||||
'react/jsx-uses-react': 'error',
|
||||
// 未定义标识符 = 直接报错(构建/CI 即拦截)。
|
||||
'no-undef': 'error',
|
||||
// 未使用的 import = error 且可 --fix 自动移除(含 JSX/副作用识别);
|
||||
// 未使用的变量 = warn(不阻断,下划线前缀豁免)。
|
||||
'no-unused-vars': 'off',
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
'unused-imports/no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
vars: 'all',
|
||||
varsIgnorePattern: '^_',
|
||||
args: 'none',
|
||||
argsIgnorePattern: '^_',
|
||||
ignoreRestSiblings: true,
|
||||
},
|
||||
],
|
||||
// React Hooks 规则。
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
+5
-5
@@ -4,6 +4,8 @@
|
||||
node_modules/
|
||||
/.pnp
|
||||
.pnp.js
|
||||
bun.lock
|
||||
bun.lockb
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
@@ -12,11 +14,8 @@ node_modules/
|
||||
|
||||
# Local acceptance tests, browser sessions, and reports
|
||||
/e2e/
|
||||
/.e2e/
|
||||
/tests/
|
||||
*.test.*
|
||||
*.spec.*
|
||||
# Maintained unit regressions are source; local acceptance suites stay ignored.
|
||||
!test/unit/*.test.js
|
||||
/playwright/.auth/
|
||||
/playwright-report/
|
||||
/test-results/
|
||||
@@ -28,6 +27,7 @@ node_modules/
|
||||
/build
|
||||
/dist/
|
||||
/dist-ssr/
|
||||
vercel.json
|
||||
|
||||
# tool caches and temporary files
|
||||
__pycache__/
|
||||
@@ -65,4 +65,4 @@ yarn.lock
|
||||
|
||||
# i18n 批次中间产物(可由 scripts/i18n_kt_batches.cjs 重新生成,勿入库)
|
||||
scripts/kt_batches/
|
||||
scripts/kt_out/
|
||||
scripts/kt_out/
|
||||
|
||||
@@ -60,7 +60,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
- **样式**:不新增 ConfigProvider、主题状态或存储 key;颜色只来自 token 或页面变量,JSX 不写十六进制,不用全局 `!important`。
|
||||
- **图标与依赖**:按钮图标从 `src/components/common/icons/ActionIcons.js` 导入,装饰图标用 `lucide-react`;禁止引入 Semi、Radix UI、Floating UI、`@lobehub/*`、MUI、Chakra、Headless UI、leva、antd-style、react-layout-kit。
|
||||
- **请求**:只用 `API`,参数用 `params`,先判 `success`;分页 `p` 从 1 开始、`page_size` ≤ 100;`catch` 不重复提示 AxiosError;`finally` 回收 loading。
|
||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;新 `.js` / `.jsx` 带 AGPL 许可证头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;不重复添加通用长版权文件头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
||||
|
||||
## 5. 目录规则
|
||||
@@ -89,6 +89,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
| 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` |
|
||||
| 模型超市 / 技能超市 | `docs/ui/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` |
|
||||
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
||||
| UI 审查清单 | `docs/ui-review-checklist.md` |
|
||||
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
||||
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
||||
|
||||
@@ -103,7 +104,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
|
||||
1. **改前**:读相关代码;UI 任务先按 `GLOBAL_UI_BASELINE.md` 第 6 节真实 UI 登录;通用测试指令按该节自动判断验收范围、企业 / 普通个人 / 超管账号并加载现有本地配置,无需用户重复指定登录类型。
|
||||
2. **服务与浏览器**:优先通过项目目录、启动日志和监听进程查找并验证用户已运行的开发服务;仅确认不存在时才启动新服务,细节见全局基线第 7.1 节;Playwright + 本机 Chrome(`channel: 'chrome'`),无人值守设 `UI_VISUAL_OFFSCREEN=1`,单 Context 串行;有头运行遵守 `GLOBAL_UI_BASELINE.md` 7.1.1 焦点约束(唯一页面,不新建 / 切换标签页、不 `bringToFront`,用 `scripts/playwright-focus-guard.mjs` 检测前台)。
|
||||
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851;正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
||||
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851 与 360×800(最小必测视口);正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
||||
4. **检查**:`npm run eslint`、`npm run lint`、`npm test -- --test-concurrency=1`、`git diff --check`,涉及依赖或图标时加 `npm run check:ui`;纯文档改动只需 `npx prettier --check <文件>` 与 `git diff --check`。构建须先经用户同意,输出到系统临时目录(如 `npx vite build --outDir <临时目录> --emptyOutDir`),不覆盖 `dist/`。
|
||||
5. **证据与交付**:截图、trace、storageState、报告只写 Git 忽略目录;说明完成范围、实际验证结果与未覆盖项,未验证的不写成通过;在 `docs/CHANGELOG.md` 追加条目,改动脚本、环境变量或目录约定时同步更新 `README.md`。
|
||||
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
||||
@@ -122,7 +123,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
||||
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
||||
|
||||
> 规范版本:v3.5 · 更新:2026-11-18
|
||||
> 规范版本:v3.8 · 更新:2026-11-24
|
||||
|
||||
## 10. 工具差异(本节允许不同)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
- **样式**:不新增 ConfigProvider、主题状态或存储 key;颜色只来自 token 或页面变量,JSX 不写十六进制,不用全局 `!important`。
|
||||
- **图标与依赖**:按钮图标从 `src/components/common/icons/ActionIcons.js` 导入,装饰图标用 `lucide-react`;禁止引入 Semi、Radix UI、Floating UI、`@lobehub/*`、MUI、Chakra、Headless UI、leva、antd-style、react-layout-kit。
|
||||
- **请求**:只用 `API`,参数用 `params`,先判 `success`;分页 `p` 从 1 开始、`page_size` ≤ 100;`catch` 不重复提示 AxiosError;`finally` 回收 loading。
|
||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;新 `.js` / `.jsx` 带 AGPL 许可证头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;不重复添加通用长版权文件头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
||||
|
||||
## 5. 目录规则
|
||||
@@ -89,6 +89,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
| 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` |
|
||||
| 模型超市 / 技能超市 | `docs/ui/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` |
|
||||
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
||||
| UI 审查清单 | `docs/ui-review-checklist.md` |
|
||||
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
||||
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
||||
|
||||
@@ -103,7 +104,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
|
||||
1. **改前**:读相关代码;UI 任务先按 `GLOBAL_UI_BASELINE.md` 第 6 节真实 UI 登录;通用测试指令按该节自动判断验收范围、企业 / 普通个人 / 超管账号并加载现有本地配置,无需用户重复指定登录类型。
|
||||
2. **服务与浏览器**:优先通过项目目录、启动日志和监听进程查找并验证用户已运行的开发服务;仅确认不存在时才启动新服务,细节见全局基线第 7.1 节;Playwright + 本机 Chrome(`channel: 'chrome'`),无人值守设 `UI_VISUAL_OFFSCREEN=1`,单 Context 串行;有头运行遵守 `GLOBAL_UI_BASELINE.md` 7.1.1 焦点约束(唯一页面,不新建 / 切换标签页、不 `bringToFront`,用 `scripts/playwright-focus-guard.mjs` 检测前台)。
|
||||
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851;正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
||||
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851 与 360×800(最小必测视口);正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
||||
4. **检查**:`npm run eslint`、`npm run lint`、`npm test -- --test-concurrency=1`、`git diff --check`,涉及依赖或图标时加 `npm run check:ui`;纯文档改动只需 `npx prettier --check <文件>` 与 `git diff --check`。构建须先经用户同意,输出到系统临时目录(如 `npx vite build --outDir <临时目录> --emptyOutDir`),不覆盖 `dist/`。
|
||||
5. **证据与交付**:截图、trace、storageState、报告只写 Git 忽略目录;说明完成范围、实际验证结果与未覆盖项,未验证的不写成通过;在 `docs/CHANGELOG.md` 追加条目,改动脚本、环境变量或目录约定时同步更新 `README.md`。
|
||||
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
||||
@@ -122,7 +123,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
||||
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
||||
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
||||
|
||||
> 规范版本:v3.5 · 更新:2026-11-18
|
||||
> 规范版本:v3.8 · 更新:2026-11-24
|
||||
|
||||
## 10. 工具差异(本节允许不同)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Monkey AI Web 是从总仓库 `weiyuan` 分支独立出来的前端工程,包
|
||||
|
||||
环境要求:Node.js ≥ 22.13.0,npm ≥ 10(`packageManager` 为 npm 10.9.9)。统一使用 npm,不要用 Bun 或 Yarn 生成其他锁文件。
|
||||
|
||||
仓库仅维护 `package-lock.json`,已移除 `bun.lock`,并忽略 `bun.lock` / `bun.lockb`。本地与 CI 使用 `npm ci` 安装依赖、`npm run dev` 启动开发服务、`npm run build` 构建;Vercel 已显式配置 npm 安装与构建命令。
|
||||
仓库仅维护 `package-lock.json`,并忽略 `bun.lock` / `bun.lockb`。本地与 CI 使用 `npm ci` 安装依赖、`npm run dev` 启动开发服务、`npm run build` 构建。
|
||||
|
||||
```bash
|
||||
git clone --branch weiyuan https://git.weytoken.com/qiubs/monkey-ai-web.git
|
||||
@@ -35,7 +35,7 @@ npm ci
|
||||
npm run dev
|
||||
```
|
||||
|
||||
开发服务监听 `0.0.0.0`,默认端口 5174,被占用时 Vite 自动顺延,以终端输出的 `Local:` 地址为准。需要供验收脚本读取地址时,把输出重定向到 `dev.log`(如 `nohup npm run dev > dev.log 2>&1 &`)。
|
||||
开发服务默认监听 `0.0.0.0`,端口为 5174,支持访问本机地址和局域网 IP。端口被占用时 Vite 自动顺延,以终端输出的 `Local:` 和 `Network:` 地址为准。开发服务禁用项目未使用的 `import.meta.glob` 转换,普通动态导入和热更新照常使用。需要供验收脚本读取地址时,把输出重定向到 `dev.log`(如 `nohup npm run dev > dev.log 2>&1 &`)。
|
||||
|
||||
| 命令 | 模式 | 自动加载的配置文件 |
|
||||
| ----------------- | ----------- | ---------------------------------- |
|
||||
@@ -55,7 +55,7 @@ npm run dev
|
||||
/api /v1 /v1beta /mj /pg /dashboard /kling /jimeng /suno
|
||||
```
|
||||
|
||||
切换联调后端时修改 `.env.development.local` 中的 `DEV_PROXY_TARGET` 并重启服务;该变量只供 Vite 代理使用,不会暴露给浏览器。生产环境需由 Nginx 或网关配置同源反向代理,`package.json` 中的 `proxy` 字段不生效。
|
||||
切换联调后端时修改 `.env.development.local` 中的 `DEV_PROXY_TARGET` 并重启服务;该变量只供 Vite 代理使用,不会暴露给浏览器。生产环境需由 Nginx 或网关配置同源反向代理,Vite 开发代理不会进入生产产物。
|
||||
|
||||
### 可选:直接访问独立后端域名
|
||||
|
||||
@@ -135,7 +135,6 @@ monkey-ai-web/
|
||||
- **路由与权限**:在 `src/App.jsx` 注册路由,用 `PrivateRoute`、`AdminRoute`(role ≥ 10)、`RootRoute`(role ≥ 100)守卫;企业中心子路由在 `src/pages/Organization/index.jsx`。部分模块的可见性来自 `/api/status`,不能只靠隐藏菜单控制权限。
|
||||
- **UI**:通用组件用 Ant Design;存量页面经 `src/components/ui` 适配层保留原契约;主题只由 `UiThemeProvider` 提供,不新增 ConfigProvider;按钮图标从 `src/components/common/icons/ActionIcons.js` 导入。页面改动需检查浅色、深色与窄屏。
|
||||
- **国际化**:文案写 `t('中文原文')`,新 key 补齐 `src/i18n/locales/` 下 9 个语言包;运行时开放语言以 `src/i18n/catalog.js` 为准(简中、繁中、英、日、韩、越、泰),`fr.json`、`ru.json` 尚未登记。
|
||||
- **文件头**:每个 `.js` / `.jsx` 顶部须带 AGPL 许可证注释(ESLint 强制),参考相邻文件。
|
||||
|
||||
## 6. 常用命令与提交检查
|
||||
|
||||
@@ -143,11 +142,12 @@ monkey-ai-web/
|
||||
| --- | --- |
|
||||
| `npm run dev` | 启动开发服务 |
|
||||
| `npm run build` | 生产构建,输出 `dist/` |
|
||||
| `npm run verify:build -- <产物目录> --startup` | 校验静态入口、首屏 JS gzip 预算和按需加载边界;产物须用 `--manifest` 生成 |
|
||||
| `npm run preview` | 本地预览构建结果(默认端口 4173) |
|
||||
| `npm test -- --test-concurrency=1` | 串行运行单测(扫描 `src/`、`tests/`、`test/unit/`) |
|
||||
| `npm test -- --test-concurrency=1` | 串行运行单测(扫描 `src/`、`tests/`、`test/unit/`;新增共享单测放 `test/unit/`) |
|
||||
| `npm run eslint` / `npm run eslint:fix` | ESLint 检查(零警告门禁)/ 自动修复 |
|
||||
| `npm run lint` / `npm run lint:fix` | Prettier 检查 / 全仓格式化 |
|
||||
| `npm run check:ui` | UI 依赖、完整 lock 图与品牌图标资产 hash 审计 |
|
||||
| `npm run check:ui` | 审计应用源码、脚本、单测和根目录 JS 配置中的旧 UI 库引用,以及依赖声明、锁文件和品牌图标资产 SHA-256 |
|
||||
| `npm run check` | 依次执行 `check:ui`、ESLint、单测与生产构建,任一步失败即停止 |
|
||||
| `npm run vendor:icons` | 重新生成品牌图标资产 |
|
||||
| `npm run test:e2e` / `test:e2e:headed` / `test:e2e:report` | Playwright 验收 / 有头运行 / 查看报告 |
|
||||
@@ -159,6 +159,8 @@ monkey-ai-web/
|
||||
|
||||
### 本地 Playwright 登录配置
|
||||
|
||||
全流程 UI 审查使用 [UI 审查清单](docs/ui-review-checklist.md)。`e2e/` 保存本地用例,`.e2e/` 保存分阶段状态、截图、验收报告与会话缓存;均由 Git 忽略。会话缓存不上传、不提交。
|
||||
|
||||
本机自动化登录入口为 `e2e/auth-login/run.mjs`(本地验收脚本,Git 忽略)。在 `.env.playwright.local` 中配置 `UI_ORG_NAME`、`UI_ORG_USER`、`UI_ORG_PASS`、`UI_PERSONAL_USER`、`UI_PERSONAL_PASS`。该文件只保存测试账号,按用户约定不作 Git 忽略,允许提交;不得把值写入脚本、日志、截图注释或报告。其他凭据与 storageState 仍不入库。运行时由 Node 加载到环境变量:
|
||||
|
||||
```powershell
|
||||
@@ -169,11 +171,12 @@ node --env-file=.env.playwright.local e2e/auth-login/run.mjs
|
||||
|
||||
测试先通过项目目录、启动日志与监听进程查找并验证已有开发服务;历史日志中的失效地址不能作为新启服务的依据。仅确认本项目服务不存在时才启动,结束时只清理本次启动的进程。项目 Playwright 配置和专项验收通过 `scripts/dev-service.mjs` 自动发现并复用服务(验证 Vite 源码映射属于当前项目,兼容 UTF-8 / UTF-16LE 日志);显式目标仍按调用方配置执行。本地登录脚本同样先发现已有服务,使用本机 Chrome 离屏串行执行企业 A/B 状态判定、真实 UI 登录、后台主体断言、个人端全新 Context 登录和 UI 退出。企业 A 路径先填写企业名称并点击“下一步”,B 路径直接填写登录名和密码;不可覆盖的路径单独记录。后续搜索按钮验收拦截非 GET 写请求;截图、脱敏失败记录与供后续用例复用的 storageState 保存在 `report/auth-login-<时间>/`,均为本地忽略产物。storageState 含会话凭据,不上传、不提交;登录规则见 `docs/ui/GLOBAL_UI_BASELINE.md` 第 6 节。
|
||||
|
||||
Playwright 与 weelink 共用设备环境约定,依赖精确锁定 1.64.1;本项目 runner 优先复用已核验的现有开发服务,仅确认不存在时才使用 4176,避免与 weelink 的 4175 冲突。配置读取 `scripts/ui-review/config.json`,用例通过 `scripts/playwright-test.mjs` 的公共 fixture 后台建页并守护焦点。独立脚本使用 `scripts/playwright-focus-guard.mjs` 的 `launchFocusSafe()`,两类流程保留各自执行策略。前台激活或探测失败会记录并停止,离屏不保证绝无瞬时激活。环境变量和截图口径见 [全局基线第 7.1 节](docs/ui/GLOBAL_UI_BASELINE.md#71-工具)。
|
||||
Playwright 默认运行桌面及两个移动项目:`chrome-mobile`(最小视口 360×800)与 `chrome-mobile-393`(393×851)。通用用例继承项目视口,专项用例可覆盖视口测试指定场景。Playwright 与 weelink 共用设备环境约定,依赖精确锁定 1.64.1;本项目 runner 优先复用已核验的现有开发服务,仅确认不存在时才使用 4176,避免与 weelink 的 4175 冲突。配置读取 `scripts/ui-review/config.json`,用例通过 `scripts/playwright-test.mjs` 的公共 fixture 后台建页并守护焦点。独立脚本使用 `scripts/playwright-focus-guard.mjs` 的 `launchFocusSafe()`,两类流程保留各自执行策略。前台激活或探测失败会记录并停止,离屏不保证绝无瞬时激活。环境变量和截图口径见 [全局基线第 7.1 节](docs/ui/GLOBAL_UI_BASELINE.md#71-工具)。
|
||||
|
||||
| 命令 / 参数 | 用途与默认值 |
|
||||
| --- | --- |
|
||||
| `npm run test:e2e:headless` | 无头运行;本地默认有头离屏,CI 强制无头 |
|
||||
| `npm run test:e2e -- --project=chrome-mobile` | 运行默认配置中的 360×800 手机项目。专项 UI 验收也须覆盖此最小视口 |
|
||||
| `npm run test:e2e:extended` | 全部 8 视口;也可设置 `PW_EXTENDED_LAYOUT=1` |
|
||||
| `npm run test:e2e:dist` | 验证已有静态产物并严格启动 4176;不自动构建 |
|
||||
| `npm run test:acceptance -- <参数>` | 串行单测、临时目录构建、产物校验、强制 local-dist/4176 测试 |
|
||||
@@ -189,6 +192,9 @@ Trace、失败截图、CI JUnit 在 `test-results/<runId>/`,HTML 在 `playwrig
|
||||
|
||||
## 7. 构建与部署
|
||||
|
||||
- **首屏分包**:React 运行时独立缓存,公告和协议预览保留在按需 chunk;首页仅在收到非空 Markdown 时下载解析器。首屏启动 JS 预算为 820 KiB gzip,不含路由按需包和 CSS;验收构建使用 `npm run build -- --manifest --outDir <临时目录>`,再执行 `npm run verify:build -- <临时目录> --startup`。
|
||||
- **开发预热**:只预热应用入口、布局和路由,不预热所有页面或禁用依赖发现。没有全量 `vendor` 分组,也没有将图表、文档等浏览器依赖外置。
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm run build
|
||||
@@ -197,19 +203,19 @@ npm run preview
|
||||
|
||||
将 `dist/` 作为静态站点发布,部署环境需处理:
|
||||
|
||||
- **共享测试环境**:局域网沿用现有域名或 IP 与端口。由网关提供构建后的静态文件和 SPA 路由回退,并继续转发测试后端接口。Vite 的源码转换与 HMR 只用于独立的开发服务。自动发布时,先完成构建与检查,再切换站点目录,避免访问到构建中的文件。
|
||||
- **路由回退**:使用 BrowserRouter,直接访问 `/org/...` 等页面时静态服务器需回退到 `index.html`,否则刷新返回 404。
|
||||
- **接口转发**:生产环境配置反向代理或独立后端地址;Vite 开发代理不会进入产物,`preview` 不能代替生产网关。
|
||||
- **流式与长连接**:SSE 接口需关闭响应缓冲并设置合理超时;WebSocket 需配置连接升级。
|
||||
- **缓存**:`index.html` 应及时更新,带哈希的静态资源可长缓存;后端地址写在产物中,切换需重新构建并发布。
|
||||
- **部署路径**:当前按域名根路径部署;部署到子目录需检查 Vite `base`、路由与静态资源地址。
|
||||
|
||||
仓库中的 `vercel.json` 只关闭了 GitHub 通知,未配置路由回退或代理,不能作为完整部署配置。
|
||||
|
||||
## 8. 常见问题
|
||||
|
||||
| 现象 | 优先检查 |
|
||||
| --- | --- |
|
||||
| 页面能打开但提示状态或接口加载失败 | 后端是否可用;Network 中 `/api/status` 的目标地址与响应;代理配置 |
|
||||
| 共享测试站出现 Vite 红色遮罩 | 检查站点网关的前端上游。共享测试站应由网关提供构建后的静态文件,Vite 开发服务仅用于联调。开发服务对 `.npmrc` 请求直接返回 404。 |
|
||||
| 登录后又回到登录页 | `/api/user/self` 响应、Cookie 是否发送、跨域凭证策略、账号状态 |
|
||||
| 企业数据为空或串到其他企业 | 当前组织选择、`current_org_id` 与请求头 `X-Org-Id` |
|
||||
| 修改环境变量后无变化 | 是否重启开发服务或重新构建发布;HTML 与静态资源缓存 |
|
||||
|
||||
+932
-1
@@ -1,6 +1,6 @@
|
||||
# 变更记录(CHANGELOG)
|
||||
|
||||
> 状态:有效(持续追加) · 更新:2026-11-19 · 版本:v3.6
|
||||
> 状态:有效(持续追加) · 更新:2026-12-01 · 版本:v3.20
|
||||
|
||||
对现状仍有影响的功能与修复记录,按日期倒序。改造、迁移、优化等一次性过程不在此记录。
|
||||
|
||||
@@ -8,8 +8,939 @@
|
||||
|
||||
**记录规则**:每条写“范围、变更、影响、回滚、关联”五项;回滚优先 `git revert <提交>`,提交含多项改动时按文件还原(`git checkout <提交>^ -- <文件>`),不整仓 reset。本文不作为规则依据。
|
||||
|
||||
## 2026-12-01
|
||||
|
||||
### 修复平台菜单搜索卡顿并接入自动搜索
|
||||
|
||||
- **范围** 控制台菜单管理和平台角色。
|
||||
- **变更** 筛选字段使用公共的 300ms 防抖搜索,搜索按钮和回车立即应用条件。菜单输入与树表渲染分离,角色筛选沿用当前分页。
|
||||
- **影响** 连续输入只应用最后一次筛选,重置取消待执行搜索并恢复默认筛选和表格状态。
|
||||
- **回滚** 按差异还原 `src/pages/Permission/MenuManage.jsx`、`src/pages/Permission/PlatformRoles.jsx` 和本条目。
|
||||
- **关联** `docs/standards/UI_COMPONENT_STANDARDS.md` 第 4 节。
|
||||
|
||||
### 对齐企业角色管理迁移提示的区块间距
|
||||
|
||||
- **范围** 企业中心 `/org/roles`。
|
||||
- **变更** 复用企业治理页的布局间距,页头、迁移提示和角色列表之间统一留出 18px。
|
||||
- **影响** 迁移提示隐藏时,页头与角色列表仍保持一个标准区块间距。
|
||||
- **回滚** 按差异还原 `src/pages/Organization/OrgRoles.jsx` 和本条目。
|
||||
- **关联** `docs/ui/GLOBAL_UI_BASELINE.md` 第 4.4 节。
|
||||
|
||||
### 修复个人登录回跳旧版用户中心地址
|
||||
|
||||
- **范围** 个人登录回跳、旧版用户中心入口与个人设置。
|
||||
- **变更** 第三方账号绑定成功或回调缺少授权码时统一返回 `/user/center`,由该入口在登录后进入用户中心首个可见页面。`/console/personal` 保留为旧个人设置链接,登录后转到 `/user-center/settings`。旧链接跳转保留查询参数和片段标识。
|
||||
- **影响** 个人账号可从旧链接进入用户中心,页面可见性继续由用户中心配置决定,控制台管理页面继续使用原有权限守卫。
|
||||
- **回滚** 按差异还原 `src/App.jsx`、`src/pages/UserCenter/index.jsx`、`src/components/auth/OAuth2Callback.jsx` 和本条目。
|
||||
- **关联** `docs/ui/USER_CENTER_SPEC.md` 第 1 节。
|
||||
|
||||
## 2026-11-30
|
||||
|
||||
### 权限重构验收手册移除 E2、T 账号验收项
|
||||
|
||||
- **范围** `docs/权限重构产品功能验收与切换手册.md`。
|
||||
- **变更** 删除账号 E2(个人账号加入企业,切换后登录名回填)与 T(企业登录两步验证)的账号说明、验收项(原 1.4.3、1.4.4、3.1.3、3.3.1、3.3.2 及 3.8.4 中 E2 部分)和客户通知中的两步验证说明;其余编号顺延,交叉引用同步更新。
|
||||
- **影响** 自动化验收不再依赖个人账号加入企业与两步验证账号,避免阻塞;上述两类场景需另行人工验证。仅文档变更。
|
||||
- **回滚** 按文件还原该手册与本条目。
|
||||
- **关联** 无。
|
||||
|
||||
## 2026-11-28
|
||||
|
||||
### 顶栏主导航在中等宽度下不再被操作区遮挡
|
||||
|
||||
- **范围** 全站共享顶栏(768px 及以上)。
|
||||
- **变更** 导航槽位按实际可用宽度切换:放不下时收为「主导航」下拉菜单,放得下时恢复平铺;折叠菜单复用移动端菜单的菜单项、选中态与跳转。品牌区可收缩截断,移动端菜单按钮补充最小宽度约束。
|
||||
- **影响** 修复前个人账号在 768px 仅剩 33px 导航宽度、6 个入口被裁切,1024px 裁切 5 个;修复后 360–3840px 均无裁切与横向溢出,1920px 及以上外观不变。路由、权限与入口条件不变。
|
||||
- **回滚** 按文件还原 `src/components/layout/headerbar/{Navigation,MobileNavMenu,index}.jsx` 与 `src/styles/prototype.css` 的导航段,以及基线第 4.1 节对应条目。
|
||||
- **关联** 全站 UI 基线第 4.1 节。
|
||||
|
||||
### WeyAi 下载页交互与多分辨率对齐原型
|
||||
|
||||
- **范围** `/weyai/download` 与 `/user-center/weyai-download` 共用页面及顶栏下载入口。
|
||||
- **变更** 系统页签和架构按钮改为原型的选择交互,安装卡和列表中的“当前选择”行同步切换。按原型重排首屏、安装卡、安装包卡片、工作台示意、功能和步骤。断点改为原型的 1180 / 850 / 520px,并按页面可用宽度计算。新增 5 条文案,并补齐 9 个语言包。
|
||||
- **影响** 默认展示自动识别的推荐包,未识别系统时不预选。下载地址、接口请求和 `window.open(url, '_self')` 触发方式不变。颜色由主题 token 派生,跟随系统主题色和深浅模式。已覆盖 3840 至 360px 宽度。
|
||||
- **回滚** 按文件还原 `src/pages/WeyAiDownload/{index.jsx,WorkbenchPreview.jsx,weyai-download.css}`、9 个语言包、`src/styles/prototype.css` 和基线第 4.1、5 节。
|
||||
- **关联** 全站 UI 基线第 4.1 和第 5 节。
|
||||
|
||||
## 2026-11-27
|
||||
|
||||
### 对齐 WeyAi 下载页原型
|
||||
|
||||
- **范围** 公开下载页、用户中心下载页及其顶栏下载入口。
|
||||
- **变更** 对齐原型的标题、版本、平台入口、推荐卡、工作台示意、安装包列表、产品能力和使用步骤,同时恢复首屏渐变与顶栏入口选中反馈。
|
||||
- **影响** 推荐和下载沿用现有处理,平台入口交互已由 2026-11-28 条目更新。页面支持浅色、深色及窄屏排布。
|
||||
- **回滚** 恢复本次下载页组件、示意资源、多语言文案、顶栏操作组件和对应样式。
|
||||
- **关联** 全站 UI 基线第 4.1 和第 5 节。
|
||||
|
||||
### 统一页面级侧栏并修复高频连点
|
||||
|
||||
- **范围** 体验中心、用户中心、控制台、企业中心、文档和伙伴工作台。
|
||||
- **变更** 页面链接去重与节流,统一侧栏外壳、菜单项、分组、折叠和加载占位。
|
||||
- **影响** 当前项连点不再重复写入导航历史,桌面折叠偏好跨页面同步,移动抽屉与底栏保留各自的入口。
|
||||
- **回滚** 恢复本次侧栏组件、样式和交互 hook。
|
||||
- **关联** 全站 UI 基线第 4.3 节。
|
||||
|
||||
### 优化右侧顶栏快捷操作
|
||||
|
||||
- **范围** 顶栏教程、WeyAi 下载、充值、推广、主题、语言和头像菜单。
|
||||
- **变更** 快捷入口复用主导航节流和当前路由去重。主题切换限制连续触发,语言和头像菜单共用展开与关闭逻辑。
|
||||
- **影响** 高频点击减少重复路由和主题更新,推广遮罩短暂过滤连点,连续退出登录只执行一个请求。
|
||||
- **回滚** 恢复本次变更涉及的顶栏操作组件和相关 hook。
|
||||
- **关联** 全站 UI 基线第 4.1 节。
|
||||
|
||||
### 修复顶栏连点、侧栏加载和头像菜单交互
|
||||
|
||||
- **范围** 全站主导航、用户中心、控制台、企业中心和顶栏头像菜单。
|
||||
- **变更** 当前目标跳过重复导航,快速切换保留最新目标。三个中心复用侧栏加载占位。头像菜单统一处理悬停、点击和关闭。
|
||||
- **影响** 侧栏加载前后保持对应的宽度和底部位置,已在默认目标页时连点顶栏不再产生路由变更。
|
||||
- **回滚** 恢复本次变更涉及的主导航、侧栏加载和头像菜单文件。
|
||||
- **关联** 全站 UI 基线第 4 节。
|
||||
|
||||
## 2026-11-26
|
||||
|
||||
### 统一智能路由的判定模型文案
|
||||
|
||||
- **范围** 个人、平台和企业的判定明细、试路由、集合、授权和管理设置。
|
||||
- **变更** 判定来源显示「智能路由」,合规闸门显示「已调用模型」或对应原因。集合开关说明使用判定模型所需的平台设置和出境授权。
|
||||
- **影响** 历史判定记录按新文案展示,新增管理日志使用「判定模型」名称。
|
||||
- **回滚** 恢复对应的状态标签、语言包与后端提示文案。
|
||||
- **关联** [智能路由判定模型文案调整方案](../../docs/04-渠道与路由/22-智能路由判定模型文案调整方案.md)。
|
||||
|
||||
### 智能路由支持 Jev 专用出站代理
|
||||
|
||||
- **范围** 智能路由全局设置中的 Jev 判定请求。
|
||||
- **变更** 超级管理员可以配置、测试和清除 HTTP、HTTPS 或 SOCKS5 系列代理。
|
||||
- **影响** 测试展示 Google 连通性、耗时、出口 IP 和国家或地区。
|
||||
- **回滚** 清除代理即可恢复 Jev 原有的服务器网络设置。
|
||||
- **关联** 智能路由 Jev 设置和管理接口。
|
||||
|
||||
### 修复 · 稳定推广分享弹窗高度
|
||||
|
||||
- **范围**:顶栏「推广分享」弹窗的链接分享和海报分享页签。
|
||||
- **变更**:两个页签共用等高的内容区,并按视口限制高度。邀请卡片和海报预览共用列宽、圆角和最小高度。
|
||||
- **影响**:切换页签时弹窗位置保持稳定,两张卡片对齐,内容超出可用高度时在页签内滚动。
|
||||
- **回滚**:恢复推广分享弹窗原有的页签高度、滚动和预览卡片样式。
|
||||
- **关联**:`src/components/promotion/promotion-poster.css`。
|
||||
|
||||
### 清理 · 移除 Bun 锁文件、Vercel 配置和根目录声明文档
|
||||
|
||||
- **范围**:依赖锁文件、Vercel 配置、根目录声明文档和 Git 忽略规则。
|
||||
- **变更**:移除 `bun.lock`、`vercel.json` 和 `NOTICE.md`,清理现行文档中的对应引用,忽略 `bun.lock`、`bun.lockb` 和 `vercel.json`。
|
||||
- **影响**:npm 继续使用 `package-lock.json`。Vercel Git 部署改由 Vercel 项目设置提供安装和构建命令。
|
||||
- **回滚**:还原本次文档和忽略规则改动,并从变更前的 Git 版本恢复三个文件。
|
||||
- **关联**:`.gitignore`、`README.md`、`docs/standards/DEV_STANDARDS.md`。
|
||||
|
||||
### 调整 · 暂时隐藏推广分享中的邀请奖励规则入口
|
||||
|
||||
- **范围**:顶栏「推广 → 推广分享」弹窗。
|
||||
- **变更**:暂停渲染弹窗底部「查看邀请奖励规则」入口。
|
||||
- **影响**:用户仍可通过弹窗分享邀请链接、邀请码和海报。
|
||||
- **回滚**:将 `SHOW_INVITATION_REWARD_RULES` 设为 `true`。
|
||||
- **关联**:`src/components/promotion/PromotionPosterModal.jsx`。
|
||||
|
||||
## 2026-11-25
|
||||
|
||||
### 优化 · 成员排行按需加载并固定翻页结果
|
||||
|
||||
- **范围**:企业中心「消耗明细 → 成员排行」。
|
||||
- **变更**:打开排行页签时按已应用的筛选查询,翻页和更改每页人数时沿用同一快照。刷新或重新筛选会获取当前榜单。
|
||||
- **影响**:查看明细日志时省去排行请求。榜单更新期间翻页仍显示同一时点的名次;快照过期后自动回到第 1 页。
|
||||
- **回滚**:恢复前端原有的排行加载与分页逻辑;分页响应兼容未传快照的客户端。
|
||||
- **关联**:`src/pages/Organization/OrgLogs.jsx`、`src/hooks/org/useOrgData.js`、`docs/ui/ORG_CENTER_SPEC.md`。
|
||||
|
||||
### 优化 · 企业消耗明细成员排行支持服务端分页
|
||||
|
||||
- **范围**:企业中心「消耗明细 → 成员排行」及 `GET /api/org/logs/ranking`。
|
||||
- **变更**:在权限和筛选范围内按成员汇总,消耗额度由高到低,同额按成员 ID 升序,返回当前页和总人数。
|
||||
- **影响**:可以翻到第 50 名以后,跨页名次连续,前三名沿用主题强调色。
|
||||
- **回滚**:先回退前端排行分页,再回退后端接口。旧前端仍可使用原有的 `limit` 查询。
|
||||
- **关联**:`src/pages/Organization/OrgLogs.jsx`、`src/hooks/org/useOrgData.js`。
|
||||
|
||||
### 同步 · 三中心列表与本地权限适配
|
||||
|
||||
- **范围**:合入纯前端仓库 `weiyuan` 从 `574b6efa1` 至 `ed693a450` 的增量。
|
||||
- **变更**:用户列表的自动搜索同时传递状态筛选和取消信号,企业日志在后续页重新筛选时同步刷新总数。企业内容页按操作权限显示创建、上传、分发与删除入口。兑换码按后端的查询、创建、编辑和删除权限显示操作,启停沿用编辑权限。个人密钥编辑表单在打开时加载模型、分组和技能选项。
|
||||
- **影响**:角色分配、额度调整、模型映射、企业代理会话以及日志查询、排行、导出的独立权限继续使用全栈接口契约。
|
||||
- **回滚**:按对应页面和共享依赖回退本次前端增量。
|
||||
- **关联**:`src/components/table/users/`、`src/hooks/org/useOrgData.js`、`src/pages/Organization/`。
|
||||
|
||||
### 优化 · 消费记录固定首尾列
|
||||
|
||||
- **范围**:用户中心 `/user-center/usage-record` 的消费记录调用明细。
|
||||
- **变更**:时间列固定在左侧,操作列显示时固定在右侧。
|
||||
- **影响**:横向滚动中间字段时,仍可读取时间并打开账单详情。
|
||||
- **回滚**:还原消费记录时间列和操作列的固定配置。
|
||||
- **关联**:`src/components/table/usage-logs/`、`docs/ui/USER_CENTER_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码编辑侧栏窗
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 编辑入口。
|
||||
- **变更**:编辑兑换码信息与添加兑换码共用右侧侧栏窗。
|
||||
- **影响**:两种表单使用相同的宽度、关闭方式和页脚,编辑继续回填当前记录。
|
||||
- **回滚**:还原兑换码编辑表单的独立弹窗。
|
||||
- **关联**:`src/components/table/redemptions/modals/EditRedemptionModal.jsx`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码列表行内操作
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 表格操作列。
|
||||
- **变更**:「查看详情」入口简化为「查看」,启用、禁用和删除从更多菜单移至行内,按钮单行排列并随操作列固定在右侧。
|
||||
- **影响**:桌面与窄屏均可直接使用行操作,启停权限和删除确认沿用原规则。
|
||||
- **回滚**:还原兑换码操作列按钮、宽度和换行样式。
|
||||
- **关联**:`src/components/table/redemptions/`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 优化 · 兑换码列表与表单
|
||||
|
||||
- **范围**:控制台 `/console/redemption` 与 `/console/channel` 的表头。
|
||||
- **变更**:沿用渠道列表的表格与行内操作样式,提升两页表头文字对比度,固定兑换码操作列,新增同页详情弹窗,统一添加侧栏窗与编辑弹窗的表单及页脚。
|
||||
- **影响**:可在详情弹窗查看与复制原码,批量复制随选中态启用,清除失效操作保留二次确认。
|
||||
- **回滚**:还原兑换码列表、表单、详情弹窗和对应样式与文案。
|
||||
- **关联**:`src/components/table/redemptions/`、`docs/ui/CONSOLE_SPEC.md`。
|
||||
|
||||
### 修复 · 企业成员排行的主题色与跨页名次
|
||||
|
||||
- **范围**:企业中心 `/org/logs` 的成员排行。
|
||||
- **变更**:前三名使用主题派生的三档底色,其他名次使用中性色;在分页前生成全表名次。
|
||||
- **影响**:切换系统主色或明暗模式时,排名徽章同步更新;翻页时继续显示全表名次。
|
||||
- **回滚**:还原排名列的名次生成和徽章配色。
|
||||
- **关联**:`src/pages/Organization/OrgLogs.jsx`、`src/styles/org-center.css`、`docs/ui/ORG_CENTER_SPEC.md`。
|
||||
|
||||
### 修复 · Vite 读取 npm 配置文件触发错误遮罩
|
||||
|
||||
- **范围**:Vite 开发服务的文件请求处理。
|
||||
- **变更**:在资源转换前拦截 `.npmrc` 请求并返回 404,同时将 `.npmrc` 加入文件访问拒绝列表。
|
||||
- **影响**:npm 配置文件请求不会启动资源转换或触发全站热更新错误遮罩。应用使用的文本资源导入继续由 Vite 转换。
|
||||
- **回滚**:还原 Vite 的 npm 配置文件拦截和对应访问规则。
|
||||
- **关联**:`vite.config.js`、`README.md`。
|
||||
|
||||
### 修复 · 控制台数据看板持续加载
|
||||
|
||||
- **范围**:控制台 `/console/analytics` 运营看板、创作作品详情抽屉及公共 API 的只读请求。
|
||||
- **变更**:看板首轮查询取消后可重新发起,作品详情的当前副作用接管加载状态。只读请求默认 60 秒超时,运营看板核心请求设置为 30 秒。
|
||||
- **影响**:两处首次加载可正常结束。只读接口持续无响应时返回超时错误,页面可按原有失败流程结束加载。
|
||||
- **回滚**:还原运营看板和作品详情的加载处理,以及公共 API 的只读超时。
|
||||
- **关联**:`src/hooks/analytics/useAnalyticsData.js`、`src/components/creation/WorkFeed/WorkDetailDrawer.jsx`、`src/helpers/api.js`。
|
||||
|
||||
## 2026-11-24
|
||||
|
||||
### 功能 · 计费详情弹窗增加费用明细与计算公式
|
||||
|
||||
- **范围**:使用记录 `/user-center/usage-record` 与控制台使用日志的「详情」弹窗(共用 `UsageLogsTable.jsx`)。
|
||||
- **变更**:新增「费用明细」:公式行(总金额 = 各计费项小计相加)与分项表(计费项、用量、单价、小计、合计),每行标注单价由哪些倍率构成;用量从「成本因子」移到分项表,成本因子只留倍率等补充信息。拆分逻辑在 `billingBreakdown.js`,口径对照后端结算公式;各行按展示精度四舍五入后与合计的差额归入「舍入与其他调整」一项,保证界面上的数字逐项相加恰好等于合计(`reconcileDisplayAmounts`);分项之和与实扣相差超过 1 个额度单位时视为口径未覆盖(如任务按时长 / 分辨率系数计价),token 兜底预扣与差额调整行同样不拆分,这些情况都不显示费用明细。已在费用明细里逐行列出的用量不再出现在成本因子区;按次 / 按秒计费的明细里没有 token 行,token 用量仍留在成本因子区。弹窗里的倍率由保留 3 位小数改为最多 6 位。超级管理员多一个「超管指标」区块,三项:官方价金额(1 倍率)= 同样用量按「模型原厂价格」计价 ÷ 原厂价登记汇率,整体倍率 = 实扣 ÷ 官方价金额,实际折扣 = 整体倍率 ÷ 登记汇率(汇率在 系统设置-倍率设置-模型原厂价格 页签顶部配置,option `OfficialPriceExchangeRate`,默认 7,仅超级管理员可读写),由后端只在超级管理员的日志响应里附加(`other.root_billing`,不落库),普通管理员与用户的接口不返回;未登记原厂价、或含音频 / 图片输入 / 工具调用等原厂价格表没有价目的计费项时不显示;按次计费但实扣含任务系数、出图接口、token 兜底预扣与差额调整行同样不显示。
|
||||
- **影响**:前端只改展示,不改请求。同批后端改动会改变扣费:Claude 联网搜索开始按次计费(此前算了价但未扣,流式与原生 Claude 格式此前也不记录次数;只对 Claude 模型收,其他走 Anthropic 协议的渠道即使上报搜索次数也不收;体验中心 / Playground 对 Claude 模型开启原生联网搜索时同样会多出这笔费用);扣费取整统一为四舍五入到 1 个额度单位(`common.QuotaFromFloat`,取整前先消除浮点噪声):Claude 原生结算、按次 / 按秒 / 任务类计费此前是向下取整,现在小数部分 ≥ 0.5 的每笔多 1 个额度单位(如 0.3 × 1.5 × 500000 由 224999 变为 225000);OpenAI 兼容路径原本就是四舍五入,不变。Claude 原生与音频 / 实时语音路径有费用时至少扣 1 个额度单位(此前不足 1 个单位扣 0)。邀请返佣仍向下取整(`common.QuotaFloorFromFloat`,只消除浮点噪声),保证返佣不超过「比例 × 消费」;token 预扣估算是准入闸门、不是最终扣费,保持原样。发布窗口内已提交未结算的视频任务,预扣(旧版向下取整)与结算(新版四舍五入)可能差 1 个额度单位:结算时重算结果与预扣只差 1 个单位的按预扣结清(`common.SettleRecomputedQuota`),不补扣不退款。缺少计费信息的日志不显示费用明细,弹窗与原来一致。后端结算公式变更时须同步 `billingBreakdown.js`。本条未做浏览器走查。
|
||||
- **回滚**:`git revert` 对应提交;`billingBreakdown.js` 与其单测为新增文件。
|
||||
- **关联**:`src/components/table/usage-logs/{UsageLogsTable.jsx,billingBreakdown.js,UsageLogs.css}`、`src/pages/Setting/Ratio/OfficialPriceExchangeRateSetting.jsx`、`test/unit/{usage-billing-breakdown,usage-billing-detail-render,official-price-exchange-rate-setting}.test.js`、后端 `common/quota.go`、`relay/compatible_handler.go`、`relay/channel/claude/relay-claude.go`、`service/quota.go`、`service/log_overall_ratio.go`、`controller/log.go`。
|
||||
|
||||
### 修复 · 企业登录接入人机验证
|
||||
|
||||
- **范围**:企业登录页 `/org/login`(企业标识登录与免企业标识直登)。
|
||||
- **变更**:系统开启 Turnstile 时,企业登录页显示人机验证,提交 `/api/org/login`、`/api/org/login/direct` 时带上 `turnstile` 参数;后端两条接口同步挂上 `TurnstileCheck`(未开启时自动放行)。
|
||||
- **影响**:未开启 Turnstile 的部署无变化。开启后,企业成员在通过人机验证前不能提交登录;两步验证、多企业选择两步不再重复验证。
|
||||
- **回滚**:`git revert` 对应提交(前后端须一起回滚,只回滚前端会导致开启 Turnstile 的部署无法企业登录)。
|
||||
- **关联**:`src/pages/OrgLogin/index.jsx`、`router/org-router.go`。
|
||||
|
||||
### 新增 · 渠道透传时应用模型映射
|
||||
|
||||
- **范围**:控制台渠道编辑框的「渠道额外设置」。
|
||||
- **变更**:「透传请求体」下方新增「透传时应用模型映射」,支持单独开启并保存。
|
||||
- **影响**:新建渠道和缺少该设置的历史渠道默认关闭。开启后,实际透传且命中渠道映射的请求使用映射后的上游模型名。
|
||||
- **回滚**:关闭该渠道的「透传时应用模型映射」并保存。
|
||||
- **关联**:`src/components/table/channels/modals/EditChannelModal.jsx`、`src/i18n/locales/`。
|
||||
|
||||
### 修复 · 控制台会员列表与弹窗
|
||||
|
||||
- **范围**:控制台 `/console/subscription` 的会员列表、新建与编辑会员卡弹窗。
|
||||
- **变更**:列表卡补充「会员列表」标题,快捷筛选移到标题之后。操作列沿用用户列表的「编辑」和「更多」,额度与金额右对齐。新建和编辑弹窗的主按钮统一为「确定」,桌面宽度调整为 575px。
|
||||
- **影响**:有效会员行可正常渲染。补发额度从「更多」进入确认弹窗,原有筛选和会员操作仍使用原接口。
|
||||
- **回滚**:还原会员页的工具栏、操作列、弹窗和对应翻译。
|
||||
- **关联**:`src/pages/Subscription/index.jsx`、`src/i18n/locales/`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 调整 · 顶栏推广海报预览
|
||||
|
||||
- **范围**:顶栏「推广分享」弹窗的「海报分享」页签。
|
||||
- **变更**:模板色铺满海报预览区,色块、预览和 PNG 导出共用配色。通过 CSS 隐藏海报页签的奖励规则入口。
|
||||
- **影响**:切换模板时整块预览同步换色,「链接分享」页签仍可打开奖励规则。
|
||||
- **回滚**:还原推广弹窗的模板配色与奖励入口显隐样式。
|
||||
- **关联**:`src/components/promotion/PromotionPosterModal.jsx`、`src/components/promotion/promotion-poster.css`。
|
||||
|
||||
### 调整 · Playwright 默认覆盖两档移动视口
|
||||
|
||||
- **范围**:项目 Playwright 配置与设备环境校验。
|
||||
- **变更**:显式保留 `chrome-mobile` 的 360×800,新增默认项目 `chrome-mobile-393` 覆盖 393×851。
|
||||
- **影响**:继承项目视口的用例默认在两档手机尺寸运行,设备环境检查校验实际尺寸、触摸和截图。
|
||||
- **回滚**:从默认项目与设备配置移除 393×851 项目,并恢复对应断言。
|
||||
- **关联**:`playwright.config.js`、`scripts/browser-environment.mjs`、`scripts/ui-review/config.json`。
|
||||
|
||||
### 修复 · 企业设置的数据库密码表单
|
||||
|
||||
- **范围**:企业设置「提示词采集」的数据库连接配置。
|
||||
- **变更**:将数据库连接字段放入原生表单,为数据库用户名和密码指定自动填充属性。
|
||||
- **影响**:消除 Chrome 对数据库凭据字段的表单和自动填充警告。
|
||||
- **回滚**:还原数据库连接配置表单的 `component` 属性和两个凭据字段的 `autoComplete` 属性。
|
||||
- **关联**:`src/pages/Organization/OrgSettings.jsx`。
|
||||
|
||||
### 修复 · 渠道自动禁用开关初始化
|
||||
|
||||
- **范围**:控制台渠道管理的新建和编辑渠道表单。
|
||||
- **变更**:表单统一初始化「是否自动禁用」,详情返回的 0 和 1 转为开关使用的布尔值。
|
||||
- **影响**:消除 `auto_ban` 重复初始化警告,提交仍使用 0 或 1。
|
||||
- **回滚**:还原自动禁用开关的初始化配置。
|
||||
- **关联**:`src/components/table/channels/modals/EditChannelModal.jsx`。
|
||||
|
||||
### 调整 · 企业设置数据安全页签间距
|
||||
|
||||
- **范围**:企业设置「数据安全」的子页签。
|
||||
- **变更**:去掉子页签叠加的顶部内边距,沿用设置卡的 24px 内容间距。
|
||||
- **影响**:子页签文字与「登录与安全」的内容标题从相同高度开始。
|
||||
- **回滚**:移除企业设置对子页签顶部内边距的覆盖。
|
||||
- **关联**:`src/styles/org-center.css`。
|
||||
|
||||
### 调整 · 编辑标签的请求头变量提示
|
||||
|
||||
- **范围**:控制台渠道管理的「编辑标签」抽屉。
|
||||
- **变更**:将「支持变量」与渠道密钥占位符合并为一行,使用相同的字体和样式。
|
||||
- **影响**:请求头模板仍使用 `{api_key}`,表单行为保持原样。
|
||||
- **回滚**:还原请求头变量提示的布局。
|
||||
- **关联**:`src/components/table/channels/modals/EditTagModal.jsx`。
|
||||
|
||||
### 调整 · 渠道列表复选框与创建入口
|
||||
|
||||
- **范围**:控制台 `/console/channel` 的普通列表和标签聚合模式。
|
||||
- **变更**:多选复选框固定在表格左侧,「创建渠道」移到列表工具栏右侧、列设置按钮左边。
|
||||
- **影响**:窄屏横向滚动时仍可选择渠道,标签分组行保持不可选。创建权限和弹窗沿用原流程。
|
||||
- **回滚**:还原多选列的固定配置,并将创建按钮移回分类页签区域。
|
||||
- **关联**:`src/components/table/channels/ChannelsTable.jsx`、`src/components/table/channels/index.jsx`、`src/components/table/channels/ChannelsTabs.jsx`。
|
||||
|
||||
### 调整 · 表格日期范围与自动搜索
|
||||
|
||||
- **范围**:控制台、企业中心、用户中心的表格筛选区。
|
||||
- **变更**:日期范围共用快捷周期、格式和确认交互。接入公共 300ms 搜索调度,可取消过期查询。个人密钥的本地过滤按批处理。
|
||||
- **影响**:搜索保留当前页与表格操作状态,重置恢复各页面默认条件及初始页。
|
||||
- **回滚**:按受影响页面恢复筛选事件和列表请求,并还原表格日期和搜索公共入口。
|
||||
- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md` 第 4、6 节,`src/hooks/common/useFilterSearch.js`。
|
||||
|
||||
### 调整 · 控制台预约、渠道与企业列表
|
||||
|
||||
- **范围**:控制台 `/console/demo-reservations`、`/console/channel`、`/console/organizations`。
|
||||
- **变更**:预约列表将「状态」改为「是否已响应」,两态开关隐藏内部文字。开启时确认「是否进行响应」,关闭时确认「是否取消响应」。渠道列表固定 ID 和名称,企业列表固定 ID 和企业名称。
|
||||
- **影响**:渠道及企业列表的操作列固定在右侧,多选框和其他未固定列在表格内横向滚动。窄屏空间不足时,左侧列参与滚动,为右侧操作和表格内容留出空间。预约开关沿用原确认流程。
|
||||
- **回滚**:还原预约表头和开关配置,以及渠道、企业列表的固定列配置。
|
||||
- **关联**:`src/pages/DemoReservations/index.jsx`、`src/components/table/channels/ChannelsTable.jsx`、`src/pages/AdminOrganizations/index.jsx`。
|
||||
|
||||
### 调整 · 业务系统授权标题
|
||||
|
||||
- **范围**:`/org/my-capabilities?tab=connectors`。
|
||||
- **变更**:主标题改为「业务系统授权」,与页签共用文案。
|
||||
- **影响**:两个页签的主标题都使用各自的页签名称。
|
||||
- **回滚**:恢复主标题单独配置。
|
||||
- **关联**:`src/pages/Organization/OrgMyCapabilities.jsx`。
|
||||
|
||||
### 调整 · 我的 AI 能力页签位置
|
||||
|
||||
- **范围**:企业中心 `/org/my-capabilities`。
|
||||
- **变更**:将「我的技能」「业务系统授权」页签移到通用页头下方,统一页签和正文的左右边距。
|
||||
- **影响**:切换后展示当前页签对应的标题、说明和使用指引,旧路由和模块开关沿用原逻辑。
|
||||
- **回滚**:还原合并页的页头渲染方式和两个子页的页头。
|
||||
- **关联**:`src/pages/Organization/OrgMyCapabilities.jsx`、`src/pages/Organization/OrgMySkills.jsx`、`src/pages/Organization/OrgMyConnectors.jsx`。
|
||||
|
||||
### 调整 · 企业云端大脑界面与导航
|
||||
|
||||
- **范围**:企业中心 `/org/cloud-brain` 的页头、页签和工作区布局。
|
||||
- **变更**:与体验中心云端大脑共用页头与线型页签,统一内容边距、图标和操作区排布。页签支持方向键移动焦点和键盘确认。
|
||||
- **影响**:保留企业专家管理、项目关联、专家卡片与任务流程。管理面板可通过「完成管理」或选择页签返回工作区。
|
||||
- **回滚**:还原企业页头和页签分支及对应样式。
|
||||
- **关联**:`src/pages/CloudBrain/index.jsx`、`src/pages/CloudBrain/cloud-brain.css`、`src/pages/ExperienceCenter/components/ExperiencePageHeader.jsx`。
|
||||
|
||||
### 调整 · 企业知识页页头、引导间距与保存文案
|
||||
|
||||
- **范围**:企业中心 `/org/knowledge`。
|
||||
- **变更**:页头对齐体验中心云端大脑,移除「企业可信知识层」标签,将 BETA 徽标移至「企业知识」标题右侧。「快速上手」提示条上方增加 12px 留白,两个知识库弹窗的主按钮统一为「保存」。
|
||||
- **影响**:页头使用统一的面包屑、标题和说明布局,两个弹窗沿用各自的提交逻辑。
|
||||
- **回滚**:还原原页头、提示条外边距和两个弹窗的确认按钮文案。
|
||||
- **关联**:`src/pages/Organization/OrgKnowledge.jsx`、`src/pages/Organization/org-knowledge.css`。
|
||||
|
||||
### 调整 · 企业调用质量页头
|
||||
|
||||
- **范围**:企业中心调用质量页。
|
||||
- **变更**:移除主标题上方重复的「调用质量」标签,使用通用企业页头。
|
||||
- **影响**:主标题和说明对齐企业中心规范,面包屑与使用指引保留原入口。
|
||||
- **回滚**:还原调用质量页头及对应的局部样式。
|
||||
- **关联**:`src/pages/Organization/OrgQuality.jsx`、`src/pages/Organization/org-quality.css`、`src/styles/org-page.css`。
|
||||
|
||||
### 修复 · 企业技能治理快速上手条
|
||||
|
||||
- **范围**:企业专家工坊、分发与锁定和业务系统连接器的快速上手条。
|
||||
- **变更**:网格内容从顶部按自然高度排列,连接器的快速上手条到页签导航的间距缩为 8px。
|
||||
- **影响**:内容较少时,页头、引导条与下方内容保持紧凑,引导条继续打开原有抽屉。
|
||||
- **回滚**:移除共用网格的顶部对齐声明和连接器页签的间距覆盖。
|
||||
- **关联**:`src/styles/org-page.css`、`src/pages/Organization/OrgConnectors.jsx`、`src/pages/Organization/org-connectors.css`。
|
||||
|
||||
### 调整 · 企业 Agent 任务审计
|
||||
|
||||
- **范围**:企业中心 `/org/agent-audit` 的任务元数据、待对账、安全策略及正文弹窗。
|
||||
- **变更**:任务卡片区分运行与计费状态,补充页签计数、空状态、表单标签与保存反馈,支持窄屏读取长编号。
|
||||
- **影响**:审计入口、筛选分页、策略保留和正文二次确认继续使用现有接口与权限。操作反馈沿用系统主题色,状态标签保留语义色。
|
||||
- **回滚**:还原该页组件、页面样式、原专家样式中的审计规则和对应语言项。
|
||||
- **关联**:`src/pages/Organization/OrgAgentAudit.jsx`、`src/pages/Organization/org-agent-audit.css`、`docs/ui/ORG_CENTER_SPEC.md`。
|
||||
|
||||
### 修复 · 个人密钥保存失败后保留表单
|
||||
|
||||
- **范围**:用户中心密钥管理的新建和编辑抽屉。
|
||||
- **变更**:保存失败时保留分组及其他输入,结束提交时统一恢复按钮状态。
|
||||
- **影响**:用户可以在原表单上修正信息或直接重试,继续沿用原有密钥接口。
|
||||
- **回滚**:还原密钥表单提交结束时的重置逻辑。
|
||||
- **关联**:`src/components/table/tokens/modals/EditTokenModal.jsx`。
|
||||
|
||||
### 调整 · 企业技能治理页面布局
|
||||
|
||||
- **范围**:分发与锁定、企业专家工坊、业务系统连接器。
|
||||
- **变更**:统一页头、主操作、列表卡片和表单弹层。整理成员预览、专家版本与连接器卡片,补齐连接器页签空态。
|
||||
- **影响**:页面权限、接口和已有治理操作沿用原流程。
|
||||
- **回滚**:还原三个页面及相关样式的布局改动。
|
||||
- **关联**:`src/pages/Organization/OrgSkillAssignments.jsx`、`src/pages/Organization/OrgExperts.jsx`、`src/pages/Organization/OrgConnectors.jsx`。
|
||||
|
||||
### 调整 · 企业技能中心布局
|
||||
|
||||
- **范围**:企业中心技能库与自研 Skill。
|
||||
- **变更**:统一页头与页签顺序,整理技能操作区、引入目录与自研技能表单标签。
|
||||
- **布局细节**:企业技能库与自研 Skill 的操作按钮统一放在当前页头右侧,与分发与锁定页一致。自研 Skill 的快速上手贴近页签。
|
||||
- **影响**:两种页签继续使用原有路由参数、权限及技能治理操作。
|
||||
- **回滚**:还原技能中心、两个子页与共用页签容器的对应布局改动。
|
||||
- **关联**:`src/pages/Organization/OrgSkillCenter.jsx`、`src/pages/Organization/org-skills.css`。
|
||||
|
||||
### 修复 · 企业质量维度分布提示栏对齐
|
||||
|
||||
- **范围**:企业中心质量监控「维度分布」的六个页签。
|
||||
- **变更**:图标和文案从提示栏左侧内边距起排,两者垂直居中对齐,间距为 6px。窄屏换行后文案各行左对齐。
|
||||
- **影响**:仅调整企业端维度分布提示栏的布局,覆盖警告和信息提示。
|
||||
- **回滚**:移除企业端维度分布提示栏的居中样式。
|
||||
- **关联**:`src/components/quality/quality.css`。
|
||||
|
||||
### 修复 · 表格分组布局与渠道分组参数
|
||||
|
||||
- **范围**:用户、企业、渠道、模型、密钥等调用分组表格,以及渠道筛选和编辑表单。
|
||||
- **变更**:分组标签统一单行紧凑显示。渠道筛选按查询参数编码,分组表单统一处理字符串和数组回填。
|
||||
- **影响**:分组显示、复制和模型更多分组入口沿用原有行为。用户、渠道、企业及密钥接口各自沿用已有字段类型。
|
||||
- **回滚**:还原分组布局、列宽配置及渠道分组转换与查询参数改动。
|
||||
- **关联**:`src/components/common/table/TableGroupTags.jsx`、`src/helpers/groupList.js`、`src/hooks/channels/useChannelsData.jsx`。
|
||||
|
||||
### 调整 · 企业效能分析页面
|
||||
|
||||
- **范围**:企业中心效能分析。
|
||||
- **变更**:统一页头、指标卡、列表卡、成本对账和移动端空态,版本下钻支持回车提交。
|
||||
- **影响**:保留各区块的排列和数据逻辑,指标图标及主操作随系统主题色。
|
||||
- **回滚**:还原效能分析页组件与页面样式。
|
||||
- **关联**:`src/pages/Organization/OrgEffectiveness.jsx`、`src/pages/Organization/org-effectiveness.css`。
|
||||
|
||||
### 修复 · 编辑用户分组提交格式
|
||||
|
||||
- **范围**:`/console/user` 编辑用户的分组字段。
|
||||
- **变更**:按后端的单分组权限契约回填和保存,历史名称中的逗号原样保留。
|
||||
- **影响**:保留已有分组选择及请求地址。
|
||||
- **回滚**:还原编辑用户表单的分组转换。
|
||||
- **关联**:`src/components/table/users/modals/EditUserModal.jsx`。
|
||||
|
||||
### 调整 · 明确最小移动验收视口
|
||||
|
||||
- **范围**:Playwright 与专项 UI 验收。
|
||||
- **变更**:明确 360×800 是必测的最小移动视口,保留 393×851 专项覆盖。
|
||||
- **影响**:默认 `chrome-mobile` 项目已使用 360×800。
|
||||
- **回滚**:还原本条对应的验收规范与 README 说明。
|
||||
- **关联**:`docs/ui/GLOBAL_UI_BASELINE.md`、`scripts/ui-review/config.json`。
|
||||
|
||||
### 修复 · 编辑用户抽屉关闭时标题闪动
|
||||
|
||||
- **范围**:`/console/user` 的编辑用户抽屉。
|
||||
- **变更**:关闭时保留当前用户,退出动画期间维持编辑标题和分区。
|
||||
- **影响**:下次打开时按选中的行重新加载用户信息。
|
||||
- **回滚**:恢复关闭抽屉时的选中用户清理逻辑。
|
||||
- **关联**:`src/hooks/users/useUsersData.jsx`。
|
||||
|
||||
### 修复 · 企业调用质量维度分布提示栏间距
|
||||
|
||||
- **范围**:`/org/quality` 的维度分布卡片。
|
||||
- **变更**:复用 18px 区块间距,统一提示栏与页签、结果区之间的留白。
|
||||
- **影响**:有提示、无提示和查询失败时均沿用同一组间距。
|
||||
- **回滚**:还原企业端维度分布的容器样式和表格上边距。
|
||||
- **关联**:`src/components/quality/QualityBreakdown.jsx`、`src/components/quality/quality.css`。
|
||||
|
||||
### 修复 · 补齐运营设置保存按钮对齐
|
||||
|
||||
- **范围**:`/console/setting?tab=operation` 的额度、邀请消费返佣、监控、兜底渠道、日志、屏蔽词过滤、跑马灯、技能超市与技能注入。
|
||||
- **变更**:9 个保存按钮复用运营设置操作区,与对应表单左边缘对齐。
|
||||
- **影响**:覆盖桌面和移动端,沿用各区块的保存处理。
|
||||
- **回滚**:还原本条涉及的保存按钮容器。
|
||||
- **关联**:`src/pages/Setting/Operation/`、`src/pages/Setting/Setting.css`。
|
||||
|
||||
### 调整 · 用户编辑抽屉对齐渠道编辑
|
||||
|
||||
- **范围**:`/console/user` 表格操作列的编辑用户抽屉。
|
||||
- **变更**:统一抽屉标题、分区标题、图标、面板间距和固定页脚,余额控件按视口切换单双列。
|
||||
- **影响**:保留原有用户字段、校验、额度调整和更新接口,提交期间防止重复保存。
|
||||
- **回滚**:还原用户编辑抽屉及对应的样式规则。
|
||||
- **关联**:`src/components/table/users/modals/EditUserModal.jsx`、`src/components/console/module-alignment.css`。
|
||||
|
||||
### 修复 · 统一表格分组标签文字
|
||||
|
||||
- **范围**:企业列表及共用分组标签的表格。
|
||||
- **变更**:分组列的 `default`、`vip`、`svip` 显示标准名称,移除企业列表追加的默认分组标记。
|
||||
- **影响**:默认分组配置、访问权限和计费规则沿用原逻辑。
|
||||
- **回滚**:还原分组列渲染与对应公共规范。
|
||||
- **关联**:`src/components/common/table/TableGroupTags.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 修复 · 运营设置操作区对齐
|
||||
|
||||
- **范围**:`/console/setting?tab=operation` 的通用、COS、提示词采集、语言与地区及管理员权限下放设置。
|
||||
- **变更**:将操作按钮与表单内容左边缘对齐,统一按钮组及语言规则校验提示的间距,权限选项沿用横向排列并统一行列间距。
|
||||
- **影响**:语言规则正常和校验失败时均保留操作区间距。
|
||||
- **回滚**:还原运营设置操作区的布局与样式。
|
||||
- **关联**:`src/pages/Setting/Operation/SettingsGeneral.jsx`、`src/pages/Setting/Operation/SettingsLanguage.jsx`、`src/pages/Setting/Setting.css`。
|
||||
|
||||
### 调整 · 企业日志筛选栏对齐消费记录
|
||||
|
||||
- **范围**:审计日志的提示词记录与操作审计卡片间距,消耗明细的明细日志、成员排行和绘图与视频筛选栏。
|
||||
- **变更**:复用个人消费记录的筛选卡布局、操作区和移动端折叠,统一搜索提交入口。审计日志的说明条上下及筛选卡至列表卡采用 18px 公共间距。
|
||||
- **影响**:沿用各页签的筛选条件、默认时间和请求逻辑。
|
||||
- **回滚**:还原本条对应的页面筛选区、公共样式和组件。
|
||||
- **关联**:`src/components/common/table/UsageRecordFilterCard.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`、`docs/ui/ORG_CENTER_SPEC.md`。
|
||||
|
||||
### 修复 · 企业成员页浮层触发节点引用
|
||||
|
||||
- **范围**:企业成员列表的状态开关和移除确认。
|
||||
- **变更**:表格状态开关和兼容层确认框将 `ref` 转发给 Ant Design 组件。
|
||||
- **影响**:消除 React 18 的 `Trigger` 引用告警,提示框可定位到对应的开关和按钮。
|
||||
- **回滚**:还原本条对应的组件引用转发及单测修改。
|
||||
- **关联**:`src/components/common/table/TableStatusSwitch.jsx`、`src/components/ui/index.jsx`。
|
||||
|
||||
### 修复 · 表格危险操作失败后可重试
|
||||
|
||||
- **范围**:表格操作列的删除、注销和冻结。
|
||||
- **变更**:业务回调回传提交结果。确认框在失败时保留当前记录,提交期间拦截重复确认。
|
||||
- **影响**:继续使用原接口、提示文案、权限判断及成功后的列表更新逻辑。
|
||||
- **回滚**:还原本条涉及的提交结果传递和确认框改动。
|
||||
- **关联**:`src/components/common/table/confirmTableAction.js`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 修复 · 模型超市筛选按钮对齐
|
||||
|
||||
- **范围**:`/market` 顶部筛选按钮。
|
||||
- **变更**:统一按钮内容的对齐方式,厂商图标调整为 16px,图标右侧文字下移 1px 以改善视觉对齐。
|
||||
- **影响**:带图标和纯文字的选项采用相同的对齐方式。
|
||||
- **回滚**:还原筛选按钮及其图标的对齐样式。
|
||||
- **关联**:`src/components/table/model-pricing/market/market.css`、`src/components/table/model-pricing/filter/PricingVendors.jsx`。
|
||||
|
||||
### 调整 · 统一 WeyAi 下载页
|
||||
|
||||
- **范围**:公开下载页与用户中心下载页。
|
||||
- **变更**:共用下载页布局和样式,用户中心保留面包屑,下载背景延伸至导航区域。
|
||||
- **影响**:两个入口使用相同的推荐卡、安装包列表与下载交互,布局按各自的可用宽度排列。
|
||||
- **回滚**:还原本条对应的下载组件、样式和布局规范。
|
||||
- **关联**:`src/pages/WeyAiDownload/`、`docs/ui/GLOBAL_UI_BASELINE.md`。
|
||||
|
||||
### 修复 · 表格危险操作确认交互
|
||||
|
||||
- **范围**:表格操作列的删除、注销和冻结。
|
||||
- **变更**:统一危险操作入口和确认按钮,补齐直接执行入口的确认步骤;取消优先聚焦。
|
||||
- **影响**:保留已有业务提示文案和提交逻辑。
|
||||
- **回滚**:还原本条对应的行操作入口和公共确认组件。
|
||||
- **关联**:`src/components/common/table/TableActionPopconfirm.jsx`、`src/components/common/table/TableActionModal.jsx`。
|
||||
|
||||
## 2026-11-23
|
||||
|
||||
### 功能 · 统一权限体系前端(合入 weiyuan 后按 antd 6 重做)
|
||||
|
||||
- **范围**:控制台路由守卫与侧栏、权限管理 5 页(菜单管理、平台角色、功能套餐、角色模板、运行模式)、用户管理、企业管理;企业中心入口与侧栏、角色管理(新增 `/org/roles`)、员工管理,以及其余企业中心页面的按钮显隐;企业登录页。
|
||||
- **变更**:新增 `src/authz`(`usePerm` / `Perm` / `PermRoute` / `ConsoleRoute`),已切到新权限体系的模块按权限点判断,未切换的沿用原角色判断;超管"进入企业"改走代理会话(`X-Proxy-Session`,只存当前标签页);当前企业统一经 `helpers/orgContext.js` 读写;员工管理合并为一张表并改为服务端筛选分页,新增员工编辑;用户管理新增状态筛选、"添加额度"(按调整量)与"分配角色";企业管理新增所有者、功能套餐、预警通知列与"更换所有者";授权树支持父子联动、半选与全部展开 / 收起;企业登录支持两步验证与首登改密。
|
||||
- **影响**:未切换时各入口的可见性与原来一致。员工管理不再有"员工权限 / 员工账号"页签;`OrgMemberAccounts.jsx` 只导出两个弹窗。接口变化见 `docs/10-数据安全与权限/10-权限体系重构改造方案.md` §13。本条所列页面均未做浏览器走查。
|
||||
- **回滚**:`git revert` 对应提交;权限管理页、`src/authz`、`orgContext.js` 为新增文件。
|
||||
- **关联**:`src/authz/*`、`src/pages/Permission/*`、`src/components/authz/PermTree.jsx`、`src/pages/Organization/{index,OrgSidebar,OrgRoles,OrgMembers,OrgMemberAccounts}.jsx`、`src/pages/Organization/orgMenuAccess.js`、`src/components/table/users/*`、`src/pages/AdminOrganizations/*`、`src/App.jsx`、`src/components/layout/SiderBar.jsx`。
|
||||
|
||||
### 修复 · 表格启停开关与分组样式统一
|
||||
|
||||
- **范围**:已有启停开关、调用或计费分组的表格,以及操作列删除确认规范。
|
||||
- **变更**:复用密钥管理的小尺寸状态开关和企业列表的分组标签;规范删除确认、提交防重及失败处理,文案可自定义。
|
||||
- **影响**:保持原接口、权限、确认及删除流程;单组与多组使用同一颜色映射。
|
||||
- **回滚**:分别还原共享组件接入和对应规范差异。
|
||||
- **关联**:`src/components/common/table/TableStatusSwitch.jsx`、`src/components/common/table/TableGroupTags.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 调整 · 渠道聚合标签编辑抽屉
|
||||
|
||||
- **范围**:`/console/channel` 标签聚合模式下的编辑标签抽屉。
|
||||
- **变更**:标签抽屉沿用编辑渠道的标题、面板和页脚,将标签名称与分组放入响应式栅格。创建渠道、编辑渠道和编辑标签的圆形图标均对齐模型编辑抽屉。
|
||||
- **影响**:可通过关闭按钮或取消退出,提交继续使用标签批量覆盖接口及校验规则。
|
||||
- **回滚**:还原标签编辑抽屉的布局、控件和页脚改动。
|
||||
- **关联**:`src/components/table/channels/modals/EditTagModal.jsx`、`src/components/table/channels/modals/EditChannelModal.jsx`、`src/components/console/module-alignment.css`。
|
||||
|
||||
### 调整 · 预约列表导出和操作确认
|
||||
|
||||
- **范围**:`/console/demo-reservations` 预约列表。
|
||||
- **变更**:复用日志页的导出按钮,水平居中表格列,加宽操作列左侧的状态列,启用、禁用与删除操作采用密钥管理页的确认弹窗样式。
|
||||
- **影响**:启停和删除在确认后提交;导出继续下载当前选中预约的 CSV。
|
||||
- **回滚**:还原预约列表的工具栏、列定义、确认弹窗与对应语言条目。
|
||||
- **关联**:`src/pages/DemoReservations/index.jsx`、`src/i18n/locales/`。
|
||||
|
||||
### 修复 · 审计提示词记录模型列样式
|
||||
|
||||
- **范围**:`/org/audit` 提示词调用记录的模型列。
|
||||
- **变更**:移除紫色标签,复用相邻提示词列的文字样式,保留长名称省略和悬浮提示。
|
||||
- **影响**:文字随浅深主题切换,不受品牌色覆盖;查询、权限和调用明细不变。
|
||||
- **回滚**:还原模型列渲染及共享文字类名提取。
|
||||
- **关联**:`src/pages/Organization/OrgPromptRecords.jsx`。
|
||||
|
||||
### 修复 · 消费记录渠道标签可读性
|
||||
|
||||
- **范围**:`/user-center/usage-record` 消费记录和绘图与视频任务记录表格的渠道列。
|
||||
- **变更**:调用明细采用与任务记录相同的默认填充标签,移除按渠道 ID 配色及井号图标,并修正点击复制的参数。
|
||||
- **影响**:两张表的渠道标签随亮暗主题使用中性底色,保留渠道名称提示和调用明细的多密钥序号。
|
||||
- **回滚**:按关联文件还原本条对应的标签渲染与样式。
|
||||
- **关联**:`src/components/table/usage-logs/UsageLogsColumnDefs.jsx`、`src/components/table/task-logs/TaskLogsColumnDefs.jsx`、`src/pages/UserCenter/UsageRecord.css`。
|
||||
|
||||
### 优化 · WeyAi 独立下载页原型对齐
|
||||
|
||||
- **范围**:`/weyai/download` 独立下载页和此路由的顶栏下载入口。
|
||||
- **变更**:首屏并排展示推荐安装区和工作台示意。安装包按系统分组,文件名和大小分行,指引区跟随可用宽度折行。
|
||||
- **影响**:首屏光晕、推荐提示、焦点环和顶栏选中态随当前主题生效。
|
||||
- **回滚**:按关联文件还原本条的布局与样式变更。
|
||||
- **关联**:`src/pages/WeyAiDownload/{index.jsx,weyai-download.css}`、`docs/ui/GLOBAL_UI_BASELINE.md` 第 5 节。
|
||||
|
||||
### 调整 · 官网设置关于我们文案
|
||||
|
||||
- **范围**:控制台官网设置。
|
||||
- **变更**:关于页签、页签说明、团队成员共用提示和跨页签校验文案统一使用“关于我们”,同步更新九个语言包。
|
||||
- **影响**:文案随当前界面语言显示,已保存的官网配置继续按原结构读取。
|
||||
- **回滚**:按关联文件还原对应文案。
|
||||
- **关联**:`src/pages/WebsiteSettings/{model.js,README.md}`、`src/i18n/locales/`。
|
||||
|
||||
### 修复 · Vite 开发服务暴露面
|
||||
|
||||
- **范围**:本地开发服务与共享测试环境部署说明。
|
||||
- **变更**:升级 Vite 和 esbuild,禁用开发服务中项目未使用的 `import.meta.glob` 转换。
|
||||
- **影响**:本机和局域网可继续访问开发端口 5174,普通动态导入和热更新沿用现有流程,共享测试环境可使用静态构建产物。
|
||||
- **回滚**:按关联文件还原配置和依赖锁定。
|
||||
- **关联**:`vite.config.js`、`package.json`、`package-lock.json`、`README.md`。
|
||||
|
||||
### 优化 · WeyAi 桌面端下载页
|
||||
|
||||
- **范围**:独立下载页 `/weyai/download` 与用户中心内嵌下载页。
|
||||
- **变更**:独立页扩大桌面内容区,整合版本信息、打开入口和推荐安装包。两处下载页均按系统分组展示安装包,按可用宽度切换列数,文件名完整换行,交互色跟随系统主题配置。
|
||||
- **影响**:鼠标或键盘激活“其他平台与架构”后,焦点落在安装包分区标题,随后按 Tab 可进入第一个包的下载按钮。
|
||||
- **回滚**:按关联文件还原本条对应的布局、样式和焦点处理。
|
||||
- **关联**:`src/pages/WeyAiDownload/{index.jsx,weyai-download.css}`、`docs/ui/GLOBAL_UI_BASELINE.md` 第 5 节。
|
||||
|
||||
### 优化 · 兜底渠道选择器
|
||||
|
||||
- **范围** 控制台「渠道管理」的渠道编辑抽屉。
|
||||
- **变更** 下拉项和已选标签显示渠道 ID 与名称,禁用状态以灰态和悬停提示表达。
|
||||
- **影响** 可按 ID、名称、分组和地域搜索。写入兜底链时仍按选择顺序提交数字 ID。
|
||||
- **回滚** 还原渠道编辑抽屉的选项标签和搜索字段。
|
||||
- **关联** `src/components/table/channels/modals/EditChannelModal.jsx`。
|
||||
|
||||
### 功能 · 预约演示列表管理
|
||||
|
||||
- **范围** 控制台「预约演示」。
|
||||
- **变更** 支持当前页多选、导出选中行的 CSV、逐条启停与确认删除。列宽按常见字段长度分配,表头字段居中,需求列随窗口加宽,窄屏下固定复选框和操作列。
|
||||
- **影响** 历史和新提交记录默认启用,删除记录从预约列表中移除并保留在数据库中。
|
||||
- **回滚** 还原本次前后端变更。旧版列表会重新显示软删除记录。
|
||||
- **关联** `src/pages/DemoReservations/` 和 `website_demo_requests`。
|
||||
|
||||
## 2026-11-21
|
||||
|
||||
### 修复 · 视频生成任务队列分页
|
||||
|
||||
- **范围**:体验中心视频生成页的任务队列。
|
||||
- **变更**:任务列表原先只请求一次 `GET /api/video/tasks`(不带分页参数,后端只返回首页),分页器仅在这一页内做前端切片,总数与翻页都不准确。改为复用该接口的服务端分页:请求携带 `p` / `page_size`,读取响应 `total`;翻页、切换每页条数(切换后回到第 1 页)都会重新请求;刷新、删除、取消、轮询结束后重载当前页,删除末页最后一条时回退到上一页;新提交的任务仅在第 1 页时插入表头,其余页只更新总数;快速翻页只采纳最后一次请求结果,加载中表格显示 loading。队列标题计数改为服务端总数,勾选仅针对当前页。
|
||||
- **影响**:分状态统计(排队 / 生成中 / 完成 / 失败)仍按当前页计算;轮询、播放、再生成、下载行为不变。
|
||||
- **回滚**:`git checkout <提交>^ -- <关联文件>`。
|
||||
- **关联**:`src/hooks/video/useVideoGeneration.js`、`src/pages/ExperienceCenter/components/AICreation/{VideoGenerationTab,Video/VideoTaskQueue}.jsx`。
|
||||
|
||||
## 2026-11-20
|
||||
|
||||
### 优化 · 体验中心页头与图片生成布局
|
||||
|
||||
- **范围**:体验中心云端大脑、图片生成、视频生成三页(新创作台灰度开启时的页面不在此范围)。
|
||||
- **变更**:三页页头统一为用户中心规格(面包屑“体验中心 / 当前页面”、28 / 32px 标题、14 / 22px 副标题、右侧操作),内容边距读取 `--uc-page-pad-*`;去掉图片、视频标题前的图标;图片生成表单卡标题改为“参数设置”,移动端收起时显示当前模型;云端大脑的使用指引与可用专家数移到页头右侧。图片生成宽屏下左侧参数栏固定,右侧生成历史整列局部滚动;视频生成宽屏下任务队列展开改为自底向上的浮层覆盖,不再挤压参数与预览区,支持 Esc 收起;队列表格样式与交互对齐密钥管理列表(middle 尺寸、46px 常规字重表头、文字链接操作),分页器移出表格滚动区并改为前端分页,修复切换每页条数时的布局抖动;任务 ID 完整纯文本展示,状态标签去掉图标、仅保留文字与边框并在单元格内水平垂直居中;图片、视频、云端大脑三页底部内边距统一减半;云端大脑“专家广场 / 我的任务”改为与 `/console/analytics` 一致的线型页签(企业中心宿主保留原分段按钮);图片生成历史工具栏合并为单行(模型、尺寸筛选并入首行),卡片提示词单行省略、缩略图 3:2,单一时间分组时省略分组标题(多分组时为紧凑标签),1920 宽屏常见浏览器可视高度(约 950px)下可完整看到工具栏与两行图片。右侧滚动视口 12px 圆角与左侧参数卡底边对齐,无匹配任务时空状态在列表区水平垂直居中。宽屏舒适密度下两行卡片按可视高度均分拉伸(行高 260–440px),第二行底边与左侧参数卡底边对齐;“清除筛选”移到筛选区最前、图标文字居中,出现时不推动下拉框;模型 / 尺寸下拉固定 190 / 128px,超长名称省略并在悬停时提示全名。对比模式勾选框缩小为 28px 浮层并修正复选框居中(去掉 antd 外层占位伪元素);云端大脑页头与页签间距减为 8px。三页(新创作台除外)页底与 `/console/analytics` 统一为 `--uc-page-bg`,云端大脑不再叠加装饰光晕;已在系统主题预设与自定义主色、浅深模式下验证。
|
||||
- **影响**:重置、移动端折叠、视频参数折叠、任务队列刷新 / 删除 / 播放、使用指引、专家 / 任务页签与无限加载行为不变;企业中心的云端大脑保留原卡片页头。
|
||||
- **回滚**:按文件还原下列文件,并删除 `ExperiencePageHeader.jsx` 与 `experience-page.css`。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/{ExperiencePageHeader,ImageGeneration,VideoGeneration}.jsx`、`src/pages/ExperienceCenter/components/AICreation/{ImageGenerationForm,ImageGenerationTab,ImageTaskList,Video/VideoTaskQueue}.jsx`、`ImageTaskList.css`、`src/pages/ExperienceCenter/experience-page.css`、`src/pages/ExperienceCenter/components/AICreation/{Image/ImageGenerationForm,Video/VideoWorkspace}.css`、`src/pages/CloudBrain/{index.jsx,cloud-brain.css}`、`docs/ui/GLOBAL_UI_BASELINE.md`。
|
||||
|
||||
### 优化 · 体验中心侧栏对齐用户中心
|
||||
|
||||
- **范围**:体验中心桌面端侧栏(云端大脑、图片生成、视频生成)。
|
||||
- **变更**:移除“体验中心”标题块与毛玻璃、渐变、选中竖条等装饰,改用用户中心侧栏同一套 `ui-center-sidebar` 结构与样式;底部按钮改为“收起导航 / 展开导航”,收起态仅显示图标并以 `title` 提示;BETA 标记与未读角标保留。
|
||||
- **影响**:展开 / 收起宽度、菜单项尺寸、选中色与用户中心一致,折叠状态在两个中心间同步;不改路由、模块可见性判定与移动端底部导航。
|
||||
- **回滚**:按文件还原 `ExperienceSidebar.jsx`、`ExperienceCenter/index.jsx` 与 `center-layout.css` 的对应段落。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/ExperienceSidebar.jsx`、`src/pages/ExperienceCenter/index.jsx`、`src/styles/center-layout.css`。
|
||||
|
||||
### 修复 · 图片生成历史首载闪烁
|
||||
|
||||
- **范围**:体验中心图片生成页的历史缩略图。
|
||||
- **变更**:首次加载仅在后台补齐缺失链接,避免已加载的缩略图因换源而重载。
|
||||
- **影响**:保留过期链接自动恢复和手动刷新入口。
|
||||
- **回滚**:逆向恢复本条对应的历史图片链接补齐逻辑。
|
||||
- **关联**:`src/hooks/image/useImageTaskManagement.js`。
|
||||
|
||||
### 修复 · 视频生成能力标签
|
||||
|
||||
- **范围**:体验中心视频生成页标题区。
|
||||
- **变更**:恢复图生视频、文生视频、多模型支持三枚说明标签;窄屏换行,配色继承系统主题。
|
||||
- **影响**:不改变模型能力判断、模式选择或生成流程。
|
||||
- **回滚**:逆向恢复标题区的标签结构和局部样式。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/VideoGeneration.jsx`。
|
||||
|
||||
### 优化 · 体验中心视频生成工作区
|
||||
|
||||
- **范围**:视频生成页的参数面板、视频预览和任务队列。
|
||||
- **变更**:以图片生成工作区的描边卡片为基准,统一标题、控件和空态;参数面板与任务队列可通过键盘折叠,任务队列不再遮挡预览;表单滚动区保留高级参数的展开高度,避免队列展开或窗口较矮时压缩折叠项。
|
||||
- **影响**:跟随系统主题配置;保持模型、视频生成、计价、任务和灰度开关契约。
|
||||
- **回滚**:仅逆向恢复本条对应的页面结构和样式。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/AICreation/VideoGenerationTab.jsx`、`src/pages/ExperienceCenter/components/AICreation/Video/VideoWorkspace.css`。
|
||||
|
||||
### 修复 · 官网设置品牌名称对齐
|
||||
|
||||
- **范围**:控制台官网设置的关于页签、说明、首页共用提示及校验提示。
|
||||
- **变更**:统一使用“微元算力”,同步九个语言包。
|
||||
- **影响**:不改变配置结构、表单校验或保存逻辑;联调存量文案仅替换实查命中的文章标题和正文。
|
||||
- **回滚**:逆向恢复本条的文案差异;如需回滚联调数据,先比对最新配置与保存前备份,只恢复本次变动的两处,避免覆盖后续编辑。
|
||||
- **关联**:`src/pages/WebsiteSettings/model.js`、`src/i18n/locales/`、`/api/website/page-config`。
|
||||
|
||||
### 优化 · 图片生成创作表单
|
||||
|
||||
- **范围**:体验中心图片生成页左侧创作表单。
|
||||
- **变更**:固定桌面端标题与生成区,归组模型和生成方式,整合提示词工具、模板、参考图与参数的视觉层次;移动端可收起表单并保留生成操作。
|
||||
- **影响**:沿用系统主题色与现有生成、引用、计价流程;右侧历史不变。
|
||||
- **回滚**:仅逆向恢复本条对应的表单结构和局部样式差异。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageSizePicker.jsx`。
|
||||
|
||||
### 优化 · 体验中心图片生成工作区
|
||||
|
||||
- **范围**:图片生成页的双栏工作区、创作表单和生成历史。
|
||||
- **变更**:以模型超市的描边卡片为参考,统一缩略图、状态占位和操作区;窄屏堆叠,选中和焦点状态跟随系统主题色。
|
||||
- **影响**:保留任务、模型和计价流程;历史卡片在各显示密度下均可打开详情和操作菜单。
|
||||
- **回滚**:逆向恢复本条的页面布局、表单及历史卡片差异。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationTab.jsx`、`ImageGenerationForm.jsx`、`ImageTaskList.jsx`。
|
||||
|
||||
### 修复 · 风控看板自动封号历史
|
||||
|
||||
- 复用运营看板折叠面板外框,展开时由分隔线连接标题和内容;保留默认展开、筛选、刷新、分页与解封行为。
|
||||
|
||||
### 修复 · 控制台调用质量维度分布
|
||||
|
||||
- 对齐维度页签、数据来源提示和表格间距;表格随内容增高,空态不滚动,仅数据列超宽时支持横向滚动。保留排序、下钻与前 50 项查询规则。
|
||||
|
||||
### 性能 · 开发预热与公共首屏分包
|
||||
|
||||
- **范围**:Vite 开发和生产配置、应用启动、首页和认证页的加载边界。
|
||||
- **变更**:预热入口、布局和路由;启动路径直接导入所需模块,拆出可单独缓存的 React 运行时;公告、协议预览和首页 Markdown 解析按需加载。
|
||||
- **影响**:减少默认首页和认证页首屏 JS,不改变接口、权限、设置与登录流程;支持基于构建清单验收启动预算及懒加载边界。
|
||||
- **回滚**:仅逆向恢复本条对应的配置、显式导入、懒加载与产物校验差异。
|
||||
- **关联**:`vite.config.js`、`src/index.jsx`、`src/components/auth/LazyAgreementModal.jsx`、`scripts/verify-build.mjs`。
|
||||
|
||||
### 修复 · 旧 UI 库审计规则统一
|
||||
|
||||
- **范围**:ESLint、UI 依赖审计、回归单测与开发文档。
|
||||
- **变更**:通过共享规则拦截旧 UI 包的导入、重导出及静态可确定的动态加载;审计扩展到根目录 JS 配置、脚本和单测,并检查 npm 别名与嵌套传递依赖。
|
||||
- **影响**:不改变运行时依赖或 UI 行为;保留本地品牌图标的来源与 SHA-256 校验。
|
||||
- **回滚**:仅逆向恢复本条对应的规则、审计、测试和文档差异。
|
||||
- **关联**:`eslint.config.cjs`、`scripts/ui-dependency-policy.cjs`、`scripts/check-ui-dependencies.mjs`、`test/unit/ui-dependency-policy.test.js`。
|
||||
|
||||
### 修复 · 个人密钥管理查询交互对齐
|
||||
|
||||
- **范围**:用户中心密钥管理的查询、搜索、分页。
|
||||
- **变更**:保留按名称、Key 或分组匹配的单输入框,对齐控制台的输入防抖、立即搜索和重置操作。
|
||||
- **影响**:普通列表复用 `/api/token/` 服务端分页;搜索复用该个人接口取全,在本地匹配和分页,不调用管理员接口。
|
||||
- **回滚**:仅逆向恢复本条对应的查询表单和密钥数据加载差异。
|
||||
- **关联**:`src/pages/KeyManagement/index.jsx`、`src/hooks/tokens/useTokensData.jsx`、`docs/ui/KEY_MANAGEMENT_SPEC.md`。
|
||||
|
||||
### 修复 · 客服浮钮收起箭头残留
|
||||
|
||||
- **范围**:全站右下角客服浮钮。
|
||||
- **变更**:从展开状态打开面板后,仅用底部圆形关闭按钮关闭时保留收起箭头;点面板右上角关闭或外部时隐藏箭头。点击侧边展开按钮后,箭头不再因按钮位置变化而立即消失;从收起状态临时打开面板后仍回到收起状态。
|
||||
- **影响**:保留键盘焦点反馈和触屏收起入口,不改变客服会话逻辑。
|
||||
- **回滚**:逆向恢复本条对应的客服浮钮焦点处理和样式差异。
|
||||
- **关联**:`src/components/customer-service/index.jsx`、`src/components/customer-service/styles.css`。
|
||||
|
||||
### 修复 · 全站表格统一分页
|
||||
|
||||
- **范围**:各中心、业务页面、卡片和弹层内原有分页的表格。
|
||||
- **变更**:统一为密钥管理的小型右对齐分页,补齐单页结果的条数入口和移动端跳页;未启用分页的表格保持原样。
|
||||
- **影响**:前端分页继续使用已加载数据,接口分页沿用原接口与筛选条件;换条数回到第一页,已分页的行不再二次切片。密钥管理本地筛选不再仅查当前接口页;兑换码翻页和换条数保留已提交的关键词。
|
||||
- **回滚**:逆向恢复本条对应的共享分页、页面分页接入、测试和规范差异。
|
||||
|
||||
### 更新 · 移除重复的长版权文件头
|
||||
|
||||
- **范围**:源码、脚本、样式、配置和测试中的统一长文件头。
|
||||
- **变更**:将原声明集中到 `NOTICE.md`,移除重复模板、ESLint 文件头规则及相关依赖。
|
||||
- **影响**:不改变业务逻辑,独立版权和第三方声明保持原样。
|
||||
- **回滚**:按本条差异逆向恢复长文件头、规则、依赖和规范,保留其他工作区改动。
|
||||
- **关联**:`NOTICE.md`、`eslint.config.cjs`、`package.json`、`package-lock.json`、`docs/standards/DEV_STANDARDS.md`。
|
||||
|
||||
### 修复 · ESLint 不再自动补写许可证头
|
||||
|
||||
- **范围**:JavaScript / JSX 许可证头检查。
|
||||
- **变更**:保留原许可证校验,关闭该规则的自动写入与替换。
|
||||
- **影响**:文件头缺失仍报错,现有版权和许可证声明保持不变。
|
||||
- **回滚**:还原本条配置和文档差异。
|
||||
- **关联**:`eslint.config.cjs`、`README.md`、`docs/standards/DEV_STANDARDS.md`。
|
||||
|
||||
### 修复 · 共享单测不再被全局忽略
|
||||
|
||||
- **范围**:Git 忽略规则和前端单测目录。
|
||||
- **变更**:移除按测试扩展名全局忽略的规则,将 12 个本地回归测试迁入 `test/unit/`,保留已跟踪的存量测试。
|
||||
- **影响**:团队可共享这些测试;本地验收目录仍被忽略,不改变生产代码。
|
||||
- **回滚**:恢复本条忽略规则与文档差异,并将迁移用例按原路径移回。
|
||||
- **关联**:`.gitignore`、`test/unit/`、`docs/standards/DEV_STANDARDS.md`、`README.md`。
|
||||
|
||||
### 修复 · 全量 undefined / NaN 展示防护与主题兼容回归
|
||||
|
||||
- **范围**:分析看板、组织/个人中心、充值/发票/订单/订阅、佣金、渠道模型测试、服务监控,以及亮色/暗色主题下的数字展示路径。
|
||||
- **变更**:新增并复用安全数字、金额、百分比与编号展示兜底;缺失或非法接口字段不再拼接为 `undefined`、`NaN%`、`xxundefined`;补齐 9 个语言包的未知档位文案与单元测试隔离 mock。
|
||||
- **影响**:只收敛用户可见展示和格式化健壮性,不改变请求载荷、权限、路由、计费或登录业务语义;主题色继续遵循现有 token 与亮暗主题派生规则。
|
||||
- **回滚**:按本条关联文件逐项回退;不使用整库 reset,保留其他会话的独立改动。
|
||||
- **关联**:`src/helpers/safeDisplay.js`、`src/helpers/render.jsx`、相关 `src/components/` 与 `src/pages/` 展示文件、`test/unit/safe-display.test.js`、`test/unit/market-name-search.test.js`、`.e2e/report/report.html`。
|
||||
|
||||
## 2026-11-19
|
||||
|
||||
### 更新 · ESLint 9
|
||||
|
||||
- **范围**:JavaScript / JSX 静态检查与 UI 依赖审计。
|
||||
- **变更**:升级至 ESLint 9.39.5 并迁移为扁平配置,保留原有检查规则。
|
||||
- **影响**:不改变应用运行时依赖。
|
||||
- **回滚**:同步还原配置、依赖锁文件和 UI 审计脚本的本条差异。
|
||||
- **关联**:`eslint.config.cjs`、`scripts/check-ui-dependencies.mjs`。
|
||||
|
||||
### 调整 · 对齐操作审计筛选栏
|
||||
|
||||
- **范围**:企业审计日志的「操作审计」页签。
|
||||
- **变更**:复用用户中心密钥管理的筛选表单布局、按钮与移动端折叠。
|
||||
- **影响**:保留操作类型、选择即筛选、重置、搜索和刷新逻辑;不影响「提示词记录」。
|
||||
- **回滚**:仅还原本条涉及的操作审计筛选栏改动。
|
||||
- **关联**:`src/pages/Organization/OrgAudit.jsx`。
|
||||
|
||||
### 调整 · 收窄表格「更多」菜单的使用范围
|
||||
|
||||
- **范围**:此前接入公共行操作菜单的表格。
|
||||
- **变更**:仅用户列表与合作伙伴列表保留新版「更多」,其他列表恢复原操作入口。
|
||||
- **影响**:保留现有权限、业务回调、筛选、分页及空态。
|
||||
- **回滚**:仅还原本条菜单差异,不覆盖其他页面改动。
|
||||
- **关联**:`src/components/common/table/TableToolbar.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 调整 · 企业表格分页与用量明细对齐
|
||||
|
||||
- **范围**:企业中心表格、企业密钥列表、用户中心调用明细及控制台使用明细。
|
||||
- **变更**:企业表格统一底部分页;密钥表按可见列宽度滚动;两端共用「用时 / 首字」标签和居中样式,调用明细与使用明细的操作入口均显示「详情」。
|
||||
- **影响**:前端分页不追加请求,接口分页沿用原有查询,树形数据保留父子关系。
|
||||
- **回滚**:只还原本条涉及的企业列表、分页适配和用量明细改动。
|
||||
- **关联**:`docs/ui/ORG_CENTER_SPEC.md`、`src/components/table/usage-logs/UsageLogsColumnDefs.jsx`。
|
||||
|
||||
### 调整 · 列表筛选、工具栏及分页对齐密钥管理
|
||||
|
||||
- **范围**:平台、企业、个人分佣,兑换码、会员卡、发票和用户中心密钥管理,含页签及明细表格。
|
||||
- **变更**:共享搜索按钮、筛选栅格和工具栏布局,统一分页总数、每页条数与切换行为。
|
||||
- **影响**:保留现有权限、接口用途和即时筛选;分佣档位每页条数传入列表请求,导出仍读取完整结果。
|
||||
- **回滚**:只还原本条所列的组件、分页和规范改动。
|
||||
- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md`、`src/components/console/ConsoleCollection.jsx`。
|
||||
|
||||
### 清理 · 移除无效的旧代理配置
|
||||
|
||||
- **范围**:前端包配置与联调说明。
|
||||
- **变更**:删除 `package.json` 中 Vite 不读取的 `proxy` 字段。
|
||||
- **影响**:不改变依赖、锁文件、本地联调后端或生产网关。
|
||||
- **回滚**:仅还原本条涉及的包配置与文档。
|
||||
- **关联**:`package.json`、`vite.config.js`、`README.md`。
|
||||
|
||||
### 修复 · 并发请求失败与会话过期提示
|
||||
|
||||
- **范围**:统一请求工具、登录入口及企业预算的关联查询。
|
||||
- **变更**:会话 401 单次处理并取消旧会话的未完成读取;支持按组取消关联读取;合并重复 HTTP 错误和过期提示。
|
||||
- **影响**:正常并发与公开请求不受限制;单个权限或服务错误不取消无关请求,也不会批量中断已发出的写入。
|
||||
- **回滚**:仅还原本条的请求生命周期、提示和关联查询改动。
|
||||
- **关联**:`src/helpers/api.js`、`src/helpers/requestLifecycle.js`、`src/pages/Organization/OrgBudgets.jsx`。
|
||||
|
||||
### 调整 · 登录与退出不再弹出成功提示
|
||||
|
||||
- **范围**:个人登录、企业登录、两步验证及顶栏退出登录。
|
||||
- **变更**:移除登录成功和退出成功弹窗。
|
||||
- **影响**:会话校验、页面跳转、失败提示及密码修改提示保持不变。
|
||||
- **回滚**:仅还原本条的成功提示改动。
|
||||
- **关联**:`src/helpers/loginFlow.js`、`src/components/auth/TwoFAVerification.jsx`、`src/hooks/common/useHeaderBar.js`。
|
||||
|
||||
### 修复 · 个人与企业登录回跳错位
|
||||
|
||||
- **范围**:个人登录、企业登录及同一浏览器切换账号。
|
||||
- **变更**:直接登录不再读取旧回跳地址;验证会话账号后才完成登录,拒绝明显不匹配的落点;旧会话的迟到响应不再覆盖新会话;企业账号跳转时不再短暂挂载受限的个人页面并误弹权限提示。
|
||||
- **影响**:保留适用的深链参数、锚点和原有权限校验;无有效落点时回到对应入口的默认页面。
|
||||
- **回滚**:仅还原本条对应的登录、回跳逻辑和测试。
|
||||
- **关联**:`src/App.jsx`、`src/helpers/loginFlow.js`、`src/helpers/data.js`、`src/components/layout/PageLayout.jsx`、`test/unit/post-login-redirect.test.js`。
|
||||
|
||||
### 调整 · 控制台列表与行操作统一
|
||||
|
||||
- **范围**:控制台兑换码、会员卡、发票管理,以及控制台、企业中心、用户中心和视频任务队列的多操作列表。
|
||||
- **变更**:筛选栅格、列表工具栏、表头、分页与空态按密钥管理收敛;低频行操作统一进入带箭头的“更多”菜单。
|
||||
- **影响**:不改变接口、载荷、权限、状态限制及危险操作确认;筛选与菜单适配移动端和亮暗主题;修复兑换码抽屉关闭后快速重新编辑时记录被延时清空的问题。
|
||||
- **回滚**:仅还原本条关联的列表、行操作和公共样式改动,不还原其他主题改动。
|
||||
- **关联**:`src/components/common/table/TableToolbar.jsx`、`src/components/console/ConsolePrimitives.jsx`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 修复 · 云端大脑撰写态左侧对齐
|
||||
|
||||
- **范围**:`/experience-center/cloud-brain` 专家列表与撰写区布局。
|
||||
- **变更**:撰写态由固定宽度居中改为从内容区左侧对齐,编辑区填充剩余空间,消除宽屏左侧与右侧的大块空白。
|
||||
- **影响**:仅调整布局样式,保留专家选择、任务填写和主题切换行为;窄屏单列布局不变。
|
||||
- **回滚**:还原 `src/pages/CloudBrain/cloud-brain.css` 中 `.brain-expert-layout.is-composing` 规则。
|
||||
|
||||
### 修复 · 图片生成底部操作区固定布局
|
||||
|
||||
- **范围**:`/experience-center/image-generation` 参数表单与生成操作区。
|
||||
- **变更**:将生成按钮及估价移出参数滚动容器,通过独立 flex 区域贴住表单底边;移除固定 124px 底部占位,操作区使用完整主题表面背景,并兼顾移动端安全区。
|
||||
- **影响**:桌面参数独立滚动,末尾参数可完整滚入可视区域;移动端保留自然堆叠与展开、收起行为,生成及估价逻辑不变。
|
||||
- **回滚**:仅还原本条涉及的表单滚动结构与操作区 CSS,保留其他主题适配改动。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`。
|
||||
|
||||
### 修复 · 图片生成表单背景与圆角主题适配
|
||||
|
||||
- **范围**:`/experience-center/image-generation` 图片生成表单外层、分区与底部生成操作区。
|
||||
- **变更**:统一使用主题卡片表面色与边框 token,补齐整块白色背景、连续圆角和底部 sticky 操作区的顶部边界;深色模式自动映射深色表面。
|
||||
- **影响**:仅调整视觉层,保留模型选择、提示词、参数、估价和生成逻辑;禁用按钮继续保持不可提交状态。
|
||||
- **回滚**:按文件还原 `ImageGenerationForm.jsx`、`ImageGenerationForm.css` 及本条记录。
|
||||
- **关联**:`src/pages/ExperienceCenter/components/AICreation/ImageGenerationForm.jsx`、`src/pages/ExperienceCenter/components/AICreation/Image/ImageGenerationForm.css`。
|
||||
|
||||
### 调整 · 推广分享弹窗布局与交互
|
||||
|
||||
- **范围**:顶栏推广入口的链接分享、海报分享及奖励规则入口。
|
||||
- **变更**:采用 800px Ant Design 弹窗;链接分享以扫码区与复制区双栏展示,奖励规则收为底部轻量入口;海报预览与模板、导出操作分栏,模板使用带名称的单选控件并支持键盘选择;移动端堆叠,短视口正文限高滚动。
|
||||
- **影响**:弹窗主体跟随系统主题色与亮暗模式,保留已有海报模板、分享接口、邀请地址、奖励页路由和 PNG 导出逻辑;邀请码不可用时不展示占位二维码。
|
||||
- **回滚**:按文件还原 `src/components/promotion/PromotionPosterModal.jsx` 与 `src/components/promotion/promotion-poster.css`。
|
||||
- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md` 第 8、10、15 节。
|
||||
|
||||
### 修复 · 系统主题色在亮暗模式下的交互对比度
|
||||
|
||||
- **范围**:共享主题入口、双端侧栏与公告、实底控件及系统设置主题色预览。
|
||||
- **变更**:由当前主题色分别派生实底、文字和选中浅底;亮暗模式分别控制亮度与饱和度。同步企业强调色、个人深色页签和设置预览;预览链接示意即时切色,气泡按渐变亮度选用可读文字。
|
||||
- **影响**:暗色原型侧栏保持琥珀选中态;默认浅色选中文字微调以达对比度要求。保留原始配置及持久化,成功、警告、错误仍独立配色。
|
||||
- **回滚**:按文件回退本条涉及的主题解析、样式桥、消费者和配色单测,不改系统设置数据。
|
||||
- **关联**:`docs/standards/UI_COMPONENT_STANDARDS.md`、`docs/ui-review-checklist.md`。
|
||||
|
||||
### 调整 · 新手教程阅读布局与主题适配
|
||||
|
||||
- **范围**:`/tutorial` 图文、视频教程及关闭入口。
|
||||
- **变更**:去除固定阅读高度和嵌套纵向滚动,桌面采用步骤目录与正文双栏、移动目录换行;目录支持滚动同步与焦点定位,代码自动折行;视频列表支持键盘选择;关闭入口使用 Ant Design 文本图标按钮与提示,修复视频空态标题。
|
||||
- **影响**:颜色跟随系统主题配置和亮暗主题;保留教程内容、请求、链接、返回逻辑和小程序充值步骤隐藏规则。
|
||||
- **回滚**:按文件还原 `src/pages/Tutorial/` 本次修改。
|
||||
- **关联**:`docs/ui/GLOBAL_UI_BASELINE.md`、`docs/standards/UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
### 调整 · 顶栏右侧工具与账户对齐
|
||||
|
||||
- **范围**:共享顶栏右侧教程、推广、下载、充值、主题、公告、语言和账户入口。
|
||||
- **变更**:统一按钮高度、图标与文字行高和间距;消除链接与公告徽标包装层的行内基线偏移;调整头像、箭头与分隔线居中,桌面专属按钮按移动断点隐藏。
|
||||
- **影响**:保留既有权限、配置和操作回调,样式随亮暗主题切换。
|
||||
- **回滚**:按文件还原 `src/components/layout/headerbar/ActionButtons.jsx` 与 `src/styles/prototype.css` 顶栏相关段落。
|
||||
- **关联**:`docs/ui/GLOBAL_UI_BASELINE.md` 第 4.1 节。
|
||||
|
||||
### 文档 · 补充双端 UI 审查清单
|
||||
|
||||
- **范围**:企业端与个人端的 UI 审查、真实操作验收与证据归档。
|
||||
- **变更**:登记可复用审查清单,忽略 `.e2e/` 的分阶段本地产物。
|
||||
- **影响**:不改变业务、路由、接口或 Playwright 默认配置;验收证据与会话缓存不入库。
|
||||
- **回滚**:按文件还原本条涉及的清单、索引与忽略规则;保留既有本地验收证据。
|
||||
- **关联**:`docs/ui-review-checklist.md`、`README.md`、`.gitignore`。
|
||||
|
||||
### 功能 · 恢复服务监控入口并接入超管开关
|
||||
|
||||
- **范围**:用户中心桌面侧栏、移动底栏、服务监控路由与面包屑。
|
||||
|
||||
+2
-1
@@ -18,7 +18,7 @@
|
||||
| 修改企业中心 / 控制台 | `ui/ORG_CENTER_SPEC.md` / `ui/CONSOLE_SPEC.md` | — |
|
||||
| 修改模型超市 / 技能超市 | `ui/MODEL_MARKET_SPEC.md` / `ui/SKILL_MARKET_SPEC.md` | — |
|
||||
| 修改任一表格的列设置 | `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | — |
|
||||
| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | 对应页面规范的“验收要点” |
|
||||
| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | `ui-review-checklist.md`、对应页面规范的“验收要点” |
|
||||
| 查改动范围或回滚方式 | `CHANGELOG.md` | — |
|
||||
|
||||
每份规范开头都有“何时阅读”和“速查”表,先看速查,需要细节再按章节号读取。
|
||||
@@ -38,6 +38,7 @@
|
||||
| `ui/MODEL_MARKET_SPEC.md` | 模型超市 | 约 8KB |
|
||||
| `ui/SKILL_MARKET_SPEC.md` | 技能超市与数据模式 | 约 8KB |
|
||||
| `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | 表格列设置 | 约 4KB |
|
||||
| `ui-review-checklist.md` | 双端 UI 审查、交互与证据记录清单 | 约 3KB |
|
||||
| `CHANGELOG.md` | 对现状仍有影响的功能与修复记录 | 约 6KB |
|
||||
|
||||
## 规则优先级
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 统一开发与 Ant Design CRUD 规范
|
||||
|
||||
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-18 · 版本:v2.3
|
||||
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-26 · 版本:v2.6
|
||||
|
||||
新增与重构 CRUD 的编码规范:目录与命名、组件选择、请求、React 组件与状态、表单与弹层、权限、i18n,以及可直接复制的页面模板。外观取值见 `UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
| React | 函数组件 + Hooks;派生值在渲染中计算;记忆化只用于测量过的问题(第 4 节) |
|
||||
| 状态命名 | `items`、`total`、`page`、`pageSize`、`filters`、`loading`、`submitting`、`editingRecord`、`drawerOpen` |
|
||||
| 表单 | `Form.useForm` + `rules`;失败不关闭弹层;提交按钮 `loading` 防重复(第 6 节) |
|
||||
| 文件 | 带 AGPL 许可证头;单测放 `test/unit/`;文案补齐 9 个语言包 |
|
||||
| 文件 | 不重复添加通用长版权文件头;单测放 `test/unit/`;文案补齐 9 个语言包 |
|
||||
|
||||
**相关代码**:`src/helpers/api.js`、`src/helpers/utils.jsx`、`src/helpers/paging.js`、`src/helpers/auth.jsx`、`src/components/ui/`、`src/components/console/`、`src/pages/Organization/components/`
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
| 视图(企业中心) | `src/pages/Organization/Org<Module>.jsx`,Hook 放 `src/hooks/org/` | 同上;单文件过大时拆到 `components/` |
|
||||
| 视图(用户中心) | `src/pages/UserCenter/<Module>.jsx` + 同名 `.css` | 同上 |
|
||||
| 控制台路由入口 | `src/pages/<Module>/index.jsx` | 由 `App.jsx` 以 `React.lazy` 加载 |
|
||||
| 单元测试 | `test/unit/<module>-*.test.js` | `.gitignore` 忽略 `*.test.*`,仅此目录可入库 |
|
||||
| 单元测试 | `test/unit/<module>-*.test.js` | `.gitignore` 不再按测试扩展名全局忽略;保留已跟踪的存量测试 |
|
||||
|
||||
### 1.2 命名
|
||||
|
||||
@@ -53,9 +53,9 @@
|
||||
| 样式 | 页面根类 + 局部变量族 `--<前缀>-*`;文件 kebab-case | `.km-page`、`--km-card-border`、`key-management.css` |
|
||||
| 后端字段 | 保持 snake_case 原样,不在前端改名 | `created_time`、`page_size` |
|
||||
|
||||
### 1.3 必备文件头
|
||||
### 1.3 版权声明
|
||||
|
||||
ESLint 规则 `header/header` 要求每个 `.js/.jsx` 顶部带 AGPL 许可证块注释,直接复制任一现有源码文件的第 1–18 行;缺失会让 `npm run eslint` 失败。
|
||||
源码不重复添加通用长版权文件头,保留独立的第三方声明。
|
||||
|
||||
## 2. Ant Design 组件边界
|
||||
|
||||
@@ -110,7 +110,7 @@ ESLint 规则 `header/header` 要求每个 `.js/.jsx` 顶部带 AGPL 许可证
|
||||
|
||||
- 外观取值(颜色、间距、圆角、字号、各组件样式)以 `docs/standards/UI_COMPONENT_STANDARDS.md` 为准,本文只写编码约束。
|
||||
- 按钮与操作图标:`import { Plus, Pencil, Trash2, RefreshCw, Search } from '@/components/common/icons/ActionIcons'`,按钮内传 `size={16}`;装饰图标用 `lucide-react`。
|
||||
- 禁止导入 `@lobehub/*`、Radix UI、Floating UI、Semi、MUI、Chakra、Headless UI、leva、antd-style、react-layout-kit(ESLint `no-restricted-imports` 与 `npm run check:ui` 拦截)。
|
||||
- 禁止导入 `@lobehub/*`、Radix UI、Floating UI、Semi、MUI(含旧 `@material-ui/*`)、Chakra、Headless UI、leva、antd-style、react-layout-kit。ESLint 的 `ui-dependencies/no-legacy-ui` 与 `npm run check:ui` 共用 `scripts/ui-dependency-policy.cjs`,不要在入口重复维护包名。
|
||||
- JSX 不写十六进制颜色;不用全局 `!important`;新视图不用 Tailwind 颜色类(如 `text-gray-500`),改用 token 或页面变量。
|
||||
|
||||
## 3. 请求封装与错误处理
|
||||
@@ -118,8 +118,10 @@ ESLint 规则 `header/header` 要求每个 `.js/.jsx` 顶部带 AGPL 许可证
|
||||
### 3.1 规则
|
||||
|
||||
- 只用 `import { API } from '@/helpers'`;禁止新建 axios 实例或用 `fetch` 调 `/api`(流式对话 `src/hooks/playground/useApiRequest.jsx` 除外)。
|
||||
- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行提示);401 清理会话并跳转 `/org/login?expired=true`。
|
||||
- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭,带取消信号或请求组的 GET 不共享);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行处理)。受会话约束的接口首次返回 401 时取消该会话未完成的只读请求,阻止该会话继续发请求,并仅清理、跳转 `/org/login?expired=true` 一次。公开接口或显式 `sessionBound: false` 的请求不参与会话联动。
|
||||
- 同一批必须全部成功的只读请求,可传入同一个 `requestGroup: new AbortController()`;首次拒绝的 HTTP 4xx/5xx 取消同组剩余读取。普通失败不取消无关请求,正常并发不限流;已发送的写入不由请求组批量取消。调用方仍须处理 Promise 拒绝,并在 `finally` 清理加载状态。
|
||||
- 查询参数用 `params` 对象,不手拼查询字符串(手拼不会编码 `&`、`#`、中文)。
|
||||
- `API` 的 GET、HEAD、OPTIONS 默认在 60 秒后超时,调用方可以通过 `timeout` 覆盖。保持在 `finally` 回收加载状态,并让过期请求与当前请求的状态互不干扰。
|
||||
- 响应按 `{ success, message, data }` 处理,先判断 `success`;具体字段以接口契约为准。
|
||||
- 分页参数 `p` 从 1 开始,`page_size` 默认 `ITEMS_PER_PAGE`(10,须与后端一致);后端对 `page_size > 100` 静默截断为 100,需要全量数据时用 `collectPagedItems(fetchPage)`(`src/helpers/paging.js`)。
|
||||
|
||||
@@ -201,7 +203,7 @@ try {
|
||||
- 批量操作:`rowSelection={{ selectedRowKeys, onChange: setSelectedRowKeys }}`。
|
||||
- 删除后的页码回退、筛选后的页码重置放在 hook 中处理(不要散落在组件中)。
|
||||
- 列设置只用于已有该功能的表格(`docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
||||
- 分页统一用适配层 `Table` / `Pagination`;`/console`、`/org` 下自动统一,其他路由按下例显式传入,避免改页容量时请求两次:
|
||||
- 所有路由的分页表格用适配层 `Table` / `Pagination`。完整数据交给 `Table` 本地分页,不传 `total`;已由页面筛选切片或由接口返回单页数据时传 `total`,表格不会再次切片。未开启分页的表格保持原样。受控分页按下例传入,条数回调自行回到第 1 页,不再触发翻页回调:
|
||||
|
||||
```jsx
|
||||
pagination={{
|
||||
@@ -210,10 +212,6 @@ pagination={{
|
||||
total,
|
||||
onPageChange: handlePageChange,
|
||||
onPageSizeChange: handlePageSizeChange,
|
||||
showSizeChanger: true,
|
||||
pageSizeOpts: [10, 20, 50, 100],
|
||||
showTotal: (count) => t('共 {{total}} 条', { total: count }),
|
||||
preventPageChangeOnPageSizeChange: true,
|
||||
}}
|
||||
```
|
||||
|
||||
@@ -225,7 +223,7 @@ pagination={{
|
||||
- 防重复:提交中按钮 `loading` 或 `confirmLoading`;hook 内 `submitting` 为真时直接返回。
|
||||
- 成功:`showSuccess` → 关闭 → 刷新当前页;失败:保留弹层与已填内容。
|
||||
- 打开时重置:弹层加 `forceRender`,在 `useEffect([open, record])` 中先 `resetFields()` 再 `setFieldsValue(record)`。
|
||||
- 删除:`Popconfirm` 的 `onConfirm` 返回 Promise 以显示加载;批量或不可撤销操作用 `Modal.confirm`。
|
||||
- 删除:确认回调返回 Promise 以显示加载;确认形态、危险按钮、失败保留与键盘交互见组件规范第 8 节。
|
||||
- 日期提交前转换为后端格式(多为 Unix 秒);有未保存内容时沿用页面已有的关闭确认流程。
|
||||
|
||||
## 7. 加载、空态与错误态
|
||||
@@ -293,7 +291,7 @@ pagination={{
|
||||
### 12.1 检查与构建
|
||||
|
||||
- Prettier:`singleQuote`、`jsxSingleQuote`,换行 LF;规范类文档使用紧凑表格(`.prettierrc.mjs` 的 overrides)。
|
||||
- ESLint:许可证头、`no-undef`、未使用 import 报错、Hooks 规则、禁用 UI 库导入,`--max-warnings=0`。
|
||||
- ESLint:`no-undef`、未使用 import 报错、Hooks 规则、禁用 UI 库导入,`--max-warnings=0`。
|
||||
|
||||
```bash
|
||||
npm run eslint # 0 错误 0 警告
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# UI 公共组件与样式规范
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.5
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-20 · 版本:v2.6
|
||||
|
||||
所有后台页面共用的主题与组件标准。页面规范只记录与本文不同的部分;编码约定见 `DEV_STANDARDS.md`,外壳与布局见 `GLOBAL_UI_BASELINE.md`。
|
||||
|
||||
@@ -53,9 +53,9 @@
|
||||
|
||||
品牌主题预设在 `src/styles/presets.js`,主题配置与持久化在 `src/helpers/theme.js` 与 `src/context/Theme`;预设 key 不改名。
|
||||
|
||||
组件级配置:`Menu`(项高 42px,选中底 `#fff3df` / `#382b1b`,选中文字 `#a95d07` / `#f2ad41`);`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。
|
||||
组件级配置:`Menu` 项高 42px,原型选中底 `#fff3df` / `#382b1b`,选中文字 `#a45a07` / `#f2ad41`;`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。
|
||||
|
||||
暗色主色:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`。系统以 `#d1963a` 作为 `colorPrimary`,其余衍生 token 仍按种子推导;页面需要“品牌强调色”时用 `brandAccentFromToken(colorPrimary, dark)`,浅色与自定义主色返回 `colorPrimary`,默认暗色返回 `#f2ad41`。
|
||||
暗色原型:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`;保留该全局主色及原型选中态。系统配置的主题色保留为原始种子,交互色根据当前明暗模式派生:选中背景低浓度着色,选中文字与强调色保证可读;实底按钮的默认、悬停和按压态共享同一前景色。页面复用 `--brand-accent`、`--brand-selection-bg`、`--brand-selection-text`,不自行写固定品牌色;成功、警告、错误继续独立于主色。
|
||||
|
||||
### 2.2 取色方式
|
||||
|
||||
@@ -125,13 +125,25 @@ html.dark .km-page {
|
||||
|
||||
## 4. 表格搜索栏(筛选卡)
|
||||
|
||||
- **筛选卡与列表卡间距**:从筛选卡底边到下方列表卡顶边统一为 18px,复用 `--uc-layout-gap`。同一对相邻区块只设置一次间距,优先由共同容器的 `gap` 控制。企业端以 `/org/logs` 为对齐基准,审计日志若在页签与筛选卡之间插入说明条,说明条上下也各留 18px。
|
||||
- 背景:使用不透明的卡片纯色;浅色为白色,深色沿用主题卡片色,不使用渐变背景。
|
||||
- 字段竖排:标签在上(13px,次文字色,下距 8px),控件在下且宽度占满单元格。
|
||||
- 栅格:列间距与行间距 16px;按页面宽度取 3–5 列(企业中心 3 列、控制台 4 列、用户中心 5 列,时间范围可跨 2 列);≤ 768px 单列。
|
||||
- 操作:“重置”“搜索”位于右下,间距 8px;“搜索”为 primary 且 `htmlType='submit'`,回车提交。
|
||||
- 行为:搜索与重置都回到第 1 页;重置 = 清空表单 + 以默认条件重新查询;只切换筛选的页签放在筛选卡上方。
|
||||
- 搜索保留当前页码、每页条数、排序、勾选和展开等表格操作状态。点击“重置”时取消待执行搜索及在途筛选请求,恢复本页的默认筛选条件,回到第 1 页并初始化本页的表格操作状态。只切换筛选的页签放在筛选卡上方。
|
||||
- 移动端:用户中心与控制台默认收起,通过“显示 / 隐藏操作项”或“筛选”按钮展开;列设置入口不随筛选收起。
|
||||
- 控制台使用 `ConsoleSearchBar` + `ConsoleSearchActions`,企业中心使用 `OrgFilterCard`,不要另写网格。
|
||||
- 控制台使用 `ConsoleSearchBar` + `ConsoleSearchActions`,企业中心常规筛选使用 `OrgFilterCard`。消耗明细及提示词记录复用个人消费记录的筛选布局和移动端折叠。
|
||||
- 标准列表以 `/console/token` 为参考,覆盖控制台分佣、兑换码、会员卡和发票,企业及个人分佣,以及用户中心密钥管理(含各自子页、页签和详情列表)。使用 `ConsoleCollection`(或通过 `CardPro` 接入);独立列表可用 `ConsoleCollectionSearch` + `ConsoleFilterGrid`。筛选栅格为三列、≤ 1100px 两列、≤ 768px 单列。
|
||||
- 搜索操作在筛选卡右下,先默认样式“重置”(无图标),再带放大镜的主按钮“搜索”;点击和回车共用同一个提交入口。移动端统一通过“显示/隐藏操作项”切换。
|
||||
- 工具栏在列表卡内、表格上方:列表标题、计数或快捷筛选在左;已有的批量、导出、刷新、列设置、新建等动作在右,主操作尽量靠右,使用公共操作图标和清晰文案。窗口变窄时自然换行。只读明细若没有筛选或业务动作,不新增占位按钮。
|
||||
|
||||
### 4.1 时间范围及自动搜索
|
||||
|
||||
- 表格筛选的范围控件使用 `DatePicker` 或 `Form.DatePicker` 的 `tableFilter`,开始和结束输入框共用一个控件,支持清除。仅日期使用 `YYYY-MM-DD`,含时间使用 `YYYY-MM-DD HH:mm:ss`。日期弹层使用当前主题;桌面快捷周期位于日历左侧,窄屏可换行。
|
||||
- 快捷周期依次为今天、近 7 天、本周、近 30 天、本月,复用 `DATE_RANGE_PRESETS`。相对周期按选择时的本地日期计算,匹配已提交范围时显示选中态。页面沿用自身初始日期或空值。选择完整范围、确认时间、选择快捷周期或清除后,通过同一个值变更入口提交;临时选择、悬浮预览和下拉搜索词不触发列表查询。
|
||||
- `useFilterSearch` 将字段变更合并为一次 300ms 防抖查询。兼容表单用 `onValueChange={scheduleSearch}`,原生 Ant Design Form 用 `onValuesChange` 传最终值;独立受控字段可用 `changeFilter(setValue)`。输入框、数字组件、选择器、开关、复选和异步选择组件均在实际筛选值变化时接入。搜索按钮和回车共用 `submitSearch`,立即执行待查询条件。
|
||||
- 后端分页沿用现有查询接口,传当前页及条件,同时将 `AbortSignal` 传到 `API`。字段变化、重置和卸载取消在途查询,忽略过期响应。以页码或已应用条件驱动请求的页面可用 `useTableFilterQuery` 将取消操作传给 `useFilterSearch`。
|
||||
- 本地分页先按条件处理完整数据集再切页。独立控件可用 `useLocalTableFilters` 分开显示值与已应用值,再用 `useFilteredTableRows` 计算结果。大数组过滤复用 `filterTableRows`,超出 500 行时分片让出主线程,并在每批检查取消状态。
|
||||
|
||||
## 5. 表格
|
||||
|
||||
@@ -148,27 +160,31 @@ html.dark .km-page {
|
||||
### 5.2 列
|
||||
|
||||
- 每列显式 `width`,长文本 `ellipsis` 并配 `Tooltip`;金额与数量右对齐;时间统一格式,必要时日期与时间分两行。
|
||||
- 状态列用 `Tag` 或 `Switch`(见第 11 节);启停开关请求中禁用,失败恢复原状态。
|
||||
- 操作列放在最后,按钮为 `type='link' size='small'`,危险操作加 `danger`,同一行操作间距 8–10px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`;操作较多时折叠到“更多”下拉。
|
||||
- 状态列用只读 `Tag` 或 `TableStatusSwitch`(见第 11 节);启停开关请求中禁用,失败恢复原状态。
|
||||
- 调用、计费和访问权限分组列使用 `TableGroupTags`,单组与多组按同一套颜色渲染(见第 11 节)。
|
||||
- 操作列放在最后,标题固定为“操作”,按钮为 `type='link' size='small'`,同一行操作间距 8px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`。`/console/user` 的用户列表、`/console/subscription` 的会员列表和 `/console/commission?view=partners` 的合作伙伴列表使用 `TableRowActions`:直出高频动作,其余放进带下箭头的文字“更多”菜单。其他列表沿用既有操作呈现方式,不批量套用此菜单。菜单点击打开、右对齐,无有效菜单项时不渲染入口;危险项置末、标记 `danger` 并保留业务确认。现有权限、状态限制、禁用项和回调不得因收纳而改变,方向键、Enter、Escape 可操作菜单。
|
||||
- 三中心表格通过 `CenterActionTable` 统一处理,最后一列存在创建、查看、编辑、测试、详情、删除、添加、设置、配置、弹窗 / 抽屉或请求交互时,列头统一显示“操作”并固定右侧,宽度按按钮 / 交互数量计算。没有操作列但估算列宽超出容器时,从右侧固定末 4 列,列数不足时降为 3、2、1 列。固定列使用不透明底色并保持表头层级;横向滚动条遵循 Ant Design 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。
|
||||
- 列显隐只在已有列设置的表格中提供,统一使用 `ColumnSettings`(见 `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
||||
- 三中心表头背景统一由 `center-table.css` 绘制:页面通过 `--center-table-head-bg` 提供色调,公共层在不透明的容器底色上叠加同色填充,普通列与固定列保持一致;页面不再直接覆盖表头 `background`。固定列使用 antd 6 的 `.ant-table-cell-fix` 与原生动态层级,不写死 `z-index`,不使用旧版 `fix-left` / `fix-right` 类名补丁;表头不换行,表头与正文沿用同一列宽和对齐方式。
|
||||
- 操作列在异步数据或列变化后重新测量可见行的按钮宽度,取最大值;列宽不超过表格容器,按钮组在空间不足时换行。左右固定区总宽超过容器时,保留右侧操作列,其余固定列参与横向滚动;容器恢复足够宽度后恢复原固定配置,避免窄屏相互遮挡。
|
||||
- 操作列的删除入口置末并用 `danger`;点击仅打开确认,确认后的提交与刷新按第 8 节执行。无权删除或当前状态不允许删除时,沿用业务的隐藏或禁用规则。
|
||||
|
||||
### 5.3 状态
|
||||
|
||||
| 状态 | 写法 |
|
||||
| --- | --- |
|
||||
| 加载 | `Table loading` |
|
||||
| 空数据 | `Empty image={Empty.PRESENTED_IMAGE_SIMPLE}`,文案沿用页面原有 |
|
||||
| 空数据 | 标准列表使用 `TableEmpty`(`ConsoleListTable` 默认接入):保留表头,简单插图 + “暂无数据”在当前可见宽度内居中;加载中不把空态当作查询结果,失败继续走错误提示 |
|
||||
| 批量操作 | `rowSelection={{ selectedRowKeys, onChange }}`,未选中时批量按钮禁用 |
|
||||
|
||||
## 6. 分页
|
||||
|
||||
- 位置:列表卡底部右对齐,上距 16px;移动端换行显示并提供快速跳页。
|
||||
- 外观:小尺寸,可切换每页条数 `[10, 20, 50, 100]`,总数文案 `t('共 {{total}} 条', { total })`。
|
||||
- 用法:分页列表使用 `@/components/ui` 的 `Table` / `Pagination`,传 `currentPage`、`pageSize`、`total`、`onPageChange(page)`、`onPageSizeChange(size)`。`/console`、`/org` 下由封装自动统一外观与回调;其他路由需显式传 `showSizeChanger`、`pageSizeOpts`、`showTotal`,并设置 `preventPageChangeOnPageSizeChange: true`,避免改页容量时请求两次。
|
||||
- 删除当前页最后一条后回到上一页;前端分页的列表在筛选或数据变化时回到第 1 页。
|
||||
- 用法:分页列表使用 `@/components/ui` 的 `Table` / `Pagination`。第 4 节的标准列表及其明细分页均沿用密钥管理:表格底部右对齐、小尺寸,依次显示“共 N 条”、上一页/页码/下一页、每页条数(10、20、50、100),移动端保留跳页。已加载的明细可本地分页;服务端分页传 `currentPage`、`pageSize`、`total` 以及分页回调,切换每页条数回到第 1 页,只发一次请求。导出仍作用于原有结果范围,不受当前页条数影响。
|
||||
- 删除当前页最后一条后回到上一页;筛选和搜索沿用当前页,重置回到第 1 页。`/org/*` 的独立表格、页签和下钻明细均用此分页规则;已加载的树形表格按根节点分页,子节点不拆散;接口已分页时沿用原查询与总数。
|
||||
- 受控分页须实现条数回调(或兼容的统一变更回调)才显示条数选择,不用客户端切片模拟固定条数的服务端接口;分页启用且有结果时单页也显示分页栏。
|
||||
- 接入自动搜索的表格使用 `preservePage`。筛选后当前页没有结果时仍保留页码,分页栏显示实际结果总数并允许手动返回。删除后的页码调整由对应删除流程处理。
|
||||
|
||||
## 7. 表单项
|
||||
|
||||
@@ -188,7 +204,11 @@ html.dark .km-page {
|
||||
| 外观 | 圆角 12px;标题 16px / 600;正文与页脚使用 antd 默认间距 |
|
||||
| 页脚 | 次操作(取消)在前、主操作(确定 / 保存)在后,按钮高 34px、间距 8px;危险确认用 `okButtonProps={{ danger: true }}` |
|
||||
| 行为 | 提交中 `confirmLoading`;校验或请求失败不关闭;X、取消、Esc、遮罩关闭行为一致 |
|
||||
| 确认框 | 单条删除用 `Popconfirm`;批量或不可撤销操作用 `Modal.confirm`(企业中心用 `OrgModal.confirm`) |
|
||||
| 表格操作列危险确认 | 删除、注销和冻结使用小尺寸危险链接,更多菜单使用危险菜单项。普通单条操作用 `TableActionPopconfirm`,注销、企业冻结等影响较大的操作用确认弹窗。取消在前,危险确认在后;优先聚焦取消 |
|
||||
|
||||
- 保留业务定制的标题、正文和按钮文案,并接入国际化。确认信息明确操作对象和影响。
|
||||
- 只有明确确认才发送请求;取消、Esc 或关闭不修改数据。确认回调返回 Promise,提交中显示加载并防止重复请求,失败保留确认及上下文并提示原因。成功后关闭确认并刷新列表,删除当前页最后一条时按分页规范回退。
|
||||
- 表格危险操作的回调在 API 明确失败时返回 `false`。确认框保持打开,业务回调保留原有错误提示。受控弹窗由业务在成功后关闭。
|
||||
|
||||
## 9. 抽屉
|
||||
|
||||
@@ -218,7 +238,8 @@ html.dark .km-page {
|
||||
- **状态**用语义色:成功 `success`、失败 `error`、进行中 `processing`、等待 / 警告 `warning`、中性 `default`。
|
||||
- **分类**(分组、类型、模型标签等)用调色板色(`blue`、`green`、`purple`、`gold`、`cyan` 等 antd 预设),不用非预设色名。
|
||||
- 全局默认描边;卡片内的分类标签与企业中心表格标签用无边框样式,新代码写 `variant='filled'`(antd 6 已弃用 `bordered={false}`,二者视觉等价;存量写法可在修改时顺带收敛)。标签间距 8px,表格内标签不留右外边距。
|
||||
- 可启停的记录用 `Switch size='small'`,`onChange` 调原处理函数;无启停接口的列表保留只读 `Tag`。
|
||||
- **表格启停开关**以 `/user-center/key-management` 为准,复用 `TableStatusSwitch`:小尺寸、开启显示「启用」并使用系统主题主色,关闭显示「禁用」并使用组件中性色。其他既有布尔含义可自定义两态文字。保留键盘焦点、可访问名称、原有确认和权限;关闭状态不等于控件不可操作。只读状态仍用 `Tag`,过期、耗尽等非二元状态的说明保留,表单与筛选区开关不套用本规则。
|
||||
- **表格分组颜色与布局**以 `/console/organizations` 分组列为准,复用 `TableGroupTags`(单个标签也可用 `TableGroupTag`)。三种分组的标签文字固定为 `default`、`vip`、`svip`,颜色分别为蓝、黄、红。分组列禁止追加「(默认)」等说明,默认分组设置继续在表单中体现。`premium`、`pro` 沿用原名及红、黄配色,自定义分组用中性色。使用 antd 浅底描边标签并适配明暗主题。标签逐个着色、去重,按 4px 间距单行排列。纯分组列复用 `TABLE_GROUP_COLUMN_WIDTH`(148px),以完整容纳三枚标准标签为准。超出单元格的分组可横向滚动,已有的「+N」展开仍可使用。空值继承、智能熔断和非调用分组沿用各自的业务展示。
|
||||
|
||||
## 12. 按钮与图标
|
||||
|
||||
@@ -242,8 +263,8 @@ html.dark .km-page {
|
||||
|
||||
组件分层(antd 原生、中心封装、契约封装、专用组件)及选用方式见 `DEV_STANDARDS.md` 2.1、2.2 节。`src/components/ui/*` 只做视图映射,不放请求、权限与业务状态。
|
||||
|
||||
- 禁止导入:`@lobehub/*`、Radix UI、Floating UI、Semi、MUI、Chakra、Headless UI、leva、antd-style、react-layout-kit(`.eslintrc.cjs` 的 `no-restricted-imports`)。
|
||||
- `npm run check:ui` 审计源码导入、完整 lock 图与品牌图标资产 hash,已包含在 `npm run check` 中。
|
||||
- 禁用范围见开发规范第 2.4 节;ESLint 与 `npm run check:ui` 共用一份规则,本地品牌图标不是运行时 UI 依赖。
|
||||
- `npm run check:ui` 审计根目录 JS 配置、应用源码、脚本和单测的包引用,并检查依赖声明、锁文件中的传递包和别名,以及品牌图标资产 SHA-256。命令已包含在 `npm run check` 中。
|
||||
- `antd` 与 `@ant-design/icons` 精确锁定版本;`src/components/ui/antd-v5-compat.css` 统一标签间距、分页选择器宽度与必填标记字体,页面样式可以覆盖。
|
||||
- 当前版本 API 约定:Card 用 `variant`,Drawer 用 `size`,弹层遮罩用 `mask` 配置,Alert 标题用 `title`;样式选择器使用 `.ant-modal-container`、`.ant-alert-title`、`.ant-collapse-body`。聊天消息列表使用 `List`(antd 已标记弃用),替换前需先建立该区域的视觉基线。
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# UI 审查清单
|
||||
|
||||
> 状态:有效 · 更新:2026-11-19 · 版本:v1.0
|
||||
|
||||
**何时阅读**:执行双端 UI 审查、视觉回归与真实操作验收时。项目设置、全局基线与对应页面规范优先,本清单不定义新增功能。
|
||||
|
||||
## 速查
|
||||
|
||||
- 环境、登录、视口与像素阈值:`ui/GLOBAL_UI_BASELINE.md` 第 6、7 节。
|
||||
- 组件与主题判定:`standards/UI_COMPONENT_STANDARDS.md` 与对应页面规范。
|
||||
- 只勾选实际验证项;无此控件写“不适用”,权限、数据或环境不足写“未覆盖”并留证,不视为通过。
|
||||
|
||||
## 检查顺序
|
||||
|
||||
- [ ] **导航布局**:侧栏展开、折叠、层级、悬停、选中与图标;顶栏 Logo、搜索、通知、头像、主题、语言、环境标识;面包屑;多页签关闭、固定、右键、滚动与回到顶部。
|
||||
- [ ] **全局视觉**:背景、渐变、蒙层与其他叠加;边距、栅格、对齐、响应折行;主题与语义色、透明度、深浅映射;字号、字重、行高、截断、等宽数字和脱敏;SVG 基线、线面、尺寸、间距、圆角、边框、分割线与阴影。
|
||||
- [ ] **容器**:卡片头、主体与分区,标签页的选中态、下划线、胶囊与位置,折叠面板与分隔线。
|
||||
- [ ] **数据区**:表头、单元格、固定列、斑马纹、空态、虚拟滚动、列设置、密度、批量、编辑和拖拽;分页条数、位置、跳转、总数;操作对齐、权限、折叠和危险态;下拉菜单分组、图标及禁用态;标签、徽标、头像、进度、描述、统计、时间线、步骤、结果、JSON、高亮、复制与二维码。
|
||||
- [ ] **输入与筛选**:文本、数字、自动补全、搜索、富文本、代码、单复选、组合框、开关、分段、日期时间、级联、树、穿梭、上传、滑块和评分;尺寸、前后缀、清除、计数、下拉空态、多选标签、远程搜索及错误、只读、禁用;标签、必填、校验、栅格、查询重置、展开收起和条件计数。
|
||||
- [ ] **操作按钮**:主、次、默认、虚线、文本、链接、图标、危险、幽灵、下拉、分裂;大小、形状、块级、图标间距、点击热区、加载和禁用;按钮组、长文案与多语言折行、工具栏及弹层主操作、权限隐藏和禁用提示;危险二次确认、防重入、键盘焦点、语义色及深浅映射。复用组件和 token。
|
||||
- [ ] **浮层与反馈**:弹窗和抽屉的尺寸、位置、结构、遮罩、关闭与二次确认;提示与气泡的定位、箭头、背景、阴影和触发;警告、消息、通知、无权占位及关闭反馈。
|
||||
- [ ] **图形**:图表、拓扑、流程的 Canvas、WebGL 或 SVG;容器、DPR、清晰度、坐标轴、网格、图例、标注、配色、提示和动画终态。
|
||||
- [ ] **状态**:骨架、加载、空态、失败、禁用、校验、选中;文字与图标能传达状态,空态操作不越权。
|
||||
- [ ] **交互**:悬停、键盘焦点、按压、展开收起、表单、弹层、搜索分页、主题语言、导航与多页签;过渡时长、缓动、关键帧、进出场与减少动态效果。真实 CRUD 按基线、创建、复查、编辑、复查、删除、复查执行。
|
||||
|
||||
## 记录口径
|
||||
|
||||
- 每项差异记录页面、组件、属性、期望、实际、严重级、截图与建议;只读、真实写入与模拟场景分别记账。
|
||||
- 视觉证据注明主题、视口、DPR、语言、字体和数据模式;跨主题像素变化不等于缺陷,只有同条件基线比较可按视觉阈值判定。
|
||||
@@ -1,6 +1,6 @@
|
||||
# 控制台 UI 规范(/console/\*)
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.4
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.7
|
||||
|
||||
管理控制台 `/console/*` 的规范:统一页头、控制台原语与差异样式。
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
- 提示栏:控制台内的 `Banner` / `Alert` 统一走 `ConsoleAlert`,内边距 12px 16px、正文 14 / 22px、图标 16px,颜色取对应语义 token。
|
||||
- 系统设置(`page.key === 'setting'`):表单统一纵向布局、8px 标签间距、24px 栅格、控件等宽,校验信息预留高度;弹窗页脚按钮高 34px、间距 8px、右对齐。规则限定在 `.settings-page` / `.settings-form-dialog`。
|
||||
- 控制台上下文中 `CompactModeToggle` 不渲染,表格密度状态保留;其他模块仍可使用紧凑模式。
|
||||
- 兑换码列表沿用渠道列表的行内链接按钮、右侧固定操作列和底部分页。「查看、复制、编辑、禁用/启用、删除」在同一行直接显示,保留既有权限和状态限制,删除仍需确认。窄屏横向滚动时操作列不换行。批量复制在选中兑换码后可用,清除失效兑换码由独立的危险操作确认承载。
|
||||
- 添加兑换码与编辑兑换码信息共用右侧侧栏窗、表单样式及页脚。查看详情使用弹窗,优先展示兑换码和状态,再列出额度、时间与兑换人信息。
|
||||
- 平台 Skill 中心的分类标签区域与搜索工具栏同宽、左对齐,不保留独立的最大宽度和自动居中;窄屏按原间距自然换行。
|
||||
- 平台 Skill 详情的审核工作台仅由抽屉正文纵向滚动,技能原文不设置独立滚动区;审核操作进入抽屉固定页脚,按钮右对齐、间距 8px,仅在审核页签展示。
|
||||
- 官网文章抽屉允许点击遮罩关闭,X、取消、遮罩共用同一未保存内容确认流程。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 后台 UI 全局基线
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v3.11
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-28 · 版本:v3.15
|
||||
|
||||
后台外壳与布局基线:顶栏、侧栏、公告、页头与内容边距、登录页,以及原型未定义场景、登录关卡与验收流程。主题与组件样式见 `UI_COMPONENT_STANDARDS.md`。
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
| 滚动条 | 全站 6px,`#8b8b8b`,悬停 `#636363`,页面不得单独设置 |
|
||||
| 装饰 | 无设计依据不加渐变、玻璃、发光、浮起与动效 |
|
||||
| 登录关卡 | 真实 UI 登录,企业先于个人,凭据只经环境变量(第 6 节) |
|
||||
| 验收 | 浅深主题 × 1920×1000 / 393×851,有头离屏串行,唯一页面不抢焦点,模拟与真实分开记录(第 7 节) |
|
||||
| 验收 | 浅深主题 × 1920×1000 / 393×851 / 360×800,有头离屏串行,唯一页面不抢焦点,模拟与真实分开记录(第 7 节) |
|
||||
|
||||
**相关代码**:`src/styles/{user-center,center-layout,org-page,prototype}.css`、`src/index.css`、`src/components/layout/`
|
||||
|
||||
@@ -51,10 +51,12 @@
|
||||
|
||||
- 桌面高 72px、移动 56px,另含 1px 底部分隔线;背景、文字、分隔线跟随双主题变量。
|
||||
- 主导航:导航项撑满顶栏,左右内边距 24px;2px 主色下划线两端内缩 16px;选中项主色文字,普通项悬停保留正常文字色,键盘焦点可见。不改链接与权限条件。
|
||||
- 右侧按钮:主题、公告、语言等图标 16px,工具按钮点击区 34px,账户下拉箭头 10px;`.ui-header-actions` 内图标容器为 inline-flex,使图标与文字垂直居中。
|
||||
- 768px 及以上,导航槽位按实际可用宽度判断:完整导航放不下时收为「主导航」下拉菜单,放得下时恢复平铺,不出现被操作区覆盖或隐藏横向滚动的导航项。菜单项、选中态、外链与鉴权跳转复用移动端菜单;槽位 ≥ 84px 显示当前页名称,更窄时为 34px 图标按钮;切换时焦点在导航内则移到菜单按钮。
|
||||
- 右侧按钮:主题、公告、语言等图标 16px,按钮高度与工具按钮点击区 34px、文字行高 20px,账户头像 32px、下拉箭头 10px;`.ui-header-actions` 内链接、徽标和图标容器为 inline-flex,图标、文字、头像与分隔线垂直居中;桌面专属操作在 768px 以下隐藏。
|
||||
- 全站共享顶栏不展示未登录用户的“登录 / 注册”按钮,桌面与移动端一致;已登录用户保留头像与账户菜单,登录 / 注册页面及受保护导航的原有鉴权跳转保持不变。
|
||||
- 主题按钮为 `Button` + `Tooltip`,点击在浅色与深色之间直接切换,不提供下拉或“跟随系统”;沿用现有主题 setter 与持久化,覆盖 `/org/login`、`/login` 与共享顶栏。
|
||||
- WeyAi 下载按钮复用现有下载配置与权限判定,跳转 `/weyai/download`;使用 antd text 按钮默认悬停背景与 `Tooltip`,不硬编码外部地址。
|
||||
- WeyAi 下载按钮复用现有下载配置与权限判定,跳转 `/weyai/download`。在两个下载路由中显示品牌强调色文字和约 6% 的主题色底,并区分悬停、按压和键盘焦点。其他页面使用 antd text 按钮默认样式,保留 `Tooltip`。
|
||||
- 右侧快捷链接复用主导航的当前路由去重与节流。主题切换即时响应首击,语言和头像菜单统一处理悬停、点击和键盘关闭。推广弹窗短暂过滤打开时落到遮罩上的连点。
|
||||
|
||||
### 4.2 公告栏与系统公告弹窗
|
||||
|
||||
@@ -64,8 +66,9 @@
|
||||
|
||||
### 4.3 侧栏
|
||||
|
||||
- 控制台侧栏显示、路由选中项变化或滚动区尺寸变化后,当前菜单超出可视范围时,仅滚动菜单区域使其完整可见;已可见时不移动,不滚动正文、不抢焦点,也不强制展开用户手动收起的分组。
|
||||
- 企业中心与用户中心共用 `src/styles/center-layout.css`:展开 216px、收起 64px;菜单行高 42px、行距 6px,图标 16px / 1.5px 线宽;折叠入口文案“收起导航”。
|
||||
- 页面级侧栏共用 `CenterSidebar` 和 `src/styles/center-layout.css`:展开 216px、收起 64px;菜单行高 42px、行距 6px,图标 16px / 1.5px 线宽;折叠入口文案“收起导航”。抽屉保留完整文字,窄屏的底部或横向导航沿用各页面的布局。
|
||||
- 当前菜单超出可视范围时,仅滚动菜单区域使其完整可见;已可见时不移动。侧栏使用当前路由去重,快速切换保留最新目标。折叠按钮和分组操作过滤同一控件的连点。
|
||||
- 体验、用户、控制台和企业中心的加载占位复用侧栏外壳,保持宽度、菜单起点及底部折叠条位置。企业身份和分组标题保留对应占位。
|
||||
- 企业信息区为无底框网格图标(24px / 1.65 线宽),内边距 28px 16px 26px,图文间距 10px;企业名与身份 12px / 20px 行高,身份上距 2px。
|
||||
- 个人侧栏只保留容器外侧分隔线,内层 Menu 不叠加 `border-inline-end`;企业侧栏不提供菜单搜索。
|
||||
- 内容外壳设 `min-width: 0`,防止宽表格挤压;桌面滚动区保留稳定槽位并补足 16px 留白,移动端不补。
|
||||
@@ -76,7 +79,7 @@
|
||||
|
||||
1. **内容边距**:读取 `user-center.css` 的 `--uc-page-pad-top/x/bottom`(桌面 30 / 36 / 36px,≤ 768px 为 16 / 16 / 24px)。普通页面根节点用 `.uc-page`;数据看板 `.uc-dashboard`、服务监控 `.user-center-service-page`(`calc(64px + 顶距)`,抵消宿主 `-mt-[64px]`)、下载页 `.weyai-download--embedded` 直接引用这些变量。企业功能页(`.org-*-page`、`.knowledge-page`、`.org-workbench`)走 `org-page.css`。禁止写死页面级边距或使用 `p-4 sm:p-6 lg:p-8`。工作区块间距 `--uc-layout-gap: 18px`。
|
||||
2. **页头**:用户中心用 `<UserCenterPageHeader title subtitle extra />`,企业中心用 `OrgPageHeader`(内部复用前者)。面包屑 12 / 18px,距内容区顶 30px,父级 `--text-secondary`、当前项 `--text-primary`,分隔符左右 10px,与标题 24px;标题 28 / 32px / 650 / 字距 -0.6px(`--uc-heading`);副标题 14 / 22px、上距 6px(`--uc-subtitle`);页头与首块 18px;右侧操作放 `extra`(间距 8px,窄屏换行)。页面不得覆盖这些数值,数据看板只保留 hero 装饰层。
|
||||
3. **面包屑登记**:用户中心在 `UserCenterBreadcrumb.jsx` 的 `pageTitles` 登记,显示“用户中心 / 当前页面”;企业中心在 `OrgBreadcrumb` 的 `orgPageGroups` 登记,分组页显示“分组 / 当前页面”,其他为“企业中心 / 当前页面”,未登记页面以标题兜底。带 hero 的企业功能页在 hero 内首个元素顶部放 `<OrgBreadcrumb />`。不在原本没有面包屑的页面新增导航;没有副标题文案时只传 `title`。
|
||||
3. **面包屑登记**:用户中心在 `UserCenterBreadcrumb.jsx` 的 `pageTitles` 登记,显示“用户中心 / 当前页面”;企业中心在 `OrgBreadcrumb` 的 `orgPageGroups` 登记,分组页显示“分组 / 当前页面”,其他为“企业中心 / 当前页面”,未登记页面以标题兜底;体验中心(云端大脑 / 图片生成 / 视频生成)用 `ExperiencePageHeader`(内部复用 `UserCenterPageHeader`),显示“体验中心 / 当前页面”,企业中心宿主的云端大脑保留原卡片页头。带 hero 的企业功能页在 hero 内首个元素顶部放 `<OrgBreadcrumb />`。不在原本没有面包屑的页面新增导航;没有副标题文案时只传 `title`。
|
||||
4. **滚动条**:全站滑块 `#8b8b8b`、悬停 `#636363`、宽高 6px、圆角 3px、轨道透明,值来自 `tokens.css` 的 `--brand-scroll` / `--brand-scroll-hover`,规则集中在 `src/index.css`。页面 CSS 与内联样式禁止设置 `scrollbar-width` / `scrollbar-color`(Chrome 121+ 设置后会忽略 `::-webkit-scrollbar`),标准属性只在 `@supports not selector(::-webkit-scrollbar)` 中给 Firefox。三中心操作表格沿用 Ant Design 固定列表格的横向滚动行为,不隐藏滚动条。
|
||||
5. **验证**:逐页核对左右边距、面包屑顶距、标题与副标题字号间距、滚动条静止与悬停颜色(桌面 / 移动 × 浅 / 深)。
|
||||
|
||||
@@ -94,6 +97,7 @@
|
||||
|
||||
- 带侧栏页面按 4.4;控制台按 `CONSOLE_SPEC.md`;其余页面内容默认 24px 30px、移动 16px。筛选区自然换行,表格在自身容器横向滚动;不通过隐藏正文、裁剪校验信息或固定整页宽度迎合截图。
|
||||
- 模型超市与技能超市的工作区居中,含内边距的最大宽度为 1760px;横向内边距为 `clamp(20px, 4vw, 80px)`,Hero 搜索区域沿用同一横向留白,600px 及以下为 20px。覆盖 3840 / 2560 / 1920 至 360px 宽度,目录按实际可用宽度减少列数,保留卡片正文和控件正常字号,不通过整体缩放压缩内容。
|
||||
- WeyAi 两个下载路由共用页头、安装卡、工作台示意、平台安装包、功能和使用步骤,结构与测量值取自桌面原型 `微元优化原型/index.html` 的 WeyAIDownload。系统页签与架构按钮切换安装卡展示的安装包,并同步列表中的“当前选择”行,默认值是自动识别的推荐包,未识别系统时不预选。下载地址、请求与触发方式不变。颜色只用主题 token 派生,跟随系统主题色和深浅模式。公开页与内嵌页的居中容器含内边距最大宽度分别为 1480px 和 1760px。断点按页面可用宽度计算,阈值沿用原型的 1180 / 850 / 520px。850px 及以下首屏、安装包和步骤改为单列,520px 及以下系统页签等宽并使用 44px 热区,文件名可换行。用户中心内嵌页沿用第 4.4 节的面包屑、标题和内容边距,下载页背景从面包屑区域开始覆盖内容区,面包屑与首屏标题区间隔 24px。
|
||||
- 背景图优先复用原型的原始 SVG / 图片,放入 `src/assets/prototype` 并注明来源;原型用 CSS 绘制的背景按测量值在页面作用域复现,不用生成插画替代。
|
||||
- 企业工作台横幅 `.ew-hero` 的浅金 / 深棕背景与三层轮廓只用于 `.org-workbench`,不扩散到其他页面。
|
||||
- 原型未定义、antd 有组件:用当前版本默认样式与主题 token。antd 无对应部件:语义背景 / 文字 / 边框,无装饰背景、阴影与动画,间距 8 / 16 / 24px,窄屏堆叠且操作可达;新增此类统一规则先写入本文。
|
||||
@@ -150,8 +154,8 @@
|
||||
| 配置 | 约定 |
|
||||
| --- | --- |
|
||||
| 设备源 | `scripts/ui-review/config.json` → `scripts/browser-environment.mjs`;与 weelink 的设备结构和 Playwright 1.64.1 保持一致,各项目独立保存 |
|
||||
| 视口 | 默认 1920×1080、360×800;扩展增加 768×1024、1024×768、1366×768、1440×900、2560×1440、3840×2160 |
|
||||
| 手机 | Pixel 5 UA、触摸、移动模式和 DPR 2.75;viewport 覆盖为 360×800,screen 沿用模板;平板仅为桌面设备的平板尺寸 |
|
||||
| 视口 | 默认 1920×1080、360×800、393×851;扩展增加 768×1024、1024×768、1366×768、1440×900、2560×1440、3840×2160 |
|
||||
| 手机 | Pixel 5 UA、触摸、移动模式和 DPR 2.75;默认项目覆盖 360×800(`chrome-mobile`)和 393×851(`chrome-mobile-393`),screen 沿用模板;平板仅为桌面设备的平板尺寸 |
|
||||
| 本地目标 | 未指定目标时自动发现并复用已有开发服务,确认不存在后才启动 `http://127.0.0.1:4176/`;开发和预览均严格占用指定端口,禁止静默回退 |
|
||||
| 目标切换 | `local-dist` 先校验静态入口与引用资源,再启动 Vite preview;`remote` 必须提供 `PW_BASE_URL`,不启动服务 |
|
||||
| 窗口 | 本地默认有头离屏;`PW_HEADLESS=1` 无头,CI 强制无头;隐藏滚动条并禁用后台降频 |
|
||||
@@ -175,7 +179,7 @@
|
||||
|
||||
### 7.3 采集与判定
|
||||
|
||||
- 固定视口(桌面 1920×1000 / 移动 393×851,专项另有规定从其规定)、DPR 1、`zh-CN`、`Asia/Shanghai`、`reducedMotion: reduce`、相同数据与状态;用角色、标签、测试标识定位,用条件等待,不依赖固定延时与坐标。
|
||||
- 固定视口(桌面 1920×1000,移动 393×851 和 360×800。360×800 是必测的最小移动视口,专项可增加其他尺寸)、DPR 1、`zh-CN`、`Asia/Shanghai`、`reducedMotion: reduce`、相同数据与状态;用角色、标签、测试标识定位,用条件等待,不依赖固定延时与坐标。
|
||||
- 等待懒加载、骨架屏、提交中状态结束;检查错误消息、控制台、实际路由与无效数值,不能只凭无 pageerror 判定通过。
|
||||
- 只读验收记录所有非 GET `/api/` 请求(应为 0);模拟响应按接口真实结构提供并标注;真实写入只用可清理的测试数据;支付未启用不得写成支付通过。
|
||||
- 定位双字按钮允许 antd 默认字间距,如 `getByRole('button', { name: /^(?:loadings+)?保s*存$/ })`;虚拟 Select 用可见选项或组合框键盘操作,不点击隐藏的辅助选项。
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
| --- | --- |
|
||||
| 路由 | `/user-center/key-management`,旧 `/key-management` 重定向 |
|
||||
| 视图 | `KeyManagement/index.jsx` + `key-management.css`;编辑抽屉由 `EditTokenModal presentation='drawer'` 渲染 |
|
||||
| 业务 | `useTokensData`、`/api/token*`、`buildTokenPayload`、启停与删除确认不变 |
|
||||
| 列表 | 固定列宽,每页 5 条;列设置不持久化 |
|
||||
| 业务 | `useTokensData` 负责后端查询与分页;`buildTokenPayload`、启停与删除确认不变 |
|
||||
| 列表 | 固定列宽,默认每页 10 条;列设置不持久化 |
|
||||
| 抽屉 | 模型列表 440px;创建 / 编辑 560px(移动 100%) |
|
||||
| 外壳 | 页头与边距按 `GLOBAL_UI_BASELINE.md` 4.4 |
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
| `src/pages/KeyManagement/key-management.css` | 页面作用域样式与 `--km-*` 变量 |
|
||||
| `src/components/table/tokens/modals/EditTokenDrawer.jsx` | 创建 / 编辑抽屉视图 |
|
||||
| `src/components/table/tokens/modals/EditTokenModal.jsx` | 状态、`formApi`、`submit`、`buildTokenPayload`;`presentation='drawer'` 时渲染抽屉 |
|
||||
| `src/hooks/tokens/useTokensData.jsx` | 列表、搜索、分页、启停、删除(不改) |
|
||||
| `src/hooks/tokens/useTokensData.jsx` | 列表、搜索、分页、启停、删除 |
|
||||
|
||||
独立路由形态(`.km-page-standalone`)只补顶栏偏移(桌面 100px、移动 80px)。
|
||||
|
||||
@@ -36,10 +36,10 @@
|
||||
| 区域 | 规则 |
|
||||
| --- | --- |
|
||||
| 页头 | `UserCenterPageHeader`;“新手教程 / 查看操作指引”图标按钮保留在右侧 |
|
||||
| 查询卡 | 单字段:标签 + `Input allowClear`(宽 620px)+“重置”“搜索”;卡片上下内边距 22px,描边 `#f0f0f0`(深色 `--border-subtle`) |
|
||||
| 列表 | `Table size='middle' tableLayout='fixed'`,列宽 150 / 300 / 150 / 100 / 180 / 100 / 100 / 130;每页 5 条;列设置用 `ColumnSettings`,不持久化 |
|
||||
| 状态 | `Switch`(`onChange` 仍走原 `Modal.confirm` → `manageToken`);已过期 / 已耗尽另显示语义 `Tag` |
|
||||
| 分组 | `Tag color='blue'` 无边框 + `Tooltip`;额度为 `Tag color='success'` |
|
||||
| 查询卡 | 保留单输入框,匹配密钥名称、Key 或分组。输入防抖,点击搜索或按回车立即提交,重置取消待提交条件并回到普通列表第 1 页 |
|
||||
| 列表 | `Table size='middle' tableLayout='fixed'`,列宽 150 / 300 / 150 / 100 / 180 / 100 / 100 / 130;默认每页 10 条;列设置用 `ColumnSettings`,不持久化 |
|
||||
| 状态 | `TableStatusSwitch`(`onChange` 仍走原 `Modal.confirm` → `manageToken`);已过期 / 已耗尽另显示语义 `Tag` |
|
||||
| 分组 | `TableGroupTags` + `Tooltip`,颜色按组件公共规范;额度为 `Tag color='success'` |
|
||||
| 密钥 | `<code>` 密钥框(底 `#f4f6f9`、描边 `#e4e9ee`,深色引用 `--surface-bg-base` / `--border-subtle`)+ 显示、隐藏、复制图标按钮 + `Tooltip`;脱敏提示 `Alert type='success'` |
|
||||
| 模型抽屉 | 440px;正文 20px;卡片间 18px;信息卡 16px(标签 12 / 18px);分类头 45px(底 `#f6f8fa`);模型名高 28px(等宽 12px、底 `#fafafa`);行距 9.5px、列距 8px;面板描边 `#e4e9ef` |
|
||||
| 编辑抽屉 | 560px(移动 100%);适配 `Form requiredMark={false}`;过期快捷 `Button` 组(间距 5px、描边 `#d9dfe6`、无按钮阴影,`aria-pressed`);仅“自定义”显示 `DatePicker showTime`;高级设置 `Collapse`(`forceRender`)+ `Switch` + `Divider`;页脚按钮间距 10px |
|
||||
@@ -48,7 +48,8 @@
|
||||
|
||||
## 3. 保留功能与已知差异
|
||||
|
||||
- 默认名称 `claudeNN`、每页 5 条、过去日期禁用为业务默认;“搜索”与回车即时生效。
|
||||
- 默认名称 `claudeNN`、过去日期禁用为业务默认。
|
||||
- 普通列表通过 `/api/token/` 服务端分页。个人搜索接口当前不支持单条件同时匹配名称、Key 和分组,也不提供分页结果;为保持原有条件,搜索复用个人列表接口取全后本地匹配和分页,不调用控制台管理接口。未取全时不展示部分搜索结果。
|
||||
- 技能注入关闭时“绑定技能”字段仅隐藏,仍注册在表单中,载荷不变。
|
||||
- 模型抽屉不显示来源说明行;“自定义”过期选项选中时仅文字变主色。
|
||||
- 第三方新手引导(Joyride)沿用其自身配色配置。
|
||||
|
||||
+18
-15
@@ -1,6 +1,6 @@
|
||||
# 企业中心 UI 规范(/org/\*)
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.3
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.5
|
||||
|
||||
企业中心 12 个目标页的规范:企业中心变量、通用组件的企业中心变体与各页面规则。
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
| 关注点 | 规则 |
|
||||
| --- | --- |
|
||||
| 范围 | 工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”“组织架构”“角色管理”不改 |
|
||||
| 范围 | 工作台、数据看板、员工管理、项目管理、预算中心、审批中心、令牌管理(原“密钥管理”)、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”不改;“组织架构”页面名称统一为“部门管理”(与权限目录一致,2026-11-23);“角色管理”为统一权限体系新增页面(2026-11-23) |
|
||||
| 样式 | `org-center.css`,作用域 `.org-center .oc-page`,颜色只写 `--oc-*`(第 2 节) |
|
||||
| 组件变体 | 紧凑表格、3 列筛选、无图标行操作、`.oc-list-tabs`、无边框标签(第 3 节) |
|
||||
| 弹层 | `OrgModal` / `OrgSideSheet`,原型风格遮罩;密钥抽屉 560px |
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
- 视觉依据:在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(深色用“切换至暗色主题”),只作视觉依据,不作业务、路由、数据依据。
|
||||
- 只对齐背景、字体、图标、表格、表单、卡片、页签、搜索条件、操作列、弹窗、按钮、颜色、文字、间距与已有交互反馈;不改请求、载荷、状态、路由、权限与触发条件。
|
||||
- 原型有而系统无的功能不补建:员工筛选卡、CSV 导出、尺寸切换分页、新建员工 / 分配角色 / 离职、角色管理、在职 / 离职筛选、订单号搜索、分组列、发票入口。例外:企业密钥管理的分组列与列设置已按需求实现。
|
||||
- 原型有而系统无的功能不补建:CSV 导出、在职 / 离职页签、订单号搜索、分组列、发票入口。例外:企业密钥管理的分组列与列设置已按需求实现。
|
||||
|
||||
## 2. 作用域与变量
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
通用卡片、筛选栏、表格、分页、弹层、页签、标签样式按 `UI_COMPONENT_STANDARDS.md`;企业中心的差异如下。
|
||||
|
||||
- **页头**:`OrgPageHeader`(内部复用 `UserCenterPageHeader`),规格见 `GLOBAL_UI_BASELINE.md` 4.4;页头不放操作按钮,操作移入列表卡头。面包屑分组见 4.4 第 3 条。
|
||||
- **列表卡 `OrgListCard`**:卡头与表格间距 20px;表格为紧凑变体(正文 13px,表头 12px / 500、底色 `--oc-soft`,行上下内边距 17px);分页不提供每页条数切换。
|
||||
- **筛选卡 `OrgFilterCard`**:固定 3 列;筛选取值与生效时机沿用原页面(审计日志为“选择即筛选”,“搜索”以当前条件重新查询)。
|
||||
- **列表卡 `OrgListCard`**:卡头与表格间距 20px;表格为紧凑变体(正文 13px,表头 12px / 500、底色 `--oc-soft`,行上下内边距 17px);分页按公共组件规范,覆盖页签及表格明细。
|
||||
- **筛选卡 `OrgFilterCard`**:默认 3 列。提示词记录和消耗明细的筛选区沿用个人消费记录的布局。筛选取值与生效时机沿用原页面(审计日志为“选择即筛选”,“搜索”以当前条件重新查询)。
|
||||
- **行操作 `OrgRowActions`**:link 按钮 13 / 24px、无内边距、间距 10px,不带图标。
|
||||
- **列表页签 `.oc-list-tabs`**:导航高 44px,页签内边距 12px 0,选中与悬停色为 `--oc-brand`;只切换筛选时加 `.oc-tabs-nav-only`。
|
||||
- **标签**:表格与卡片内标签统一无边框(`variant='filled'`);非 antd 预设色改用 `gold` / `purple`。
|
||||
@@ -64,14 +64,15 @@
|
||||
| --- | --- | --- |
|
||||
| 工作台 | `OrgHero` 标签化身份与 `oc-wb-*` 卡片(额度、密钥、用量、最近申请);横幅 `.ew-hero` 背景只在 `.org-workbench` 作用域 | 额度周期标签放在重置卡;最近申请无分页 |
|
||||
| 数据看板 | `oc-dash-*` hero(健康提示“企业运行正常”、企业名、企业额度、组织概况)+ `OrgAnalyticsPanel`(汇总条、趋势 `Segmented`、分布、明细页签) | 时间范围 7 / 30 / 90 天;企业名来自 `orgInfo.name`,无值时隐藏 |
|
||||
| 员工管理 | 页签(员工权限 / 员工账号)+ 列表卡;首列与操作列固定;备注独立列;状态 `Switch` | 无筛选卡与在职 / 离职页签 |
|
||||
| 员工管理 | 筛选卡(关键字、分组、组织、状态,服务端筛选)+ 单张列表卡,不分页签;备注独立列;状态 `Switch`;新建 / 编辑用抽屉 | 无在职 / 离职页签 |
|
||||
| 项目管理 | `OrgListCard` + link 操作(模型 / 分组 / 成员 / 密钥 / 编辑);状态开关 | 操作列不再显示“停用” |
|
||||
| 预算中心 | `.oc-policy` 固定说明条;列宽 300 / 110 / 260 / 120 / 120 / 130;状态开关 | 无分页 |
|
||||
| 预算中心 | `.oc-policy` 固定说明条;列宽 300 / 110 / 260 / 120 / 120 / 130;状态开关 | 已加载数据前端分页 |
|
||||
| 审批中心 | 状态页签(回调 `setStatusFilter`)+ 申请列表卡;拒绝弹窗竖排表单项 | — |
|
||||
| 密钥管理 | 密钥框 + 显隐 / 复制、可用模型 link、分组列、状态开关、绝对时间;列设置用共享组件;创建 / 编辑为 560px `OrgSideSheet` | 列设置只在当前页面生效 |
|
||||
| Agent 任务审计 | 保留页头状态筛选、任务元数据 / 待对账 / 安全策略三个页签。记录按卡片排列,任务状态和计费状态使用独立标签,弹窗使用 `OrgModal` | 正文必须填写有效审计原因并经二次确认。页签计数、操作和焦点使用系统品牌色,状态标签使用语义色。窄屏按单列排列卡片,长编号换行 |
|
||||
| 密钥管理 | 密钥框 + 显隐 / 复制、可用模型 link、分组列、状态开关、绝对时间;列设置用共享组件;创建 / 编辑为 560px `OrgSideSheet` | 列设置只在当前页面生效;非操作列整体横向滚动,仅在可见列宽度超过容器时显示滚动条 |
|
||||
| 企业充值 | 企业钱包 + 充值工作区(额度卡 / 自定义 / 支付方式)+ 订单卡 + 记录;订单“立即充值”与支付方式点击同为 `handlePreTopUp` | 档位与折扣来自后台配置;无订单号搜索与发票入口 |
|
||||
| 消耗明细 | 统计卡 + 页签(明细日志 / 成员排行 / 绘图与视频)+ 三列筛选卡 + 列表卡;查询按钮为“搜索”(`handleSearch`) | 见第 5 节 |
|
||||
| 审计日志 | 页签 + 筛选卡(操作类型)+ 操作记录卡;“提示词记录”页签沿用原显隐 | — |
|
||||
| 消耗明细 | 统计卡 + 页签(明细日志 / 成员排行 / 绘图与视频)+ 消费记录样式筛选卡 + 列表卡;查询按钮为“搜索”(`handleSearch`) | 见第 5 节 |
|
||||
| 审计日志 | 页签 + 筛选卡(操作类型)+ 操作记录卡;“提示词记录”页签沿用原显隐,筛选区参考消费记录;说明条上下与筛选卡至列表卡均间隔 18px | — |
|
||||
| 个人设置 | 复用用户中心 `ui-personal-*`、`AvatarSection`、`SectionHeader`;三页签:头像设置 / 个人资料 / 通知设置;企业身份并入资料头 | 昵称在弹窗中修改 |
|
||||
| 企业设置 | 设置卡内页签 + 区块头(刷新 / 保存设置);复制为 14px 无内边距图标按钮 | 保留“数据安全”“危险区域”页签 |
|
||||
|
||||
@@ -79,18 +80,20 @@
|
||||
|
||||
- 剩余额度提示按未取整占比判定:> 20% 为“可用额度充足”(`#438568`),0 < 占比 ≤ 20% 为“可用额度偏低”(`#9c6b25`),≤ 0 为“可用额度已用尽”(`#b34c4c`);数据无效时隐藏,仅作提示,不影响计费或拦截。
|
||||
- 多维用量分析工具组用原生 `Select` / `Button`:维度 132px、时间 86px、刷新 34px,高 34px、间距 8px。
|
||||
- 模型明细使用已加载数据做前端分页(每页 10 条),翻页不请求接口,维度、时间或数据变化时回到第一页;表格随页面自然展开,仅窄屏横向滚动。
|
||||
- 模型明细使用已加载数据做前端分页(默认每页 10 条),翻页不请求接口,维度、时间或数据变化时回到第一页;表格随页面自然展开,仅窄屏横向滚动。
|
||||
|
||||
## 5. 消耗明细(/org/logs)
|
||||
|
||||
- 绘图与视频由 `components/OrgTaskRecords.jsx` 呈现,复用 `useTaskLogsData({ organizationMode: true })`、`TaskLogsFilters`、`getTaskLogsColumns`、`exportTaskLogsPageCsv`、`ColumnSelectorModal`、`ContentModal`;结构为筛选卡 + “任务记录”列表卡(导出本页 / 刷新 / 列设置),不渲染“本页统计”区块,移动端筛选直接展开。
|
||||
- 任务表列宽 185 / 185 / 110 / 110 / 250 / 330 / 110 / 155 / 145 / 150;模型为行内胶囊,费用主色右对齐;分页 10 / 20 / 50,“共 N 条”。“刷新”与“搜索”调用同一 `refresh`。
|
||||
- 三个页签和审计日志下的提示词记录共用个人消费记录的筛选布局:桌面五列,时间范围跨两列;窄屏三列,移动端单列并默认收起。操作区位于右下,“重置”在前,“搜索”在后,点击和回车共用提交入口。
|
||||
- 绘图与视频由 `components/OrgTaskRecords.jsx` 呈现,复用 `useTaskLogsData({ organizationMode: true })`、`TaskLogsFilters`、`getTaskLogsColumns`、`exportTaskLogsPageCsv`、`ColumnSelectorModal`、`ContentModal`;结构为筛选卡 + “任务记录”列表卡(导出本页 / 刷新 / 列设置),不渲染“本页统计”区块。
|
||||
- 任务表列宽 185 / 185 / 110 / 110 / 250 / 330 / 110 / 155 / 145 / 150;模型为行内胶囊,费用主色右对齐;分页沿用公共规范。“刷新”与“搜索”调用同一 `refresh`。
|
||||
- 时间范围为本页签自有的可编辑字段(默认最近 7 天,含快捷预设),与“明细日志”筛选互不影响;起止颠倒沿用原提示。
|
||||
- 末列“操作”不固定:视频任务显示“点击预览视频”,失败任务保留失败原因查看,其余显示“-”。
|
||||
- 预览视频沿用 `ContentModal`:标题栏“视频预览”与关闭按钮、16:9 播放区、加载态、播放失败或无地址时 `Empty` 空态、页脚复制链接 / 新标签页打开 / 关闭;关闭时暂停视频,重开同一视频不残留加载指示。
|
||||
- 成员排行行键使用 `user_id-名次序号`,避免后端同一成员多行时出现重复 key。
|
||||
- 只有具备排行权限并打开「成员排行」时才查询榜单。首次打开使用已生效的成员、模型和时间范围,默认每页 10 人。翻页和更改每页人数均携带服务端返回的 `snapshot`。搜索、重置、刷新及切换企业会重新查询当前条件下的榜单。快照过期时自动按原筛选和页容量回到第 1 页重取一次。
|
||||
- 服务端按成员汇总后按消耗额度降序排列,同额按成员 ID 升序。行键使用 `user_id`,名次按返回页码、页容量和行号连续计算。前三名使用当前主题的强调色及三档底色,其余名次使用中性色。
|
||||
- 明细日志查询不写 URL;绘图与视频筛选沿用原有 URL 同步。
|
||||
- 保留差异:明细日志无列设置、分组列、操作列与尺寸切换;任务表无渠道 / 用户 ID 筛选、平台列、排序与任务 ID 复制。
|
||||
- 保留差异:明细日志无列设置、分组列、操作列;任务表无渠道 / 用户 ID 筛选、平台列、排序与任务 ID 复制。
|
||||
|
||||
## 6. 验收要点
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 用户中心 UI 规范(/user-center/\*)
|
||||
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.4
|
||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.5
|
||||
|
||||
个人登录后用户中心页面的规范,只记录与公共规范不同的部分;密钥管理、服务监控见各自规范。
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
- 页签:纯文字页签(公共列表页签样式),与下方 20px,URL `?tab=` 同步并懒挂载。
|
||||
- 筛选卡:5 列栅格,时间范围跨 2 列;背景使用 `--surface-card` 纯色(浅色为白色、深色为主题卡片色);操作“重置 / 搜索”右下。
|
||||
- 列表卡:标题 15px / 600,导出、列设置位于卡头右侧;表头字重 400(公共标准为 500,待收敛)。
|
||||
- 消费记录调用明细为固定列宽宽表,时间分两行(日期 11px、时间 15px / 600),操作列文字“查看”,固定在右侧;横向滚动条保留 Ant Design 官方固定列表格行为,固定列兼容规则遵循公共规范第 5.2 节。
|
||||
- 消费记录调用明细为固定列宽宽表,横向滚动时“时间”列固定在左侧,“操作”列显示时固定在右侧,中间列可滚动。时间分两行(日期 11px、时间 15px / 600),固定列兼容规则遵循公共规范第 5.2 节。
|
||||
- 消费记录“用时 / 首字”列宽 190px,总用时、首字耗时与流式状态分别用 antd 默认带描边 `Tag` 展示,保留主题算法生成的浅底 / 文字 / 边框。总用时对 `use_time` 取整数秒,`<101s` 用 `green`、`101–299s` 用 `gold`、`≥300s` 用 `magenta`;首字耗时取 `other.frt / 1000`,先保留一位小数再判色,`<3s` 用 `cyan`、`3–<10s` 用 `orange`、`≥10s` 用 `red`。流式显示三枚标签(状态为蓝色“流”),非流式仅显示总用时与中性“非流”;零值正常展示,缺失、非数值或负耗时显示中性破折号。
|
||||
- 绘图与视频:三张统计卡(高 70px、间距 15px)+ 任务记录表。
|
||||
- Webhook 示例为 `<pre class='ui-notify-code'>` +“复制”链接,复制提示沿用原文案。
|
||||
|
||||
@@ -0,0 +1,407 @@
|
||||
# 权限重构 · 产品功能验收与切换手册
|
||||
|
||||
| 项 | 内容 |
|
||||
| --- | --- |
|
||||
| 对应需求 | 《MaaS平台用户菜单权限重构PRD-V1.2》(本目录 `V1.2/`) |
|
||||
| 对应版本 | `weiyuan` 分支 `801eda5ff` 及之后 |
|
||||
| 适用对象 | 产品验收、测试、运维(迁移命令、切换与回滚由运维执行) |
|
||||
| 更新日期 | 2026-11-30(移除 E2 登录名回填、T 两步验证验收项;2026-11-24 已逐条对照代码核对) |
|
||||
|
||||
---
|
||||
|
||||
## 怎么用这份手册
|
||||
|
||||
验收和切换分五个阶段,**必须按顺序做,上一阶段全部通过再进入下一阶段**。每一项做完在「结果」列填 ✅ / ❌,❌ 的在「备注」写清现象并截图。
|
||||
|
||||
| 阶段 | 做什么 | 会不会改变线上权限 | 谁来做 |
|
||||
| --- | --- | --- | --- |
|
||||
| 一 | 升级后验收:确认原有功能没坏、新页面能用 | 不会 | 产品 / 测试 |
|
||||
| 二 | 生成迁移角色,打开影子对比,观察新旧权限判断有没有差异 | 不会(只记录) | 产品 + 运维 |
|
||||
| 三 | 选一家**内部测试企业**切到新权限体系,完整验收 | 只影响测试企业 | 产品 / 测试,运维配合 |
|
||||
| 四 | 平台侧(控制台)分批切换 | 影响平台管理员 | 产品 + 运维 |
|
||||
| 五 | 客户企业分批切换 | 影响客户企业 | 产品 + 运维 + 客户成功 |
|
||||
|
||||
**四个基本事实,验收时请记住:**
|
||||
|
||||
1. **升级后默认是「旧模式」**:所有权限判断和升级前一样。新的权限管理页面能打开,但在某个模块或企业被切换之前,配置不会影响实际权限。
|
||||
2. **迁移角色不会随升级自动生成**:「平台管理员(迁移)」「管理员(迁移)」等角色和迁移套餐,要运维执行一次迁移对账命令(第二章 2.1)才会出现;不执行的话,切换企业时也会自动生成。
|
||||
3. **新权限变化以「重新登录」生效**:已切换的模块或企业里,某人的权限一旦变化,他的页面会在 1 分钟内(或切回窗口时)弹出「权限已变更 · 你的权限已变更,请重新登录。」,点「重新登录」后看到新菜单。下文写「重新登录后」即指这一步。
|
||||
4. **切换可以撤回**:把企业从切换名单里移除(或把平台模块移除),立即恢复旧逻辑。**移除之前**运维要先跑投影命令(第六章),顺序反了命令会报错。
|
||||
|
||||
---
|
||||
|
||||
## 0. 准备工作
|
||||
|
||||
### 0.1 环境
|
||||
|
||||
- [ ] 已按《01-常规升级操作卡》完成升级,`verify` 五项自动检查全绿(另有 4 项人工检查按操作卡执行)。
|
||||
- [ ] 浏览器使用 Chrome 最新版,验收前 `Ctrl+F5` 强制刷新。
|
||||
- [ ] 下文地址都是相对站点域名,例如 `https://<域名>/console/authz/menus`。
|
||||
- [ ] 第三阶段建议在**预发环境**做;3.7.4 等全局配置项在生产上会影响所有已切换企业。
|
||||
|
||||
### 0.2 验收账号
|
||||
|
||||
至少准备以下账号(企业侧账号都建在一家**内部测试企业**里,不要用客户企业):
|
||||
|
||||
| 代号 | 身份 | 用途 |
|
||||
| --- | --- | --- |
|
||||
| R | 平台超级管理员(root) | 权限管理、代理进入企业、运行模式。**权限管理菜单只有 root 能看到** |
|
||||
| A | 平台管理员(非 root) | 验证平台侧权限 |
|
||||
| U | 普通个人用户 | 验证个人功能、模型调用、平台自定义角色 |
|
||||
| O | 测试企业所有者 | 企业侧最高权限 |
|
||||
| M | 测试企业管理员 | 迁移来的「管理员(迁移)」 |
|
||||
| D | 测试企业部门负责人(某部门的负责人) | 「我管辖的部门」 |
|
||||
| E | 测试企业普通员工(企业创建的托管账号),工号已填 | 企业登录、首登改密、角色授权 |
|
||||
|
||||
测试企业里准备至少两个一级部门(例如「研发部」「销售部」),研发部下再建一个二级部门(例如「研发一组」)。E 放在研发部,研发部、研发一组、销售部各至少再有 1 名员工。
|
||||
|
||||
---
|
||||
|
||||
## 一、阶段一:升级后验收(旧模式)
|
||||
|
||||
目标:原有功能不受影响,新增入口能正常打开。**本阶段不要修改任何角色、套餐、运行模式。**
|
||||
|
||||
### 1.1 原有功能回归(必做)
|
||||
|
||||
| 编号 | 账号 | 入口 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| 1.1.1 | U | 个人登录 `/login` | 登录,调用一次模型(操练场或 API) | 正常返回、正常扣费;「使用日志」里有记录 | | |
|
||||
| 1.1.2 | U | 个人中心 | 修改一次密码,退出用新密码登录 | 改密成功、新密码可登录 | | |
|
||||
| 1.1.3 | A | 控制台 | 打开平时使用的页面(渠道、日志、用户等) | 能看到的菜单和升级前一致;**看不到**「权限管理」分组(只有 root 可见) | | |
|
||||
| 1.1.4 | O | 企业登录 `/org/login` | 登录 | 进入企业中心 | | |
|
||||
| 1.1.5 | O | 企业中心各菜单 | 依次打开「数据看板」「员工管理」「令牌管理」「部门管理」「预算中心」「项目管理」 | 列表正常显示,无报错 | | |
|
||||
| 1.1.6 | M | 企业中心 | 登录并打开员工管理、令牌管理 | 能看到的菜单与升级前一致 | | |
|
||||
| 1.1.7 | D | 企业中心 →「我管辖的部门」`/org/dept-manage` | 打开 | 能看到自己负责的部门及成员(只有部门负责人或部门管理员才有这个菜单) | | |
|
||||
| 1.1.8 | E | 企业登录 | 登录,在「令牌管理」新建一个令牌并调用模型 | 正常 | | |
|
||||
| 1.1.9 | O | 「令牌管理」 | 编辑任意令牌并保存 | 保存成功 | | |
|
||||
|
||||
### 1.2 平台侧新页面(账号 R)
|
||||
|
||||
| 编号 | 入口 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1.2.1 | 控制台侧栏 | 查看是否有「权限管理」分组 | 有,下含「菜单管理」「平台角色」「功能套餐」「角色模板」「运行模式」 | | |
|
||||
| 1.2.2 | 「菜单管理」`/console/authz/menus` | 打开,切换「平台」/「企业」两个页签,全部展开 | 两棵权限树完整,按钮挂在对应菜单下,每行有「显示」「启用」开关 | | |
|
||||
| 1.2.3 | 「平台角色」`/console/authz/roles` | 打开 | 页面正常。**此时还没有迁移角色**(第二章 2.1 执行后才出现),列表为空或只有内置角色属正常 | | |
|
||||
| 1.2.4 | 「功能套餐」`/console/authz/packages` | 打开 | 页面正常(同上,迁移套餐在 2.1 之后出现) | | |
|
||||
| 1.2.5 | 「角色模板」`/console/authz/templates` | 打开 | 页面正常 | | |
|
||||
| 1.2.6 | 「运行模式」`/console/authz/mode` | 打开 | 「平台侧」的「已切换模块」、「企业侧」的「已切换企业 ID」「已切换模块」均为空;两侧「影子对比」均为关闭 | | |
|
||||
| 1.2.7 | 「企业管理」`/console/organizations` | 查看列表 | 新增「企业所有者」「功能套餐」「企业预警通知」列;没有套餐的企业显示「跟随默认套餐」 | | |
|
||||
| 1.2.8 | 「企业管理」 | 点击测试企业名称 | 进入该企业的「数据看板」,顶部出现黄色提示条「超管代理模式:正在代理操作企业「…」,所有操作都会记录审计」 | | |
|
||||
| 1.2.9 | 代理状态下 | 打开员工管理,然后点提示条上的「退出代理」 | 员工列表正常;退出后回到「企业管理」列表 | | |
|
||||
| 1.2.10 | 「用户管理」`/console/user` | 编辑一个用户 | 「剩余额度」只读,提示调整请用列表操作列的「添加额度」 | | |
|
||||
| 1.2.11 | 「用户管理」 | 对一个测试用户点操作列「添加额度」:先 +100,再 -100;再试填 0、填一个超过剩余额度的负数 | 额度先加后减回到原值;填 0 提示「调整额度不能为 0」;减成负数提示「调整后的剩余额度不能小于 0」 | | |
|
||||
| 1.2.12 | 「用户管理」 | 查看操作列 | 有「分配角色」入口(超级管理员行没有);切换前分配不改变该用户的管理员身份 | | |
|
||||
|
||||
### 1.3 企业侧新页面与改动(账号 O)
|
||||
|
||||
| 编号 | 入口 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1.3.1 | 企业中心侧栏 | 核对菜单名称 | 「令牌管理」(原密钥管理)、「部门管理」(原组织架构);O 若是某部门负责人,还有「我管辖的部门」。**「角色管理」切换前不显示**,地址栏输入 `/org/roles` 会被送走,属正常 | | |
|
||||
| 1.3.2 | 「员工管理」`/org/members` | 打开 | 合并为一张表(不再分「员工权限 / 员工账号」页签),筛选项有「关键字」「分组」「组织」(部门)「状态」 | | |
|
||||
| 1.3.3 | 「员工管理」 | 新建员工,姓名留空提交 | 提示「请输入姓名」 | | |
|
||||
| 1.3.4 | 「员工管理」 | 新建员工,邮箱填 `abc` | 提示「邮箱格式不正确」 | | |
|
||||
| 1.3.5 | 「员工管理」 | 新建员工,工号填 E 的工号 | 提示「工号在企业内已存在」(已停用、离职成员的工号不占用) | | |
|
||||
| 1.3.6 | 「员工管理」 | 编辑员工资料,修改工号、备注 | 保存成功 | | |
|
||||
| 1.3.7 | 「员工管理」→ CSV 导入 | 导入一个含:正常行、姓名为空行、邮箱格式错误行的 CSV(Excel 另存的带 BOM 文件也要试;上限 500 行、5MB) | 正常行成功并给出初始密码;错误行逐行显示原因 | | |
|
||||
| 1.3.8 | 「令牌管理」 | 对一个令牌点查看 / 复制密钥 | 正常显示 | | |
|
||||
| 1.3.9 | 「部门管理」`/org/departments` | 新建部门,负责人选一个本企业员工 | 保存成功 | | |
|
||||
|
||||
### 1.4 企业登录(账号 E)
|
||||
|
||||
| 编号 | 账号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1.4.1 | O | 在「员工管理」给 E 重置密码(只能重置托管账号),E 用初始密码从 `/org/login` 登录 | 登录后进入「首次登录,请修改初始密码」步骤;改密前企业功能不可用 | | |
|
||||
| 1.4.2 | E | 改密后 | 正常进入企业中心 | | |
|
||||
| 1.4.3 | — | 若系统开启了 Turnstile | 企业登录页显示人机验证,验证通过才能提交 | | |
|
||||
| 1.4.4 | E | 从个人入口 `/login` 登录 | 切换前仍可登录,并被送到企业中心(切换后会被拒绝,见 3.3.1) | | |
|
||||
|
||||
**阶段一通过标准**:1.1 全部通过;1.2–1.4 无阻断性问题。
|
||||
|
||||
---
|
||||
|
||||
## 二、阶段二:生成迁移角色与影子对比
|
||||
|
||||
目标:在不改变实际权限的情况下,让系统同时按新旧两套规则判断,记录两者不一致的地方。**建议在预发环境运行至少一周**,生产也可以开启(只记录、不拦截)。
|
||||
|
||||
### 2.1 生成迁移角色(运维执行,先于影子对比)
|
||||
|
||||
影子对比按库里的新角色计算。不先生成迁移角色,管理员、部门负责人的每次操作都会被记成「缩权」,结果没有参考价值。
|
||||
|
||||
在部署目录(`.env` 所在目录)、用新版本程序、单实例执行:
|
||||
|
||||
```bash
|
||||
# ① 预演:只出报告,不写库,报告文件 authz-migrate-report.md
|
||||
SERVICE_MODE=authz-migrate ./monkey-ai
|
||||
# ② 产品审阅报告无误后,正式生成(旧模式 / 影子模式下不改变现有权限;报告有"扩大"项时拒绝执行)
|
||||
SERVICE_MODE=authz-migrate AUTHZ_MIGRATE_APPLY=1 ./monkey-ai
|
||||
```
|
||||
|
||||
| 编号 | 检查项 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 2.1.1 | 产品审阅预演报告 | 「扩大」一节为空,其他各节与实际情况相符 | | |
|
||||
| 2.1.2 | R 打开「平台角色」 | 出现「平台管理员(迁移)」,旧管理员都已绑定 | | |
|
||||
| 2.1.3 | R 打开「功能套餐」 | 有一个默认套餐;按企业原有功能开关组合可能还有「套餐(迁移)1」「套餐(迁移)2」… | | |
|
||||
| 2.1.4 | R 代理进入测试企业,查看员工的角色 | 各成员已绑定管理员(迁移)、部门管理员(迁移)、部门负责人(迁移)、员工(迁移)等角色 | | |
|
||||
|
||||
### 2.2 开启(账号 R,运行模式页)
|
||||
|
||||
1. 打开「权限管理」→「运行模式」`/console/authz/mode`。
|
||||
2. 「平台侧」打开「影子对比」,保存。
|
||||
3. 「企业侧」打开「影子对比」,保存。
|
||||
|
||||
只改影子对比开关不会弹确认框,保存即生效。
|
||||
|
||||
### 2.3 观察
|
||||
|
||||
运行期间让各类账号正常使用系统。每天在运行模式页下方的「影子差异」表查看:
|
||||
|
||||
- 可按「域」(平台 / 企业 / 代理)和时间(最近 1 / 6 / 24 / 72 / 168 小时)筛选;点击一行可展开看是哪些人。
|
||||
- 「方向」一列:
|
||||
- **扩权**:旧规则拒绝、新规则放行。**必须为 0,或逐条找到原因并确认可以接受。**
|
||||
- **缩权**:旧规则放行、新规则拒绝。逐条确认原因(通常是迁移角色缺了某个权限点)。
|
||||
- 迁移角色在切换前只由对账命令维护:观察期内如果调整过旧身份(设管理员、换部门负责人),判断差异前请运维重跑一次 2.1 第②步,否则这些人会出现误报。
|
||||
|
||||
| 编号 | 检查项 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 2.3.1 | 运行满 7 天 | 已运行 ___ 天 | | |
|
||||
| 2.3.2 | 平台域「扩权」差异 | 0 条,或已逐条说明 | | |
|
||||
| 2.3.3 | 企业域「扩权」差异 | 0 条,或已逐条说明 | | |
|
||||
| 2.3.4 | 「缩权」差异 | 已逐条说明,需要补权限的已在菜单管理 / 角色中补齐 | | |
|
||||
|
||||
**阶段二通过标准**:2.1 完成;2.3.2、2.3.3 无未解释的扩权差异。
|
||||
|
||||
---
|
||||
|
||||
## 三、阶段三:内部测试企业切换(企业侧)
|
||||
|
||||
目标:在一家内部测试企业上完整走一遍「切换 → 验收 → 回退 → 再切换」。**只用内部测试企业,不要用客户企业。**
|
||||
|
||||
### 3.1 切换前
|
||||
|
||||
| 编号 | 检查项 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- |
|
||||
| 3.1.1 | 已记下测试企业 ID:______ | | |
|
||||
| 3.1.2 | 已通知测试企业所有成员:切换后**只能从企业登录入口 `/org/login` 登录**;个人账号加入的成员用原用户名、原密码登录 | | |
|
||||
| 3.1.3 | 测试企业的所有者有效(所有者是在职成员);否则先在「企业管理 → 编辑 → 更换所有者」处理 | | |
|
||||
|
||||
### 3.2 执行切换(账号 R,运行模式页)
|
||||
|
||||
1. 「企业侧」的「已切换模块」选「全部(*)」(建议企业侧一次切全)。
|
||||
2. 「已切换企业 ID」输入框填测试企业 ID(多个用逗号分隔),保存,在「确认切换权限运行模式」框点「确认」。
|
||||
3. 系统会先做**切换前对账**。报告里有「扩大」或「登录」项时,弹出「切换前对账未通过」:
|
||||
- 顶部是各类条数(扩大 / 登录 / 冲突 / 缩小 / 未知),下面是完整报告;
|
||||
- **扩大**:切换后谁会多出哪些权限;
|
||||
- **登录**:切换后无法用密码从企业入口登录的成员(登录名已被他人占用、保留名、没有密码、成员的企业登录被关闭);
|
||||
- **未知**:需要人工确认的情况(企业没有有效所有者、旧管理员可查看令牌密钥、未切换期间新建的普通角色);
|
||||
- 企业原本没开「企业登录」的,对账会自动打开,在报告摘要里列出;
|
||||
- 全部确认可以接受后,点「已逐条确认,继续切换」。没有扩大和登录项时不弹框,直接切换。
|
||||
4. 切换立即生效。
|
||||
|
||||
| 编号 | 检查项 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 3.2.1 | 对账报告 | 内容与测试企业实际情况相符;记录扩大 ___ 条、登录 ___ 条 | | |
|
||||
| 3.2.2 | 保存后刷新运行模式页 | 测试企业 ID 出现在「已切换企业 ID」中 | | |
|
||||
|
||||
### 3.3 登录与入口
|
||||
|
||||
| 编号 | 账号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 3.3.1 | E | 从个人入口 `/login` 登录 | 被拒绝,提示「该账号为企业账号,请从企业登录入口登录」 | | |
|
||||
| 3.3.2 | E | 从企业入口登录后,地址栏输入 `/console/token` | 被送回企业中心 `/org` | | |
|
||||
| 3.3.3 | O、M、D、E | 分别从企业入口登录,查看侧栏菜单 | 各自能看到的菜单与切换前一致(迁移角色保证不变);O 新出现「角色管理」 | | |
|
||||
| 3.3.4 | R | 「企业管理」点击测试企业名称,代理进入后修改一名员工的备注 | 代理进入,顶部有代理提示条;企业中心「审计日志」里能查到这次修改(进入 / 退出代理本身记在平台审计表,页面上不显示) | | |
|
||||
|
||||
### 3.4 角色管理(账号 O,`/org/roles`)
|
||||
|
||||
权限点名称以授权树为准,下文用到的:员工管理 →「查询」「编辑资料、模型限制与备注」「重置密码」;令牌管理 →「查询」「创建令牌」「编辑与启停」「删除」「查看与复制密钥」;消耗明细 →「查询」。
|
||||
|
||||
| 编号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 3.4.1 | 「新建角色」:名称「测试-只读」,数据范围「本部门及以下」,「菜单与按钮权限」只勾「员工管理 → 查询」 | 创建成功 | | |
|
||||
| 3.4.2 | 行操作「分配员工」:把 E 分配到「测试-只读」 | 保存成功,成员数 +1 | | |
|
||||
| 3.4.3 | E 等待「权限已变更」提示后重新登录 | 侧栏出现「员工管理」,只能看到研发部和研发一组的员工;没有新建、编辑等按钮 | | |
|
||||
| 3.4.4 | 编辑「测试-只读」,再勾上「员工管理 → 编辑资料、模型限制与备注」 | E 重新登录后出现编辑按钮,能编辑本部门员工 | | |
|
||||
| 3.4.5 | E 尝试编辑销售部员工(直接改地址或调接口) | 被拒绝 | | |
|
||||
| 3.4.6 | 把「测试-只读」数据范围改为「仅本人」 | E 重新登录后员工列表只剩自己 | | |
|
||||
| 3.4.7 | 在「状态」列尝试停用该角色(E 仍在角色中) | 被拒绝,提示「该角色仍分配给 1 个成员,请先移除后再停用/删除」 | | |
|
||||
| 3.4.8 | 「分配员工」里移除 E,然后停用、再删除该角色 | E 重新登录后失去员工管理菜单;停用、删除均成功 | | |
|
||||
| 3.4.9 | 授权树:勾选一个菜单 | 其下按钮全部勾上(父子联动);只勾部分按钮时菜单显示半选 | | |
|
||||
| 3.4.10 | 新建一个只含「令牌管理 → 查询」的角色,点「设为默认」;在员工管理新建一个员工 | 提示「新建员工将自动分配该角色,已有员工角色保持不变。」;新员工自动获得该角色。**测完把默认改回原默认角色**(默认角色不能停用或删除) | | |
|
||||
| 3.4.11 | 尝试给企业所有者分配角色 | 被拒绝,提示「不能对企业所有者执行该操作,所有者变更请走所有者移交」 | | |
|
||||
| 3.4.12 | 编辑「管理员(迁移)」,移除「令牌管理 → 查看与复制密钥」 | 保存成功(切换后迁移角色可以修改);M 重新登录后看不到查看 / 复制密钥按钮,直接调接口也被拒 | | |
|
||||
|
||||
### 3.5 数据范围(六类)
|
||||
|
||||
给 E 绑定一个角色(授权含员工管理查询、令牌管理查询、消耗明细查询),依次把数据范围改成下表各项,E 每次重新登录后核对员工列表、令牌列表、消耗明细:
|
||||
|
||||
| 编号 | 数据范围 | E 所在部门 | 期望能看到 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 3.5.1 | 全部数据 | 研发部 | 全企业 | | |
|
||||
| 3.5.2 | 本部门 | 研发部 | 只有研发部,**不含**研发一组 | | |
|
||||
| 3.5.3 | 本部门及以下 | 研发部 | 研发部 + 研发一组 | | |
|
||||
| 3.5.4 | 本部门及以下或本人 | 研发部 | 研发部 + 研发一组 + 本人 | | |
|
||||
| 3.5.5 | 自定义部门(关闭「父子联动」,只勾销售部) | 研发部 | 只有销售部 | | |
|
||||
| 3.5.6 | 仅本人 | 研发部 | 只有自己 | | |
|
||||
|
||||
### 3.6 员工管理与令牌(新体系下)
|
||||
|
||||
| 编号 | 账号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 3.6.1 | O → M | 承接 3.4.12(M 已没有「查看与复制密钥」):给 E 的角色勾上「令牌管理 → 查看与复制密钥」,M 重新登录后给 E 重置密码 | 被拒绝,提示「该账号的权限超出你的权限范围,不能操作」 | | |
|
||||
| 3.6.2 | M、R(代理) | 分别尝试修改所有者 O 的邮箱 | 都被拒绝,提示「不能对企业所有者执行该操作…」;切换后所有者邮箱只能本人改 | | |
|
||||
| 3.6.3 | 持「令牌管理 → 查询 + 创建令牌」但无「编辑与启停 / 删除 / 查看与复制密钥」的员工 | 查看自己令牌的操作 | 不显示编辑、删除、查看 / 复制密钥;启停开关为灰色不可点 | | |
|
||||
| 3.6.4 | 持「查看与复制密钥」的员工 | 1 分钟内反复「隐藏 → 显示」令牌密钥超过 20 次 | 第 21 次提示「查看密钥过于频繁,请稍后再试」。**本地测试环境关闭了限流,此项须在预发验证** | | |
|
||||
| 3.6.5 | O | 停用一个部门 | 提示「停用后,该部门 N 名直属成员将被一并停用,其 API 令牌将被禁用;下级部门不受影响。」;确认后这些成员被停用、令牌被禁用(所有者不受影响) | | |
|
||||
| 3.6.6 | O | 重新启用该部门 | 直属成员全部恢复(含此前被单独停用的);**令牌不会自动启用**,需手动启用;若某成员工号已被其他在职员工占用,该成员保持停用(审计日志里有记录) | | |
|
||||
|
||||
### 3.7 平台对已切换企业的管理(账号 R)
|
||||
|
||||
| 编号 | 入口 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 3.7.1 | 「企业管理」→ 功能套餐 | 给测试企业换一个套餐(先在「功能套餐」新建一个去掉「项目管理」的套餐) | 企业中心不再显示项目管理;角色授权树里也不再出现该菜单 | | |
|
||||
| 3.7.2 | 同上 | 把套餐改回原套餐 | 菜单恢复;之前已有的授权自动恢复 | | |
|
||||
| 3.7.3 | 「企业管理」→ 编辑 →「更换所有者」 | 把所有者换成 M | 新所有者获得全部权限;原所有者降为成员,保留原有普通角色并追加默认员工角色(未切换企业的原所有者则降为管理员) | | |
|
||||
| 3.7.4 | 「菜单管理」→「企业」页签 | 把「数据看板」的「显示」关掉,验证后再打开 | 关掉后测试企业成员侧栏不显示数据看板、直接访问也被送走;打开后恢复。**这是全局设置,会影响所有已切换企业,生产上不要做** | | |
|
||||
|
||||
### 3.8 回退演练
|
||||
|
||||
| 编号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 3.8.1 | 运维执行投影命令并生成负责人报告(见第六章 6.2 第 1 步)。**必须在移出名单之前执行**;顺序反了命令会报错退出并列出已不在名单中的企业 | 生成报告文件 | | |
|
||||
| 3.8.2 | 产品审阅报告中的两份名单:①回退后会获得部门管理权限的人、②回退后会失去部门管理权限的人 | 已逐一确认 | | |
|
||||
| 3.8.3 | 运行模式页:从「已切换企业 ID」删掉测试企业,保存 | 立即生效 | | |
|
||||
| 3.8.4 | O、M、D、E 各登录一次 | 菜单与切换前一致 | | |
|
||||
| 3.8.5 | 再次把测试企业加入名单 | 对账报告把 3.4.12 撤掉的权限列为扩大项(「迁移角色「管理员(迁移)」将被对账校正为旧体系推导结果:…」),确认后切换成功;3.4 新建的普通角色若还在会重新生效 | | |
|
||||
|
||||
**阶段三通过标准**:3.2–3.8 全部通过,或不通过项已有结论并经产品确认。
|
||||
|
||||
---
|
||||
|
||||
## 四、阶段四:平台侧切换(控制台)
|
||||
|
||||
平台侧按三批切换,每批切换后用账号 A 和一名自定义角色用户验收。「已切换模块」下拉框里显示的是模块代号,对照如下:
|
||||
|
||||
| 批次 | 模块代号(菜单名) |
|
||||
| --- | --- |
|
||||
| P1a | `authz.menu`(菜单管理)、`authz.role`(平台角色)、`authz.package`(功能套餐)、`authz.template`(角色模板)、`user`(用户管理)、`redemption`(兑换码管理)、`admin_token`(秘钥管理)、`org`(企业管理) |
|
||||
| P1b | `channel`(渠道管理)、`model`(模型管理)、`log`(使用日志)、`drawing_log`(绘图日志)、`task_log`(任务日志)、`monitor`(监控中心)、`topup`(充值记录)、`analytics`(运营看板)、`subscription`(会员卡管理)、`skill`(平台 Skill 中心)、`expert`(平台专家中心)、`router`(智能路由)、`order`(订单管理)、`invoice`(发票管理)、`commission`(分佣管理) |
|
||||
| P1c | `setting`(系统设置) |
|
||||
|
||||
### 4.1 每批的操作(账号 R,运行模式页)
|
||||
|
||||
1. 「平台侧」的「已切换模块」**在原有基础上**加选本批模块,保存,在「确认切换权限运行模式」框点「确认」。
|
||||
2. 平台侧第一次切换时会做对账;有扩大项时弹出「切换前对账未通过」,逐条确认后继续。
|
||||
3. 运行模式只由一人修改,避免多人同时操作。
|
||||
|
||||
### 4.2 每批的验收
|
||||
|
||||
| 编号 | 账号 | 操作 | 期望结果 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 4.2.1 | A | 完成本批模块的日常操作 | 全部可用(A 已绑定「平台管理员(迁移)」) | | |
|
||||
| 4.2.2 | R | 在「平台角色」新建角色,只授权本批某个页面的「查询」(选有「查询」按钮的页面,如用户管理、兑换码管理、渠道管理),分配给 U | U 重新登录后能进入该页面查看,不能修改 | | |
|
||||
| 4.2.3 | U | 尝试该页面的修改操作 | 被拒绝 | | |
|
||||
| 4.2.4 | R | 第一批起:在「平台角色」给 U 分配「平台管理员(迁移)」,再移除 | 分配后 U 成为管理员;移除后恢复普通用户 | | |
|
||||
| 4.2.5 | R | P1a 起:查看用户管理操作列 | 不再出现「提升」「降级」,改用「分配角色」 | | |
|
||||
| 4.2.6 | A | P1a 起:对一名在企业里是所有者、管理员或部门管理员的用户改密、停用 | 被拒绝,提示「该账号的权限超出你的权限范围,不能操作」(只能由 root 处理) | | |
|
||||
|
||||
**阶段四通过标准**:每批 4.2 全部通过后再切下一批。
|
||||
|
||||
---
|
||||
|
||||
## 五、阶段五:客户企业分批切换
|
||||
|
||||
### 5.1 每批切换前
|
||||
|
||||
| 编号 | 检查项 | 结果 | 备注 |
|
||||
| --- | --- | --- | --- |
|
||||
| 5.1.1 | 本批企业 ID 已确定,**每批新增不超过 50 家**(系统硬限制,超过会提示「一次最多新切换 50 家企业…」) | | |
|
||||
| 5.1.2 | 已提前通知本批企业(建议至少提前 3 个工作日,通知要点见 5.3) | | |
|
||||
| 5.1.3 | 用预演命令看过本批企业的报告(运维:`SERVICE_MODE=authz-migrate AUTHZ_MIGRATE_SCOPE=org AUTHZ_MIGRATE_ORG_IDS=<本批ID> ./monkey-ai`),「未知」里没有有效所有者的企业已先更换所有者 | | |
|
||||
| 5.1.4 | 选在业务低峰执行 | | |
|
||||
|
||||
### 5.2 执行与观察
|
||||
|
||||
1. 运行模式页:在「已切换企业 ID」**追加**本批企业 ID(保留已切换的,逗号分隔),保存并确认。
|
||||
2. 逐条阅读对账报告,重点看「登录」(无法从企业入口登录的成员,逐人处理或确认)、「未知」(普通角色会直接生效、旧管理员的令牌密钥权限),确认后继续。
|
||||
3. 切换后抽查本批 3–5 家企业:所有者、管理员各登录一次,核对菜单。
|
||||
4. 观察 1–2 天,收集客户反馈的登录失败、页面无权限问题,无异常再切下一批。
|
||||
5. 全部企业切换完成后,「已切换企业 ID」改为 `*`。此后新建的企业自动按新体系运行(自动建好迁移角色、默认员工角色并打开企业登录)。
|
||||
6. 运维执行一次存量消耗日志的部门回填:`SERVICE_MODE=authz-migrate AUTHZ_BACKFILL_LOG_DEPT=1 ./monkey-ai`(可中断、可重入)。
|
||||
|
||||
| 批次 | 企业数 | 切换时间 | 对账扩大 / 登录条数 | 抽查结果 | 执行人 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 第 1 批 | | | | | |
|
||||
| 第 2 批 | | | | | |
|
||||
| 第 3 批 | | | | | |
|
||||
|
||||
### 5.3 给企业客户的通知要点
|
||||
|
||||
- 切换后**只能从企业登录入口**登录,个人登录后切换企业的方式不再可用;已用个人账号登录的成员需要退出,改从企业入口重新登录。
|
||||
- 企业创建的员工账号不能再从个人登录入口登录。
|
||||
- 以个人账号加入企业的成员:用**原个人用户名和原密码**在企业登录入口登录。
|
||||
- 从企业入口登录后只能使用企业功能;个人令牌、个人日志、充值与会员、发票、邀请、操练场与体验中心、伙伴门户等请从个人登录入口登录。本身是企业成员的合作伙伴,伙伴门户须从个人入口登录。
|
||||
- 原「调整角色」「设置管理员权限」改为在「角色管理」页分配角色。
|
||||
- 切换时在线的用户:权限有变化的会提示重新登录,没变化的刷新页面即可。
|
||||
- 被重置过密码或首次登录的员工,要先修改初始密码才能使用企业功能。
|
||||
|
||||
---
|
||||
|
||||
## 六、回退
|
||||
|
||||
### 6.1 什么情况下回退
|
||||
|
||||
- 切换后出现大面积无法登录、无法使用核心功能,且无法在当天逐个处理;
|
||||
- 发现扩权问题(有人能看到或操作不该看到的数据)。
|
||||
|
||||
### 6.2 企业侧回退(运维执行)
|
||||
|
||||
1. **先**生成投影与负责人报告(`12,15` 换成要回退的企业 ID;在部署目录、用新版本程序、单实例执行):
|
||||
```bash
|
||||
SERVICE_MODE=authz-migrate AUTHZ_PROJECT=1 AUTHZ_MIGRATE_SCOPE=org AUTHZ_MIGRATE_ORG_IDS=12,15 \
|
||||
AUTHZ_MIGRATE_REPORT=rollback-12-15.md ./monkey-ai
|
||||
```
|
||||
2. 产品审阅报告中的两份名单并与企业确认。
|
||||
3. **再**到运行模式页从「已切换企业 ID」删掉这些企业,保存,立即生效。
|
||||
|
||||
注意:
|
||||
- 回退后在「角色管理」里新建的普通角色不再生效,只保留迁移角色对应的旧身份;这些角色和分配**不会被删除**,再次切换时重新生效。
|
||||
- 再次切换时,切换后在迁移角色上撤掉的权限会被恢复(对账列为扩大项)。
|
||||
- 切换后被分配了自定义范围「部门管理员(迁移)」、而主部门不在该范围内的成员,回退后会多出主部门的管理权,回退前人工核对。
|
||||
|
||||
### 6.3 平台侧回退(运维执行)
|
||||
|
||||
1. **先**生成投影:
|
||||
```bash
|
||||
SERVICE_MODE=authz-migrate AUTHZ_PROJECT=1 AUTHZ_MIGRATE_SCOPE=platform ./monkey-ai
|
||||
```
|
||||
2. **再**到运行模式页从平台侧「已切换模块」去掉要回退的模块,保存,立即生效。只回退部分模块时,自定义平台角色在其余已切换模块上仍然有效。
|
||||
|
||||
### 6.4 紧急兜底
|
||||
|
||||
新版本的路由兜底拦截出现误拦时,运维可临时设 `AUTHZ_GATE_MODE=log` 重启,退回只记录不拦截。
|
||||
|
||||
详细说明见代码仓库 `docs/01-部署运维/24-权限体系分批切换上线与回滚操作卡.md`。
|
||||
|
||||
---
|
||||
|
||||
## 七、问题记录
|
||||
|
||||
| 编号 | 对应验收项 | 现象 | 账号 | 截图 / 接口返回 | 严重程度 | 处理结论 |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| | | | | | | |
|
||||
|
||||
反馈问题时请附:页面截图、浏览器开发者工具(F12 → Network)中出错接口的请求地址和返回内容、操作账号。
|
||||
|
||||
---
|
||||
|
||||
## 八、验收签字
|
||||
|
||||
| 阶段 | 结论(通过 / 有条件通过 / 不通过) | 验收人 | 日期 |
|
||||
| --- | --- | --- | --- |
|
||||
| 一、升级后验收 | | | |
|
||||
| 二、迁移角色与影子对比 | | | |
|
||||
| 三、测试企业切换 | | | |
|
||||
| 四、平台侧切换 P1a | | | |
|
||||
| 四、平台侧切换 P1b | | | |
|
||||
| 四、平台侧切换 P1c | | | |
|
||||
| 五、客户企业切换完成 | | | |
|
||||
@@ -0,0 +1,66 @@
|
||||
const globals = require('globals');
|
||||
const react = require('eslint-plugin-react');
|
||||
const reactHooks = require('eslint-plugin-react-hooks');
|
||||
const unusedImports = require('eslint-plugin-unused-imports');
|
||||
const { uiDependencyConfig } = require('./scripts/ui-dependency-policy.cjs');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
ignores: [
|
||||
'**/.*',
|
||||
'dist/**',
|
||||
'node_modules/**',
|
||||
'logs/**',
|
||||
'report/**',
|
||||
'playwright-report/**',
|
||||
'test-results/**',
|
||||
'blob-report/**',
|
||||
'src/assets/brand-icons/*.js',
|
||||
],
|
||||
},
|
||||
uiDependencyConfig,
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
linterOptions: { reportUnusedDisableDirectives: 'off' },
|
||||
languageOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
parserOptions: { ecmaFeatures: { jsx: true } },
|
||||
globals: { ...globals.browser, ...globals.node, ...globals.es2021 },
|
||||
},
|
||||
settings: { react: { version: 'detect' } },
|
||||
plugins: {
|
||||
react,
|
||||
'react-hooks': reactHooks,
|
||||
'unused-imports': unusedImports,
|
||||
},
|
||||
rules: {
|
||||
'no-multiple-empty-lines': ['error', { max: 1 }],
|
||||
|
||||
// ===== 防线:杜绝“用了未定义/未导入标识符”导致的运行时崩溃(本次线上事故根因)=====
|
||||
// 让规则识别 JSX 中使用到的组件/React,避免误报。
|
||||
'react/jsx-uses-vars': 'error',
|
||||
'react/jsx-uses-react': 'error',
|
||||
// 未定义标识符 = 直接报错(构建/CI 即拦截)。
|
||||
'no-undef': 'error',
|
||||
// 未使用的 import = error 且可 --fix 自动移除(含 JSX/副作用识别);
|
||||
// 未使用的变量 = warn(不阻断,下划线前缀豁免)。
|
||||
'no-unused-vars': 'off',
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
'unused-imports/no-unused-vars': [
|
||||
'warn',
|
||||
{
|
||||
vars: 'all',
|
||||
varsIgnorePattern: '^_',
|
||||
args: 'none',
|
||||
caughtErrors: 'none',
|
||||
argsIgnorePattern: '^_',
|
||||
ignoreRestSiblings: true,
|
||||
},
|
||||
],
|
||||
// React Hooks 规则。
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { defineConfig } from 'i18next-cli';
|
||||
|
||||
/** @type {import('i18next-cli').I18nextToolkitConfig} */
|
||||
|
||||
Generated
+467
-386
File diff suppressed because it is too large
Load Diff
+6
-7
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "react-template",
|
||||
"name": "monkey-ai-web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
@@ -89,19 +89,18 @@
|
||||
"@playwright/test": "1.64.1",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"esbuild": "0.21.5",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-plugin-header": "^3.1.1",
|
||||
"esbuild": "0.25.12",
|
||||
"eslint": "9.39.5",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-unused-imports": "^3.2.0",
|
||||
"eslint-plugin-unused-imports": "4.4.1",
|
||||
"globals": "16.5.0",
|
||||
"i18next-cli": "^1.10.3",
|
||||
"postcss": "^8.5.3",
|
||||
"prettier": "^3.0.0",
|
||||
"tailwindcss": "^3",
|
||||
"vite": "5.4.21"
|
||||
"vite": "6.4.6"
|
||||
},
|
||||
"proxy": "http://localhost:3000",
|
||||
"engines": {
|
||||
"node": ">=22.13.0",
|
||||
"npm": ">=10"
|
||||
|
||||
+2
-22
@@ -1,26 +1,8 @@
|
||||
/*
|
||||
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 { defineConfig } from '@playwright/test';
|
||||
import {
|
||||
browserChannel,
|
||||
contextOptions,
|
||||
defaultProjectViewports,
|
||||
projectViewports,
|
||||
} from './scripts/browser-environment.mjs';
|
||||
import { runtimeOptions } from './scripts/playwright-runtime.mjs';
|
||||
@@ -48,9 +30,7 @@ if (
|
||||
)
|
||||
)
|
||||
throw new Error('CI requires headless non-interactive tests');
|
||||
const viewports = runtime.extended
|
||||
? projectViewports
|
||||
: projectViewports.slice(0, 2);
|
||||
const viewports = runtime.extended ? projectViewports : defaultProjectViewports;
|
||||
|
||||
// UI_VISUAL_OFFSCREEN=0 仅限人工本地可视化调试时临时使用。
|
||||
// Agent、CI、无头/自动化环境禁止设置该值,必须保持默认离屏模式
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 有头 Chrome 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
||||
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { readFileSync } from 'node:fs';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { devices } from '@playwright/test';
|
||||
@@ -32,9 +13,9 @@ const aliases = {
|
||||
'laptop-wxga': 'wxga',
|
||||
};
|
||||
export const browserChannel = config.browser.channel;
|
||||
export const defaultProjectViewports = ['desktop', 'mobile', 'mobile-393'];
|
||||
export const projectViewports = [
|
||||
'desktop',
|
||||
'mobile',
|
||||
...defaultProjectViewports,
|
||||
'tablet',
|
||||
'desktop-boundary',
|
||||
'laptop-hd',
|
||||
@@ -49,7 +30,9 @@ export function deviceOptions(name) {
|
||||
if (!size) throw new Error(`Unknown viewport: ${name}`);
|
||||
const descriptor =
|
||||
devices[
|
||||
config.browser[key === 'mobile' ? 'mobileDevice' : 'desktopDevice']
|
||||
config.browser[
|
||||
key.startsWith('mobile') ? 'mobileDevice' : 'desktopDevice'
|
||||
]
|
||||
];
|
||||
if (!descriptor) throw new Error(`Unknown device profile for ${name}`);
|
||||
const { defaultBrowserType, ...context } = descriptor;
|
||||
|
||||
@@ -3,20 +3,28 @@ import { createHash } from 'node:crypto';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { Linter } from 'eslint';
|
||||
import policy from './ui-dependency-policy.cjs';
|
||||
|
||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||
const forbidden = [
|
||||
/^@radix-ui\//,
|
||||
/^@floating-ui\//,
|
||||
/^@lobehub\/(?:ui|icons)(?:\/|$)/,
|
||||
/^@douyinfe\/semi-(?:ui|icons|foundation)(?:\/|$)/,
|
||||
/^@headlessui\//,
|
||||
/^@mui\//,
|
||||
/^@chakra-ui\//,
|
||||
/^(?:leva|antd-style|react-layout-kit)(?:\/|$)/,
|
||||
];
|
||||
export const isForbiddenUiDependency = (name) =>
|
||||
forbidden.some((pattern) => pattern.test(name));
|
||||
const { isForbiddenUiDependency, uiDependencyConfig } = policy;
|
||||
const linter = new Linter({ cwd: root });
|
||||
const sourceConfig = [uiDependencyConfig];
|
||||
const sourceDirectories = new Set(['src', 'scripts', 'test', 'tests']);
|
||||
const excludedDirectories = new Set([
|
||||
'node_modules',
|
||||
'dist',
|
||||
'dist-ssr',
|
||||
'build',
|
||||
'coverage',
|
||||
'report',
|
||||
'logs',
|
||||
'test-results',
|
||||
'playwright-report',
|
||||
'blob-report',
|
||||
'kt_batches',
|
||||
'kt_out',
|
||||
]);
|
||||
export { isForbiddenUiDependency };
|
||||
|
||||
export function auditManifest(manifest, lock) {
|
||||
const issues = [];
|
||||
@@ -26,14 +34,22 @@ export function auditManifest(manifest, lock) {
|
||||
'optionalDependencies',
|
||||
'peerDependencies',
|
||||
]) {
|
||||
for (const name of Object.keys(manifest[section] || {})) {
|
||||
if (isForbiddenUiDependency(name))
|
||||
for (const [name, specifier] of Object.entries(manifest[section] || {})) {
|
||||
const alias = /^npm:((?:@[^/]+\/)?[^@/]+)(?:@|$)/.exec(specifier)?.[1];
|
||||
if (isForbiddenUiDependency(name)) {
|
||||
issues.push(`package.json ${section}: ${name}`);
|
||||
} else if (isForbiddenUiDependency(alias)) {
|
||||
issues.push(`package.json ${section}: ${name} -> ${alias}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const location of Object.keys(lock.packages || {})) {
|
||||
if (isForbiddenUiDependency(location.split('node_modules/').at(-1))) {
|
||||
for (const [location, entry] of Object.entries(lock.packages || {})) {
|
||||
const names = location.split(/(?:^|\/)node_modules\//);
|
||||
if (names.length === 1) continue;
|
||||
if (isForbiddenUiDependency(names.at(-1))) {
|
||||
issues.push(`package-lock.json: ${location}`);
|
||||
} else if (isForbiddenUiDependency(entry.name)) {
|
||||
issues.push(`package-lock.json: ${location} -> ${entry.name}`);
|
||||
}
|
||||
}
|
||||
if (!lock.packages || lock.lockfileVersion < 2)
|
||||
@@ -42,58 +58,26 @@ export function auditManifest(manifest, lock) {
|
||||
}
|
||||
|
||||
export function auditSource(source, filename) {
|
||||
const linter = new Linter();
|
||||
linter.defineRule('ui-dependencies', {
|
||||
create(context) {
|
||||
const inspect = (node) => {
|
||||
if (
|
||||
node?.type === 'Literal' &&
|
||||
typeof node.value === 'string' &&
|
||||
isForbiddenUiDependency(node.value)
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
message: `Use Ant Design or the audited local brand assets: ${node.value}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
return {
|
||||
ImportDeclaration: (node) => inspect(node.source),
|
||||
ExportNamedDeclaration: (node) => inspect(node.source),
|
||||
ExportAllDeclaration: (node) => inspect(node.source),
|
||||
ImportExpression: (node) => inspect(node.source),
|
||||
CallExpression: (node) => {
|
||||
if (
|
||||
node.callee.type === 'Identifier' &&
|
||||
node.callee.name === 'require'
|
||||
)
|
||||
inspect(node.arguments[0]);
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
return linter
|
||||
.verify(
|
||||
source,
|
||||
{
|
||||
parserOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: { jsx: true },
|
||||
},
|
||||
rules: { 'ui-dependencies': 'error' },
|
||||
},
|
||||
{ filename, allowInlineConfig: false },
|
||||
)
|
||||
.verify(source, sourceConfig, { filename, allowInlineConfig: false })
|
||||
.map((issue) => `${filename}:${issue.line}: ${issue.message}`);
|
||||
}
|
||||
|
||||
async function sourceFiles(dir) {
|
||||
async function sourceFiles(dir, isRoot = true) {
|
||||
const files = [];
|
||||
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
||||
const name = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) files.push(...(await sourceFiles(name)));
|
||||
else if (/\.[cm]?[jt]sx?$/.test(entry.name)) files.push(name);
|
||||
if (entry.isDirectory()) {
|
||||
if (
|
||||
isRoot
|
||||
? sourceDirectories.has(entry.name)
|
||||
: !entry.name.startsWith('.') && !excludedDirectories.has(entry.name)
|
||||
) {
|
||||
files.push(...(await sourceFiles(name, false)));
|
||||
}
|
||||
} else if (entry.isFile() && /\.(?:js|jsx|cjs|mjs)$/.test(entry.name)) {
|
||||
files.push(name);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
@@ -106,7 +90,7 @@ export async function checkUiDependencies(directory = root) {
|
||||
await readFile(path.join(directory, 'package-lock.json'), 'utf8'),
|
||||
);
|
||||
const issues = auditManifest(manifest, lock);
|
||||
const files = await sourceFiles(path.join(directory, 'src'));
|
||||
const files = await sourceFiles(directory);
|
||||
for (const filename of files) {
|
||||
issues.push(
|
||||
...auditSource(
|
||||
@@ -143,7 +127,7 @@ export async function checkUiDependencies(directory = root) {
|
||||
return {
|
||||
issues,
|
||||
files: files.length,
|
||||
packages: Object.keys(lock.packages).length - 1,
|
||||
packages: Math.max(0, Object.keys(lock.packages || {}).length - 1),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { readFile, readdir } from 'node:fs/promises';
|
||||
import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// 找出会溢出的具体位置。控制台是围绕中文两字标签设计的,泰语平均膨胀 3.16x,
|
||||
// 短标签最高 9x,密集表格首当其冲。
|
||||
//
|
||||
// 判据:Semi 的 Table column `width: N`(px)在 14px 字号下大致可容
|
||||
// 判据:表格列的 `width: N`(px)在 14px 字号下大致可容
|
||||
// 中文 ≈ N/14 字,拉丁/泰文 ≈ N/7.5 字符(泰文含上下叠加符号,按拉丁估更保守)。
|
||||
// 超出即报,按超出比例排序。这是静态估算,不替代真机目视走查。
|
||||
const fs = require('fs');
|
||||
@@ -20,7 +20,7 @@ const DICTS = LANGS.map((l) => [l, load(l)]);
|
||||
const PX_PER_CHAR = 7.5; // 拼音文字/韩/泰在 14px 下的保守平均字宽
|
||||
// 日文假名与汉字、繁体中文都是全角,按字号整宽计
|
||||
const PX_PER_CHAR_BY_LANG = { ja: 14, 'zh-TW': 14 };
|
||||
const PADDING = 24; // Semi 表头左右内边距 + 排序图标余量
|
||||
const PADDING = 24; // 表头左右内边距及排序图标的估算余量
|
||||
|
||||
function walk(dir, files = []) {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 有头 Chrome 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
||||
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
const FOCUS_ANNOTATION = 'focus-guard';
|
||||
|
||||
export default class AcceptanceReporter {
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 浏览器焦点守护:有头真实 Chrome 运行时尽最大可能不抢占用户桌面焦点。
|
||||
// - 唯一页面:每个用例只有一个页面,由 CDP Target.createTarget({ background: true }) 后台创建,
|
||||
// 不走 context.newPage()(Playwright 内部创建时不带 background,会以前台方式打开窗口)。
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { randomUUID } from 'node:crypto';
|
||||
|
||||
export const browserStabilityArgs = Object.freeze([
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { test as base, expect } from '@playwright/test';
|
||||
import {
|
||||
checkFocus,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { preview } from 'vite';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { positiveInteger } from './playwright-runtime.mjs';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { mkdtemp, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { spawn } from 'node:child_process';
|
||||
import { readdir, stat, access } from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { mkdtemp, writeFile, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { readdir } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
const forbiddenPackages = [
|
||||
/^@(?:radix-ui|floating-ui|lobehub|headlessui|mui|material-ui|chakra-ui)\//,
|
||||
/^@douyinfe\/semi-/,
|
||||
/^(?:leva|antd-style|react-layout-kit)(?:[/?#]|$)/,
|
||||
];
|
||||
|
||||
function isForbiddenUiDependency(specifier) {
|
||||
return (
|
||||
typeof specifier === 'string' &&
|
||||
forbiddenPackages.some((pattern) => pattern.test(specifier))
|
||||
);
|
||||
}
|
||||
|
||||
const rule = {
|
||||
meta: {
|
||||
schema: [],
|
||||
messages: {
|
||||
forbidden:
|
||||
'Use Ant Design or the audited local brand assets instead of {{specifier}}.',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const inspect = (node) => {
|
||||
const specifier =
|
||||
node?.type === 'Literal'
|
||||
? node.value
|
||||
: node?.type === 'TemplateLiteral' && node.expressions.length === 0
|
||||
? node.quasis[0].value.cooked
|
||||
: null;
|
||||
|
||||
if (isForbiddenUiDependency(specifier)) {
|
||||
context.report({ node, messageId: 'forbidden', data: { specifier } });
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
ImportDeclaration: (node) => inspect(node.source),
|
||||
ExportNamedDeclaration: (node) => inspect(node.source),
|
||||
ExportAllDeclaration: (node) => inspect(node.source),
|
||||
ImportExpression: (node) => inspect(node.source),
|
||||
CallExpression: (node) => {
|
||||
const { callee } = node;
|
||||
const isRequire =
|
||||
callee.type === 'Identifier' && callee.name === 'require';
|
||||
const isRequireResolve =
|
||||
callee.type === 'MemberExpression' &&
|
||||
!callee.computed &&
|
||||
callee.object.type === 'Identifier' &&
|
||||
callee.object.name === 'require' &&
|
||||
callee.property.name === 'resolve';
|
||||
if (isRequire || isRequireResolve) inspect(node.arguments[0]);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const uiDependencyConfig = {
|
||||
files: ['**/*.{js,jsx,cjs,mjs}'],
|
||||
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
|
||||
plugins: { 'ui-dependencies': { rules: { 'no-legacy-ui': rule } } },
|
||||
rules: { 'ui-dependencies/no-legacy-ui': 'error' },
|
||||
};
|
||||
|
||||
module.exports = { isForbiddenUiDependency, uiDependencyConfig };
|
||||
@@ -9,6 +9,7 @@
|
||||
"viewports": {
|
||||
"desktop": [1920, 1080],
|
||||
"mobile": [360, 800],
|
||||
"mobile-393": [393, 851],
|
||||
"tablet": [768, 1024],
|
||||
"laptop": [1024, 768],
|
||||
"hd": [1366, 768],
|
||||
|
||||
+81
-26
@@ -1,27 +1,77 @@
|
||||
/*
|
||||
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 { readFile, access } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { gzipSync } from 'node:zlib';
|
||||
|
||||
export async function verifyBuild(directory) {
|
||||
const BOOTSTRAP_GZIP_LIMIT = 820 * 1024;
|
||||
const NOTICE = 'src/components/layout/NoticeModal.jsx';
|
||||
const AGREEMENT = 'src/components/common/DocumentRenderer/AgreementModal.jsx';
|
||||
const HEADER = 'src/components/layout/headerbar/index.jsx';
|
||||
const HOME = 'src/pages/Home/index.jsx';
|
||||
const MARKED = 'node_modules/marked/lib/marked.esm.js';
|
||||
|
||||
function resolveAsset(root, asset) {
|
||||
const filename = path.resolve(root, asset.replace(/^\//, ''));
|
||||
if (!filename.startsWith(root + path.sep))
|
||||
throw new Error(`Build asset escapes output directory: ${asset}`);
|
||||
return filename;
|
||||
}
|
||||
|
||||
function staticChunks(manifest, roots) {
|
||||
const seen = new Set();
|
||||
const visit = (key) => {
|
||||
if (seen.has(key)) return;
|
||||
const chunk = manifest[key];
|
||||
if (!chunk) throw new Error(`Missing build manifest chunk: ${key}`);
|
||||
seen.add(key);
|
||||
for (const dependency of chunk.imports || []) visit(dependency);
|
||||
};
|
||||
roots.forEach(visit);
|
||||
return seen;
|
||||
}
|
||||
|
||||
async function verifyStartup(root) {
|
||||
const manifest = JSON.parse(
|
||||
await readFile(path.join(root, '.vite', 'manifest.json'), 'utf8'),
|
||||
);
|
||||
const entry = 'index.html';
|
||||
for (const [routes, deferred] of [
|
||||
[
|
||||
[entry, HOME, HEADER],
|
||||
[NOTICE, MARKED],
|
||||
],
|
||||
[
|
||||
[entry, 'src/components/auth/LoginForm.jsx', HEADER],
|
||||
[AGREEMENT, NOTICE],
|
||||
],
|
||||
[
|
||||
[entry, 'src/components/auth/RegisterForm.jsx', HEADER],
|
||||
[AGREEMENT, NOTICE],
|
||||
],
|
||||
]) {
|
||||
const eager = staticChunks(manifest, routes);
|
||||
for (const feature of deferred) {
|
||||
if (!manifest[feature]?.isDynamicEntry || eager.has(feature))
|
||||
throw new Error(`Expected an independent lazy chunk: ${feature}`);
|
||||
}
|
||||
}
|
||||
|
||||
const files = new Set(
|
||||
[...staticChunks(manifest, [entry])].map((key) => manifest[key].file),
|
||||
);
|
||||
let bootstrapGzipBytes = 0;
|
||||
for (const file of files) {
|
||||
const source = await readFile(resolveAsset(root, file));
|
||||
bootstrapGzipBytes += gzipSync(source).length;
|
||||
}
|
||||
if (bootstrapGzipBytes > BOOTSTRAP_GZIP_LIMIT)
|
||||
throw new Error(
|
||||
`Bootstrap JS exceeds 820 KiB gzip: ${bootstrapGzipBytes} B`,
|
||||
);
|
||||
return { bootstrapGzipBytes, bootstrapChunks: files.size };
|
||||
}
|
||||
|
||||
export async function verifyBuild(directory, { startup = false } = {}) {
|
||||
const root = path.resolve(directory);
|
||||
const html = await readFile(path.join(root, 'index.html'), 'utf8');
|
||||
// Inspect actual resource tags, not URLs embedded in comments or inline scripts.
|
||||
@@ -40,17 +90,22 @@ export async function verifyBuild(directory) {
|
||||
if (!assets.some((value) => /\.js$/.test(value)))
|
||||
throw new Error('Build has no JavaScript entry');
|
||||
for (const asset of assets) {
|
||||
const filename = path.resolve(root, asset.replace(/^\//, ''));
|
||||
if (!filename.startsWith(root + path.sep))
|
||||
throw new Error(`Build asset escapes output directory: ${asset}`);
|
||||
await access(filename);
|
||||
await access(resolveAsset(root, asset));
|
||||
}
|
||||
return { root, assets: assets.length };
|
||||
return {
|
||||
root,
|
||||
assets: assets.length,
|
||||
...(startup ? await verifyStartup(root) : {}),
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
process.argv[1] &&
|
||||
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
||||
) {
|
||||
console.log(await verifyBuild(process.argv[2] || 'dist'));
|
||||
const args = process.argv.slice(2);
|
||||
const directory = args.find((argument) => argument !== '--startup') || 'dist';
|
||||
console.log(
|
||||
await verifyBuild(directory, { startup: args.includes('--startup') }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
/*
|
||||
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 postcss from 'postcss';
|
||||
|
||||
// 旧浏览器的级联层(@layer)兜底。
|
||||
//
|
||||
// index.css 把 Tailwind 的 base / components / utilities 整体包在原生 @layer 里,
|
||||
// Semi 的按需样式也由 vitePluginSemi({ cssLayer: true }) 包进 @layer semi。
|
||||
// @layer 自 Chromium 99 / Firefox 97 / Safari 15.4 才支持;更老的内核(停更的
|
||||
// Edge、Win10 LTSC 自带 Edge、各类国产壳浏览器)把它当未知 at-rule 连同块内
|
||||
// 全部规则一起丢弃 —— Tailwind 整体失效,页面只剩无尺寸约束的原图 logo。
|
||||
@@ -91,8 +71,7 @@ export function flattenCssLayers(sources) {
|
||||
roots.forEach(assertSupportedShape);
|
||||
|
||||
// 层外已有逐字相同的规则时,层内那份不必收:选择器与声明都一样、层外的又加载
|
||||
// 在后,它在旧浏览器里必然被覆盖。Semi 的 @layer 副本整份属于这种情况
|
||||
// (index.jsx 另行全量引入了层外的 semi.css),剔掉后兜底表只剩约五分之一。
|
||||
// 在后,它在旧浏览器里必然被覆盖。
|
||||
const unlayered = new Set();
|
||||
for (const root of roots) {
|
||||
root.each((node) => {
|
||||
|
||||
+176
-124
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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, { lazy, Suspense, useContext, useMemo } from 'react';
|
||||
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
||||
import {
|
||||
@@ -24,7 +5,9 @@ import {
|
||||
isMiniProgramWebView,
|
||||
} from './helpers/miniProgram';
|
||||
import Loading from './components/common/ui/Loading';
|
||||
import { AuthRedirect, PrivateRoute, AdminRoute, RootRoute } from './helpers';
|
||||
import { CenterRouteLoading } from './components/layout/components/CenterSidebarLoading';
|
||||
import { AuthRedirect, PrivateRoute, RootRoute } from './helpers/auth';
|
||||
import { PermRoute, ConsoleRoute, ConsoleIndexRoute } from './authz';
|
||||
import NotFound from './pages/NotFound';
|
||||
import Forbidden from './pages/Forbidden';
|
||||
import { StatusContext } from './context/Status';
|
||||
@@ -88,14 +71,19 @@ const Task = lazy(() => import('./pages/Task'));
|
||||
const ModelPage = lazy(() => import('./pages/Model'));
|
||||
const Playground = lazy(() => import('./pages/Playground'));
|
||||
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
||||
const PersonalSetting = lazy(
|
||||
() => import('./components/settings/PersonalSetting'),
|
||||
);
|
||||
const Setup = lazy(() => import('./pages/Setup'));
|
||||
const Analytics = lazy(() => import('./pages/Analytics'));
|
||||
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
|
||||
const Organization = lazy(() => import('./pages/Organization'));
|
||||
const AdminOrganizations = lazy(() => import('./pages/AdminOrganizations'));
|
||||
// 平台侧权限管理(菜单管理 / 平台角色 / 功能套餐 / 角色模板 / 运行模式)
|
||||
const AuthzMenuManage = lazy(() => import('./pages/Permission/MenuManage'));
|
||||
const AuthzPlatformRoles = lazy(
|
||||
() => import('./pages/Permission/PlatformRoles'),
|
||||
);
|
||||
const AuthzPackages = lazy(() => import('./pages/Permission/Packages'));
|
||||
const AuthzTemplates = lazy(() => import('./pages/Permission/Templates'));
|
||||
const AuthzRunMode = lazy(() => import('./pages/Permission/RunMode'));
|
||||
const AdminOrder = lazy(() => import('./pages/AdminOrder'));
|
||||
const AdminInvoice = lazy(() => import('./pages/AdminInvoice'));
|
||||
const Subscription = lazy(() => import('./pages/Subscription'));
|
||||
@@ -130,9 +118,11 @@ const ORG_USER_NAV_PATHS = {
|
||||
keyManagement: ['/key-management', '/user-center/key-management'],
|
||||
userCenter: ['/user-center'],
|
||||
};
|
||||
const matchesPathPrefix = (pathname, prefix) =>
|
||||
pathname === prefix || pathname.startsWith(`${prefix}/`);
|
||||
const isOrgAllowedPath = (pathname, extraPrefixes = []) =>
|
||||
[...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some(
|
||||
(p) => pathname === p || pathname.startsWith(p + '/'),
|
||||
[...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some((prefix) =>
|
||||
matchesPathPrefix(pathname, prefix),
|
||||
);
|
||||
|
||||
// 模型超市旧路径 /pricing → /market。用组件而非静态 <Navigate>,
|
||||
@@ -147,20 +137,10 @@ const PricingLegacyRedirect = () => {
|
||||
);
|
||||
};
|
||||
|
||||
// 密钥管理旧路径 /key-management → /user-center/key-management,同样保留 query/hash
|
||||
// (如创作台 ?from=creation_studio 埋点来源、旧书签与登录回跳带参)
|
||||
const KeyManagementLegacyRedirect = () => {
|
||||
const location = useLocation();
|
||||
return (
|
||||
<Navigate
|
||||
to={{
|
||||
pathname: '/user-center/key-management',
|
||||
search: location.search,
|
||||
hash: location.hash,
|
||||
}}
|
||||
replace
|
||||
/>
|
||||
);
|
||||
// 用户中心旧地址保留登录回跳、分享链接及书签中的参数。
|
||||
const UserCenterLegacyRedirect = ({ to }) => {
|
||||
const { search, hash } = useLocation();
|
||||
return <Navigate to={{ pathname: to, search, hash }} replace />;
|
||||
};
|
||||
|
||||
function App() {
|
||||
@@ -220,27 +200,38 @@ function App() {
|
||||
// /org,从此无任何路径把平台技能加入企业技能库——技能库与分发页永远为空。
|
||||
// 顶栏开关的本意是收敛"员工浏览目录",不应连带阉割企业治理能力,故对
|
||||
// 管理员无条件放行该路由(页面内部仍按 skill_manage 决定是否出现启用按钮)。
|
||||
if (isOrgAdmin && !prefixes.includes('/skill-market')) {
|
||||
if (
|
||||
orgMembershipLoaded &&
|
||||
isOrgAdmin &&
|
||||
!prefixes.includes('/skill-market')
|
||||
) {
|
||||
prefixes.push('/skill-market');
|
||||
}
|
||||
return prefixes;
|
||||
}, [statusState?.status?.HeaderNavModulesOrgUser, isOrgAdmin]);
|
||||
}, [
|
||||
statusState?.status?.HeaderNavModulesOrgUser,
|
||||
orgMembershipLoaded,
|
||||
isOrgAdmin,
|
||||
]);
|
||||
|
||||
// 路由级封锁:org_only 员工访问非企业路由一律回到企业空间。
|
||||
// 仅在企业中心可用时启用,避免企业中心被全局关闭时与其内部回退跳转形成重定向死循环。
|
||||
// 企业列表未到位前不做封锁判定:isOrgAdmin 首帧恒 false,此时若直接重定向,
|
||||
// 硬刷新/收藏夹直达 /skill-market 的 org_only 管理员会在放行判据还没算出来时
|
||||
// 就被弹回 /org,而重定向不可逆——之后 isOrgAdmin 变 true 也回不去。
|
||||
// 只有技能超市的企业管理员特例需要等待企业列表;等待时也不挂载受限页面。
|
||||
const routePath = location.pathname.toLowerCase();
|
||||
const orgConfined =
|
||||
userState?.user?.org_only_mode === true &&
|
||||
orgMembershipLoaded &&
|
||||
isOrgCenterAvailable &&
|
||||
!isOrgAllowedPath(location.pathname, orgUserAllowedPrefixes);
|
||||
!isOrgAllowedPath(routePath, orgUserAllowedPrefixes);
|
||||
|
||||
if (orgConfined) {
|
||||
return (
|
||||
<SetupCheck>
|
||||
<Navigate to='/org' replace />
|
||||
{!orgMembershipLoaded &&
|
||||
matchesPathPrefix(routePath, '/skill-market') ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<Navigate to='/org' replace />
|
||||
)}
|
||||
</SetupCheck>
|
||||
);
|
||||
}
|
||||
@@ -281,51 +272,51 @@ function App() {
|
||||
<Route
|
||||
path='/console/models'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.model'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<ModelPage />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/channel'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.channel'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Channel />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/token'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.admin_token'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Token />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/playground'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.playground'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Playground />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/monitor'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.monitor'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<MonitorCenter />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
@@ -341,11 +332,11 @@ function App() {
|
||||
<Route
|
||||
path='/console/analytics'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.analytics'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Analytics />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
@@ -372,40 +363,91 @@ function App() {
|
||||
/* 分佣管理为 Root 专属:侧边栏一直用 isRoot() 隐藏该入口,后端结算/销售/成本/
|
||||
伙伴管理各路由组也已全部 Root 收口。这里把路由守卫对齐,避免 role=10 直接
|
||||
输 URL 进到一个读得到、写按钮全 403 的半残页面。 */
|
||||
<RootRoute>
|
||||
<ConsoleRoute code='platform.commission' legacy='root'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<CommissionV2 />
|
||||
</Suspense>
|
||||
</RootRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/experience-center-audit'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.analytics'>
|
||||
<Navigate to='/console/analytics?tab=audit' replace />
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/organizations'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.org'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AdminOrganizations />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
{/* 平台侧权限管理:路由按与侧边栏相同的权限点守卫(PermRoute),接口权限由后端校验;运行模式仅 root */}
|
||||
<Route
|
||||
path='/console/authz/menus'
|
||||
element={
|
||||
<PermRoute code='platform.authz.menu.query'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AuthzMenuManage />
|
||||
</Suspense>
|
||||
</PermRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/authz/roles'
|
||||
element={
|
||||
<PermRoute code='platform.authz.role.query'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AuthzPlatformRoles />
|
||||
</Suspense>
|
||||
</PermRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/authz/packages'
|
||||
element={
|
||||
<PermRoute code='platform.authz.package.query'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AuthzPackages />
|
||||
</Suspense>
|
||||
</PermRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/authz/templates'
|
||||
element={
|
||||
<PermRoute code='platform.authz.template.query'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AuthzTemplates />
|
||||
</Suspense>
|
||||
</PermRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/authz/mode'
|
||||
element={
|
||||
<RootRoute>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AuthzRunMode />
|
||||
</Suspense>
|
||||
</RootRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/skill-platform'
|
||||
element={
|
||||
CLOUD_BRAIN_UI_ENABLED ? (
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.skill'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<SkillPlatform />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
) : (
|
||||
<Navigate to='/console' replace />
|
||||
)
|
||||
@@ -415,11 +457,11 @@ function App() {
|
||||
path='/console/expert-platform'
|
||||
element={
|
||||
CLOUD_BRAIN_UI_ENABLED ? (
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.expert'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<ExpertPlatform />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
) : (
|
||||
<Navigate to='/console' replace />
|
||||
)
|
||||
@@ -428,21 +470,21 @@ function App() {
|
||||
<Route
|
||||
path='/console/order'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.order'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AdminOrder />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/invoice'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.invoice'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<AdminInvoice />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
{/* 旧路由重定向到用户中心内的服务监控 */}
|
||||
@@ -455,7 +497,9 @@ function App() {
|
||||
element={
|
||||
CLOUD_BRAIN_UI_ENABLED ? (
|
||||
<PrivateRoute>
|
||||
<Suspense fallback={<Loading />} key={location.pathname}>
|
||||
<Suspense
|
||||
fallback={<CenterRouteLoading variant='experience' />}
|
||||
>
|
||||
<ExperienceCenter />
|
||||
</Suspense>
|
||||
</PrivateRoute>
|
||||
@@ -470,14 +514,13 @@ function App() {
|
||||
moduleAuthConfig.experienceCenter ? (
|
||||
<PrivateRoute>
|
||||
<Suspense
|
||||
fallback={<Loading></Loading>}
|
||||
key={location.pathname}
|
||||
fallback={<CenterRouteLoading variant='experience' />}
|
||||
>
|
||||
<ExperienceCenter />
|
||||
</Suspense>
|
||||
</PrivateRoute>
|
||||
) : (
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Suspense fallback={<CenterRouteLoading variant='experience' />}>
|
||||
<ExperienceCenter />
|
||||
</Suspense>
|
||||
)
|
||||
@@ -486,31 +529,31 @@ function App() {
|
||||
<Route
|
||||
path='/console/redemption'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.redemption'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Redemption />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/user'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.user'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<User />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/subscription'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.subscription'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Subscription />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
@@ -632,89 +675,78 @@ function App() {
|
||||
<Route
|
||||
path='/console/setting'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.setting'>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Setting />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/website-setting'
|
||||
element={
|
||||
<AdminRoute permission='website-setting'>
|
||||
<ConsoleRoute
|
||||
code='platform.setting.website_setting'
|
||||
permission='website-setting'
|
||||
>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<WebsiteSettings />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/demo-reservations'
|
||||
element={
|
||||
<AdminRoute permission='demo-reservations'>
|
||||
<ConsoleRoute
|
||||
code='platform.setting.demo_reservations'
|
||||
permission='demo-reservations'
|
||||
>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<DemoReservations />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/personal'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<PersonalSetting />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/topup'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.topup'>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<TopUp />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/log'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.log'>
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Log />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<Navigate to='/console/analytics' replace />
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route path='/console' element={<ConsoleIndexRoute />} />
|
||||
<Route
|
||||
path='/console/midjourney'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.drawing_log'>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Midjourney />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/console/task'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.task_log'>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Task />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
@@ -760,10 +792,27 @@ function App() {
|
||||
)
|
||||
}
|
||||
/>
|
||||
{/* 密钥管理归入用户中心路径;旧地址保留为重定向(旧链接、登录回跳、书签) */}
|
||||
<Route
|
||||
path='/console/personal'
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<UserCenterLegacyRedirect to='/user-center/settings' />
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/user/center'
|
||||
element={
|
||||
<PrivateRoute>
|
||||
<UserCenterLegacyRedirect to='/user-center' />
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/key-management'
|
||||
element={<KeyManagementLegacyRedirect />}
|
||||
element={
|
||||
<UserCenterLegacyRedirect to='/user-center/key-management' />
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path='/user-center/key-management'
|
||||
@@ -771,14 +820,17 @@ function App() {
|
||||
moduleAuthConfig.keyManagement ? (
|
||||
<PrivateRoute>
|
||||
<Suspense
|
||||
fallback={<Loading></Loading>}
|
||||
fallback={<CenterRouteLoading />}
|
||||
key={location.pathname}
|
||||
>
|
||||
<UserCenter keyManagementMode />
|
||||
</Suspense>
|
||||
</PrivateRoute>
|
||||
) : (
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Suspense
|
||||
fallback={<CenterRouteLoading />}
|
||||
key={location.pathname}
|
||||
>
|
||||
<UserCenter keyManagementMode />
|
||||
</Suspense>
|
||||
)
|
||||
@@ -789,12 +841,12 @@ function App() {
|
||||
element={
|
||||
moduleAuthConfig.userCenter ? (
|
||||
<PrivateRoute>
|
||||
<Suspense fallback={<Loading></Loading>}>
|
||||
<Suspense fallback={<CenterRouteLoading />}>
|
||||
<UserCenter />
|
||||
</Suspense>
|
||||
</PrivateRoute>
|
||||
) : (
|
||||
<Suspense fallback={<Loading></Loading>}>
|
||||
<Suspense fallback={<CenterRouteLoading />}>
|
||||
<UserCenter />
|
||||
</Suspense>
|
||||
)
|
||||
@@ -866,11 +918,11 @@ function App() {
|
||||
<Route
|
||||
path='/console/chat/:id?'
|
||||
element={
|
||||
<AdminRoute>
|
||||
<ConsoleRoute code='platform.chat'>
|
||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||
<Chat />
|
||||
</Suspense>
|
||||
</AdminRoute>
|
||||
</ConsoleRoute>
|
||||
}
|
||||
/>
|
||||
{/* 方便使用chat2link直接跳转聊天... */}
|
||||
@@ -898,7 +950,7 @@ function App() {
|
||||
element={
|
||||
<PrivateRoute>
|
||||
{isOrgCenterAvailable ? (
|
||||
<Suspense fallback={<Loading />}>
|
||||
<Suspense fallback={<CenterRouteLoading variant='org' />}>
|
||||
<Organization />
|
||||
</Suspense>
|
||||
) : (
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
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, {
|
||||
createContext,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { Modal } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../helpers/api';
|
||||
import {
|
||||
clearUserData,
|
||||
isOrgLoginSession,
|
||||
ORG_LOGIN_SESSION_KEY,
|
||||
USER_STORAGE_KEY,
|
||||
} from '../helpers/data';
|
||||
import {
|
||||
clearProxyExpired,
|
||||
getCurrentOrgId,
|
||||
getProxySession,
|
||||
} from '../helpers/orgContext';
|
||||
import { UserContext } from '../context/User';
|
||||
import { normalizeView } from './permLogic';
|
||||
|
||||
// 权限上下文(权限重构 §9 GET /api/authz/me):同时持有平台视图与当前企业视图。
|
||||
// 企业视图随当前企业(或代理会话)切换重新加载。有已切换模块、处于代理会话或上一次加载失败时,页面重新获得焦点
|
||||
// (10 秒内不重复)、或每 60 秒刷新一次;否则(未切换,视图只用于判断是否已切换)每 10 分钟刷新一次、获得焦点时
|
||||
// 2 分钟内不重复,不挤占按 IP 计数的全局限流,同时切换后用户切回窗口即可较快跟上。
|
||||
// 当前视图的有效内容(权限点、菜单、数据范围)发生变化且涉及已切换模块时,按 Q12 要求重新登录。
|
||||
|
||||
export const AuthzContext = createContext({
|
||||
platform: null,
|
||||
org: null,
|
||||
orgLoadedKey: null,
|
||||
platformLoadedFor: 0,
|
||||
platformLoadFailed: false,
|
||||
reload: () => {},
|
||||
});
|
||||
|
||||
const REFRESH_MS = 60 * 1000;
|
||||
// 未切换时的刷新间隔
|
||||
const IDLE_REFRESH_MS = 10 * 60 * 1000;
|
||||
// 窗口 focus 触发刷新的节流间隔:频繁切换窗口时不重复拉取
|
||||
const FOCUS_THROTTLE_MS = 10 * 1000;
|
||||
// 未切换时 focus 触发刷新的节流间隔
|
||||
const IDLE_FOCUS_THROTTLE_MS = 2 * 60 * 1000;
|
||||
|
||||
// 未登录(会话失效、其他标签页已登出):不算"加载失败",不因此转入高频刷新
|
||||
const UNAUTHORIZED = Symbol('unauthorized');
|
||||
|
||||
// 拉取视图;接口 success:false 或网络错误返回 null(调用方按"加载失败"处理),401 返回 UNAUTHORIZED
|
||||
const fetchView = async (headers) => {
|
||||
try {
|
||||
const res = await API.get('/api/authz/me', {
|
||||
headers,
|
||||
skipErrorHandler: true,
|
||||
disableDuplicate: true,
|
||||
});
|
||||
return res.data?.success ? normalizeView(res.data.data) : null;
|
||||
} catch (e) {
|
||||
return e?.response?.status === 401 ? UNAUTHORIZED : null;
|
||||
}
|
||||
};
|
||||
|
||||
// 当前企业视图的标识(企业 ID + 代理会话):企业中心据此判断企业视图是否已按当前企业加载过
|
||||
export const currentOrgViewKey = () =>
|
||||
`${getCurrentOrgId()}:${getProxySession()?.id || ''}`;
|
||||
|
||||
const orgHeaders = () => {
|
||||
const proxy = getProxySession();
|
||||
const orgId = getCurrentOrgId();
|
||||
if (!orgId) return null;
|
||||
const h = { 'X-Org-Id': String(orgId) };
|
||||
if (proxy) h['X-Proxy-Session'] = proxy.id;
|
||||
return h;
|
||||
};
|
||||
|
||||
// 视图有效内容的指纹:只取已切换模块(前后两次 enforced_modules 的并集)内的权限点、
|
||||
// 菜单(code 与 visible)与数据范围类型(全部 / 部门 / 本人);未切换模块的变化不影响页面行为,不纳入。
|
||||
// 部门个数不纳入:它是按部门树展开后的个数,新增子部门就会变化,而页面行为不变。
|
||||
// 已切换模块列表本身不纳入:模块切换(或回退)只是把页面从旧判断改为按权限点判断,界面就地更新,
|
||||
// 不属于 Q12 所说的撤权,不要求重新登录;切换前后权限点本身的变化仍会按上面的并集比较提示。
|
||||
// 不用 version:它包含目录与企业版本,改任意菜单名、角色名都会变化,会误弹重新登录。
|
||||
const viewSignature = (v, inScope) =>
|
||||
JSON.stringify([
|
||||
(v.perms || []).filter(inScope).sort(),
|
||||
(v.menus || [])
|
||||
.filter((m) => inScope(m.code))
|
||||
.map((m) => `${m.code}:${m.visible ? 1 : 0}`)
|
||||
.sort(),
|
||||
Object.entries(v.scopes || {})
|
||||
.filter(([code]) => inScope(code))
|
||||
.map(
|
||||
([code, sc]) =>
|
||||
`${code}:${sc?.all ? 1 : 0}:${sc?.depts ? 1 : 0}:${sc?.self ? 1 : 0}`,
|
||||
)
|
||||
.sort(),
|
||||
]);
|
||||
|
||||
// 有效内容变化且涉及已切换模块:权限确实影响到页面行为,需要重新登录
|
||||
const changedUnderEnforce = (prev, next) => {
|
||||
if (!prev || !next) return false;
|
||||
// 用户、企业或登录域不同都是换了会话(如个人会话改用企业入口登录),不是权限变更
|
||||
if (
|
||||
prev.user_id !== next.user_id ||
|
||||
prev.org_id !== next.org_id ||
|
||||
prev.domain !== next.domain ||
|
||||
(prev.session_domain || '') !== (next.session_domain || '')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const modules = new Set([
|
||||
...(prev.enforced_modules || []),
|
||||
...(next.enforced_modules || []),
|
||||
]);
|
||||
if (modules.size === 0) return false;
|
||||
const moduleOf = { ...(prev.module_of || {}), ...(next.module_of || {}) };
|
||||
const inScope = (code) => modules.has(moduleOf[code]);
|
||||
return viewSignature(prev, inScope) !== viewSignature(next, inScope);
|
||||
};
|
||||
|
||||
// 视图是否涉及已切换模块(需要高频刷新以及时发现权限变更;代理会话另由调用方判断)
|
||||
const isActiveView = (v) => !!v && (v.enforced_modules || []).length > 0;
|
||||
|
||||
// 内容相同的视图不重新写入状态,避免每次刷新都让订阅方(企业中心等)重渲染
|
||||
const sameView = (a, b) => {
|
||||
if (a === b) return true;
|
||||
if (!a || !b) return false;
|
||||
try {
|
||||
return JSON.stringify(a) === JSON.stringify(b);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const AuthzProvider = ({ children }) => {
|
||||
const { t } = useTranslation();
|
||||
const [userState, userDispatch] = useContext(UserContext);
|
||||
const userId = userState?.user?.id || 0;
|
||||
const location = useLocation();
|
||||
const [platform, setPlatform] = useState(null);
|
||||
const [org, setOrg] = useState(null);
|
||||
// 最近一次企业视图加载(无论成败)对应的 currentOrgViewKey;未加载过为 null
|
||||
const [orgLoadedKey, setOrgLoadedKey] = useState(null);
|
||||
// 平台视图已为哪个用户加载过(成败均算);路由守卫据此等待视图到达,避免先按旧判断误拦
|
||||
const [platformLoadedFor, setPlatformLoadedFor] = useState(0);
|
||||
// 最近一次平台视图加载是否失败(配合 platformLoadedFor 使用):路由守卫据此显示可重试提示
|
||||
const [platformLoadFailed, setPlatformLoadFailed] = useState(false);
|
||||
const prevRef = useRef({ platform: null, org: null });
|
||||
const promptedRef = useRef(false);
|
||||
// 已弹出的"权限已变更"提示实例:其他标签页换了会话时关闭它
|
||||
const modalRef = useRef(null);
|
||||
// 最近一次开始拉取视图的时间,用于 focus 刷新节流
|
||||
const lastFetchRef = useRef(0);
|
||||
// 最近一次加载是否有视图失败:失败后按高频刷新重试,否则已切换企业首次加载失败时会按旧判断渲染最长 10 分钟
|
||||
const failedRef = useRef(false);
|
||||
// 最新的 reload:storage 事件处理里主动重新加载(事件处理只注册一次)
|
||||
const reloadRef = useRef(null);
|
||||
// 企业会话(企业域登录、或仅企业资源账号)重新登录回 /org/login,否则回 /login
|
||||
const orgOnlyRef = useRef(false);
|
||||
orgOnlyRef.current = userState?.user?.org_only_mode === true;
|
||||
const onOrgPage = location.pathname.startsWith('/org');
|
||||
const orgKey = onOrgPage ? currentOrgViewKey() : '';
|
||||
|
||||
const promptRelogin = useCallback(() => {
|
||||
if (promptedRef.current) return;
|
||||
promptedRef.current = true;
|
||||
// 只能点"重新登录":不提供关闭按钮,点遮罩与按 Esc 都不关闭
|
||||
modalRef.current = Modal.warning({
|
||||
title: t('权限已变更'),
|
||||
content: t('你的权限已变更,请重新登录。'),
|
||||
okText: t('重新登录'),
|
||||
centered: true,
|
||||
closable: false,
|
||||
keyboard: false,
|
||||
mask: { closable: false },
|
||||
onOk: async () => {
|
||||
modalRef.current = null;
|
||||
// 先判断会话域,再登出清理(清理会移除企业登录标记)
|
||||
// 以后端返回的登录域为准;老版本后端没有该字段时退回本地标记
|
||||
const view = prevRef.current.org || prevRef.current.platform;
|
||||
const orgSession = view?.session_domain
|
||||
? view.session_domain === 'org'
|
||||
: isOrgLoginSession() || orgOnlyRef.current;
|
||||
const target = orgSession ? '/org/login' : '/login';
|
||||
try {
|
||||
await API.get('/api/user/logout', {
|
||||
skipErrorHandler: true,
|
||||
disableDuplicate: true,
|
||||
});
|
||||
} catch {
|
||||
// 登出失败也继续清理本地数据并跳转登录页
|
||||
}
|
||||
clearUserData();
|
||||
userDispatch({ type: 'logout' });
|
||||
window.location.href = target;
|
||||
},
|
||||
});
|
||||
}, [t, userDispatch]);
|
||||
|
||||
const reload = useCallback(async () => {
|
||||
lastFetchRef.current = Date.now();
|
||||
const loadingKey = currentOrgViewKey();
|
||||
if (!userId) {
|
||||
setPlatform(null);
|
||||
setOrg(null);
|
||||
prevRef.current = { platform: null, org: null };
|
||||
setOrgLoadedKey(loadingKey);
|
||||
setPlatformLoadedFor(0);
|
||||
setPlatformLoadFailed(false);
|
||||
return;
|
||||
}
|
||||
const headers = onOrgPage ? orgHeaders() : null;
|
||||
const [pr, or] = await Promise.all([
|
||||
fetchView(undefined),
|
||||
headers ? fetchView(headers) : Promise.resolve(null),
|
||||
]);
|
||||
const unauthorized = pr === UNAUTHORIZED || or === UNAUTHORIZED;
|
||||
const p = pr === UNAUTHORIZED ? null : pr;
|
||||
const o = or === UNAUTHORIZED ? null : or;
|
||||
if (p) {
|
||||
if (changedUnderEnforce(prevRef.current.platform, p)) promptRelogin();
|
||||
const same = sameView(prevRef.current.platform, p);
|
||||
prevRef.current.platform = p;
|
||||
if (!same) setPlatform(p);
|
||||
} else {
|
||||
// 加载失败:保留上一份视图作比较基准;不属于当前用户的旧视图不能再用
|
||||
const kept = prevRef.current.platform;
|
||||
if (kept && kept.user_id !== userId) {
|
||||
prevRef.current.platform = null;
|
||||
setPlatform(null);
|
||||
}
|
||||
}
|
||||
setPlatformLoadFailed(!p);
|
||||
setPlatformLoadedFor(userId);
|
||||
failedRef.current = !unauthorized && (!p || (!!headers && !o));
|
||||
if (!headers) {
|
||||
prevRef.current.org = null;
|
||||
setOrg(null);
|
||||
// 不在企业页时并未加载企业视图,不能标记为已就绪(否则进入企业中心时会按旧判断先行守卫)
|
||||
setOrgLoadedKey(onOrgPage ? loadingKey : null);
|
||||
return;
|
||||
}
|
||||
if (o) {
|
||||
if (changedUnderEnforce(prevRef.current.org, o)) promptRelogin();
|
||||
const same = sameView(prevRef.current.org, o);
|
||||
prevRef.current.org = o;
|
||||
if (!same) setOrg(o);
|
||||
} else {
|
||||
// 加载失败:保留上一份视图作比较基准;只有仍属于当前用户与当前企业时才继续使用
|
||||
const kept = prevRef.current.org;
|
||||
if (
|
||||
kept &&
|
||||
(kept.user_id !== userId || kept.org_id !== getCurrentOrgId())
|
||||
) {
|
||||
prevRef.current.org = null;
|
||||
setOrg(null);
|
||||
}
|
||||
}
|
||||
setOrgLoadedKey(loadingKey);
|
||||
}, [userId, onOrgPage, promptRelogin]);
|
||||
|
||||
// 换账号、换企业(含进入 / 退出代理)都要重新加载:企业键不参与 reload 本身的计算,单独作为触发条件
|
||||
useEffect(() => {
|
||||
reloadRef.current = reload;
|
||||
}, [reload]);
|
||||
useEffect(() => {
|
||||
reload();
|
||||
}, [reload, orgKey]);
|
||||
|
||||
// 换账号(含登出):允许对新账号重新提示
|
||||
useEffect(() => {
|
||||
promptedRef.current = false;
|
||||
}, [userId]);
|
||||
|
||||
// 离开企业中心:清除本标签页的"代理已失效"标记,之后再进入 /org 按正常企业上下文解析
|
||||
useEffect(() => {
|
||||
if (!onOrgPage) clearProxyExpired();
|
||||
}, [onOrgPage]);
|
||||
|
||||
// 多标签页:其他标签页重新登录或登出(localStorage 用户数据变化)时,关闭本页已弹出的提示,
|
||||
// 避免在旧标签页点"重新登录"把新会话注销;同时丢弃旧的比较基准,下一次加载按新会话重新建立
|
||||
useEffect(() => {
|
||||
// 只看用户身份:登出(键被删)或换成另一个用户才算换会话;额度等字段刷新不算,
|
||||
// 否则会关掉仍然有效的提示并丢弃比较基准,本标签页就再也不会提示了
|
||||
const userIdOf = (raw) => {
|
||||
try {
|
||||
return raw ? JSON.parse(raw)?.id || 0 : 0;
|
||||
} catch {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
const onStorage = (e) => {
|
||||
if (
|
||||
e.key !== USER_STORAGE_KEY &&
|
||||
e.key !== ORG_LOGIN_SESSION_KEY &&
|
||||
e.key !== null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// 企业登录标记变化:同一用户在其他标签页改用企业入口(或个人入口)登录,登录域变了,按换会话处理
|
||||
if (
|
||||
e.key === USER_STORAGE_KEY &&
|
||||
e.newValue !== null &&
|
||||
userIdOf(e.oldValue) === userIdOf(e.newValue)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (modalRef.current) {
|
||||
modalRef.current.destroy();
|
||||
modalRef.current = null;
|
||||
}
|
||||
promptedRef.current = false;
|
||||
prevRef.current = { platform: null, org: null };
|
||||
// 立即按新会话重新加载:本标签页的 UserContext 不跨标签同步,不会自己触发加载;
|
||||
// 清空基准后也不再算"有已切换模块",不主动加载就要等最长 10 分钟
|
||||
if (reloadRef.current) reloadRef.current();
|
||||
};
|
||||
window.addEventListener('storage', onStorage);
|
||||
return () => window.removeEventListener('storage', onStorage);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!userId) return undefined;
|
||||
const active = () =>
|
||||
failedRef.current ||
|
||||
isActiveView(prevRef.current.platform) ||
|
||||
isActiveView(prevRef.current.org) ||
|
||||
!!getProxySession();
|
||||
const timer = setInterval(() => {
|
||||
if (
|
||||
active() ||
|
||||
Date.now() - lastFetchRef.current >= IDLE_REFRESH_MS - 1000
|
||||
) {
|
||||
reload();
|
||||
}
|
||||
}, REFRESH_MS);
|
||||
const onFocus = () => {
|
||||
const throttle = active() ? FOCUS_THROTTLE_MS : IDLE_FOCUS_THROTTLE_MS;
|
||||
if (Date.now() - lastFetchRef.current < throttle) return;
|
||||
reload();
|
||||
};
|
||||
window.addEventListener('focus', onFocus);
|
||||
return () => {
|
||||
clearInterval(timer);
|
||||
window.removeEventListener('focus', onFocus);
|
||||
};
|
||||
}, [userId, reload]);
|
||||
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
platform,
|
||||
org,
|
||||
orgLoadedKey,
|
||||
platformLoadedFor,
|
||||
platformLoadFailed,
|
||||
reload,
|
||||
}),
|
||||
[
|
||||
platform,
|
||||
org,
|
||||
orgLoadedKey,
|
||||
platformLoadedFor,
|
||||
platformLoadFailed,
|
||||
reload,
|
||||
],
|
||||
);
|
||||
return (
|
||||
<AuthzContext.Provider value={value}>{children}</AuthzContext.Provider>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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 { usePerm } from './usePerm';
|
||||
|
||||
// <Perm code='org.member.edit' legacy={isAdmin} fallback={null}>…</Perm>
|
||||
const Perm = ({ code, legacy, fallback = null, children }) => {
|
||||
const allowed = usePerm(code, legacy);
|
||||
return <>{allowed ? children : fallback}</>;
|
||||
};
|
||||
|
||||
export default Perm;
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useContext, useState } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Result } from 'antd';
|
||||
import Loading from '../components/common/ui/Loading';
|
||||
import { AdminRoute, PrivateRoute, RootRoute } from '../helpers/auth';
|
||||
import { isRoot } from '../helpers/utils';
|
||||
import { UserContext } from '../context/User';
|
||||
import { AuthzContext } from './AuthzProvider';
|
||||
import { usePerm } from './usePerm';
|
||||
|
||||
// 平台视图加载失败:给出可重试的提示,而不是按旧判断直接跳 /forbidden
|
||||
const LoadFailed = ({ reload }) => {
|
||||
const { t } = useTranslation();
|
||||
const [retrying, setRetrying] = useState(false);
|
||||
const retry = async () => {
|
||||
setRetrying(true);
|
||||
try {
|
||||
await reload();
|
||||
} finally {
|
||||
setRetrying(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<Result
|
||||
status='warning'
|
||||
title={t('权限信息加载失败')}
|
||||
subTitle={t('请检查网络后重试')}
|
||||
extra={
|
||||
<Button type='primary' loading={retrying} onClick={retry}>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// 会话已在其他标签页变更:刷新页面按新会话重新加载
|
||||
const SessionChanged = () => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Result
|
||||
status='info'
|
||||
title={t('登录状态已变化')}
|
||||
subTitle={t('你已在其他页面切换了账号,请刷新页面')}
|
||||
extra={
|
||||
<Button type='primary' onClick={() => window.location.reload()}>
|
||||
{t('刷新页面')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
// 平台视图是否已就绪。返回 null 表示就绪,否则返回等待期间应显示的内容。
|
||||
// 就绪:已有属于当前用户的平台视图(之后的刷新失败不影响);否则本用户的加载已结束且失败时提示重试。
|
||||
const useViewPending = () => {
|
||||
const [userState] = useContext(UserContext);
|
||||
const { platform, platformLoadedFor, platformLoadFailed, reload } =
|
||||
useContext(AuthzContext);
|
||||
const userId = userState?.user?.id || 0;
|
||||
const viewReady = !!platform && platform.user_id === userId;
|
||||
if (!userId || viewReady) return { pending: null, failed: false };
|
||||
if (platformLoadedFor === userId && platformLoadFailed) {
|
||||
return { pending: <LoadFailed reload={reload} />, failed: true };
|
||||
}
|
||||
// 视图已加载但属于另一个用户:其他标签页换了账号,本页的用户信息已过期,提示刷新而不是一直转圈
|
||||
if (platformLoadedFor === userId && platform) {
|
||||
return { pending: <SessionChanged />, failed: false };
|
||||
}
|
||||
return { pending: <Loading />, failed: false };
|
||||
};
|
||||
|
||||
// 按平台权限点守卫的路由:判断与侧边栏一致(usePerm(code, isRoot())),
|
||||
// 平台视图到达前显示加载中,加载失败显示可重试提示,无权限时与其它守卫一样跳 /forbidden。
|
||||
const PermGate = ({ code, children }) => {
|
||||
const allowed = usePerm(code, isRoot());
|
||||
const { pending } = useViewPending();
|
||||
if (pending) return pending;
|
||||
if (!allowed) return <Navigate to='/forbidden' replace />;
|
||||
return children;
|
||||
};
|
||||
|
||||
const PermRoute = ({ code, children }) => (
|
||||
<PrivateRoute>
|
||||
<PermGate code={code}>{children}</PermGate>
|
||||
</PrivateRoute>
|
||||
);
|
||||
|
||||
// 原有守卫:legacy='root' 为 RootRoute,否则为 AdminRoute(permission 为系统设置页签委派校验)
|
||||
const LegacyRoute = ({ legacy, permission, children }) =>
|
||||
legacy === 'root' ? (
|
||||
<RootRoute>{children}</RootRoute>
|
||||
) : (
|
||||
<AdminRoute permission={permission}>{children}</AdminRoute>
|
||||
);
|
||||
|
||||
// 控制台路由守卫(新旧双路径):code 所属模块已切到新体系时按权限点判断(持有权限点的非管理员也能进入,
|
||||
// 没有权限点的管理员进不去);未切换时完全沿用原有守卫(AdminRoute / RootRoute)。
|
||||
// 用法:<ConsoleRoute code='platform.channel'>、<ConsoleRoute code='platform.commission' legacy='root'>、
|
||||
// <ConsoleRoute code='platform.setting.website_setting' permission='website-setting'>
|
||||
export const ConsoleRoute = ({
|
||||
code,
|
||||
legacy = 'admin',
|
||||
permission,
|
||||
children,
|
||||
}) => {
|
||||
const [userState] = useContext(UserContext);
|
||||
const { platform } = useContext(AuthzContext);
|
||||
const { pending, failed } = useViewPending();
|
||||
const user = userState?.user;
|
||||
const legacyRoute = (
|
||||
<LegacyRoute legacy={legacy} permission={permission}>
|
||||
{children}
|
||||
</LegacyRoute>
|
||||
);
|
||||
// 未登录或登录态校验中:交给原有守卫(跳登录页或显示加载中)
|
||||
if (!user) return legacyRoute;
|
||||
if (pending) {
|
||||
// 视图加载失败时无从得知模块是否已切换:原判断会放行的人仍按原有守卫进入(接口权限由后端校验),
|
||||
// 避免权限接口故障把管理员挡在控制台外;其余人显示可重试提示
|
||||
const legacyRole = legacy === 'root' ? 100 : 10;
|
||||
if (failed && typeof user.role === 'number' && user.role >= legacyRole) {
|
||||
return legacyRoute;
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
const mod = platform.moduleOf[code];
|
||||
if (!mod || !platform.enforcedSet.has(mod)) return legacyRoute;
|
||||
if (!platform.permSet.has(code)) return <Navigate to='/forbidden' replace />;
|
||||
return children;
|
||||
};
|
||||
|
||||
// 控制台入口 /console:原行为是管理员进运营看板。运营看板模块已切换且当前用户没有该菜单时
|
||||
// (含持有其他平台菜单的非管理员),改进第一个已切换且持有的控制台菜单;都没有时按原有守卫处理。
|
||||
export const ConsoleIndexRoute = () => {
|
||||
const [userState] = useContext(UserContext);
|
||||
const { platform } = useContext(AuthzContext);
|
||||
const { pending, failed } = useViewPending();
|
||||
const user = userState?.user;
|
||||
const legacyRoute = (
|
||||
<AdminRoute>
|
||||
<Navigate to='/console/analytics' replace />
|
||||
</AdminRoute>
|
||||
);
|
||||
if (!user) return legacyRoute;
|
||||
if (pending) {
|
||||
if (failed && typeof user.role === 'number' && user.role >= 10) {
|
||||
return legacyRoute;
|
||||
}
|
||||
return pending;
|
||||
}
|
||||
const enforced = (code) => platform.enforcedSet.has(platform.moduleOf[code]);
|
||||
const analyticsEnforced = enforced('platform.analytics');
|
||||
const canAnalytics = analyticsEnforced
|
||||
? platform.permSet.has('platform.analytics')
|
||||
: typeof user.role === 'number' && user.role >= 10;
|
||||
if (canAnalytics) return <Navigate to='/console/analytics' replace />;
|
||||
// view.menus 已按 sort 排好,且只含当前用户持有的节点
|
||||
const first = (platform.menus || []).find(
|
||||
(m) =>
|
||||
m.type === 'menu' &&
|
||||
m.visible &&
|
||||
typeof m.route === 'string' &&
|
||||
m.route.startsWith('/console/') &&
|
||||
enforced(m.code),
|
||||
);
|
||||
if (first) return <Navigate to={first.route} replace />;
|
||||
return legacyRoute;
|
||||
};
|
||||
|
||||
export default PermRoute;
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
export { AuthzContext, AuthzProvider } from './AuthzProvider';
|
||||
export {
|
||||
usePerm,
|
||||
useAnyPerm,
|
||||
useAuthzView,
|
||||
useAuthzReload,
|
||||
useOrgViewReady,
|
||||
} from './usePerm';
|
||||
export { default as Perm } from './Perm';
|
||||
export {
|
||||
default as PermRoute,
|
||||
ConsoleRoute,
|
||||
ConsoleIndexRoute,
|
||||
} from './PermRoute';
|
||||
export { checkPerm, checkAnyPerm, buildMenuTree } from './permLogic';
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
// 权限判断的纯逻辑(权限重构 §7.1 新旧双路径),与 React 无关,便于单测。
|
||||
// view 为 /api/authz/me 的返回;legacy 为旧判断(布尔或返回布尔的函数)。
|
||||
|
||||
export function normalizeView(data) {
|
||||
if (!data) return null;
|
||||
return {
|
||||
...data,
|
||||
permSet: new Set(data.perms || []),
|
||||
enforcedSet: new Set(data.enforced_modules || []),
|
||||
moduleOf: data.module_of || {},
|
||||
};
|
||||
}
|
||||
|
||||
const evalLegacy = (legacy) =>
|
||||
typeof legacy === 'function' ? !!legacy() : !!legacy;
|
||||
|
||||
// 模块已切到新体系(enforced):以权限点为准;否则走旧判断。未提供旧判断时按权限点判断。
|
||||
// view 尚未加载:有旧判断走旧判断,否则不放行。
|
||||
export function checkPerm(view, code, legacy) {
|
||||
if (!view) return legacy === undefined ? false : evalLegacy(legacy);
|
||||
const mod = view.moduleOf[code];
|
||||
if (mod && view.enforcedSet.has(mod)) return view.permSet.has(code);
|
||||
if (legacy === undefined) return view.permSet.has(code);
|
||||
return evalLegacy(legacy);
|
||||
}
|
||||
|
||||
// 是否持有任一权限点(同样按模块逐个走新旧路径)。
|
||||
export function checkAnyPerm(view, codes, legacy) {
|
||||
return codes.some((c) => checkPerm(view, c, legacy));
|
||||
}
|
||||
|
||||
// 视图对应的域:org.* 权限点看企业视图,其余看平台视图。
|
||||
export function viewForCode(views, code) {
|
||||
return code.startsWith('org.') ? views.org : views.platform;
|
||||
}
|
||||
|
||||
// 菜单树:按 parent 组装,同级按 sort;只保留 visible 的节点。
|
||||
export function buildMenuTree(menus) {
|
||||
const byParent = new Map();
|
||||
for (const m of menus || []) {
|
||||
if (!m.visible) continue;
|
||||
const list = byParent.get(m.parent || '') || [];
|
||||
list.push(m);
|
||||
byParent.set(m.parent || '', list);
|
||||
}
|
||||
const build = (parent) =>
|
||||
(byParent.get(parent) || [])
|
||||
.sort((a, b) => a.sort - b.sort || a.code.localeCompare(b.code))
|
||||
.map((m) => ({ ...m, children: build(m.code) }));
|
||||
return build('');
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
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 test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import {
|
||||
normalizeView,
|
||||
checkPerm,
|
||||
checkAnyPerm,
|
||||
buildMenuTree,
|
||||
} from './permLogic.js';
|
||||
|
||||
const view = normalizeView({
|
||||
perms: ['org.member', 'org.member.query'],
|
||||
enforced_modules: ['member'],
|
||||
module_of: {
|
||||
'org.member': 'member',
|
||||
'org.member.query': 'member',
|
||||
'org.member.edit': 'member',
|
||||
'org.dept.query': 'dept',
|
||||
},
|
||||
});
|
||||
|
||||
test('enforced module follows perms, ignoring the legacy check', () => {
|
||||
assert.equal(checkPerm(view, 'org.member.query', false), true);
|
||||
assert.equal(checkPerm(view, 'org.member.edit', true), false);
|
||||
});
|
||||
|
||||
test('non-enforced module follows the legacy check', () => {
|
||||
assert.equal(checkPerm(view, 'org.dept.query', true), true);
|
||||
assert.equal(
|
||||
checkPerm(view, 'org.dept.query', () => false),
|
||||
false,
|
||||
);
|
||||
assert.equal(checkPerm(view, 'org.dept.query'), false);
|
||||
});
|
||||
|
||||
test('view not loaded yet', () => {
|
||||
assert.equal(checkPerm(null, 'org.member.query'), false);
|
||||
assert.equal(checkPerm(null, 'org.member.query', true), true);
|
||||
});
|
||||
|
||||
test('any of several perms', () => {
|
||||
assert.equal(
|
||||
checkAnyPerm(view, ['org.member.edit', 'org.member.query']),
|
||||
true,
|
||||
);
|
||||
assert.equal(checkAnyPerm(view, ['org.member.edit']), false);
|
||||
});
|
||||
|
||||
test('menu tree keeps visible nodes ordered by sort', () => {
|
||||
const tree = buildMenuTree([
|
||||
{ code: 'b', parent: '', sort: 20, visible: true },
|
||||
{ code: 'a', parent: '', sort: 10, visible: true },
|
||||
{ code: 'a.x', parent: 'a', sort: 10, visible: true },
|
||||
{ code: 'a.h', parent: 'a', sort: 5, visible: false },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
tree.map((n) => n.code),
|
||||
['a', 'b'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
tree[0].children.map((n) => n.code),
|
||||
['a.x'],
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 { useContext, useEffect } from 'react';
|
||||
import { AuthzContext, currentOrgViewKey } from './AuthzProvider';
|
||||
import { checkPerm, checkAnyPerm, viewForCode } from './permLogic';
|
||||
|
||||
// usePerm(code, legacy):模块已切到新体系时按权限点判断,否则按 legacy(旧判断)判断。
|
||||
export function usePerm(code, legacy) {
|
||||
const ctx = useContext(AuthzContext);
|
||||
return checkPerm(viewForCode(ctx, code), code, legacy);
|
||||
}
|
||||
|
||||
// useAnyPerm(codes, legacy):持有其中任一权限点。
|
||||
export function useAnyPerm(codes, legacy) {
|
||||
const ctx = useContext(AuthzContext);
|
||||
if (!codes.length) return false;
|
||||
return checkAnyPerm(viewForCode(ctx, codes[0]), codes, legacy);
|
||||
}
|
||||
|
||||
// useAuthzView(domain):'platform' | 'org' 的原始视图(菜单树渲染等)。
|
||||
export function useAuthzView(domain) {
|
||||
const ctx = useContext(AuthzContext);
|
||||
return domain === 'org' ? ctx.org : ctx.platform;
|
||||
}
|
||||
|
||||
export function useAuthzReload() {
|
||||
return useContext(AuthzContext).reload;
|
||||
}
|
||||
|
||||
// useOrgViewReady():企业视图是否已按当前企业(含代理会话)加载过(成败均算)。
|
||||
// 企业中心在它就绪前不做路由守卫,避免新体系下持有菜单的人在视图到达前被旧判断重定向走。
|
||||
// 当前企业刚由解析器写入、Provider 尚未感知时主动触发一次加载。
|
||||
export function useOrgViewReady() {
|
||||
const ctx = useContext(AuthzContext);
|
||||
const key = currentOrgViewKey();
|
||||
const ready = ctx.orgLoadedKey === key;
|
||||
const { reload } = ctx;
|
||||
useEffect(() => {
|
||||
if (!ready) reload();
|
||||
}, [ready, key, reload]);
|
||||
return ready;
|
||||
}
|
||||
@@ -1,21 +1,4 @@
|
||||
/*
|
||||
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 { formatPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
import React, { useState } from 'react';
|
||||
@@ -118,7 +101,7 @@ const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => {
|
||||
width: 80,
|
||||
align: 'right',
|
||||
render: (val) => (
|
||||
<span className='text-gray-500'>{(val || 0).toFixed(1)}%</span>
|
||||
<span className='text-gray-500'>{formatPercent(val || 0, 1)}</span>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { ChevronDown as ActionChevronDown } from '@/components/common/icons/ActionIcons';
|
||||
import React from 'react';
|
||||
import './collapsible-panel.css';
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
/*
|
||||
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 { Card, Table, Button } from '@/components/ui';
|
||||
import { IconDownload } from '@/components/ui/icons';
|
||||
import { renderQuota } from '../../helpers';
|
||||
import { formatNumber, toFiniteNumber } from '../../helpers/safeDisplay';
|
||||
|
||||
const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||
const columns = [
|
||||
@@ -68,7 +50,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||
align: 'right',
|
||||
render: (val) => (
|
||||
<span className='text-yellow-600 font-medium'>
|
||||
¥{(val || 0).toFixed(2)}
|
||||
¥{formatNumber(val, 2, '0.00')}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
@@ -99,7 +81,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||
width: 120,
|
||||
align: 'right',
|
||||
render: (val) => {
|
||||
const tokens = val || 0;
|
||||
const tokens = toFiniteNumber(val) ?? 0;
|
||||
if (tokens >= 1000000) {
|
||||
return <span>{(tokens / 1000000).toFixed(2)}M</span>;
|
||||
} else if (tokens >= 1000) {
|
||||
@@ -198,6 +180,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||
columns={columns}
|
||||
dataSource={data || []}
|
||||
pagination={{
|
||||
preservePage: true,
|
||||
pageSize: 10,
|
||||
showSizeChanger: true,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total, count: total }),
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
/*
|
||||
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 { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import {
|
||||
@@ -113,7 +96,9 @@ const HighFreqLowCostUsers = ({
|
||||
width: 160,
|
||||
render: (v, row) => (
|
||||
<div className='flex flex-col'>
|
||||
<Text strong>{v || row.username || `user_${row.user_id}`}</Text>
|
||||
<Text strong>
|
||||
{formatUserReference(v || row.username, row.user_id, t('未知用户'))}
|
||||
</Text>
|
||||
{row.username && v && row.username !== v && (
|
||||
<Text type='tertiary' size='small'>
|
||||
@{row.username}
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
/*
|
||||
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, { useMemo } from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
import { renderQuota } from '../../helpers';
|
||||
import { formatPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
const ModelDistribution = ({ data, title, icon, t }) => {
|
||||
const pieSpec = useMemo(() => {
|
||||
@@ -119,12 +101,12 @@ const ModelDistribution = ({ data, title, icon, t }) => {
|
||||
<span className='text-xs text-gray-500 w-4'>{index + 1}</span>
|
||||
<span
|
||||
className='text-sm flex-1 truncate'
|
||||
title={item.model_name}
|
||||
title={item.model_name || t('未知')}
|
||||
>
|
||||
{item.model_name}
|
||||
{item.model_name || t('未知')}
|
||||
</span>
|
||||
<span className='text-xs text-gray-500'>
|
||||
{item.percent?.toFixed(1)}%
|
||||
{formatPercent(item.percent, 1)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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, { useMemo, useState, useEffect } from 'react';
|
||||
import { Button, Empty, Segmented, Skeleton, theme } from 'antd';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
@@ -25,6 +6,7 @@ import { RefreshCw } from '@/components/common/icons/ActionIcons';
|
||||
import { ConsoleDrawer } from '@/components/console/ConsolePrimitives';
|
||||
import useOrgCacheHourly from '../../hooks/analytics/useOrgCacheHourly';
|
||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { formatIdReference, formatPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
// 图表序列色属于专用图表(VChart)配色,统计块沿用同色以便与图例对应。
|
||||
// 千分位缩写。线上单小时 cache_read 能到十亿量级,不缩写轴标签会糊成一片。
|
||||
@@ -179,7 +161,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
||||
value: (datum) =>
|
||||
datum?.hit_rate === null || datum?.hit_rate === undefined
|
||||
? t('无流量')
|
||||
: `${Number(datum.hit_rate).toFixed(1)}%`,
|
||||
: formatPercent(datum.hit_rate, 1),
|
||||
},
|
||||
{
|
||||
key: () => t('实际消费'),
|
||||
@@ -228,14 +210,15 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
||||
// 自适应量程会把 76%~87% 的波动拉成满屏振荡,像出了故障。
|
||||
min: 0,
|
||||
max: 100,
|
||||
label: { formatMethod: (v) => `${Math.round(v)}%` },
|
||||
label: { formatMethod: (v) => formatPercent(v, 0) },
|
||||
seriesIndex: [1],
|
||||
},
|
||||
],
|
||||
};
|
||||
}, [points, hasTraffic, t]);
|
||||
|
||||
const orgTitle = org?.org_name || (org ? `${t('企业')} ${org.org_id}` : '');
|
||||
const orgReference = formatIdReference(org?.org_id);
|
||||
const orgTitle = org?.org_name || (org ? `${t('企业')} ${orgReference}` : '');
|
||||
|
||||
return (
|
||||
<ConsoleDrawer
|
||||
@@ -250,7 +233,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
||||
</span>
|
||||
{org?.org_id ? (
|
||||
<span className='text-xs font-normal text-[var(--text-secondary)]'>
|
||||
#{org.org_id}
|
||||
{orgReference}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -284,7 +267,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
||||
value={
|
||||
totals.hit_rate === null || totals.hit_rate === undefined
|
||||
? '--'
|
||||
: `${Number(totals.hit_rate).toFixed(2)}%`
|
||||
: formatPercent(totals.hit_rate, 2)
|
||||
}
|
||||
sub={t('按 token 加权')}
|
||||
color={SERIES_COLORS.hitRate}
|
||||
|
||||
@@ -1,22 +1,4 @@
|
||||
/*
|
||||
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 { formatIdReference, formatPercent } from '../../helpers/safeDisplay';
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import { Badge, Empty, Progress, Skeleton, Tag, Tooltip, theme } from 'antd';
|
||||
import { ArrowDown } from 'lucide-react';
|
||||
@@ -103,16 +85,19 @@ const OrgRealtimeUsage = ({
|
||||
key: 'org_name',
|
||||
width: 220,
|
||||
fixed: 'left',
|
||||
render: (text, record) => (
|
||||
<div className='flex items-center gap-2 min-w-0'>
|
||||
<span className='text-sm font-medium truncate' title={text || ''}>
|
||||
{text || `${t('企业')} ${record.org_id}`}
|
||||
</span>
|
||||
<span className='text-xs text-[var(--text-secondary)] flex-shrink-0'>
|
||||
#{record.org_id}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
render: (text, record) => {
|
||||
const orgReference = formatIdReference(record.org_id);
|
||||
return (
|
||||
<div className='flex items-center gap-2 min-w-0'>
|
||||
<span className='text-sm font-medium truncate' title={text || ''}>
|
||||
{text || `${t('企业')} ${orgReference}`}
|
||||
</span>
|
||||
<span className='text-xs text-[var(--text-secondary)] flex-shrink-0'>
|
||||
{orgReference}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: (
|
||||
@@ -275,7 +260,7 @@ const OrgRealtimeUsage = ({
|
||||
className='text-sm font-semibold group-hover:underline'
|
||||
style={{ color: cacheRateColor(rate, token) }}
|
||||
>
|
||||
{rate.toFixed(1)}%
|
||||
{formatPercent(rate, 1)}
|
||||
</span>
|
||||
<span
|
||||
aria-hidden
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
/*
|
||||
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 { formatNumber, formatPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
import React from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
@@ -65,7 +48,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
||||
},
|
||||
{
|
||||
title: t('今日充值'),
|
||||
value: `¥${overview.today_topup?.toFixed(2) || '0.00'}`,
|
||||
value: `¥${formatNumber(overview.today_topup, 2, '0.00')}`,
|
||||
change: overview.today_topup_change,
|
||||
icon: <DollarSign className='w-5 h-5' />,
|
||||
color: 'yellow',
|
||||
@@ -92,7 +75,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
||||
},
|
||||
{
|
||||
title: t('付费率'),
|
||||
value: `${overview.pay_rate?.toFixed(1) || '0.0'}%`,
|
||||
value: formatPercent(overview.pay_rate, 1, '0.0%'),
|
||||
change: null,
|
||||
icon: <Percent className='w-5 h-5' />,
|
||||
color: 'pink',
|
||||
@@ -117,7 +100,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
||||
)}
|
||||
<span>
|
||||
{isPositive ? '+' : ''}
|
||||
{change.toFixed(1)}%
|
||||
{formatPercent(change, 1)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
/*
|
||||
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 { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import React, { useState } from 'react';
|
||||
@@ -246,7 +229,9 @@ const RiskControlBanLogs = ({
|
||||
<div>
|
||||
<Text type='tertiary'>{t('用户:')}</Text>
|
||||
<Text strong>
|
||||
{unbanRow.user_snapshot || `user_${unbanRow.user_id}`}(ID:
|
||||
{unbanRow.user_snapshot ||
|
||||
formatUserReference('', unbanRow.user_id, t('未知用户'))}
|
||||
(ID:
|
||||
{unbanRow.user_id})
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { Trans } from 'react-i18next';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
/*
|
||||
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 { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
import {
|
||||
formatNumber,
|
||||
formatPercent,
|
||||
toFiniteNumber,
|
||||
} from '../../helpers/safeDisplay';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
@@ -48,8 +34,8 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
||||
const chartData = data.map((item) => ({
|
||||
name: item.payment_method ? t(item.payment_method) : t('未知'),
|
||||
rawName: item.payment_method,
|
||||
value: item.amount || 0,
|
||||
count: item.count || 0,
|
||||
value: toFiniteNumber(item.amount) ?? 0,
|
||||
count: toFiniteNumber(item.count) ?? 0,
|
||||
}));
|
||||
|
||||
// 根据支付渠道名称生成颜色数组
|
||||
@@ -78,7 +64,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
||||
content: [
|
||||
{
|
||||
key: (datum) => datum?.name,
|
||||
value: (datum) => `¥${(datum?.value || 0).toFixed(2)}`,
|
||||
value: (datum) => `¥${formatNumber(datum?.value, 2, '0.00')}`,
|
||||
},
|
||||
{
|
||||
key: () => t('笔数'),
|
||||
@@ -108,7 +94,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
||||
// 统计列表
|
||||
const channelList = data || [];
|
||||
const totalAmount = channelList.reduce(
|
||||
(sum, item) => sum + (item.amount || 0),
|
||||
(sum, item) => sum + (toFiniteNumber(item.amount) ?? 0),
|
||||
0,
|
||||
);
|
||||
|
||||
@@ -141,10 +127,10 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
||||
</span>
|
||||
<div className='text-right'>
|
||||
<span className='font-medium'>
|
||||
¥{(item.amount || 0).toFixed(2)}
|
||||
¥{formatNumber(item.amount, 2, '0.00')}
|
||||
</span>
|
||||
<span className='text-gray-400 text-xs ml-2'>
|
||||
({item.percent?.toFixed(1)}
|
||||
({formatPercent(item.percent, 1).replace('%', '')}
|
||||
{I18N_TECHNICAL_TEXT.PERCENT_CLOSE}
|
||||
</span>
|
||||
</div>
|
||||
@@ -152,7 +138,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
||||
))}
|
||||
<div className='flex items-center justify-between text-sm pt-2 font-semibold'>
|
||||
<span>{t('合计')}</span>
|
||||
<span>¥{totalAmount.toFixed(2)}</span>
|
||||
<span>¥{formatNumber(totalAmount, 2, '0.00')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,25 +1,7 @@
|
||||
/*
|
||||
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, { useMemo } from 'react';
|
||||
import { Card } from '@/components/ui';
|
||||
import { VChart } from '@visactor/react-vchart';
|
||||
import { formatCurrency } from '@/helpers/safeDisplay';
|
||||
|
||||
const TrendCharts = ({ title, icon, data, type, t }) => {
|
||||
const spec = useMemo(() => {
|
||||
@@ -142,7 +124,7 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
|
||||
content: [
|
||||
{
|
||||
key: () => topupKey,
|
||||
value: (datum) => `¥${(datum?.[topupKey] || 0).toFixed(2)}`,
|
||||
value: (datum) => formatCurrency(datum?.[topupKey]),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -174,8 +156,7 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
|
||||
content: [
|
||||
{
|
||||
key: () => consumeKey,
|
||||
value: (datum) =>
|
||||
`¥${(datum?.[consumeKey] || 0).toFixed(2)}`,
|
||||
value: (datum) => formatCurrency(datum?.[consumeKey]),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
/*
|
||||
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 {
|
||||
formatIdReference,
|
||||
formatUserReference,
|
||||
} from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
@@ -104,11 +90,15 @@ const UserRanking = ({ data, title, icon, t }) => {
|
||||
<div className='flex items-center justify-between'>
|
||||
<span
|
||||
className='text-sm font-medium truncate'
|
||||
title={`${item.display_name || item.username || 'User'} (ID: ${item.user_id})`}
|
||||
title={`${formatUserReference(item.display_name || item.username, item.user_id, t('未知用户'))}`}
|
||||
>
|
||||
{item.display_name || item.username || `User ${item.user_id}`}
|
||||
{formatUserReference(
|
||||
item.display_name || item.username,
|
||||
item.user_id,
|
||||
t('未知用户'),
|
||||
)}
|
||||
<span className='text-xs text-gray-400 ml-1'>
|
||||
#{item.user_id}
|
||||
{formatIdReference(item.user_id)}
|
||||
</span>
|
||||
</span>
|
||||
<span className='text-sm font-semibold text-gray-700 dark:text-gray-300 ml-2'>
|
||||
|
||||
@@ -1,21 +1,4 @@
|
||||
/*
|
||||
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 { formatPercent, formatRatioPercent } from '../../helpers/safeDisplay';
|
||||
|
||||
import React, { useMemo, useState, useEffect, useCallback } from 'react';
|
||||
import { Card, Spin, Tag, Progress } from '@/components/ui';
|
||||
@@ -130,7 +113,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
},
|
||||
{
|
||||
key: () => t('占比'),
|
||||
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -186,7 +169,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
},
|
||||
{
|
||||
key: () => t('占比'),
|
||||
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -334,10 +317,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
{techUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((techUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
{formatRatioPercent(techUsers, totalUsers, 1, '0.0%')}
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 rounded-xl'>
|
||||
@@ -351,10 +331,12 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
{activeAIUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((activeAIUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
{formatRatioPercent(
|
||||
activeAIUsers,
|
||||
totalUsers,
|
||||
1,
|
||||
'0.0%',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className='p-4 bg-gradient-to-br from-orange-50 to-amber-50 dark:from-orange-900/20 dark:to-amber-900/20 rounded-xl'>
|
||||
@@ -368,10 +350,12 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
||||
{interestedUsers}
|
||||
</div>
|
||||
<div className='text-xs text-gray-400 mt-1'>
|
||||
{totalUsers > 0
|
||||
? ((interestedUsers / totalUsers) * 100).toFixed(1)
|
||||
: 0}
|
||||
%
|
||||
{formatRatioPercent(
|
||||
interestedUsers,
|
||||
totalUsers,
|
||||
1,
|
||||
'0.0%',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
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 {
|
||||
formatNumber,
|
||||
formatIdReference,
|
||||
formatUserReference,
|
||||
} from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
@@ -80,12 +67,12 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
||||
<div className='flex flex-col'>
|
||||
<span
|
||||
className='font-medium text-sm truncate'
|
||||
title={text || `User ${record.user_id}`}
|
||||
title={formatUserReference(text, record.user_id, t('未知用户'))}
|
||||
>
|
||||
{text || `User ${record.user_id}`}
|
||||
{formatUserReference(text, record.user_id, t('未知用户'))}
|
||||
</span>
|
||||
<span className='text-xs text-gray-400 truncate'>
|
||||
{I18N_TECHNICAL_TEXT.ID} {record.user_id}
|
||||
{I18N_TECHNICAL_TEXT.ID} {formatIdReference(record.user_id)}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
@@ -98,7 +85,7 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
||||
defaultSortOrder: 'descend',
|
||||
render: (value) => (
|
||||
<span className='font-semibold text-red-500'>
|
||||
¥{(value || 0).toFixed(2)}
|
||||
¥{formatNumber(value, 2, '0.00')}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||
import React from 'react';
|
||||
import {
|
||||
@@ -30,6 +11,7 @@ import {
|
||||
} from '@/components/ui';
|
||||
import { ClipboardList } from 'lucide-react';
|
||||
import { ChangeText, OrgNameCell, ReasonTags, SectionCard } from './shared';
|
||||
import { formatRatioPercent } from '../../../helpers/safeDisplay';
|
||||
import {
|
||||
daysSince,
|
||||
downloadCsv,
|
||||
@@ -284,7 +266,11 @@ const columnsFor = (tab, cny, t, atRisk) => {
|
||||
{v}/{r.member_count}
|
||||
{r.member_count > 0 ? (
|
||||
<span className='text-xs text-gray-400 ml-1'>
|
||||
{Math.min(100, (v / r.member_count) * 100).toFixed(0)}%
|
||||
{formatRatioPercent(
|
||||
Math.min(100, Number(v) || 0),
|
||||
r.member_count,
|
||||
0,
|
||||
)}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
@@ -513,11 +499,7 @@ export const ActionCenter = ({ lists, activeTab, onTabChange, cny, t }) => (
|
||||
rowKey='org_id'
|
||||
size='small'
|
||||
scroll={{ x: 1200 }}
|
||||
pagination={
|
||||
lists[tab].length > 10
|
||||
? { pageSize: 10, showSizeChanger: false }
|
||||
: false
|
||||
}
|
||||
pagination={lists[tab].length > 10 ? { pageSize: 10 } : false}
|
||||
empty={<Empty description={t('暂无需要跟进的企业')} />}
|
||||
/>
|
||||
</TabPane>
|
||||
|
||||
Binary file not shown.
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { Trans } from 'react-i18next';
|
||||
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
|
||||
import { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||
@@ -31,6 +12,10 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { ChangeText, KpiCard, SectionCard } from './shared';
|
||||
import { formatCny, formatCst, pct, SEGMENTS } from './utils';
|
||||
import {
|
||||
formatPercent,
|
||||
formatRatioPercent,
|
||||
} from '../../../helpers/safeDisplay';
|
||||
|
||||
// ─── 报表抬头:统计口径 + 数据状态 ─────────────────────────────────
|
||||
export const ReportHeader = ({ report, onExport, t }) => {
|
||||
@@ -209,7 +194,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
n: (k.active_orgs || 0).toLocaleString(),
|
||||
count: k.active_orgs || 0,
|
||||
}),
|
||||
sub: `${t('活跃率')} ${pct(k.active_orgs, servingOrgs).toFixed(1)}% · ${t('新增')} ${k.new_orgs || 0}`,
|
||||
sub: `${t('活跃率')} ${formatRatioPercent(k.active_orgs, servingOrgs)} · ${t('新增')} ${k.new_orgs || 0}`,
|
||||
compare: (
|
||||
<ChangeText cur={k.active_orgs} prev={k.prev_active_orgs} t={t} />
|
||||
),
|
||||
@@ -229,7 +214,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
n: (k.active_members || 0).toLocaleString(),
|
||||
count: k.active_members || 0,
|
||||
}),
|
||||
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
sub: `${t('渗透率')} ${formatPercent(Math.min(100, pct(k.active_members, k.total_members)))} · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
||||
onClick: () => onJump('growth'),
|
||||
},
|
||||
@@ -277,7 +262,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
||||
},
|
||||
{
|
||||
title: t('企业消耗占平台'),
|
||||
value: `${share.toFixed(1)}%`,
|
||||
value: formatPercent(share),
|
||||
sub: `${t('个人消耗')} ${formatCny(k.personal_quota, cny)}`,
|
||||
compare:
|
||||
shareDelta === null ? null : (
|
||||
@@ -341,7 +326,7 @@ export const HealthSegments = ({ report, cny, activeSegment, onSelect, t }) => {
|
||||
{t(meta.label)}
|
||||
</Tag>
|
||||
<span className='text-xs text-gray-400 tabular-nums'>
|
||||
{pct(s.count, totalCount).toFixed(0)}%
|
||||
{formatPercent(pct(s.count, totalCount), 0)}
|
||||
</span>
|
||||
</div>
|
||||
<div className='mt-2 text-lg font-bold text-gray-800 dark:text-gray-100 tabular-nums'>
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||
import React, { useMemo } from 'react';
|
||||
import {
|
||||
@@ -30,6 +11,7 @@ import {
|
||||
} from '@/components/ui';
|
||||
import { Search, Table2, UserCog } from 'lucide-react';
|
||||
import { ChangeText, OrgNameCell, SectionCard } from './shared';
|
||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
||||
import {
|
||||
ALERT_LEVELS,
|
||||
ORG_STATUS,
|
||||
@@ -141,9 +123,7 @@ export const SalesRepTable = ({ reps, cny, onSelect, t }) => {
|
||||
rowKey={(r) => r.sales_rep || '__none__'}
|
||||
size='small'
|
||||
scroll={{ x: 920 }}
|
||||
pagination={
|
||||
reps.length > 8 ? { pageSize: 8, showSizeChanger: false } : false
|
||||
}
|
||||
pagination={reps.length > 8 ? { pageSize: 10 } : false}
|
||||
empty={<Empty description={t('暂无数据')} />}
|
||||
/>
|
||||
</SectionCard>
|
||||
@@ -266,7 +246,7 @@ export const OrgDetailTable = ({ report, filter, setFilter, cny, t }) => {
|
||||
align: 'right',
|
||||
render: (v) =>
|
||||
v > 0 ? (
|
||||
<span className='tabular-nums'>{v.toFixed(1)}%</span>
|
||||
<span className='tabular-nums'>{formatPercent(v, 1)}</span>
|
||||
) : (
|
||||
<Text type='tertiary'>—</Text>
|
||||
),
|
||||
@@ -501,8 +481,8 @@ export const exportOrgDetail = (rows, cny, t) => {
|
||||
SEGMENTS[o.segment] ? t(SEGMENTS[o.segment].label) : '',
|
||||
yuan(o.quota),
|
||||
yuan(o.prev_quota),
|
||||
rate === null ? '' : `${rate.toFixed(1)}%`,
|
||||
o.share ? `${o.share.toFixed(2)}%` : '',
|
||||
rate === null ? '' : formatPercent(rate, 1),
|
||||
o.share ? formatPercent(o.share, 2) : '',
|
||||
o.requests,
|
||||
o.active_members,
|
||||
o.member_count,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import { Button, Card, Typography } from '@/components/ui';
|
||||
import { ActionCenter, ACTION_TABS } from './ActionCenter';
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
/*
|
||||
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 { Card, Tag, Tooltip } from '@/components/ui';
|
||||
import { TrendingDown, TrendingUp } from 'lucide-react';
|
||||
import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils';
|
||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
||||
|
||||
export const SectionCard = ({
|
||||
id,
|
||||
@@ -90,7 +72,7 @@ export const ChangeText = ({ cur, prev, t, size = 'xs', showNew = true }) => {
|
||||
<TrendingDown className='w-3 h-3' />
|
||||
)}
|
||||
{up ? '+' : ''}
|
||||
{rate.toFixed(1)}%
|
||||
{formatPercent(rate, 1)}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
/*
|
||||
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 {
|
||||
formatIdReference,
|
||||
formatPercent,
|
||||
toFiniteNumber,
|
||||
} from '../../../helpers/safeDisplay';
|
||||
|
||||
// 企业经营决策报表:口径常量、行动清单派生、要点生成、CSV 导出
|
||||
|
||||
@@ -27,7 +14,8 @@ export const getCnyParams = () => {
|
||||
let usdRate = 1;
|
||||
try {
|
||||
const s = JSON.parse(localStorage.getItem('status') || '{}');
|
||||
usdRate = s?.usd_exchange_rate || 1;
|
||||
const parsedRate = toFiniteNumber(s?.usd_exchange_rate);
|
||||
usdRate = parsedRate !== null && parsedRate > 0 ? parsedRate : 1;
|
||||
} catch (e) {
|
||||
usdRate = 1;
|
||||
}
|
||||
@@ -35,7 +23,7 @@ export const getCnyParams = () => {
|
||||
};
|
||||
|
||||
export const quotaToCny = (quota, { quotaPerUnit, usdRate }) =>
|
||||
((quota || 0) / quotaPerUnit) * usdRate;
|
||||
((toFiniteNumber(quota) ?? 0) / quotaPerUnit) * usdRate;
|
||||
|
||||
export const formatCny = (quota, params, digits = 2) =>
|
||||
`¥${quotaToCny(quota, params).toLocaleString(undefined, {
|
||||
@@ -47,12 +35,22 @@ export const formatCny = (quota, params, digits = 2) =>
|
||||
export const changeRate = (cur, prev) =>
|
||||
prev > 0 ? (((cur || 0) - prev) / prev) * 100 : null;
|
||||
|
||||
export const formatRate = (rate) =>
|
||||
rate === null || rate === undefined
|
||||
export const formatRate = (rate) => {
|
||||
const number = Number(rate);
|
||||
return rate === null || rate === undefined || !Number.isFinite(number)
|
||||
? '—'
|
||||
: `${rate >= 0 ? '+' : ''}${rate.toFixed(1)}%`;
|
||||
: `${number >= 0 ? '+' : ''}${number.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
export const pct = (part, total) => (total > 0 ? (part / total) * 100 : 0);
|
||||
export const pct = (part, total) => {
|
||||
const numerator = Number(part);
|
||||
const denominator = Number(total);
|
||||
return Number.isFinite(numerator) &&
|
||||
Number.isFinite(denominator) &&
|
||||
denominator > 0
|
||||
? (numerator / denominator) * 100
|
||||
: 0;
|
||||
};
|
||||
|
||||
// ─── 时间(报表口径统一为 UTC+8,与浏览器时区无关) ─────────────────
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
@@ -405,11 +403,11 @@ export const deriveFindings = (report, lists, cny, t) => {
|
||||
? t(
|
||||
'头部依赖较高:Top5 企业贡献 {{share}} 的企业消耗,需关注大客户稳定性',
|
||||
{
|
||||
share: `${k.top5_share.toFixed(1)}%`,
|
||||
share: formatPercent(k.top5_share, 1),
|
||||
},
|
||||
)
|
||||
: t('客户结构较分散:Top5 企业贡献 {{share}} 的企业消耗', {
|
||||
share: `${k.top5_share.toFixed(1)}%`,
|
||||
share: formatPercent(k.top5_share, 1),
|
||||
}),
|
||||
target: 'tiers',
|
||||
});
|
||||
@@ -426,7 +424,7 @@ export const deriveFindings = (report, lists, cny, t) => {
|
||||
text: t(
|
||||
'企业成员渗透率 {{rate}},{{count}} 家企业成员活跃率低于 30%,存在增量空间',
|
||||
{
|
||||
rate: `${Math.min(100, penetration).toFixed(1)}%`,
|
||||
rate: formatPercent(Math.min(100, penetration), 1),
|
||||
count: lowPen,
|
||||
},
|
||||
),
|
||||
@@ -467,4 +465,6 @@ export const downloadCsv = (filename, headers, rows) => {
|
||||
};
|
||||
|
||||
export const orgDisplayName = (o, t) =>
|
||||
o.deleted ? `${t('已删除企业')} #${o.org_id}` : o.name || `#${o.org_id}`;
|
||||
o.deleted
|
||||
? `${t('已删除企业')} ${formatIdReference(o.org_id)}`
|
||||
: o.name || formatIdReference(o.org_id);
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { useTranslation } from 'react-i18next';
|
||||
import React from 'react';
|
||||
import { Sparkles } from 'lucide-react';
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
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 { MessageCircle as ActionMessageCircle } from '@/components/common/icons/ActionIcons';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Avatar } from '@/components/ui';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
/*
|
||||
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 { Button } from 'antd';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { isSafePostLoginRedirect } from '../../helpers/data';
|
||||
|
||||
/**
|
||||
* 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。
|
||||
@@ -34,6 +16,12 @@ import { useTranslation } from 'react-i18next';
|
||||
const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const redirect = searchParams.get('redirect');
|
||||
const loginSearch =
|
||||
mode === 'login' && isSafePostLoginRedirect(redirect)
|
||||
? `?${new URLSearchParams({ redirect })}`
|
||||
: '';
|
||||
|
||||
// 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口
|
||||
const tabs =
|
||||
@@ -57,7 +45,7 @@ const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
||||
type={isActive ? 'primary' : 'text'}
|
||||
aria-pressed={isActive}
|
||||
onClick={() => {
|
||||
if (!isActive) navigate(tab.to);
|
||||
if (!isActive) navigate(`${tab.to}${loginSearch}`);
|
||||
}}
|
||||
className='flex-1 font-medium'
|
||||
>
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import React, { lazy, Suspense } from 'react';
|
||||
|
||||
const AgreementModal = lazy(
|
||||
() => import('../common/DocumentRenderer/AgreementModal'),
|
||||
);
|
||||
|
||||
export default function LazyAgreementModal(props) {
|
||||
if (!props.type) return null;
|
||||
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<AgreementModal {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { ArrowRight as ActionArrowRight } from '@/components/common/icons/ActionIcons';
|
||||
import React, {
|
||||
useContext,
|
||||
@@ -72,7 +53,7 @@ import GlassCard from './GlassCard';
|
||||
import AuthCardHeader from './AuthCardHeader';
|
||||
import AuthLoginTabs from './AuthLoginTabs';
|
||||
import AuthDivider from './AuthDivider';
|
||||
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||
import AgreementModal from './LazyAgreementModal';
|
||||
import {
|
||||
isMiniProgramWebView,
|
||||
withMiniProgramLogins,
|
||||
@@ -220,12 +201,17 @@ const LoginForm = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const redirect = searchParams.get('redirect');
|
||||
useEffect(() => {
|
||||
const redirect = searchParams.get('redirect');
|
||||
if (redirect) {
|
||||
savePostLoginRedirect(redirect);
|
||||
}
|
||||
if (searchParams.get('expired')) {
|
||||
savePostLoginRedirect(redirect);
|
||||
}, [redirect]);
|
||||
|
||||
const expiryShown = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!searchParams.get('expired')) {
|
||||
expiryShown.current = false;
|
||||
} else if (!expiryShown.current) {
|
||||
expiryShown.current = true;
|
||||
showError(t('未登录或登录已过期,请重新登录'));
|
||||
const nextParams = new URLSearchParams(searchParams);
|
||||
nextParams.delete('expired');
|
||||
@@ -234,15 +220,15 @@ const LoginForm = () => {
|
||||
}, [searchParams, setSearchParams, t]);
|
||||
|
||||
const finishLogin = useCallback(
|
||||
(data, successMessage) =>
|
||||
(data) =>
|
||||
runLoginFlow({
|
||||
data,
|
||||
userDispatch,
|
||||
navigate,
|
||||
t,
|
||||
successMessage,
|
||||
redirect,
|
||||
}),
|
||||
[navigate, t, userDispatch],
|
||||
[navigate, redirect, t, userDispatch],
|
||||
);
|
||||
|
||||
const onWeChatLoginClicked = () => {
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { useEffectEvent } from '../../hooks/common/useEffectEvent';
|
||||
import React, { useContext, useEffect } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
@@ -55,7 +36,7 @@ const OAuth2Callback = (props) => {
|
||||
|
||||
if (message === 'bind') {
|
||||
showSuccess(t('绑定成功!'));
|
||||
navigate('/console/personal');
|
||||
navigate('/user/center', { replace: true });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +74,7 @@ const OAuth2Callback = (props) => {
|
||||
// 参数缺失直接返回
|
||||
if (!code) {
|
||||
showError(t('未获取到授权码'));
|
||||
navigate('/console/personal');
|
||||
navigate('/user/center', { replace: true });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { Copy as ActionCopy } from '@/components/common/icons/ActionIcons';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
API,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
API,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { ArrowRight as ActionArrowRight } from '@/components/common/icons/ActionIcons';
|
||||
import React, {
|
||||
useContext,
|
||||
@@ -67,7 +48,7 @@ import AuthCardHeader from './AuthCardHeader';
|
||||
import AuthLoginTabs from './AuthLoginTabs';
|
||||
import AuthDivider from './AuthDivider';
|
||||
import { Shield, Smartphone, QrCode } from 'lucide-react';
|
||||
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||
import AgreementModal from './LazyAgreementModal';
|
||||
import {
|
||||
isMiniProgramWebView,
|
||||
withMiniProgramLogins,
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
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 TelegramLoginButton from 'react-telegram-login';
|
||||
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
/*
|
||||
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 { Trans } from 'react-i18next';
|
||||
import { API, showError, showSuccess } from '../../helpers';
|
||||
import { API, showError } from '../../helpers';
|
||||
import { Button, Card, Divider, Form, Typography } from '@/components/ui';
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -51,7 +33,6 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
||||
});
|
||||
|
||||
if (res.data.success) {
|
||||
showSuccess(t('登录成功'));
|
||||
if (onSuccess) {
|
||||
onSuccess(res.data.data);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Button, Empty, Input, Tag, Tree, theme } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Search } from '@/components/common/icons/ActionIcons';
|
||||
|
||||
// 权限授权树(平台角色、套餐、模板、企业角色共用)。nodes 为后端 GrantNode 列表:
|
||||
// { code, parent, type: 'dir'|'menu'|'button', name, sort, sensitive, grantable }。
|
||||
// value 为已勾选的权限编码数组,只会包含 grantable 的节点;grantable=false 的节点只作为祖先展示,不可勾选。
|
||||
//
|
||||
// 联动规则(PRD AC50 / AC62 / AC80):
|
||||
// - 勾选一个节点 = 勾选它和它全部可选后代,并带上可选祖先(后端本来也会补齐祖先);
|
||||
// - 取消一个节点 = 只取消它和它的后代,兄弟不受影响;祖先下已没有任何选中的后代时祖先一并取消;
|
||||
// - 祖先的显示状态由"子树内可选节点是否全部选中"推导:全部选中为勾选,部分选中为半选。
|
||||
// 半选的祖先只提交它自己的编码,不会把未选中的后代带上。
|
||||
|
||||
const TYPE_META = {
|
||||
dir: { color: 'default', label: '目录' },
|
||||
menu: { color: 'blue', label: '菜单' },
|
||||
button: { color: 'green', label: '按钮' },
|
||||
};
|
||||
|
||||
const bySort = (a, b) =>
|
||||
(a.sort || 0) - (b.sort || 0) || a.code.localeCompare(b.code);
|
||||
|
||||
// 由扁平节点建索引:parent(父编码,根为 '')、children(已排序的子编码)、
|
||||
// subtree(子树内可选的编码,含自身)、order(先序遍历的编码)。
|
||||
export const buildPermIndex = (nodes) => {
|
||||
const byCode = new Map();
|
||||
for (const n of nodes || []) byCode.set(n.code, n);
|
||||
const parent = new Map();
|
||||
const childNodes = new Map();
|
||||
for (const n of byCode.values()) {
|
||||
// parent 不在列表里的节点当作根
|
||||
const p =
|
||||
n.parent && n.parent !== n.code && byCode.has(n.parent) ? n.parent : '';
|
||||
parent.set(n.code, p);
|
||||
const list = childNodes.get(p) || [];
|
||||
list.push(n);
|
||||
childNodes.set(p, list);
|
||||
}
|
||||
const children = new Map();
|
||||
for (const [p, list] of childNodes) {
|
||||
children.set(
|
||||
p,
|
||||
list.sort(bySort).map((n) => n.code),
|
||||
);
|
||||
}
|
||||
const subtree = new Map();
|
||||
const order = [];
|
||||
const walk = (code) => {
|
||||
order.push(code);
|
||||
const own = byCode.get(code).grantable ? [code] : [];
|
||||
for (const c of children.get(code) || []) own.push(...walk(c));
|
||||
subtree.set(code, own);
|
||||
return own;
|
||||
};
|
||||
for (const c of children.get('') || []) walk(c);
|
||||
return { byCode, parent, children, subtree, order };
|
||||
};
|
||||
|
||||
// 去掉树里不存在或不可授予的编码(提交它们会被后端拒绝)。
|
||||
// 只认 subtree 里登记过的节点:父链成环而从根走不到的节点不参与勾选。
|
||||
const selectableSet = (index, value) =>
|
||||
new Set(
|
||||
(value || []).filter(
|
||||
(c) => index.subtree.has(c) && index.byCode.get(c).grantable === true,
|
||||
),
|
||||
);
|
||||
|
||||
// 可以提交给后端的勾选结果(已排序):保存前用它过一遍,避免带上树里没有的历史编码
|
||||
export const selectablePerms = (index, value) =>
|
||||
[...selectableSet(index, value)].sort();
|
||||
|
||||
// 各节点的显示状态:checked = 子树内可选节点全部选中;halfChecked = 部分选中
|
||||
export const permCheckState = (index, value) => {
|
||||
const set = selectableSet(index, value);
|
||||
const checked = [];
|
||||
const halfChecked = [];
|
||||
for (const [code, list] of index.subtree) {
|
||||
if (!list.length) continue;
|
||||
let hit = 0;
|
||||
for (const c of list) if (set.has(c)) hit += 1;
|
||||
if (hit === list.length) checked.push(code);
|
||||
else if (hit > 0) halfChecked.push(code);
|
||||
}
|
||||
return { checked, halfChecked };
|
||||
};
|
||||
|
||||
// 点击一个节点后的新勾选结果(已排序)
|
||||
export const togglePerm = (index, value, code) => {
|
||||
const set = selectableSet(index, value);
|
||||
const sub = index.subtree.get(code) || [];
|
||||
if (!sub.length) return [...set].sort();
|
||||
if (sub.every((c) => set.has(c))) {
|
||||
for (const c of sub) set.delete(c);
|
||||
for (let p = index.parent.get(code); p; p = index.parent.get(p)) {
|
||||
if (index.subtree.get(p).some((c) => c !== p && set.has(c))) break;
|
||||
set.delete(p);
|
||||
}
|
||||
} else {
|
||||
for (const c of sub) set.add(c);
|
||||
for (let p = index.parent.get(code); p; p = index.parent.get(p)) {
|
||||
if (index.byCode.get(p).grantable) set.add(p);
|
||||
}
|
||||
}
|
||||
return [...set].sort();
|
||||
};
|
||||
|
||||
// 权限摘要:已选的菜单(附其下已选按钮数)与菜单、按钮总数。用于列表里的"权限摘要"列。
|
||||
export const summarizePerms = (index, perms) => {
|
||||
const set = selectableSet(index, perms);
|
||||
const menus = [];
|
||||
let buttonCount = 0;
|
||||
for (const code of index.order) {
|
||||
if (!set.has(code)) continue;
|
||||
const n = index.byCode.get(code);
|
||||
if (n.type === 'button') {
|
||||
buttonCount += 1;
|
||||
} else if (n.type === 'menu') {
|
||||
const buttons = index.subtree
|
||||
.get(code)
|
||||
.filter(
|
||||
(c) => set.has(c) && index.byCode.get(c).type === 'button',
|
||||
).length;
|
||||
menus.push({ code, name: n.name, buttons });
|
||||
}
|
||||
}
|
||||
return { menus, menuCount: menus.length, buttonCount, total: set.size };
|
||||
};
|
||||
|
||||
const expandableKeys = (index, keep) =>
|
||||
index.order.filter(
|
||||
(c) =>
|
||||
(!keep || keep.has(c)) &&
|
||||
(index.children.get(c) || []).some((k) => !keep || keep.has(k)),
|
||||
);
|
||||
|
||||
// 搜索:保留命中的节点、它的祖先(定位用)和它的整棵子树(方便直接勾选下面的按钮)
|
||||
const matchKeys = (index, keyword) => {
|
||||
const kw = keyword.trim().toLowerCase();
|
||||
if (!kw) return null;
|
||||
const keep = new Set();
|
||||
const addSubtree = (code) => {
|
||||
keep.add(code);
|
||||
for (const c of index.children.get(code) || []) addSubtree(c);
|
||||
};
|
||||
for (const code of index.order) {
|
||||
const n = index.byCode.get(code);
|
||||
if (
|
||||
!(n.name || '').toLowerCase().includes(kw) &&
|
||||
!code.toLowerCase().includes(kw)
|
||||
)
|
||||
continue;
|
||||
addSubtree(code);
|
||||
for (let p = index.parent.get(code); p; p = index.parent.get(p))
|
||||
keep.add(p);
|
||||
}
|
||||
return keep;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {object} props
|
||||
* @param {Array} props.nodes 后端 GrantNode 列表
|
||||
* @param {string[]} [props.value] 已勾选的权限编码
|
||||
* @param {(codes: string[]) => void} [props.onChange] 勾选变化,参数为排序后的编码数组
|
||||
* @param {boolean} [props.disabled] 只读:不可勾选,仍可展开、收起与搜索
|
||||
* @param {number|string} [props.height=480] 树区域的最大高度,超出滚动
|
||||
* @param {boolean} [props.showToolbar=true] 是否显示搜索框与"全部展开 / 全部收起"
|
||||
* @param {boolean} [props.defaultExpandAll=true] 初始是否全部展开(false 时只显示根级节点)
|
||||
* @param {string} [props.className]
|
||||
*/
|
||||
const PermTree = ({
|
||||
nodes,
|
||||
value,
|
||||
onChange,
|
||||
disabled,
|
||||
height = 480,
|
||||
showToolbar = true,
|
||||
defaultExpandAll = true,
|
||||
className,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { token } = theme.useToken();
|
||||
const index = useMemo(() => buildPermIndex(nodes), [nodes]);
|
||||
const [keyword, setKeyword] = useState('');
|
||||
// null = 尚未手动操作,按 defaultExpandAll 取初始值(节点异步到达后仍然生效)
|
||||
const [expandedKeys, setExpandedKeys] = useState(null);
|
||||
// 搜索期间单独记一份展开状态,清空搜索后回到原来的展开状态
|
||||
const [searchExpandedKeys, setSearchExpandedKeys] = useState(null);
|
||||
|
||||
const keep = useMemo(() => matchKeys(index, keyword), [index, keyword]);
|
||||
const allExpandable = useMemo(
|
||||
() => expandableKeys(index, keep),
|
||||
[index, keep],
|
||||
);
|
||||
const checkState = useMemo(
|
||||
() => permCheckState(index, value),
|
||||
[index, value],
|
||||
);
|
||||
|
||||
const treeData = useMemo(() => {
|
||||
const build = (parentCode) =>
|
||||
(index.children.get(parentCode) || [])
|
||||
.filter((code) => !keep || keep.has(code))
|
||||
.map((code) => {
|
||||
const n = index.byCode.get(code);
|
||||
const meta = TYPE_META[n.type];
|
||||
return {
|
||||
key: code,
|
||||
disableCheckbox: disabled || !n.grantable,
|
||||
title: (
|
||||
<span className='inline-flex flex-wrap items-center gap-1'>
|
||||
<span>{n.name}</span>
|
||||
{meta ? (
|
||||
<Tag color={meta.color} style={{ marginInlineEnd: 0 }}>
|
||||
{t(meta.label)}
|
||||
</Tag>
|
||||
) : null}
|
||||
{n.sensitive ? (
|
||||
<Tag color='error' style={{ marginInlineEnd: 0 }}>
|
||||
{t('敏感')}
|
||||
</Tag>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
children: build(code),
|
||||
};
|
||||
});
|
||||
return build('');
|
||||
}, [index, keep, disabled, t]);
|
||||
|
||||
const searching = keep !== null;
|
||||
const currentExpanded = searching
|
||||
? (searchExpandedKeys ?? allExpandable)
|
||||
: (expandedKeys ?? (defaultExpandAll ? allExpandable : []));
|
||||
const setCurrentExpanded = searching
|
||||
? setSearchExpandedKeys
|
||||
: setExpandedKeys;
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
{showToolbar ? (
|
||||
<div className='mb-2 flex flex-wrap items-center gap-2'>
|
||||
<Input
|
||||
allowClear
|
||||
value={keyword}
|
||||
prefix={<Search size={14} />}
|
||||
placeholder={t('搜索权限')}
|
||||
aria-label={t('搜索权限')}
|
||||
style={{ flex: '1 1 180px', minWidth: 0 }}
|
||||
onChange={(e) => {
|
||||
setKeyword(e.target.value);
|
||||
// 每次改关键字都重新展开全部命中路径
|
||||
setSearchExpandedKeys(null);
|
||||
}}
|
||||
/>
|
||||
<Button onClick={() => setCurrentExpanded(allExpandable)}>
|
||||
{t('全部展开')}
|
||||
</Button>
|
||||
<Button onClick={() => setCurrentExpanded([])}>
|
||||
{t('全部收起')}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
<div
|
||||
style={{
|
||||
maxHeight: height,
|
||||
overflow: 'auto',
|
||||
padding: 8,
|
||||
border: `1px solid ${token.colorBorderSecondary}`,
|
||||
borderRadius: token.borderRadius,
|
||||
}}
|
||||
>
|
||||
{treeData.length ? (
|
||||
<Tree
|
||||
checkable
|
||||
// 联动与半选由本组件按"可选节点"自行计算;antd 自带的联动会把已保存的祖先当成全选
|
||||
checkStrictly
|
||||
selectable={false}
|
||||
treeData={treeData}
|
||||
checkedKeys={checkState}
|
||||
expandedKeys={currentExpanded}
|
||||
autoExpandParent={false}
|
||||
onExpand={(keys) => setCurrentExpanded(keys)}
|
||||
onCheck={(_, info) =>
|
||||
onChange?.(togglePerm(index, value, info.node.key))
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={searching ? t('没有匹配的权限') : t('暂无数据')}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PermTree;
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
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, { Suspense, lazy, useContext } from 'react';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import './CinematicTokenFactory.css';
|
||||
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 i18next from 'i18next';
|
||||
import React from 'react';
|
||||
import Loading from './ui/Loading';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 { X as ActionX } from '@/components/common/icons/ActionIcons';
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import { Modal } from '@/components/ui';
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 {
|
||||
ChevronUp as ActionChevronUp,
|
||||
ArrowLeft as ActionArrowLeft,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 {
|
||||
OpenAI,
|
||||
Claude,
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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 assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
|
||||
const MapleBackground = () => {
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { Select, Spin, Typography, Empty, Tag, Tooltip } from '@/components/ui';
|
||||
import { Lock } from 'lucide-react';
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
/*
|
||||
* PageGuide —— 企业控制台页面级「使用指引」三层体系的可复用实现。
|
||||
*
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user