Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 628fa323a8 | |||
| f9daeacaf9 | |||
| a57aae3043 | |||
| dfa5c1edd6 | |||
| 92380ebab6 | |||
| e7a7541b2b | |||
| ef93825c07 | |||
| d563fe7c76 | |||
| 34a7eca5c7 | |||
| 93128a77d3 | |||
| 1a943465ec | |||
| 7821b0198a | |||
| 0eb8f4d476 | |||
| 53821db673 | |||
| 85854f2f56 | |||
| 1ca241ee57 | |||
| 428c3dc310 | |||
| 9704706a00 | |||
| 3297cca457 | |||
| 32be8094dc | |||
| 0759e1a58c | |||
| 7364edd68c | |||
| 6ea8a0f7c2 | |||
| 43e7fbc20e | |||
| d224d5b6fa | |||
| d46926f334 | |||
| e3b82b981a | |||
| 5713d541b0 | |||
| 6ad95e2baa | |||
| cddf574498 | |||
| 72bec4f8f1 | |||
| d58e468969 | |||
| b80afd273c | |||
| bc6af74e9e | |||
| e6c41e7587 | |||
| 472e534fe1 | |||
| 7dc1981f84 | |||
| 815194a2a9 | |||
| a9c31708c3 | |||
| 21d64e43ce | |||
| 5bd2b3405d | |||
| 1bf13bc226 | |||
| 7b80c3bbb3 | |||
| 8a7a3b45ff | |||
| 599966060f | |||
| e74008239d | |||
| 9b1e806489 | |||
| 82a56092bc | |||
| d35330d530 | |||
| 89dfff96df | |||
| a5215dc3fd | |||
| e2b96dc503 |
@@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"allow": ["Bash(go build:*)"]
|
"allow": ["Bash(go build:*)"]
|
||||||
},
|
}
|
||||||
"$schema": "https://json.schemastore.org/claude-code-settings.json",
|
}
|
||||||
"promptCacheTtl": "1h"
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
# Loaded by npm run dev. Override locally in .env.development.local.
|
# Loaded by npm run dev. Override locally in .env.development.local.
|
||||||
# Public configuration only; VITE_* values are exposed to the browser.
|
# Public configuration only; VITE_* values are exposed to the browser.
|
||||||
VITE_REACT_APP_SERVER_URL=
|
VITE_REACT_APP_SERVER_URL=
|
||||||
VITE_CLOUD_BRAIN_UI_ENABLED=true
|
VITE_CLOUD_BRAIN_UI_ENABLED=false
|
||||||
|
|
||||||
# Vite development proxy only. Keep the browser URL empty to use this proxy.
|
# Vite development proxy only. Keep the browser URL empty to use this proxy.
|
||||||
DEV_PROXY_TARGET=http://134.175.227.134:13000
|
DEV_PROXY_TARGET=http://134.175.227.134:13000
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
UI_ORG_NAME=测试企业1
|
|
||||||
UI_ORG_USER=test111
|
|
||||||
UI_ORG_PASS=2uT7anlhzR5w
|
|
||||||
UI_PERSONAL_USER=test222
|
|
||||||
UI_PERSONAL_PASS=12345678
|
|
||||||
UI_VISUAL_OFFSCREEN=1
|
|
||||||
UI_ADMIN_USER=ltadmin
|
|
||||||
UI_ADMIN_PASS=DoWtIMTli7njHYQeCNaR
|
|
||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
+7
-5
@@ -4,8 +4,6 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
bun.lock
|
|
||||||
bun.lockb
|
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
@@ -14,8 +12,11 @@ bun.lockb
|
|||||||
|
|
||||||
# Local acceptance tests, browser sessions, and reports
|
# Local acceptance tests, browser sessions, and reports
|
||||||
/e2e/
|
/e2e/
|
||||||
/.e2e/
|
|
||||||
/tests/
|
/tests/
|
||||||
|
*.test.*
|
||||||
|
*.spec.*
|
||||||
|
# Maintained unit regressions are source; local acceptance suites stay ignored.
|
||||||
|
!test/unit/*.test.js
|
||||||
/playwright/.auth/
|
/playwright/.auth/
|
||||||
/playwright-report/
|
/playwright-report/
|
||||||
/test-results/
|
/test-results/
|
||||||
@@ -27,7 +28,6 @@ bun.lockb
|
|||||||
/build
|
/build
|
||||||
/dist/
|
/dist/
|
||||||
/dist-ssr/
|
/dist-ssr/
|
||||||
vercel.json
|
|
||||||
|
|
||||||
# tool caches and temporary files
|
# tool caches and temporary files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
@@ -62,7 +62,9 @@ yarn-debug.log*
|
|||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
.idea
|
.idea
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
# i18n 批次中间产物(可由 scripts/i18n_kt_batches.cjs 重新生成,勿入库)
|
# i18n 批次中间产物(可由 scripts/i18n_kt_batches.cjs 重新生成,勿入库)
|
||||||
scripts/kt_batches/
|
scripts/kt_batches/
|
||||||
scripts/kt_out/
|
scripts/kt_out/
|
||||||
|
|
||||||
|
# 本地 Playwright 登录凭据(GLOBAL_UI_BASELINE §6:未跟踪且已忽略,禁止提交)
|
||||||
|
/.env.playwright.local
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
- **技术栈**:React 18.3、react-router-dom 6.30、Vite 5.4,JS / JSX(未启用 TypeScript);antd 6.7.0 + @ant-design/icons 6.3.4(精确锁定);axios、i18next、Tailwind 3、lucide-react;专用组件 VChart、XYFlow、Quill、Joyride。
|
- **技术栈**:React 18.3、react-router-dom 6.30、Vite 5.4,JS / JSX(未启用 TypeScript);antd 6.7.0 + @ant-design/icons 6.3.4(精确锁定);axios、i18next、Tailwind 3、lucide-react;专用组件 VChart、XYFlow、Quill、Joyride。
|
||||||
- **环境**:`package.json` 要求 Node ≥ 22.13.0、npm ≥ 10,`packageManager` 指定 npm 10.9.9;依赖范围以 `package.json`、解析版本以 `package-lock.json` 为准,安装使用 `npm ci`,升级依赖时同步 lock。
|
- **环境**:`package.json` 要求 Node ≥ 22.13.0、npm ≥ 10,`packageManager` 指定 npm 10.9.9;依赖范围以 `package.json`、解析版本以 `package-lock.json` 为准,安装使用 `npm ci`,升级依赖时同步 lock。
|
||||||
- **入口与别名**:`@` → `src`;`index.html` → `src/index.jsx` → `src/components/layout/PageLayout.jsx` → `src/App.jsx`(路由、懒加载、守卫)。开发服务按全局基线第 7.1 节结合项目目录、启动日志和监听进程发现,优先复用已有服务。
|
- **入口与别名**:`@` → `src`;`index.html` → `src/index.jsx` → `src/components/layout/PageLayout.jsx` → `src/App.jsx`(路由、懒加载、守卫)。开发地址以 `dev.log` 最后一个 `Local:` 为准。
|
||||||
- **三个中心**:控制台 `/console/*`;企业中心 `/org/*`(子路由在 `src/pages/Organization/index.jsx`);用户中心 `/user-center/*`。
|
- **三个中心**:控制台 `/console/*`;企业中心 `/org/*`(子路由在 `src/pages/Organization/index.jsx`);用户中心 `/user-center/*`。
|
||||||
- **请求**:`src/helpers/api.js` 的 `API`(统一报错、GET 去重、`/api/org/*` 自动带 `X-Org-Id`),响应 `{ success, message, data }`。
|
- **请求**:`src/helpers/api.js` 的 `API`(统一报错、GET 去重、`/api/org/*` 自动带 `X-Org-Id`),响应 `{ success, message, data }`。
|
||||||
- **状态**:页面状态放模块 hook;全局只用 `src/context/{User,Status,Theme,Org,Playground}`。
|
- **状态**:页面状态放模块 hook;全局只用 `src/context/{User,Status,Theme,Org,Playground}`。
|
||||||
@@ -60,7 +60,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- **样式**:不新增 ConfigProvider、主题状态或存储 key;颜色只来自 token 或页面变量,JSX 不写十六进制,不用全局 `!important`。
|
- **样式**:不新增 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。
|
- **图标与依赖**:按钮图标从 `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。
|
- **请求**:只用 `API`,参数用 `params`,先判 `success`;分页 `p` 从 1 开始、`page_size` ≤ 100;`catch` 不重复提示 AxiosError;`finally` 回收 loading。
|
||||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;不重复添加通用长版权文件头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;新 `.js` / `.jsx` 带 AGPL 许可证头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||||
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
||||||
|
|
||||||
## 5. 目录规则
|
## 5. 目录规则
|
||||||
@@ -89,7 +89,6 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
| 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` |
|
| 企业中心 / 控制台 | `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/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` |
|
||||||
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
||||||
| UI 审查清单 | `docs/ui-review-checklist.md` |
|
|
||||||
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
||||||
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
||||||
|
|
||||||
@@ -103,8 +102,8 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
## 7. 开发、验收与交付
|
## 7. 开发、验收与交付
|
||||||
|
|
||||||
1. **改前**:读相关代码;UI 任务先按 `GLOBAL_UI_BASELINE.md` 第 6 节真实 UI 登录;通用测试指令按该节自动判断验收范围、企业 / 普通个人 / 超管账号并加载现有本地配置,无需用户重复指定登录类型。
|
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` 检测前台)。
|
2. **服务与浏览器**:复用已运行服务,Base URL 只取 `dev.log` 最后一个 `Local:`;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 与 360×800(最小必测视口);正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851;正常、空数据、失败、校验、重复提交;只读验收的非 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/`。
|
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`。
|
5. **证据与交付**:截图、trace、storageState、报告只写 Git 忽略目录;说明完成范围、实际验证结果与未覆盖项,未验证的不写成通过;在 `docs/CHANGELOG.md` 追加条目,改动脚本、环境变量或目录约定时同步更新 `README.md`。
|
||||||
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
||||||
@@ -114,7 +113,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- 无设计依据的渐变、玻璃、发光、浮起与动效;生成插画。
|
- 无设计依据的渐变、玻璃、发光、浮起与动效;生成插画。
|
||||||
- 伪造线上数据、开放隐藏菜单、绕过真实 UI 登录;点击真实支付、购买、升级、删除账户的确认按钮。
|
- 伪造线上数据、开放隐藏菜单、绕过真实 UI 登录;点击真实支付、购买、升级、删除账户的确认按钮。
|
||||||
- 删除或跳过已受跟踪的测试;隐藏失败;把模拟结果或本地截图基线写成真实通过或像素一致。
|
- 删除或跳过已受跟踪的测试;隐藏失败;把模拟结果或本地截图基线写成真实通过或像素一致。
|
||||||
- 对外输出凭据值,或将凭据、storageState、截图与报告提交到 Git(仅 `.env.playwright.local` 中的测试账号按用户约定允许入库);本地脱敏报告按第 7 节交付。
|
- 对外输出凭据值,或将凭据、storageState、截图与报告提交到 Git;本地脱敏报告按第 7 节交付。
|
||||||
|
|
||||||
## 9. 维护
|
## 9. 维护
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
||||||
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
||||||
|
|
||||||
> 规范版本:v3.8 · 更新:2026-11-24
|
> 规范版本:v3.4 · 更新:2026-11-17
|
||||||
|
|
||||||
## 10. 工具差异(本节允许不同)
|
## 10. 工具差异(本节允许不同)
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
- **技术栈**:React 18.3、react-router-dom 6.30、Vite 5.4,JS / JSX(未启用 TypeScript);antd 6.7.0 + @ant-design/icons 6.3.4(精确锁定);axios、i18next、Tailwind 3、lucide-react;专用组件 VChart、XYFlow、Quill、Joyride。
|
- **技术栈**:React 18.3、react-router-dom 6.30、Vite 5.4,JS / JSX(未启用 TypeScript);antd 6.7.0 + @ant-design/icons 6.3.4(精确锁定);axios、i18next、Tailwind 3、lucide-react;专用组件 VChart、XYFlow、Quill、Joyride。
|
||||||
- **环境**:`package.json` 要求 Node ≥ 22.13.0、npm ≥ 10,`packageManager` 指定 npm 10.9.9;依赖范围以 `package.json`、解析版本以 `package-lock.json` 为准,安装使用 `npm ci`,升级依赖时同步 lock。
|
- **环境**:`package.json` 要求 Node ≥ 22.13.0、npm ≥ 10,`packageManager` 指定 npm 10.9.9;依赖范围以 `package.json`、解析版本以 `package-lock.json` 为准,安装使用 `npm ci`,升级依赖时同步 lock。
|
||||||
- **入口与别名**:`@` → `src`;`index.html` → `src/index.jsx` → `src/components/layout/PageLayout.jsx` → `src/App.jsx`(路由、懒加载、守卫)。开发服务按全局基线第 7.1 节结合项目目录、启动日志和监听进程发现,优先复用已有服务。
|
- **入口与别名**:`@` → `src`;`index.html` → `src/index.jsx` → `src/components/layout/PageLayout.jsx` → `src/App.jsx`(路由、懒加载、守卫)。开发地址以 `dev.log` 最后一个 `Local:` 为准。
|
||||||
- **三个中心**:控制台 `/console/*`;企业中心 `/org/*`(子路由在 `src/pages/Organization/index.jsx`);用户中心 `/user-center/*`。
|
- **三个中心**:控制台 `/console/*`;企业中心 `/org/*`(子路由在 `src/pages/Organization/index.jsx`);用户中心 `/user-center/*`。
|
||||||
- **请求**:`src/helpers/api.js` 的 `API`(统一报错、GET 去重、`/api/org/*` 自动带 `X-Org-Id`),响应 `{ success, message, data }`。
|
- **请求**:`src/helpers/api.js` 的 `API`(统一报错、GET 去重、`/api/org/*` 自动带 `X-Org-Id`),响应 `{ success, message, data }`。
|
||||||
- **状态**:页面状态放模块 hook;全局只用 `src/context/{User,Status,Theme,Org,Playground}`。
|
- **状态**:页面状态放模块 hook;全局只用 `src/context/{User,Status,Theme,Org,Playground}`。
|
||||||
@@ -60,7 +60,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- **样式**:不新增 ConfigProvider、主题状态或存储 key;颜色只来自 token 或页面变量,JSX 不写十六进制,不用全局 `!important`。
|
- **样式**:不新增 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。
|
- **图标与依赖**:按钮图标从 `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。
|
- **请求**:只用 `API`,参数用 `params`,先判 `success`;分页 `p` 从 1 开始、`page_size` ≤ 100;`catch` 不重复提示 AxiosError;`finally` 回收 loading。
|
||||||
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;不重复添加通用长版权文件头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
- **命名与文件**:状态用 `items`、`total`、`page`、`pageSize`、`loading`、`submitting`、`editingRecord`、`drawerOpen`;新 `.js` / `.jsx` 带 AGPL 许可证头;入库单测放 `test/unit/`;新文案用 `t('中文原文')` 并补齐 9 个语言包。
|
||||||
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
- **可访问性**:交互元素可键盘操作且焦点可见;纯图标按钮加 `aria-label`;状态不只靠颜色表达;动效遵守 `prefers-reduced-motion`。
|
||||||
|
|
||||||
## 5. 目录规则
|
## 5. 目录规则
|
||||||
@@ -89,7 +89,6 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
| 企业中心 / 控制台 | `docs/ui/ORG_CENTER_SPEC.md` / `docs/ui/CONSOLE_SPEC.md` |
|
| 企业中心 / 控制台 | `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/MODEL_MARKET_SPEC.md` / `docs/ui/SKILL_MARKET_SPEC.md` |
|
||||||
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
| 表格列设置 | `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md` |
|
||||||
| UI 审查清单 | `docs/ui-review-checklist.md` |
|
|
||||||
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
| 历史改动与回滚 | `docs/CHANGELOG.md` |
|
||||||
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
| Windows 命令、代码风格与提交规范 | `docs/standards/DEV_STANDARDS.md` 第 12 节 |
|
||||||
|
|
||||||
@@ -103,8 +102,8 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
## 7. 开发、验收与交付
|
## 7. 开发、验收与交付
|
||||||
|
|
||||||
1. **改前**:读相关代码;UI 任务先按 `GLOBAL_UI_BASELINE.md` 第 6 节真实 UI 登录;通用测试指令按该节自动判断验收范围、企业 / 普通个人 / 超管账号并加载现有本地配置,无需用户重复指定登录类型。
|
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` 检测前台)。
|
2. **服务与浏览器**:复用已运行服务,Base URL 只取 `dev.log` 最后一个 `Local:`;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 与 360×800(最小必测视口);正常、空数据、失败、校验、重复提交;只读验收的非 GET `/api/` 请求为 0;模拟与真实分开记录。配置默认值、服务复用与规范矩阵的差异见基线第 7.1 节,不能用默认 runner 结果替代完整验收。
|
3. **覆盖**:UI 规范验收为浅深主题 × 桌面 1920×1000 / 移动 393×851;正常、空数据、失败、校验、重复提交;只读验收的非 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/`。
|
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`。
|
5. **证据与交付**:截图、trace、storageState、报告只写 Git 忽略目录;说明完成范围、实际验证结果与未覆盖项,未验证的不写成通过;在 `docs/CHANGELOG.md` 追加条目,改动脚本、环境变量或目录约定时同步更新 `README.md`。
|
||||||
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
6. **提交**:授权按第 0 节,格式、检查与暂存边界见开发规范第 12.2 节。
|
||||||
@@ -114,7 +113,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- 无设计依据的渐变、玻璃、发光、浮起与动效;生成插画。
|
- 无设计依据的渐变、玻璃、发光、浮起与动效;生成插画。
|
||||||
- 伪造线上数据、开放隐藏菜单、绕过真实 UI 登录;点击真实支付、购买、升级、删除账户的确认按钮。
|
- 伪造线上数据、开放隐藏菜单、绕过真实 UI 登录;点击真实支付、购买、升级、删除账户的确认按钮。
|
||||||
- 删除或跳过已受跟踪的测试;隐藏失败;把模拟结果或本地截图基线写成真实通过或像素一致。
|
- 删除或跳过已受跟踪的测试;隐藏失败;把模拟结果或本地截图基线写成真实通过或像素一致。
|
||||||
- 对外输出凭据值,或将凭据、storageState、截图与报告提交到 Git(仅 `.env.playwright.local` 中的测试账号按用户约定允许入库);本地脱敏报告按第 7 节交付。
|
- 对外输出凭据值,或将凭据、storageState、截图与报告提交到 Git;本地脱敏报告按第 7 节交付。
|
||||||
|
|
||||||
## 9. 维护
|
## 9. 维护
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ Windows 执行命令前按开发规范第 12.3 节设置 UTF-8;使用 `npm.cmd
|
|||||||
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
- 新规则先写入对应 `docs/` 文档,再在第 6 节加索引;改动只动相关段落,更新本节版本与日期。
|
||||||
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
- 文档的新增、调整、删除按 `docs/README.md` 的“阅读与维护”执行;删除与重命名需用户确认清单。
|
||||||
|
|
||||||
> 规范版本:v3.8 · 更新:2026-11-24
|
> 规范版本:v3.4 · 更新:2026-11-17
|
||||||
|
|
||||||
## 10. 工具差异(本节允许不同)
|
## 10. 工具差异(本节允许不同)
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ Monkey AI Web 是从总仓库 `weiyuan` 分支独立出来的前端工程,包
|
|||||||
|
|
||||||
环境要求:Node.js ≥ 22.13.0,npm ≥ 10(`packageManager` 为 npm 10.9.9)。统一使用 npm,不要用 Bun 或 Yarn 生成其他锁文件。
|
环境要求:Node.js ≥ 22.13.0,npm ≥ 10(`packageManager` 为 npm 10.9.9)。统一使用 npm,不要用 Bun 或 Yarn 生成其他锁文件。
|
||||||
|
|
||||||
仓库仅维护 `package-lock.json`,并忽略 `bun.lock` / `bun.lockb`。本地与 CI 使用 `npm ci` 安装依赖、`npm run dev` 启动开发服务、`npm run build` 构建。
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone --branch weiyuan https://git.weytoken.com/qiubs/monkey-ai-web.git
|
git clone --branch weiyuan https://git.weytoken.com/qiubs/monkey-ai-web.git
|
||||||
cd monkey-ai-web
|
cd monkey-ai-web
|
||||||
@@ -35,7 +33,7 @@ npm ci
|
|||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
开发服务默认监听 `0.0.0.0`,端口为 5174,支持访问本机地址和局域网 IP。端口被占用时 Vite 自动顺延,以终端输出的 `Local:` 和 `Network:` 地址为准。开发服务禁用项目未使用的 `import.meta.glob` 转换,普通动态导入和热更新照常使用。需要供验收脚本读取地址时,把输出重定向到 `dev.log`(如 `nohup npm run dev > dev.log 2>&1 &`)。
|
开发服务监听 `0.0.0.0`,默认端口 5174,被占用时 Vite 自动顺延,以终端输出的 `Local:` 地址为准。需要供验收脚本读取地址时,把输出重定向到 `dev.log`(如 `nohup npm run dev > dev.log 2>&1 &`)。
|
||||||
|
|
||||||
| 命令 | 模式 | 自动加载的配置文件 |
|
| 命令 | 模式 | 自动加载的配置文件 |
|
||||||
| ----------------- | ----------- | ---------------------------------- |
|
| ----------------- | ----------- | ---------------------------------- |
|
||||||
@@ -55,7 +53,7 @@ npm run dev
|
|||||||
/api /v1 /v1beta /mj /pg /dashboard /kling /jimeng /suno
|
/api /v1 /v1beta /mj /pg /dashboard /kling /jimeng /suno
|
||||||
```
|
```
|
||||||
|
|
||||||
切换联调后端时修改 `.env.development.local` 中的 `DEV_PROXY_TARGET` 并重启服务;该变量只供 Vite 代理使用,不会暴露给浏览器。生产环境需由 Nginx 或网关配置同源反向代理,Vite 开发代理不会进入生产产物。
|
切换联调后端时修改 `.env.development.local` 中的 `DEV_PROXY_TARGET` 并重启服务;该变量只供 Vite 代理使用,不会暴露给浏览器。生产环境需由 Nginx 或网关配置同源反向代理,`package.json` 中的 `proxy` 字段不生效。
|
||||||
|
|
||||||
### 可选:直接访问独立后端域名
|
### 可选:直接访问独立后端域名
|
||||||
|
|
||||||
@@ -67,7 +65,7 @@ npm run dev
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `DEV_PROXY_TARGET` | 开发代理的后端地址(仅 Vite 使用) |
|
| `DEV_PROXY_TARGET` | 开发代理的后端地址(仅 Vite 使用) |
|
||||||
| `VITE_REACT_APP_SERVER_URL` | 浏览器直连的后端根地址,留空为同源 |
|
| `VITE_REACT_APP_SERVER_URL` | 浏览器直连的后端根地址,留空为同源 |
|
||||||
| `VITE_CLOUD_BRAIN_UI_ENABLED` | 云脑入口与路由开关,开发环境默认开启,生产环境默认关闭 |
|
| `VITE_CLOUD_BRAIN_UI_ENABLED` | 云脑入口与路由开关,默认关闭 |
|
||||||
| `VITE_SKILL_MARKET_MOCK` | 设为 `true` 时技能超市进入本地演示模式;默认不设置 |
|
| `VITE_SKILL_MARKET_MOCK` | 设为 `true` 时技能超市进入本地演示模式;默认不设置 |
|
||||||
| `VITE_UMAMI_WEBSITE_ID`、`VITE_UMAMI_SCRIPT_URL` | Umami 统计,ID 留空则不注入脚本 |
|
| `VITE_UMAMI_WEBSITE_ID`、`VITE_UMAMI_SCRIPT_URL` | Umami 统计,ID 留空则不注入脚本 |
|
||||||
| `VITE_GOOGLE_ANALYTICS_ID` | Google Analytics,留空则不注入 |
|
| `VITE_GOOGLE_ANALYTICS_ID` | Google Analytics,留空则不注入 |
|
||||||
@@ -81,7 +79,6 @@ monkey-ai-web/
|
|||||||
├── docs/ # 开发与组件规范、页面 UI 规范、变更记录(入口 docs/README.md)
|
├── docs/ # 开发与组件规范、页面 UI 规范、变更记录(入口 docs/README.md)
|
||||||
├── public/ # 原样复制到产物的静态资源
|
├── public/ # 原样复制到产物的静态资源
|
||||||
├── scripts/ # 开发启动、单测发现、UI 依赖审计、品牌图标生成、i18n 辅助脚本
|
├── scripts/ # 开发启动、单测发现、UI 依赖审计、品牌图标生成、i18n 辅助脚本
|
||||||
│ └── vite/ # 自定义 Vite 插件:legacy-css-layers.js 提供旧浏览器 @layer 样式兜底
|
|
||||||
├── src/
|
├── src/
|
||||||
│ ├── index.jsx # React 挂载、语言初始化、全局 Provider
|
│ ├── index.jsx # React 挂载、语言初始化、全局 Provider
|
||||||
│ ├── App.jsx # 路由、懒加载、访问守卫
|
│ ├── App.jsx # 路由、懒加载、访问守卫
|
||||||
@@ -135,6 +132,7 @@ monkey-ai-web/
|
|||||||
- **路由与权限**:在 `src/App.jsx` 注册路由,用 `PrivateRoute`、`AdminRoute`(role ≥ 10)、`RootRoute`(role ≥ 100)守卫;企业中心子路由在 `src/pages/Organization/index.jsx`。部分模块的可见性来自 `/api/status`,不能只靠隐藏菜单控制权限。
|
- **路由与权限**:在 `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` 导入。页面改动需检查浅色、深色与窄屏。
|
- **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` 尚未登记。
|
- **国际化**:文案写 `t('中文原文')`,新 key 补齐 `src/i18n/locales/` 下 9 个语言包;运行时开放语言以 `src/i18n/catalog.js` 为准(简中、繁中、英、日、韩、越、泰),`fr.json`、`ru.json` 尚未登记。
|
||||||
|
- **文件头**:每个 `.js` / `.jsx` 顶部须带 AGPL 许可证注释(ESLint 强制),参考相邻文件。
|
||||||
|
|
||||||
## 6. 常用命令与提交检查
|
## 6. 常用命令与提交检查
|
||||||
|
|
||||||
@@ -142,12 +140,11 @@ monkey-ai-web/
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `npm run dev` | 启动开发服务 |
|
| `npm run dev` | 启动开发服务 |
|
||||||
| `npm run build` | 生产构建,输出 `dist/` |
|
| `npm run build` | 生产构建,输出 `dist/` |
|
||||||
| `npm run verify:build -- <产物目录> --startup` | 校验静态入口、首屏 JS gzip 预算和按需加载边界;产物须用 `--manifest` 生成 |
|
|
||||||
| `npm run preview` | 本地预览构建结果(默认端口 4173) |
|
| `npm run preview` | 本地预览构建结果(默认端口 4173) |
|
||||||
| `npm test -- --test-concurrency=1` | 串行运行单测(扫描 `src/`、`tests/`、`test/unit/`;新增共享单测放 `test/unit/`) |
|
| `npm test -- --test-concurrency=1` | 串行运行单测(扫描 `src/`、`tests/`、`test/unit/`) |
|
||||||
| `npm run eslint` / `npm run eslint:fix` | ESLint 检查(零警告门禁)/ 自动修复 |
|
| `npm run eslint` / `npm run eslint:fix` | ESLint 检查(零警告门禁)/ 自动修复 |
|
||||||
| `npm run lint` / `npm run lint:fix` | Prettier 检查 / 全仓格式化 |
|
| `npm run lint` / `npm run lint:fix` | Prettier 检查 / 全仓格式化 |
|
||||||
| `npm run check:ui` | 审计应用源码、脚本、单测和根目录 JS 配置中的旧 UI 库引用,以及依赖声明、锁文件和品牌图标资产 SHA-256 |
|
| `npm run check:ui` | UI 依赖、完整 lock 图与品牌图标资产 hash 审计 |
|
||||||
| `npm run check` | 依次执行 `check:ui`、ESLint、单测与生产构建,任一步失败即停止 |
|
| `npm run check` | 依次执行 `check:ui`、ESLint、单测与生产构建,任一步失败即停止 |
|
||||||
| `npm run vendor:icons` | 重新生成品牌图标资产 |
|
| `npm run vendor:icons` | 重新生成品牌图标资产 |
|
||||||
| `npm run test:e2e` / `test:e2e:headed` / `test:e2e:report` | Playwright 验收 / 有头运行 / 查看报告 |
|
| `npm run test:e2e` / `test:e2e:headed` / `test:e2e:report` | Playwright 验收 / 有头运行 / 查看报告 |
|
||||||
@@ -159,9 +156,7 @@ monkey-ai-web/
|
|||||||
|
|
||||||
### 本地 Playwright 登录配置
|
### 本地 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 ls-files -- .env.playwright.local` 确认未跟踪(应无输出),再用 `git check-ignore -- .env.playwright.local` 确认已忽略(应输出路径)。已跟踪文件不会因新增忽略规则而解除跟踪;检查不满足时先记录风险,跟踪与历史处置另行授权,不向该文件写入真实凭据。账号密码不写入脚本或提交。运行时由 Node 加载到环境变量:
|
||||||
|
|
||||||
本机自动化登录入口为 `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
|
```powershell
|
||||||
node --env-file=.env.playwright.local e2e/auth-login/run.mjs
|
node --env-file=.env.playwright.local e2e/auth-login/run.mjs
|
||||||
@@ -169,21 +164,20 @@ node --env-file=.env.playwright.local e2e/auth-login/run.mjs
|
|||||||
|
|
||||||
收到通用测试指令时,代理按 `docs/ui/GLOBAL_UI_BASELINE.md` 第 6 节自动判断受影响页面与账号类型,选择登录流程和脚本参数,无需用户重复说明个人或企业登录。手工运行脚本时,超管个人登录单独使用 `UI_ADMIN_USER` / `UI_ADMIN_PASS`,添加 `--admin` 选择超管账号,默认使用普通个人账号。仅执行个人端阶段可添加 `--personal-only`,例如 `node --env-file=.env.playwright.local e2e/auth-login/run.mjs --personal-only --admin`。超管同样通过 `/login` 的真实 UI 登录,不绕过权限校验。
|
收到通用测试指令时,代理按 `docs/ui/GLOBAL_UI_BASELINE.md` 第 6 节自动判断受影响页面与账号类型,选择登录流程和脚本参数,无需用户重复说明个人或企业登录。手工运行脚本时,超管个人登录单独使用 `UI_ADMIN_USER` / `UI_ADMIN_PASS`,添加 `--admin` 选择超管账号,默认使用普通个人账号。仅执行个人端阶段可添加 `--personal-only`,例如 `node --env-file=.env.playwright.local e2e/auth-login/run.mjs --personal-only --admin`。超管同样通过 `/login` 的真实 UI 登录,不绕过权限校验。
|
||||||
|
|
||||||
测试先通过项目目录、启动日志与监听进程查找并验证已有开发服务;历史日志中的失效地址不能作为新启服务的依据。仅确认本项目服务不存在时才启动,结束时只清理本次启动的进程。项目 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 节。
|
脚本从 `dev.log` 最后一个 `Local:` 提取并验证系统地址,使用本机 Chrome 离屏串行执行企业 A/B 状态判定、真实 UI 登录、后台主体断言、个人端全新 Context 登录和 UI 退出。企业 A 路径先填写企业名称并点击“下一步”,B 路径直接填写登录名和密码;不可覆盖的路径单独记录。后续搜索按钮验收拦截非 GET 写请求;截图、脱敏失败记录与供后续用例复用的 storageState 保存在 `report/auth-login-<时间>/`,均为本地忽略产物。storageState 含会话凭据,不上传、不提交;登录规则见 `docs/ui/GLOBAL_UI_BASELINE.md` 第 6 节。
|
||||||
|
|
||||||
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-工具)。
|
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: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:extended` | 全部 8 视口;也可设置 `PW_EXTENDED_LAYOUT=1` |
|
||||||
| `npm run test:e2e:dist` | 验证已有静态产物并严格启动 4176;不自动构建 |
|
| `npm run test:e2e:dist` | 验证已有静态产物并严格启动 4176;不自动构建 |
|
||||||
| `npm run test:acceptance -- <参数>` | 串行单测、临时目录构建、产物校验、强制 local-dist/4176 测试 |
|
| `npm run test:acceptance -- <参数>` | 串行单测、临时目录构建、产物校验、强制 local-dist/4176 测试 |
|
||||||
| `npm run test:e2e:environment` | 隔离验证 8 视口、手机 UA/触摸/DPR、CSS 截图;不代表业务验收 |
|
| `npm run test:e2e:environment` | 隔离验证 8 视口、手机 UA/触摸/DPR、CSS 截图;不代表业务验收 |
|
||||||
| `npm run test:e2e:report` | 打开最新完整 HTML 报告;仅人工使用 |
|
| `npm run test:e2e:report` | 打开最新完整 HTML 报告;仅人工使用 |
|
||||||
| `PW_WORKERS` | 默认 1,只接受正安全整数;保留串行优先策略 |
|
| `PW_WORKERS` | 默认 1,只接受正安全整数;保留串行优先策略 |
|
||||||
| `PW_TARGET` / `PW_BASE_URL` | 未指定时优先自动发现并复用开发服务,确认不存在后默认 local-dev / `http://127.0.0.1:4176/`;remote 必填 URL |
|
| `PW_TARGET` / `PW_BASE_URL` | 默认 local-dev / `http://127.0.0.1:4176/`;remote 必填 URL |
|
||||||
| `PW_VIDEO` / `PW_REQUIRE_ALL` | 默认 0;开启失败保留视频 / 全部通过约束 |
|
| `PW_VIDEO` / `PW_REQUIRE_ALL` | 默认 0;开启失败保留视频 / 全部通过约束 |
|
||||||
|
|
||||||
`UI_VISUAL_OFFSCREEN=0` 仅限人工本地可视化调试时临时使用。Agent、CI、无头/自动化环境禁止设置该值,必须保持默认离屏模式(或 `UI_VISUAL_OFFSCREEN=1`),避免弹出 UI 或依赖显示环境。配置会拦截 CI、无头及已识别的 Codex/Claude Agent 标记;其他自动化调用方也必须遵守此约定。
|
`UI_VISUAL_OFFSCREEN=0` 仅限人工本地可视化调试时临时使用。Agent、CI、无头/自动化环境禁止设置该值,必须保持默认离屏模式(或 `UI_VISUAL_OFFSCREEN=1`),避免弹出 UI 或依赖显示环境。配置会拦截 CI、无头及已识别的 Codex/Claude Agent 标记;其他自动化调用方也必须遵守此约定。
|
||||||
@@ -192,9 +186,6 @@ Trace、失败截图、CI JUnit 在 `test-results/<runId>/`,HTML 在 `playwrig
|
|||||||
|
|
||||||
## 7. 构建与部署
|
## 7. 构建与部署
|
||||||
|
|
||||||
- **首屏分包**:React 运行时独立缓存,公告和协议预览保留在按需 chunk;首页仅在收到非空 Markdown 时下载解析器。首屏启动 JS 预算为 820 KiB gzip,不含路由按需包和 CSS;验收构建使用 `npm run build -- --manifest --outDir <临时目录>`,再执行 `npm run verify:build -- <临时目录> --startup`。
|
|
||||||
- **开发预热**:只预热应用入口、布局和路由,不预热所有页面或禁用依赖发现。没有全量 `vendor` 分组,也没有将图表、文档等浏览器依赖外置。
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
@@ -203,19 +194,19 @@ npm run preview
|
|||||||
|
|
||||||
将 `dist/` 作为静态站点发布,部署环境需处理:
|
将 `dist/` 作为静态站点发布,部署环境需处理:
|
||||||
|
|
||||||
- **共享测试环境**:局域网沿用现有域名或 IP 与端口。由网关提供构建后的静态文件和 SPA 路由回退,并继续转发测试后端接口。Vite 的源码转换与 HMR 只用于独立的开发服务。自动发布时,先完成构建与检查,再切换站点目录,避免访问到构建中的文件。
|
|
||||||
- **路由回退**:使用 BrowserRouter,直接访问 `/org/...` 等页面时静态服务器需回退到 `index.html`,否则刷新返回 404。
|
- **路由回退**:使用 BrowserRouter,直接访问 `/org/...` 等页面时静态服务器需回退到 `index.html`,否则刷新返回 404。
|
||||||
- **接口转发**:生产环境配置反向代理或独立后端地址;Vite 开发代理不会进入产物,`preview` 不能代替生产网关。
|
- **接口转发**:生产环境配置反向代理或独立后端地址;Vite 开发代理不会进入产物,`preview` 不能代替生产网关。
|
||||||
- **流式与长连接**:SSE 接口需关闭响应缓冲并设置合理超时;WebSocket 需配置连接升级。
|
- **流式与长连接**:SSE 接口需关闭响应缓冲并设置合理超时;WebSocket 需配置连接升级。
|
||||||
- **缓存**:`index.html` 应及时更新,带哈希的静态资源可长缓存;后端地址写在产物中,切换需重新构建并发布。
|
- **缓存**:`index.html` 应及时更新,带哈希的静态资源可长缓存;后端地址写在产物中,切换需重新构建并发布。
|
||||||
- **部署路径**:当前按域名根路径部署;部署到子目录需检查 Vite `base`、路由与静态资源地址。
|
- **部署路径**:当前按域名根路径部署;部署到子目录需检查 Vite `base`、路由与静态资源地址。
|
||||||
|
|
||||||
|
仓库中的 `vercel.json` 只关闭了 GitHub 通知,未配置路由回退或代理,不能作为完整部署配置。
|
||||||
|
|
||||||
## 8. 常见问题
|
## 8. 常见问题
|
||||||
|
|
||||||
| 现象 | 优先检查 |
|
| 现象 | 优先检查 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 页面能打开但提示状态或接口加载失败 | 后端是否可用;Network 中 `/api/status` 的目标地址与响应;代理配置 |
|
| 页面能打开但提示状态或接口加载失败 | 后端是否可用;Network 中 `/api/status` 的目标地址与响应;代理配置 |
|
||||||
| 共享测试站出现 Vite 红色遮罩 | 检查站点网关的前端上游。共享测试站应由网关提供构建后的静态文件,Vite 开发服务仅用于联调。开发服务对 `.npmrc` 请求直接返回 404。 |
|
|
||||||
| 登录后又回到登录页 | `/api/user/self` 响应、Cookie 是否发送、跨域凭证策略、账号状态 |
|
| 登录后又回到登录页 | `/api/user/self` 响应、Cookie 是否发送、跨域凭证策略、账号状态 |
|
||||||
| 企业数据为空或串到其他企业 | 当前组织选择、`current_org_id` 与请求头 `X-Org-Id` |
|
| 企业数据为空或串到其他企业 | 当前组织选择、`current_org_id` 与请求头 `X-Org-Id` |
|
||||||
| 修改环境变量后无变化 | 是否重启开发服务或重新构建发布;HTML 与静态资源缓存 |
|
| 修改环境变量后无变化 | 是否重启开发服务或重新构建发布;HTML 与静态资源缓存 |
|
||||||
|
|||||||
+9
-1134
File diff suppressed because it is too large
Load Diff
+1
-2
@@ -18,7 +18,7 @@
|
|||||||
| 修改企业中心 / 控制台 | `ui/ORG_CENTER_SPEC.md` / `ui/CONSOLE_SPEC.md` | — |
|
| 修改企业中心 / 控制台 | `ui/ORG_CENTER_SPEC.md` / `ui/CONSOLE_SPEC.md` | — |
|
||||||
| 修改模型超市 / 技能超市 | `ui/MODEL_MARKET_SPEC.md` / `ui/SKILL_MARKET_SPEC.md` | — |
|
| 修改模型超市 / 技能超市 | `ui/MODEL_MARKET_SPEC.md` / `ui/SKILL_MARKET_SPEC.md` | — |
|
||||||
| 修改任一表格的列设置 | `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | — |
|
| 修改任一表格的列设置 | `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | — |
|
||||||
| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | `ui-review-checklist.md`、对应页面规范的“验收要点” |
|
| 做 UI 验收 | `ui/GLOBAL_UI_BASELINE.md` 第 6、7 节 | 对应页面规范的“验收要点” |
|
||||||
| 查改动范围或回滚方式 | `CHANGELOG.md` | — |
|
| 查改动范围或回滚方式 | `CHANGELOG.md` | — |
|
||||||
|
|
||||||
每份规范开头都有“何时阅读”和“速查”表,先看速查,需要细节再按章节号读取。
|
每份规范开头都有“何时阅读”和“速查”表,先看速查,需要细节再按章节号读取。
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
| `ui/MODEL_MARKET_SPEC.md` | 模型超市 | 约 8KB |
|
| `ui/MODEL_MARKET_SPEC.md` | 模型超市 | 约 8KB |
|
||||||
| `ui/SKILL_MARKET_SPEC.md` | 技能超市与数据模式 | 约 8KB |
|
| `ui/SKILL_MARKET_SPEC.md` | 技能超市与数据模式 | 约 8KB |
|
||||||
| `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | 表格列设置 | 约 4KB |
|
| `ui/TABLE_COLUMN_SETTINGS_SPEC.md` | 表格列设置 | 约 4KB |
|
||||||
| `ui-review-checklist.md` | 双端 UI 审查、交互与证据记录清单 | 约 3KB |
|
|
||||||
| `CHANGELOG.md` | 对现状仍有影响的功能与修复记录 | 约 6KB |
|
| `CHANGELOG.md` | 对现状仍有影响的功能与修复记录 | 约 6KB |
|
||||||
|
|
||||||
## 规则优先级
|
## 规则优先级
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 统一开发与 Ant Design CRUD 规范
|
# 统一开发与 Ant Design CRUD 规范
|
||||||
|
|
||||||
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-26 · 版本:v2.6
|
> 状态:有效 · 适用:React 18.3、antd 6.7.0、Vite 5.4、Node ≥ 22.13 · 更新:2026-11-18 · 版本:v2.3
|
||||||
|
|
||||||
新增与重构 CRUD 的编码规范:目录与命名、组件选择、请求、React 组件与状态、表单与弹层、权限、i18n,以及可直接复制的页面模板。外观取值见 `UI_COMPONENT_STANDARDS.md`。
|
新增与重构 CRUD 的编码规范:目录与命名、组件选择、请求、React 组件与状态、表单与弹层、权限、i18n,以及可直接复制的页面模板。外观取值见 `UI_COMPONENT_STANDARDS.md`。
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
| React | 函数组件 + Hooks;派生值在渲染中计算;记忆化只用于测量过的问题(第 4 节) |
|
| React | 函数组件 + Hooks;派生值在渲染中计算;记忆化只用于测量过的问题(第 4 节) |
|
||||||
| 状态命名 | `items`、`total`、`page`、`pageSize`、`filters`、`loading`、`submitting`、`editingRecord`、`drawerOpen` |
|
| 状态命名 | `items`、`total`、`page`、`pageSize`、`filters`、`loading`、`submitting`、`editingRecord`、`drawerOpen` |
|
||||||
| 表单 | `Form.useForm` + `rules`;失败不关闭弹层;提交按钮 `loading` 防重复(第 6 节) |
|
| 表单 | `Form.useForm` + `rules`;失败不关闭弹层;提交按钮 `loading` 防重复(第 6 节) |
|
||||||
| 文件 | 不重复添加通用长版权文件头;单测放 `test/unit/`;文案补齐 9 个语言包 |
|
| 文件 | 带 AGPL 许可证头;单测放 `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/`
|
**相关代码**:`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/Organization/Org<Module>.jsx`,Hook 放 `src/hooks/org/` | 同上;单文件过大时拆到 `components/` |
|
||||||
| 视图(用户中心) | `src/pages/UserCenter/<Module>.jsx` + 同名 `.css` | 同上 |
|
| 视图(用户中心) | `src/pages/UserCenter/<Module>.jsx` + 同名 `.css` | 同上 |
|
||||||
| 控制台路由入口 | `src/pages/<Module>/index.jsx` | 由 `App.jsx` 以 `React.lazy` 加载 |
|
| 控制台路由入口 | `src/pages/<Module>/index.jsx` | 由 `App.jsx` 以 `React.lazy` 加载 |
|
||||||
| 单元测试 | `test/unit/<module>-*.test.js` | `.gitignore` 不再按测试扩展名全局忽略;保留已跟踪的存量测试 |
|
| 单元测试 | `test/unit/<module>-*.test.js` | `.gitignore` 忽略 `*.test.*`,仅此目录可入库 |
|
||||||
|
|
||||||
### 1.2 命名
|
### 1.2 命名
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@
|
|||||||
| 样式 | 页面根类 + 局部变量族 `--<前缀>-*`;文件 kebab-case | `.km-page`、`--km-card-border`、`key-management.css` |
|
| 样式 | 页面根类 + 局部变量族 `--<前缀>-*`;文件 kebab-case | `.km-page`、`--km-card-border`、`key-management.css` |
|
||||||
| 后端字段 | 保持 snake_case 原样,不在前端改名 | `created_time`、`page_size` |
|
| 后端字段 | 保持 snake_case 原样,不在前端改名 | `created_time`、`page_size` |
|
||||||
|
|
||||||
### 1.3 版权声明
|
### 1.3 必备文件头
|
||||||
|
|
||||||
源码不重复添加通用长版权文件头,保留独立的第三方声明。
|
ESLint 规则 `header/header` 要求每个 `.js/.jsx` 顶部带 AGPL 许可证块注释,直接复制任一现有源码文件的第 1–18 行;缺失会让 `npm run eslint` 失败。
|
||||||
|
|
||||||
## 2. Ant Design 组件边界
|
## 2. Ant Design 组件边界
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
|
|
||||||
- 外观取值(颜色、间距、圆角、字号、各组件样式)以 `docs/standards/UI_COMPONENT_STANDARDS.md` 为准,本文只写编码约束。
|
- 外观取值(颜色、间距、圆角、字号、各组件样式)以 `docs/standards/UI_COMPONENT_STANDARDS.md` 为准,本文只写编码约束。
|
||||||
- 按钮与操作图标:`import { Plus, Pencil, Trash2, RefreshCw, Search } from '@/components/common/icons/ActionIcons'`,按钮内传 `size={16}`;装饰图标用 `lucide-react`。
|
- 按钮与操作图标:`import { Plus, Pencil, Trash2, RefreshCw, Search } from '@/components/common/icons/ActionIcons'`,按钮内传 `size={16}`;装饰图标用 `lucide-react`。
|
||||||
- 禁止导入 `@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`,不要在入口重复维护包名。
|
- 禁止导入 `@lobehub/*`、Radix UI、Floating UI、Semi、MUI、Chakra、Headless UI、leva、antd-style、react-layout-kit(ESLint `no-restricted-imports` 与 `npm run check:ui` 拦截)。
|
||||||
- JSX 不写十六进制颜色;不用全局 `!important`;新视图不用 Tailwind 颜色类(如 `text-gray-500`),改用 token 或页面变量。
|
- JSX 不写十六进制颜色;不用全局 `!important`;新视图不用 Tailwind 颜色类(如 `text-gray-500`),改用 token 或页面变量。
|
||||||
|
|
||||||
## 3. 请求封装与错误处理
|
## 3. 请求封装与错误处理
|
||||||
@@ -118,10 +118,8 @@
|
|||||||
### 3.1 规则
|
### 3.1 规则
|
||||||
|
|
||||||
- 只用 `import { API } from '@/helpers'`;禁止新建 axios 实例或用 `fetch` 调 `/api`(流式对话 `src/hooks/playground/useApiRequest.jsx` 除外)。
|
- 只用 `import { API } from '@/helpers'`;禁止新建 axios 实例或用 `fetch` 调 `/api`(流式对话 `src/hooks/playground/useApiRequest.jsx` 除外)。
|
||||||
- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭,带取消信号或请求组的 GET 不共享);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行处理)。受会话约束的接口首次返回 401 时取消该会话未完成的只读请求,阻止该会话继续发请求,并仅清理、跳转 `/org/login?expired=true` 一次。公开接口或显式 `sessionBound: false` 的请求不参与会话联动。
|
- `API` 已提供:`New-API-User` 请求头;`/api/org/*` 自动注入 `X-Org-Id`(显式传入优先);并发相同 GET 去重(`disableDuplicate: true` 关闭);HTTP 错误统一提示(`skipErrorHandler: true` 跳过并由页面自行提示);401 清理会话并跳转 `/org/login?expired=true`。
|
||||||
- 同一批必须全部成功的只读请求,可传入同一个 `requestGroup: new AbortController()`;首次拒绝的 HTTP 4xx/5xx 取消同组剩余读取。普通失败不取消无关请求,正常并发不限流;已发送的写入不由请求组批量取消。调用方仍须处理 Promise 拒绝,并在 `finally` 清理加载状态。
|
|
||||||
- 查询参数用 `params` 对象,不手拼查询字符串(手拼不会编码 `&`、`#`、中文)。
|
- 查询参数用 `params` 对象,不手拼查询字符串(手拼不会编码 `&`、`#`、中文)。
|
||||||
- `API` 的 GET、HEAD、OPTIONS 默认在 60 秒后超时,调用方可以通过 `timeout` 覆盖。保持在 `finally` 回收加载状态,并让过期请求与当前请求的状态互不干扰。
|
|
||||||
- 响应按 `{ success, message, data }` 处理,先判断 `success`;具体字段以接口契约为准。
|
- 响应按 `{ success, message, data }` 处理,先判断 `success`;具体字段以接口契约为准。
|
||||||
- 分页参数 `p` 从 1 开始,`page_size` 默认 `ITEMS_PER_PAGE`(10,须与后端一致);后端对 `page_size > 100` 静默截断为 100,需要全量数据时用 `collectPagedItems(fetchPage)`(`src/helpers/paging.js`)。
|
- 分页参数 `p` 从 1 开始,`page_size` 默认 `ITEMS_PER_PAGE`(10,须与后端一致);后端对 `page_size > 100` 静默截断为 100,需要全量数据时用 `collectPagedItems(fetchPage)`(`src/helpers/paging.js`)。
|
||||||
|
|
||||||
@@ -203,7 +201,7 @@ try {
|
|||||||
- 批量操作:`rowSelection={{ selectedRowKeys, onChange: setSelectedRowKeys }}`。
|
- 批量操作:`rowSelection={{ selectedRowKeys, onChange: setSelectedRowKeys }}`。
|
||||||
- 删除后的页码回退、筛选后的页码重置放在 hook 中处理(不要散落在组件中)。
|
- 删除后的页码回退、筛选后的页码重置放在 hook 中处理(不要散落在组件中)。
|
||||||
- 列设置只用于已有该功能的表格(`docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
- 列设置只用于已有该功能的表格(`docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
||||||
- 所有路由的分页表格用适配层 `Table` / `Pagination`。完整数据交给 `Table` 本地分页,不传 `total`;已由页面筛选切片或由接口返回单页数据时传 `total`,表格不会再次切片。未开启分页的表格保持原样。受控分页按下例传入,条数回调自行回到第 1 页,不再触发翻页回调:
|
- 分页统一用适配层 `Table` / `Pagination`;`/console`、`/org` 下自动统一,其他路由按下例显式传入,避免改页容量时请求两次:
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
pagination={{
|
pagination={{
|
||||||
@@ -212,6 +210,10 @@ pagination={{
|
|||||||
total,
|
total,
|
||||||
onPageChange: handlePageChange,
|
onPageChange: handlePageChange,
|
||||||
onPageSizeChange: handlePageSizeChange,
|
onPageSizeChange: handlePageSizeChange,
|
||||||
|
showSizeChanger: true,
|
||||||
|
pageSizeOpts: [10, 20, 50, 100],
|
||||||
|
showTotal: (count) => t('共 {{total}} 条', { total: count }),
|
||||||
|
preventPageChangeOnPageSizeChange: true,
|
||||||
}}
|
}}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -223,7 +225,7 @@ pagination={{
|
|||||||
- 防重复:提交中按钮 `loading` 或 `confirmLoading`;hook 内 `submitting` 为真时直接返回。
|
- 防重复:提交中按钮 `loading` 或 `confirmLoading`;hook 内 `submitting` 为真时直接返回。
|
||||||
- 成功:`showSuccess` → 关闭 → 刷新当前页;失败:保留弹层与已填内容。
|
- 成功:`showSuccess` → 关闭 → 刷新当前页;失败:保留弹层与已填内容。
|
||||||
- 打开时重置:弹层加 `forceRender`,在 `useEffect([open, record])` 中先 `resetFields()` 再 `setFieldsValue(record)`。
|
- 打开时重置:弹层加 `forceRender`,在 `useEffect([open, record])` 中先 `resetFields()` 再 `setFieldsValue(record)`。
|
||||||
- 删除:确认回调返回 Promise 以显示加载;确认形态、危险按钮、失败保留与键盘交互见组件规范第 8 节。
|
- 删除:`Popconfirm` 的 `onConfirm` 返回 Promise 以显示加载;批量或不可撤销操作用 `Modal.confirm`。
|
||||||
- 日期提交前转换为后端格式(多为 Unix 秒);有未保存内容时沿用页面已有的关闭确认流程。
|
- 日期提交前转换为后端格式(多为 Unix 秒);有未保存内容时沿用页面已有的关闭确认流程。
|
||||||
|
|
||||||
## 7. 加载、空态与错误态
|
## 7. 加载、空态与错误态
|
||||||
@@ -291,7 +293,7 @@ pagination={{
|
|||||||
### 12.1 检查与构建
|
### 12.1 检查与构建
|
||||||
|
|
||||||
- Prettier:`singleQuote`、`jsxSingleQuote`,换行 LF;规范类文档使用紧凑表格(`.prettierrc.mjs` 的 overrides)。
|
- 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
|
```bash
|
||||||
npm run eslint # 0 错误 0 警告
|
npm run eslint # 0 错误 0 警告
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# UI 公共组件与样式规范
|
# UI 公共组件与样式规范
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-20 · 版本:v2.6
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.4
|
||||||
|
|
||||||
所有后台页面共用的主题与组件标准。页面规范只记录与本文不同的部分;编码约定见 `DEV_STANDARDS.md`,外壳与布局见 `GLOBAL_UI_BASELINE.md`。
|
所有后台页面共用的主题与组件标准。页面规范只记录与本文不同的部分;编码约定见 `DEV_STANDARDS.md`,外壳与布局见 `GLOBAL_UI_BASELINE.md`。
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@
|
|||||||
|
|
||||||
品牌主题预设在 `src/styles/presets.js`,主题配置与持久化在 `src/helpers/theme.js` 与 `src/context/Theme`;预设 key 不改名。
|
品牌主题预设在 `src/styles/presets.js`,主题配置与持久化在 `src/helpers/theme.js` 与 `src/context/Theme`;预设 key 不改名。
|
||||||
|
|
||||||
组件级配置:`Menu` 项高 42px,原型选中底 `#fff3df` / `#382b1b`,选中文字 `#a45a07` / `#f2ad41`;`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。
|
组件级配置:`Menu`(项高 42px,选中底 `#fff3df` / `#382b1b`,选中文字 `#a95d07` / `#f2ad41`);`Card` 标题 15px;`Modal` 圆角 12px;`Tag` 默认描边样式;弹窗与抽屉遮罩默认不模糊。
|
||||||
|
|
||||||
暗色原型:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`;保留该全局主色及原型选中态。系统配置的主题色保留为原始种子,交互色根据当前明暗模式派生:选中背景低浓度着色,选中文字与强调色保证可读;实底按钮的默认、悬停和按压态共享同一前景色。页面复用 `--brand-accent`、`--brand-selection-bg`、`--brand-selection-text`,不自行写固定品牌色;成功、警告、错误继续独立于主色。
|
暗色主色:antd 暗色算法由种子 `#f2ad41` 推导出 `#d1963a`。系统以 `#d1963a` 作为 `colorPrimary`,其余衍生 token 仍按种子推导;页面需要“品牌强调色”时用 `brandAccentFromToken(colorPrimary, dark)`,浅色与自定义主色返回 `colorPrimary`,默认暗色返回 `#f2ad41`。
|
||||||
|
|
||||||
### 2.2 取色方式
|
### 2.2 取色方式
|
||||||
|
|
||||||
@@ -125,25 +125,13 @@ html.dark .km-page {
|
|||||||
|
|
||||||
## 4. 表格搜索栏(筛选卡)
|
## 4. 表格搜索栏(筛选卡)
|
||||||
|
|
||||||
- **筛选卡与列表卡间距**:从筛选卡底边到下方列表卡顶边统一为 18px,复用 `--uc-layout-gap`。同一对相邻区块只设置一次间距,优先由共同容器的 `gap` 控制。企业端以 `/org/logs` 为对齐基准,审计日志若在页签与筛选卡之间插入说明条,说明条上下也各留 18px。
|
|
||||||
- 背景:使用不透明的卡片纯色;浅色为白色,深色沿用主题卡片色,不使用渐变背景。
|
- 背景:使用不透明的卡片纯色;浅色为白色,深色沿用主题卡片色,不使用渐变背景。
|
||||||
- 字段竖排:标签在上(13px,次文字色,下距 8px),控件在下且宽度占满单元格。
|
- 字段竖排:标签在上(13px,次文字色,下距 8px),控件在下且宽度占满单元格。
|
||||||
- 栅格:列间距与行间距 16px;按页面宽度取 3–5 列(企业中心 3 列、控制台 4 列、用户中心 5 列,时间范围可跨 2 列);≤ 768px 单列。
|
- 栅格:列间距与行间距 16px;按页面宽度取 3–5 列(企业中心 3 列、控制台 4 列、用户中心 5 列,时间范围可跨 2 列);≤ 768px 单列。
|
||||||
- 操作:“重置”“搜索”位于右下,间距 8px;“搜索”为 primary 且 `htmlType='submit'`,回车提交。
|
- 操作:“重置”“搜索”位于右下,间距 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. 表格
|
## 5. 表格
|
||||||
|
|
||||||
@@ -160,31 +148,27 @@ html.dark .km-page {
|
|||||||
### 5.2 列
|
### 5.2 列
|
||||||
|
|
||||||
- 每列显式 `width`,长文本 `ellipsis` 并配 `Tooltip`;金额与数量右对齐;时间统一格式,必要时日期与时间分两行。
|
- 每列显式 `width`,长文本 `ellipsis` 并配 `Tooltip`;金额与数量右对齐;时间统一格式,必要时日期与时间分两行。
|
||||||
- 状态列用只读 `Tag` 或 `TableStatusSwitch`(见第 11 节);启停开关请求中禁用,失败恢复原状态。
|
- 状态列用 `Tag` 或 `Switch`(见第 11 节);启停开关请求中禁用,失败恢复原状态。
|
||||||
- 调用、计费和访问权限分组列使用 `TableGroupTags`,单组与多组按同一套颜色渲染(见第 11 节)。
|
- 操作列放在最后,按钮为 `type='link' size='small'`,危险操作加 `danger`,同一行操作间距 8–10px;用户中心、企业中心、控制台(含系统设置)的操作列统一 `fixed: 'right'`;操作较多时折叠到“更多”下拉。
|
||||||
- 操作列放在最后,标题固定为“操作”,按钮为 `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 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。
|
- 三中心表格通过 `CenterActionTable` 统一处理,最后一列存在创建、查看、编辑、测试、详情、删除、添加、设置、配置、弹窗 / 抽屉或请求交互时,列头统一显示“操作”并固定右侧,宽度按按钮 / 交互数量计算。没有操作列但估算列宽超出容器时,从右侧固定末 4 列,列数不足时降为 3、2、1 列。固定列使用不透明底色并保持表头层级;横向滚动条遵循 Ant Design 官方固定列表格行为,允许鼠标、触控板、触屏和键盘滚动,不隐藏滚动条。
|
||||||
- 列显隐只在已有列设置的表格中提供,统一使用 `ColumnSettings`(见 `docs/ui/TABLE_COLUMN_SETTINGS_SPEC.md`)。
|
- 列显隐只在已有列设置的表格中提供,统一使用 `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` 类名补丁;表头不换行,表头与正文沿用同一列宽和对齐方式。
|
- 三中心表头背景统一由 `center-table.css` 绘制:页面通过 `--center-table-head-bg` 提供色调,公共层在不透明的容器底色上叠加同色填充,普通列与固定列保持一致;页面不再直接覆盖表头 `background`。固定列使用 antd 6 的 `.ant-table-cell-fix` 与原生动态层级,不写死 `z-index`,不使用旧版 `fix-left` / `fix-right` 类名补丁;表头不换行,表头与正文沿用同一列宽和对齐方式。
|
||||||
- 操作列在异步数据或列变化后重新测量可见行的按钮宽度,取最大值;列宽不超过表格容器,按钮组在空间不足时换行。左右固定区总宽超过容器时,保留右侧操作列,其余固定列参与横向滚动;容器恢复足够宽度后恢复原固定配置,避免窄屏相互遮挡。
|
- 操作列在异步数据或列变化后重新测量可见行的按钮宽度,取最大值;列宽不超过表格容器,按钮组在空间不足时换行。左右固定区总宽超过容器时,保留右侧操作列,其余固定列参与横向滚动;容器恢复足够宽度后恢复原固定配置,避免窄屏相互遮挡。
|
||||||
- 操作列的删除入口置末并用 `danger`;点击仅打开确认,确认后的提交与刷新按第 8 节执行。无权删除或当前状态不允许删除时,沿用业务的隐藏或禁用规则。
|
|
||||||
|
|
||||||
### 5.3 状态
|
### 5.3 状态
|
||||||
|
|
||||||
| 状态 | 写法 |
|
| 状态 | 写法 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 加载 | `Table loading` |
|
| 加载 | `Table loading` |
|
||||||
| 空数据 | 标准列表使用 `TableEmpty`(`ConsoleListTable` 默认接入):保留表头,简单插图 + “暂无数据”在当前可见宽度内居中;加载中不把空态当作查询结果,失败继续走错误提示 |
|
| 空数据 | `Empty image={Empty.PRESENTED_IMAGE_SIMPLE}`,文案沿用页面原有 |
|
||||||
| 批量操作 | `rowSelection={{ selectedRowKeys, onChange }}`,未选中时批量按钮禁用 |
|
| 批量操作 | `rowSelection={{ selectedRowKeys, onChange }}`,未选中时批量按钮禁用 |
|
||||||
|
|
||||||
## 6. 分页
|
## 6. 分页
|
||||||
|
|
||||||
- 位置:列表卡底部右对齐,上距 16px;移动端换行显示并提供快速跳页。
|
- 位置:列表卡底部右对齐,上距 16px;移动端换行显示并提供快速跳页。
|
||||||
- 外观:小尺寸,可切换每页条数 `[10, 20, 50, 100]`,总数文案 `t('共 {{total}} 条', { total })`。
|
- 外观:小尺寸,可切换每页条数 `[10, 20, 50, 100]`,总数文案 `t('共 {{total}} 条', { total })`。
|
||||||
- 用法:分页列表使用 `@/components/ui` 的 `Table` / `Pagination`。第 4 节的标准列表及其明细分页均沿用密钥管理:表格底部右对齐、小尺寸,依次显示“共 N 条”、上一页/页码/下一页、每页条数(10、20、50、100),移动端保留跳页。已加载的明细可本地分页;服务端分页传 `currentPage`、`pageSize`、`total` 以及分页回调,切换每页条数回到第 1 页,只发一次请求。导出仍作用于原有结果范围,不受当前页条数影响。
|
- 用法:分页列表使用 `@/components/ui` 的 `Table` / `Pagination`,传 `currentPage`、`pageSize`、`total`、`onPageChange(page)`、`onPageSizeChange(size)`。`/console`、`/org` 下由封装自动统一外观与回调;其他路由需显式传 `showSizeChanger`、`pageSizeOpts`、`showTotal`,并设置 `preventPageChangeOnPageSizeChange: true`,避免改页容量时请求两次。
|
||||||
- 删除当前页最后一条后回到上一页;筛选和搜索沿用当前页,重置回到第 1 页。`/org/*` 的独立表格、页签和下钻明细均用此分页规则;已加载的树形表格按根节点分页,子节点不拆散;接口已分页时沿用原查询与总数。
|
- 删除当前页最后一条后回到上一页;前端分页的列表在筛选或数据变化时回到第 1 页。
|
||||||
- 受控分页须实现条数回调(或兼容的统一变更回调)才显示条数选择,不用客户端切片模拟固定条数的服务端接口;分页启用且有结果时单页也显示分页栏。
|
|
||||||
- 接入自动搜索的表格使用 `preservePage`。筛选后当前页没有结果时仍保留页码,分页栏显示实际结果总数并允许手动返回。删除后的页码调整由对应删除流程处理。
|
|
||||||
|
|
||||||
## 7. 表单项
|
## 7. 表单项
|
||||||
|
|
||||||
@@ -204,11 +188,7 @@ html.dark .km-page {
|
|||||||
| 外观 | 圆角 12px;标题 16px / 600;正文与页脚使用 antd 默认间距 |
|
| 外观 | 圆角 12px;标题 16px / 600;正文与页脚使用 antd 默认间距 |
|
||||||
| 页脚 | 次操作(取消)在前、主操作(确定 / 保存)在后,按钮高 34px、间距 8px;危险确认用 `okButtonProps={{ danger: true }}` |
|
| 页脚 | 次操作(取消)在前、主操作(确定 / 保存)在后,按钮高 34px、间距 8px;危险确认用 `okButtonProps={{ danger: true }}` |
|
||||||
| 行为 | 提交中 `confirmLoading`;校验或请求失败不关闭;X、取消、Esc、遮罩关闭行为一致 |
|
| 行为 | 提交中 `confirmLoading`;校验或请求失败不关闭;X、取消、Esc、遮罩关闭行为一致 |
|
||||||
| 表格操作列危险确认 | 删除、注销和冻结使用小尺寸危险链接,更多菜单使用危险菜单项。普通单条操作用 `TableActionPopconfirm`,注销、企业冻结等影响较大的操作用确认弹窗。取消在前,危险确认在后;优先聚焦取消 |
|
| 确认框 | 单条删除用 `Popconfirm`;批量或不可撤销操作用 `Modal.confirm`(企业中心用 `OrgModal.confirm`) |
|
||||||
|
|
||||||
- 保留业务定制的标题、正文和按钮文案,并接入国际化。确认信息明确操作对象和影响。
|
|
||||||
- 只有明确确认才发送请求;取消、Esc 或关闭不修改数据。确认回调返回 Promise,提交中显示加载并防止重复请求,失败保留确认及上下文并提示原因。成功后关闭确认并刷新列表,删除当前页最后一条时按分页规范回退。
|
|
||||||
- 表格危险操作的回调在 API 明确失败时返回 `false`。确认框保持打开,业务回调保留原有错误提示。受控弹窗由业务在成功后关闭。
|
|
||||||
|
|
||||||
## 9. 抽屉
|
## 9. 抽屉
|
||||||
|
|
||||||
@@ -228,7 +208,6 @@ html.dark .km-page {
|
|||||||
| 类型 | 用法 |
|
| 类型 | 用法 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 列表页签 | antd `Tabs`;导航与下方内容间距 20px(控制台 16px);页签间距 28px;文字 14 / 22px;选中与悬停为品牌色,2px 下划线 |
|
| 列表页签 | antd `Tabs`;导航与下方内容间距 20px(控制台 16px);页签间距 28px;文字 14 / 22px;选中与悬停为品牌色,2px 下划线 |
|
||||||
| 卡片首部页签 | 控制台卡片主体以 `Tabs` 开始、页签上方没有标题或提示时,主体顶部内边距 8px,参考 `/console/website-setting`、`/console/smart-router`;保留页签默认上下内边距 12px、导航高 46px、与下方内容间距 16px,不叠加空白占位或顶部外边距。卡片其余内边距不变;页签前有错误提示或说明块时按对应容器规则处理。浅深主题、桌面与移动端一致。 |
|
|
||||||
| 筛选页签 | 只切换筛选条件时隐藏内容区(企业中心 `.oc-tabs-nav-only`),筛选结果由下方列表卡展示 |
|
| 筛选页签 | 只切换筛选条件时隐藏内容区(企业中心 `.oc-tabs-nav-only`),筛选结果由下方列表卡展示 |
|
||||||
| 分段控件 | 2–4 个互斥选项(如趋势维度、充值类型、头像类型)用 `Segmented`,`onChange(value)` 直接接值处理函数 |
|
| 分段控件 | 2–4 个互斥选项(如趋势维度、充值类型、头像类型)用 `Segmented`,`onChange(value)` 直接接值处理函数 |
|
||||||
| 预渲染 | 原先预渲染全部页签的页面保留 `forceRender`,不改变请求时机 |
|
| 预渲染 | 原先预渲染全部页签的页面保留 `forceRender`,不改变请求时机 |
|
||||||
@@ -238,8 +217,7 @@ html.dark .km-page {
|
|||||||
- **状态**用语义色:成功 `success`、失败 `error`、进行中 `processing`、等待 / 警告 `warning`、中性 `default`。
|
- **状态**用语义色:成功 `success`、失败 `error`、进行中 `processing`、等待 / 警告 `warning`、中性 `default`。
|
||||||
- **分类**(分组、类型、模型标签等)用调色板色(`blue`、`green`、`purple`、`gold`、`cyan` 等 antd 预设),不用非预设色名。
|
- **分类**(分组、类型、模型标签等)用调色板色(`blue`、`green`、`purple`、`gold`、`cyan` 等 antd 预设),不用非预设色名。
|
||||||
- 全局默认描边;卡片内的分类标签与企业中心表格标签用无边框样式,新代码写 `variant='filled'`(antd 6 已弃用 `bordered={false}`,二者视觉等价;存量写法可在修改时顺带收敛)。标签间距 8px,表格内标签不留右外边距。
|
- 全局默认描边;卡片内的分类标签与企业中心表格标签用无边框样式,新代码写 `variant='filled'`(antd 6 已弃用 `bordered={false}`,二者视觉等价;存量写法可在修改时顺带收敛)。标签间距 8px,表格内标签不留右外边距。
|
||||||
- **表格启停开关**以 `/user-center/key-management` 为准,复用 `TableStatusSwitch`:小尺寸、开启显示「启用」并使用系统主题主色,关闭显示「禁用」并使用组件中性色。其他既有布尔含义可自定义两态文字。保留键盘焦点、可访问名称、原有确认和权限;关闭状态不等于控件不可操作。只读状态仍用 `Tag`,过期、耗尽等非二元状态的说明保留,表单与筛选区开关不套用本规则。
|
- 可启停的记录用 `Switch size='small'`,`onChange` 调原处理函数;无启停接口的列表保留只读 `Tag`。
|
||||||
- **表格分组颜色与布局**以 `/console/organizations` 分组列为准,复用 `TableGroupTags`(单个标签也可用 `TableGroupTag`)。三种分组的标签文字固定为 `default`、`vip`、`svip`,颜色分别为蓝、黄、红。分组列禁止追加「(默认)」等说明,默认分组设置继续在表单中体现。`premium`、`pro` 沿用原名及红、黄配色,自定义分组用中性色。使用 antd 浅底描边标签并适配明暗主题。标签逐个着色、去重,按 4px 间距单行排列。纯分组列复用 `TABLE_GROUP_COLUMN_WIDTH`(148px),以完整容纳三枚标准标签为准。超出单元格的分组可横向滚动,已有的「+N」展开仍可使用。空值继承、智能熔断和非调用分组沿用各自的业务展示。
|
|
||||||
|
|
||||||
## 12. 按钮与图标
|
## 12. 按钮与图标
|
||||||
|
|
||||||
@@ -263,8 +241,8 @@ html.dark .km-page {
|
|||||||
|
|
||||||
组件分层(antd 原生、中心封装、契约封装、专用组件)及选用方式见 `DEV_STANDARDS.md` 2.1、2.2 节。`src/components/ui/*` 只做视图映射,不放请求、权限与业务状态。
|
组件分层(antd 原生、中心封装、契约封装、专用组件)及选用方式见 `DEV_STANDARDS.md` 2.1、2.2 节。`src/components/ui/*` 只做视图映射,不放请求、权限与业务状态。
|
||||||
|
|
||||||
- 禁用范围见开发规范第 2.4 节;ESLint 与 `npm run check:ui` 共用一份规则,本地品牌图标不是运行时 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` 审计根目录 JS 配置、应用源码、脚本和单测的包引用,并检查依赖声明、锁文件中的传递包和别名,以及品牌图标资产 SHA-256。命令已包含在 `npm run check` 中。
|
- `npm run check:ui` 审计源码导入、完整 lock 图与品牌图标资产 hash,已包含在 `npm run check` 中。
|
||||||
- `antd` 与 `@ant-design/icons` 精确锁定版本;`src/components/ui/antd-v5-compat.css` 统一标签间距、分页选择器宽度与必填标记字体,页面样式可以覆盖。
|
- `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 已标记弃用),替换前需先建立该区域的视觉基线。
|
- 当前版本 API 约定:Card 用 `variant`,Drawer 用 `size`,弹层遮罩用 `mask` 配置,Alert 标题用 `title`;样式选择器使用 `.ant-modal-container`、`.ant-alert-title`、`.ant-collapse-body`。聊天消息列表使用 `List`(antd 已标记弃用),替换前需先建立该区域的视觉基线。
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
# 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/\*)
|
# 控制台 UI 规范(/console/\*)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.7
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.3
|
||||||
|
|
||||||
管理控制台 `/console/*` 的规范:统一页头、控制台原语与差异样式。
|
管理控制台 `/console/*` 的规范:统一页头、控制台原语与差异样式。
|
||||||
|
|
||||||
@@ -58,10 +58,6 @@
|
|||||||
- 提示栏:控制台内的 `Banner` / `Alert` 统一走 `ConsoleAlert`,内边距 12px 16px、正文 14 / 22px、图标 16px,颜色取对应语义 token。
|
- 提示栏:控制台内的 `Banner` / `Alert` 统一走 `ConsoleAlert`,内边距 12px 16px、正文 14 / 22px、图标 16px,颜色取对应语义 token。
|
||||||
- 系统设置(`page.key === 'setting'`):表单统一纵向布局、8px 标签间距、24px 栅格、控件等宽,校验信息预留高度;弹窗页脚按钮高 34px、间距 8px、右对齐。规则限定在 `.settings-page` / `.settings-form-dialog`。
|
- 系统设置(`page.key === 'setting'`):表单统一纵向布局、8px 标签间距、24px 栅格、控件等宽,校验信息预留高度;弹窗页脚按钮高 34px、间距 8px、右对齐。规则限定在 `.settings-page` / `.settings-form-dialog`。
|
||||||
- 控制台上下文中 `CompactModeToggle` 不渲染,表格密度状态保留;其他模块仍可使用紧凑模式。
|
- 控制台上下文中 `CompactModeToggle` 不渲染,表格密度状态保留;其他模块仍可使用紧凑模式。
|
||||||
- 兑换码列表沿用渠道列表的行内链接按钮、右侧固定操作列和底部分页。「查看、复制、编辑、禁用/启用、删除」在同一行直接显示,保留既有权限和状态限制,删除仍需确认。窄屏横向滚动时操作列不换行。批量复制在选中兑换码后可用,清除失效兑换码由独立的危险操作确认承载。
|
|
||||||
- 添加兑换码与编辑兑换码信息共用右侧侧栏窗、表单样式及页脚。查看详情使用弹窗,优先展示兑换码和状态,再列出额度、时间与兑换人信息。
|
|
||||||
- 平台 Skill 中心的分类标签区域与搜索工具栏同宽、左对齐,不保留独立的最大宽度和自动居中;窄屏按原间距自然换行。
|
|
||||||
- 平台 Skill 详情的审核工作台仅由抽屉正文纵向滚动,技能原文不设置独立滚动区;审核操作进入抽屉固定页脚,按钮右对齐、间距 8px,仅在审核页签展示。
|
|
||||||
- 官网文章抽屉允许点击遮罩关闭,X、取消、遮罩共用同一未保存内容确认流程。
|
- 官网文章抽屉允许点击遮罩关闭,X、取消、遮罩共用同一未保存内容确认流程。
|
||||||
|
|
||||||
## 4. 验收要点
|
## 4. 验收要点
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 后台 UI 全局基线
|
# 后台 UI 全局基线
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-28 · 版本:v3.15
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-17 · 版本:v3.6
|
||||||
|
|
||||||
后台外壳与布局基线:顶栏、侧栏、公告、页头与内容边距、登录页,以及原型未定义场景、登录关卡与验收流程。主题与组件样式见 `UI_COMPONENT_STANDARDS.md`。
|
后台外壳与布局基线:顶栏、侧栏、公告、页头与内容边距、登录页,以及原型未定义场景、登录关卡与验收流程。主题与组件样式见 `UI_COMPONENT_STANDARDS.md`。
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
| 滚动条 | 全站 6px,`#8b8b8b`,悬停 `#636363`,页面不得单独设置 |
|
| 滚动条 | 全站 6px,`#8b8b8b`,悬停 `#636363`,页面不得单独设置 |
|
||||||
| 装饰 | 无设计依据不加渐变、玻璃、发光、浮起与动效 |
|
| 装饰 | 无设计依据不加渐变、玻璃、发光、浮起与动效 |
|
||||||
| 登录关卡 | 真实 UI 登录,企业先于个人,凭据只经环境变量(第 6 节) |
|
| 登录关卡 | 真实 UI 登录,企业先于个人,凭据只经环境变量(第 6 节) |
|
||||||
| 验收 | 浅深主题 × 1920×1000 / 393×851 / 360×800,有头离屏串行,唯一页面不抢焦点,模拟与真实分开记录(第 7 节) |
|
| 验收 | 浅深主题 × 1920×1000 / 393×851,有头离屏串行,唯一页面不抢焦点,模拟与真实分开记录(第 7 节) |
|
||||||
|
|
||||||
**相关代码**:`src/styles/{user-center,center-layout,org-page,prototype}.css`、`src/index.css`、`src/components/layout/`
|
**相关代码**:`src/styles/{user-center,center-layout,org-page,prototype}.css`、`src/index.css`、`src/components/layout/`
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
- 原型定义的颜色、尺寸、样式、状态与视觉交互优先;原型只作视觉依据,不作业务、数据、状态、接口、路由依据。
|
- 原型定义的颜色、尺寸、样式、状态与视觉交互优先;原型只作视觉依据,不作业务、数据、状态、接口、路由依据。
|
||||||
- 专项规范见 `docs/README.md` 索引;专项未覆盖的部分按本文执行。
|
- 专项规范见 `docs/README.md` 索引;专项未覆盖的部分按本文执行。
|
||||||
- 不重做:WeyAI 外部页与第三方 SDK 的内部视觉;本站托管的 `/weyai/download` 属于系统页面,沿用统一主题、顶栏与浮层 token。体验中心只检查宿主布局。图表、流程画布、编辑器与新手引导保留专用组件。
|
- 不重做:WeyAI 外部页与第三方 SDK 的内部视觉;体验中心只检查宿主布局。图表、流程画布、编辑器与新手引导保留专用组件。
|
||||||
- 改造前先列出已覆盖、未覆盖、排除的页面;配置隐藏、权限重定向和原型失效入口单独列出。
|
- 改造前先列出已覆盖、未覆盖、排除的页面;配置隐藏、权限重定向和原型失效入口单独列出。
|
||||||
|
|
||||||
## 2. 目录职责
|
## 2. 目录职责
|
||||||
@@ -51,12 +51,9 @@
|
|||||||
|
|
||||||
- 桌面高 72px、移动 56px,另含 1px 底部分隔线;背景、文字、分隔线跟随双主题变量。
|
- 桌面高 72px、移动 56px,另含 1px 底部分隔线;背景、文字、分隔线跟随双主题变量。
|
||||||
- 主导航:导航项撑满顶栏,左右内边距 24px;2px 主色下划线两端内缩 16px;选中项主色文字,普通项悬停保留正常文字色,键盘焦点可见。不改链接与权限条件。
|
- 主导航:导航项撑满顶栏,左右内边距 24px;2px 主色下划线两端内缩 16px;选中项主色文字,普通项悬停保留正常文字色,键盘焦点可见。不改链接与权限条件。
|
||||||
- 768px 及以上,导航槽位按实际可用宽度判断:完整导航放不下时收为「主导航」下拉菜单,放得下时恢复平铺,不出现被操作区覆盖或隐藏横向滚动的导航项。菜单项、选中态、外链与鉴权跳转复用移动端菜单;槽位 ≥ 84px 显示当前页名称,更窄时为 34px 图标按钮;切换时焦点在导航内则移到菜单按钮。
|
- 右侧按钮:主题、公告、语言等图标 16px,工具按钮点击区 34px,账户下拉箭头 10px;`.ui-header-actions` 内图标容器为 inline-flex,使图标与文字垂直居中。
|
||||||
- 右侧按钮:主题、公告、语言等图标 16px,按钮高度与工具按钮点击区 34px、文字行高 20px,账户头像 32px、下拉箭头 10px;`.ui-header-actions` 内链接、徽标和图标容器为 inline-flex,图标、文字、头像与分隔线垂直居中;桌面专属操作在 768px 以下隐藏。
|
|
||||||
- 全站共享顶栏不展示未登录用户的“登录 / 注册”按钮,桌面与移动端一致;已登录用户保留头像与账户菜单,登录 / 注册页面及受保护导航的原有鉴权跳转保持不变。
|
|
||||||
- 主题按钮为 `Button` + `Tooltip`,点击在浅色与深色之间直接切换,不提供下拉或“跟随系统”;沿用现有主题 setter 与持久化,覆盖 `/org/login`、`/login` 与共享顶栏。
|
- 主题按钮为 `Button` + `Tooltip`,点击在浅色与深色之间直接切换,不提供下拉或“跟随系统”;沿用现有主题 setter 与持久化,覆盖 `/org/login`、`/login` 与共享顶栏。
|
||||||
- WeyAi 下载按钮复用现有下载配置与权限判定,跳转 `/weyai/download`。在两个下载路由中显示品牌强调色文字和约 6% 的主题色底,并区分悬停、按压和键盘焦点。其他页面使用 antd text 按钮默认样式,保留 `Tooltip`。
|
- WeyAi 下载按钮复用现有下载配置与权限判定,跳转 `/weyai/download`;使用 antd text 按钮默认悬停背景与 `Tooltip`,不硬编码外部地址。
|
||||||
- 右侧快捷链接复用主导航的当前路由去重与节流。主题切换即时响应首击,语言和头像菜单统一处理悬停、点击和键盘关闭。推广弹窗短暂过滤打开时落到遮罩上的连点。
|
|
||||||
|
|
||||||
### 4.2 公告栏与系统公告弹窗
|
### 4.2 公告栏与系统公告弹窗
|
||||||
|
|
||||||
@@ -66,9 +63,7 @@
|
|||||||
|
|
||||||
### 4.3 侧栏
|
### 4.3 侧栏
|
||||||
|
|
||||||
- 页面级侧栏共用 `CenterSidebar` 和 `src/styles/center-layout.css`:展开 216px、收起 64px;菜单行高 42px、行距 6px,图标 16px / 1.5px 线宽;折叠入口文案“收起导航”。抽屉保留完整文字,窄屏的底部或横向导航沿用各页面的布局。
|
- 企业中心与用户中心共用 `src/styles/center-layout.css`:展开 216px、收起 64px;菜单行高 42px、行距 6px,图标 16px / 1.5px 线宽;折叠入口文案“收起导航”。
|
||||||
- 当前菜单超出可视范围时,仅滚动菜单区域使其完整可见;已可见时不移动。侧栏使用当前路由去重,快速切换保留最新目标。折叠按钮和分组操作过滤同一控件的连点。
|
|
||||||
- 体验、用户、控制台和企业中心的加载占位复用侧栏外壳,保持宽度、菜单起点及底部折叠条位置。企业身份和分组标题保留对应占位。
|
|
||||||
- 企业信息区为无底框网格图标(24px / 1.65 线宽),内边距 28px 16px 26px,图文间距 10px;企业名与身份 12px / 20px 行高,身份上距 2px。
|
- 企业信息区为无底框网格图标(24px / 1.65 线宽),内边距 28px 16px 26px,图文间距 10px;企业名与身份 12px / 20px 行高,身份上距 2px。
|
||||||
- 个人侧栏只保留容器外侧分隔线,内层 Menu 不叠加 `border-inline-end`;企业侧栏不提供菜单搜索。
|
- 个人侧栏只保留容器外侧分隔线,内层 Menu 不叠加 `border-inline-end`;企业侧栏不提供菜单搜索。
|
||||||
- 内容外壳设 `min-width: 0`,防止宽表格挤压;桌面滚动区保留稳定槽位并补足 16px 留白,移动端不补。
|
- 内容外壳设 `min-width: 0`,防止宽表格挤压;桌面滚动区保留稳定槽位并补足 16px 留白,移动端不补。
|
||||||
@@ -79,15 +74,15 @@
|
|||||||
|
|
||||||
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`。
|
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 装饰层。
|
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` 登记,分组页显示“分组 / 当前页面”,其他为“企业中心 / 当前页面”,未登记页面以标题兜底;体验中心(云端大脑 / 图片生成 / 视频生成)用 `ExperiencePageHeader`(内部复用 `UserCenterPageHeader`),显示“体验中心 / 当前页面”,企业中心宿主的云端大脑保留原卡片页头。带 hero 的企业功能页在 hero 内首个元素顶部放 `<OrgBreadcrumb />`。不在原本没有面包屑的页面新增导航;没有副标题文案时只传 `title`。
|
3. **面包屑登记**:用户中心在 `UserCenterBreadcrumb.jsx` 的 `pageTitles` 登记,显示“用户中心 / 当前页面”;企业中心在 `OrgBreadcrumb` 的 `orgPageGroups` 登记,分组页显示“分组 / 当前页面”,其他为“企业中心 / 当前页面”,未登记页面以标题兜底。带 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 固定列表格的横向滚动行为,不隐藏滚动条。
|
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. **验证**:逐页核对左右边距、面包屑顶距、标题与副标题字号间距、滚动条静止与悬停颜色(桌面 / 移动 × 浅 / 深)。
|
5. **验证**:逐页核对左右边距、面包屑顶距、标题与副标题字号间距、滚动条静止与悬停颜色(桌面 / 移动 × 浅 / 深)。
|
||||||
|
|
||||||
### 4.5 登录页与认证顶栏
|
### 4.5 登录页与认证顶栏
|
||||||
|
|
||||||
- 认证页(`/login`、`/org/login`、`/org/:slug/login`、`/register`、`/org/register`、`/reset`、`/user/reset`)统一使用登录顶栏 `.login-layout-header` 与局部布局 `.auth-login-page`,顶栏采用后台标准样式,无品牌条、玻璃渐变与反光层;仅客户端授权页 `/client/authorize` 保留 `.auth-layout-header` 透出背景。
|
- `/org/login` 与 `/login` 顶栏采用后台标准样式,无品牌条、玻璃渐变与反光层。登录页局部布局 `.auth-login-page`;其他认证顶栏 `.auth-layout-header` 透出既有背景;登录顶栏 `.login-layout-header`。
|
||||||
- 登录卡片无顶部装饰线、反光、外发光、角落光晕与 Logo 光环 / 星标;企业 / 个人切换用 antd `Button`;输入框、下拉、整行按钮与认证弹窗(`.auth-login-modal`)控件统一 36px 高、8px 圆角(`--auth-control-height`),必填标识经 `Form.Item` 呈现;表单项无下边距,label 12px、与输入框间距 7px,输入框下方固定预留 22px 报错位(`--auth-error-line`),必填与非必填项间距一致,正常、报错、修正三态布局稳定。第三方登录用描边整行按钮,无位移与扫光;分隔线用 `AuthDivider`。规则集中在 `src/styles/prototype.css` 的 `.auth-login-page` 段。
|
- 登录卡片无顶部装饰线与反光;企业 / 个人切换用 antd `Button`;输入框 34px 高、8px 圆角,必填标识经 `Form.Item` 呈现;凭据字段只预留必要的错误提示高度,正常、报错、修正三态布局稳定。
|
||||||
- 副标题、“记住登录名”、管理员重置提示与“忘记密码”使用加深 20% 的次文字色,无悬停底色,“忘记密码”悬停再加深;“切换企业”与“登录”同为主按钮样式。认证表单必填项显示 `*` 并就地提示:输入框“请输入 + label”,选择框“请选择 + label”;邮箱等格式校验沿用原判断与文案;校验用 `rules` / `validate`,通过后调用原处理函数,页面自管的受控输入(企业登录第 1 步)失焦为空时提示且不改按钮禁用条件。样式与校验调整不得改变登录校验、回调与载荷。
|
- 副标题、“记住登录名”、管理员重置提示与“忘记密码”使用加深 20% 的次文字色,无悬停底色,“忘记密码”悬停再加深;“切换企业”与“登录”同为主按钮样式。个人登录必填校验用 `rules`,通过后调用原登录处理函数。样式调整不得改变登录校验、回调与载荷。
|
||||||
|
|
||||||
### 4.6 导航入口
|
### 4.6 导航入口
|
||||||
|
|
||||||
@@ -97,7 +92,6 @@
|
|||||||
|
|
||||||
- 带侧栏页面按 4.4;控制台按 `CONSOLE_SPEC.md`;其余页面内容默认 24px 30px、移动 16px。筛选区自然换行,表格在自身容器横向滚动;不通过隐藏正文、裁剪校验信息或固定整页宽度迎合截图。
|
- 带侧栏页面按 4.4;控制台按 `CONSOLE_SPEC.md`;其余页面内容默认 24px 30px、移动 16px。筛选区自然换行,表格在自身容器横向滚动;不通过隐藏正文、裁剪校验信息或固定整页宽度迎合截图。
|
||||||
- 模型超市与技能超市的工作区居中,含内边距的最大宽度为 1760px;横向内边距为 `clamp(20px, 4vw, 80px)`,Hero 搜索区域沿用同一横向留白,600px 及以下为 20px。覆盖 3840 / 2560 / 1920 至 360px 宽度,目录按实际可用宽度减少列数,保留卡片正文和控件正常字号,不通过整体缩放压缩内容。
|
- 模型超市与技能超市的工作区居中,含内边距的最大宽度为 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 绘制的背景按测量值在页面作用域复现,不用生成插画替代。
|
- 背景图优先复用原型的原始 SVG / 图片,放入 `src/assets/prototype` 并注明来源;原型用 CSS 绘制的背景按测量值在页面作用域复现,不用生成插画替代。
|
||||||
- 企业工作台横幅 `.ew-hero` 的浅金 / 深棕背景与三层轮廓只用于 `.org-workbench`,不扩散到其他页面。
|
- 企业工作台横幅 `.ew-hero` 的浅金 / 深棕背景与三层轮廓只用于 `.org-workbench`,不扩散到其他页面。
|
||||||
- 原型未定义、antd 有组件:用当前版本默认样式与主题 token。antd 无对应部件:语义背景 / 文字 / 边框,无装饰背景、阴影与动画,间距 8 / 16 / 24px,窄屏堆叠且操作可达;新增此类统一规则先写入本文。
|
- 原型未定义、antd 有组件:用当前版本默认样式与主题 token。antd 无对应部件:语义背景 / 文字 / 边框,无装饰背景、阴影与动画,间距 8 / 16 / 24px,窄屏堆叠且操作可达;新增此类统一规则先写入本文。
|
||||||
@@ -112,12 +106,12 @@
|
|||||||
- `/console/*` 控制台:超管账号,经 `/login` 登录;不先用普通账号试探控制台权限。
|
- `/console/*` 控制台:超管账号,经 `/login` 登录;不先用普通账号试探控制台权限。
|
||||||
- 共享组件或跨中心改动:追踪实际引用,在受影响的中心分别验收;不同账号使用独立 Context,避免企业、个人与超管会话混用。不因一句泛化测试指令执行无关页面的全量验收。
|
- 共享组件或跨中心改动:追踪实际引用,在受影响的中心分别验收;不同账号使用独立 Context,避免企业、个人与超管会话混用。不因一句泛化测试指令执行无关页面的全量验收。
|
||||||
- 执行前用简短进度说明告知已判断的范围与账号类型,直接继续。先使用现有本地配置;仅在范围经代码分析仍不明确、必要凭据缺失或实际权限不足时询问。用户明确“无需测试”“无需生产测试”等限制优先,普通测试指令不自动授权生产构建或生产环境操作。
|
- 执行前用简短进度说明告知已判断的范围与账号类型,直接继续。先使用现有本地配置;仅在范围经代码分析仍不明确、必要凭据缺失或实际权限不足时询问。用户明确“无需测试”“无需生产测试”等限制优先,普通测试指令不自动授权生产构建或生产环境操作。
|
||||||
2. Base URL 按第 7.1 节通过项目目录、启动日志与监听进程查找并核验,服务可用即复用;日志中的失效地址不能作为新启服务的依据。仅确认不存在时,Windows 用 `Start-Process -WindowStyle Hidden` 启动并写入 `dev.log`,支持 nohup 的 shell 用 `nohup npm run dev > dev.log 2>&1 &`。
|
2. Base URL 只取 `dev.log` 最后一个 `Local:`(去除 ANSI 色码),禁止写死 IP / 端口;服务可用即复用。Windows 用 `Start-Process -WindowStyle Hidden` 启动并写入 `dev.log`,支持 nohup 的 shell 用 `nohup npm run dev > dev.log 2>&1 &`。
|
||||||
3. 企业入口 `{Base URL}/org/login`,`waitForLoadState('networkidle')` 后检查可见非隐藏、非复选框输入框的数量、placeholder / 标签与按钮,打印不含输入值的判定并截图。
|
3. 企业入口 `{Base URL}/org/login`,`waitForLoadState('networkidle')` 后检查可见非隐藏、非复选框输入框的数量、placeholder / 标签与按钮,打印不含输入值的判定并截图。
|
||||||
- 状态 A:一个企业输入框 +“下一步”。先填企业名称,点击“下一步”,等“企业内登录名”“密码”“登录”出现后再填凭据;不得把登录名当企业名,不得跳过企业查询。
|
- 状态 A:一个企业输入框 +“下一步”。先填企业名称,点击“下一步”,等“企业内登录名”“密码”“登录”出现后再填凭据;不得把登录名当企业名,不得跳过企业查询。
|
||||||
- 状态 B:已出现登录名、密码与“登录”。直接填写凭据,保留已解析的企业上下文。
|
- 状态 B:已出现登录名、密码与“登录”。直接填写凭据,保留已解析的企业上下文。
|
||||||
4. 个人端:新建无企业 Cookies / Storage 的 Context,进入 `{Base URL}/login`,按页面原有协议勾选与登录,确认用户中心侧栏与主体渲染后保存 storageState。
|
4. 个人端:新建无企业 Cookies / Storage 的 Context,进入 `{Base URL}/login`,按页面原有协议勾选与登录,确认用户中心侧栏与主体渲染后保存 storageState。
|
||||||
5. 凭据只经环境变量传入:企业 `UI_ORG_NAME` / `UI_ORG_USER` / `UI_ORG_PASS`,普通个人 `UI_PERSONAL_USER` / `UI_PERSONAL_PASS`,超管 `UI_ADMIN_USER` / `UI_ADMIN_PASS`。本机通过 `.env.playwright.local` 加载,不要求用户每次重新提供;该文件仅保存测试账号,按用户约定不作 Git 忽略,允许入库。值仍不得回显或写入脚本、日志、截图注释、报告;登录阶段不录 trace / HAR,其他凭据与 storageState 不入库。本地入口和账号选择参数见 `README.md` 的“本地 Playwright 登录配置”。
|
5. 凭据只经环境变量传入:企业 `UI_ORG_NAME` / `UI_ORG_USER` / `UI_ORG_PASS`,普通个人 `UI_PERSONAL_USER` / `UI_PERSONAL_PASS`,超管 `UI_ADMIN_USER` / `UI_ADMIN_PASS`。本机可通过确认未跟踪且已忽略的 `.env.playwright.local` 加载,不要求用户在每次任务中重新提供;不得输出其值,不写入脚本、日志、截图注释、报告或提交;登录阶段不录 trace / HAR。本地入口、跟踪 / 忽略检查和账号选择参数见 `README.md` 的“本地 Playwright 登录配置”。
|
||||||
6. 失败时截图,记录 `dev.log` 尾部与失败请求(密码、Cookie、token、ticket 脱敏),写入风险;不盲目重试,不改登录业务代码。
|
6. 失败时截图,记录 `dev.log` 尾部与失败请求(密码、Cookie、token、ticket 脱敏),写入风险;不盲目重试,不改登录业务代码。
|
||||||
7. 结束时通过顶栏用户菜单“退出登录”,确认回到登录页(当前为 `/org/login`)且受保护路由不再渲染。
|
7. 结束时通过顶栏用户菜单“退出登录”,确认回到登录页(当前为 `/org/login`)且受保护路由不再渲染。
|
||||||
|
|
||||||
@@ -126,7 +120,7 @@
|
|||||||
### 7.1 工具
|
### 7.1 工具
|
||||||
|
|
||||||
- 优先使用项目 Playwright 配置(`playwright.config.js`:`testDir: ./e2e`、`workers` 默认 1,可由正整数 `PW_WORKERS` 覆盖)与本机 Chrome(`channel: 'chrome'`)。默认离屏,保留 `UI_VISUAL_OFFSCREEN=1`(只降低可见干扰,不保证没有瞬时焦点激活);要求不启动有头窗口时可用无头模式并在报告注明。
|
- 优先使用项目 Playwright 配置(`playwright.config.js`:`testDir: ./e2e`、`workers` 默认 1,可由正整数 `PW_WORKERS` 覆盖)与本机 Chrome(`channel: 'chrome'`)。默认离屏,保留 `UI_VISUAL_OFFSCREEN=1`(只降低可见干扰,不保证没有瞬时焦点激活);要求不启动有头窗口时可用无头模式并在报告注明。
|
||||||
- 测试优先复用用户已启动的本项目开发服务:结合项目目录、启动日志(优先 `dev.log`,兼容 UTF-8 / UTF-16LE)、进程和监听端口查找候选地址,验证响应属于当前项目。历史日志地址失效时继续查找,不得直接启动新服务;仅确认本项目服务不存在时才启动,并记录、清理本次进程,不结束用户进程。项目 Playwright 配置通过 `scripts/dev-service.mjs` 自动发现服务并以 `PW_TARGET=remote` + `PW_BASE_URL` 复用;显式指定目标时保留调用方配置。专项脚本是否接收 `PLAYWRIGHT_BASE_URL` 以其实现为准,不能用它替代 runner 的 `PW_BASE_URL`。Playwright 失败先排查服务地址、元素定位、等待条件、浏览器环境与登录状态。
|
- 运行前从 `dev.log` 最后一个 `Local:` 提取地址;runner 复用服务时设 `PW_TARGET=remote` + `PW_BASE_URL`,不会启动或关闭已有服务。专项脚本是否接收 `PLAYWRIGHT_BASE_URL` 以其实现为准,不能用它替代 runner 的 `PW_BASE_URL`。Playwright 失败先排查服务地址、元素定位、等待条件、浏览器环境与登录状态。
|
||||||
- 默认 runner 为浅色、1920×1080 / 360×800,本地有头、CI 无头,`webServer.reuseExistingServer=false`;默认执行不等于完成第 7.3 节浅深主题与规范视口矩阵,须在用例或专项脚本补足。严格有头焦点约束见第 7.1.1 节。
|
- 默认 runner 为浅色、1920×1080 / 360×800,本地有头、CI 无头,`webServer.reuseExistingServer=false`;默认执行不等于完成第 7.3 节浅深主题与规范视口矩阵,须在用例或专项脚本补足。严格有头焦点约束见第 7.1.1 节。
|
||||||
- `e2e/` 为本地忽略目录,验收脚本不随仓库分发;新增脚本同样放在该目录。
|
- `e2e/` 为本地忽略目录,验收脚本不随仓库分发;新增脚本同样放在该目录。
|
||||||
|
|
||||||
@@ -154,9 +148,9 @@
|
|||||||
| 配置 | 约定 |
|
| 配置 | 约定 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 设备源 | `scripts/ui-review/config.json` → `scripts/browser-environment.mjs`;与 weelink 的设备结构和 Playwright 1.64.1 保持一致,各项目独立保存 |
|
| 设备源 | `scripts/ui-review/config.json` → `scripts/browser-environment.mjs`;与 weelink 的设备结构和 Playwright 1.64.1 保持一致,各项目独立保存 |
|
||||||
| 视口 | 默认 1920×1080、360×800、393×851;扩展增加 768×1024、1024×768、1366×768、1440×900、2560×1440、3840×2160 |
|
| 视口 | 默认 1920×1080、360×800;扩展增加 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 沿用模板;平板仅为桌面设备的平板尺寸 |
|
| 手机 | Pixel 5 UA、触摸、移动模式和 DPR 2.75;viewport 覆盖为 360×800,screen 沿用模板;平板仅为桌面设备的平板尺寸 |
|
||||||
| 本地目标 | 未指定目标时自动发现并复用已有开发服务,确认不存在后才启动 `http://127.0.0.1:4176/`;开发和预览均严格占用指定端口,禁止静默回退 |
|
| 本地目标 | `PW_TARGET=local-dev` 默认启动 `http://127.0.0.1:4176/`,weelink 使用 4175;开发和预览均严格占用指定端口,禁止静默回退 |
|
||||||
| 目标切换 | `local-dist` 先校验静态入口与引用资源,再启动 Vite preview;`remote` 必须提供 `PW_BASE_URL`,不启动服务 |
|
| 目标切换 | `local-dist` 先校验静态入口与引用资源,再启动 Vite preview;`remote` 必须提供 `PW_BASE_URL`,不启动服务 |
|
||||||
| 窗口 | 本地默认有头离屏;`PW_HEADLESS=1` 无头,CI 强制无头;隐藏滚动条并禁用后台降频 |
|
| 窗口 | 本地默认有头离屏;`PW_HEADLESS=1` 无头,CI 强制无头;隐藏滚动条并禁用后台降频 |
|
||||||
| 并发 | 默认单 worker、文件内不拆分;`PW_WORKERS` 只接受正安全整数,不代表动态内存调度 |
|
| 并发 | 默认单 worker、文件内不拆分;`PW_WORKERS` 只接受正安全整数,不代表动态内存调度 |
|
||||||
@@ -179,7 +173,7 @@
|
|||||||
|
|
||||||
### 7.3 采集与判定
|
### 7.3 采集与判定
|
||||||
|
|
||||||
- 固定视口(桌面 1920×1000,移动 393×851 和 360×800。360×800 是必测的最小移动视口,专项可增加其他尺寸)、DPR 1、`zh-CN`、`Asia/Shanghai`、`reducedMotion: reduce`、相同数据与状态;用角色、标签、测试标识定位,用条件等待,不依赖固定延时与坐标。
|
- 固定视口(桌面 1920×1000 / 移动 393×851,专项另有规定从其规定)、DPR 1、`zh-CN`、`Asia/Shanghai`、`reducedMotion: reduce`、相同数据与状态;用角色、标签、测试标识定位,用条件等待,不依赖固定延时与坐标。
|
||||||
- 等待懒加载、骨架屏、提交中状态结束;检查错误消息、控制台、实际路由与无效数值,不能只凭无 pageerror 判定通过。
|
- 等待懒加载、骨架屏、提交中状态结束;检查错误消息、控制台、实际路由与无效数值,不能只凭无 pageerror 判定通过。
|
||||||
- 只读验收记录所有非 GET `/api/` 请求(应为 0);模拟响应按接口真实结构提供并标注;真实写入只用可清理的测试数据;支付未启用不得写成支付通过。
|
- 只读验收记录所有非 GET `/api/` 请求(应为 0);模拟响应按接口真实结构提供并标注;真实写入只用可清理的测试数据;支付未启用不得写成支付通过。
|
||||||
- 定位双字按钮允许 antd 默认字间距,如 `getByRole('button', { name: /^(?:loadings+)?保s*存$/ })`;虚拟 Select 用可见选项或组合框键盘操作,不点击隐藏的辅助选项。
|
- 定位双字按钮允许 antd 默认字间距,如 `getByRole('button', { name: /^(?:loadings+)?保s*存$/ })`;虚拟 Select 用可见选项或组合框键盘操作,不点击隐藏的辅助选项。
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 路由 | `/user-center/key-management`,旧 `/key-management` 重定向 |
|
| 路由 | `/user-center/key-management`,旧 `/key-management` 重定向 |
|
||||||
| 视图 | `KeyManagement/index.jsx` + `key-management.css`;编辑抽屉由 `EditTokenModal presentation='drawer'` 渲染 |
|
| 视图 | `KeyManagement/index.jsx` + `key-management.css`;编辑抽屉由 `EditTokenModal presentation='drawer'` 渲染 |
|
||||||
| 业务 | `useTokensData` 负责后端查询与分页;`buildTokenPayload`、启停与删除确认不变 |
|
| 业务 | `useTokensData`、`/api/token*`、`buildTokenPayload`、启停与删除确认不变 |
|
||||||
| 列表 | 固定列宽,默认每页 10 条;列设置不持久化 |
|
| 列表 | 固定列宽,每页 5 条;列设置不持久化 |
|
||||||
| 抽屉 | 模型列表 440px;创建 / 编辑 560px(移动 100%) |
|
| 抽屉 | 模型列表 440px;创建 / 编辑 560px(移动 100%) |
|
||||||
| 外壳 | 页头与边距按 `GLOBAL_UI_BASELINE.md` 4.4 |
|
| 外壳 | 页头与边距按 `GLOBAL_UI_BASELINE.md` 4.4 |
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
| `src/pages/KeyManagement/key-management.css` | 页面作用域样式与 `--km-*` 变量 |
|
| `src/pages/KeyManagement/key-management.css` | 页面作用域样式与 `--km-*` 变量 |
|
||||||
| `src/components/table/tokens/modals/EditTokenDrawer.jsx` | 创建 / 编辑抽屉视图 |
|
| `src/components/table/tokens/modals/EditTokenDrawer.jsx` | 创建 / 编辑抽屉视图 |
|
||||||
| `src/components/table/tokens/modals/EditTokenModal.jsx` | 状态、`formApi`、`submit`、`buildTokenPayload`;`presentation='drawer'` 时渲染抽屉 |
|
| `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)。
|
独立路由形态(`.km-page-standalone`)只补顶栏偏移(桌面 100px、移动 80px)。
|
||||||
|
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
| 区域 | 规则 |
|
| 区域 | 规则 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 页头 | `UserCenterPageHeader`;“新手教程 / 查看操作指引”图标按钮保留在右侧 |
|
| 页头 | `UserCenterPageHeader`;“新手教程 / 查看操作指引”图标按钮保留在右侧 |
|
||||||
| 查询卡 | 保留单输入框,匹配密钥名称、Key 或分组。输入防抖,点击搜索或按回车立即提交,重置取消待提交条件并回到普通列表第 1 页 |
|
| 查询卡 | 单字段:标签 + `Input allowClear`(宽 620px)+“重置”“搜索”;卡片上下内边距 22px,描边 `#f0f0f0`(深色 `--border-subtle`) |
|
||||||
| 列表 | `Table size='middle' tableLayout='fixed'`,列宽 150 / 300 / 150 / 100 / 180 / 100 / 100 / 130;默认每页 10 条;列设置用 `ColumnSettings`,不持久化 |
|
| 列表 | `Table size='middle' tableLayout='fixed'`,列宽 150 / 300 / 150 / 100 / 180 / 100 / 100 / 130;每页 5 条;列设置用 `ColumnSettings`,不持久化 |
|
||||||
| 状态 | `TableStatusSwitch`(`onChange` 仍走原 `Modal.confirm` → `manageToken`);已过期 / 已耗尽另显示语义 `Tag` |
|
| 状态 | `Switch`(`onChange` 仍走原 `Modal.confirm` → `manageToken`);已过期 / 已耗尽另显示语义 `Tag` |
|
||||||
| 分组 | `TableGroupTags` + `Tooltip`,颜色按组件公共规范;额度为 `Tag color='success'` |
|
| 分组 | `Tag color='blue'` 无边框 + `Tooltip`;额度为 `Tag color='success'` |
|
||||||
| 密钥 | `<code>` 密钥框(底 `#f4f6f9`、描边 `#e4e9ee`,深色引用 `--surface-bg-base` / `--border-subtle`)+ 显示、隐藏、复制图标按钮 + `Tooltip`;脱敏提示 `Alert type='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` |
|
| 模型抽屉 | 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 |
|
| 编辑抽屉 | 560px(移动 100%);适配 `Form requiredMark={false}`;过期快捷 `Button` 组(间距 5px、描边 `#d9dfe6`、无按钮阴影,`aria-pressed`);仅“自定义”显示 `DatePicker showTime`;高级设置 `Collapse`(`forceRender`)+ `Switch` + `Divider`;页脚按钮间距 10px |
|
||||||
@@ -48,8 +48,7 @@
|
|||||||
|
|
||||||
## 3. 保留功能与已知差异
|
## 3. 保留功能与已知差异
|
||||||
|
|
||||||
- 默认名称 `claudeNN`、过去日期禁用为业务默认。
|
- 默认名称 `claudeNN`、每页 5 条、过去日期禁用为业务默认;“搜索”与回车即时生效。
|
||||||
- 普通列表通过 `/api/token/` 服务端分页。个人搜索接口当前不支持单条件同时匹配名称、Key 和分组,也不提供分页结果;为保持原有条件,搜索复用个人列表接口取全后本地匹配和分页,不调用控制台管理接口。未取全时不展示部分搜索结果。
|
|
||||||
- 技能注入关闭时“绑定技能”字段仅隐藏,仍注册在表单中,载荷不变。
|
- 技能注入关闭时“绑定技能”字段仅隐藏,仍注册在表单中,载荷不变。
|
||||||
- 模型抽屉不显示来源说明行;“自定义”过期选项选中时仅文字变主色。
|
- 模型抽屉不显示来源说明行;“自定义”过期选项选中时仅文字变主色。
|
||||||
- 第三方新手引导(Joyride)沿用其自身配色配置。
|
- 第三方新手引导(Joyride)沿用其自身配色配置。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 模型超市 UI 规范(/market)
|
# 模型超市 UI 规范(/market)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.5
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-16 · 版本:v2.4
|
||||||
|
|
||||||
个人端模型超市 `/market` 的规范。本页为独立视觉页面,组件映射优先于公共规范。
|
个人端模型超市 `/market` 的规范。本页为独立视觉页面,组件映射优先于公共规范。
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
| 区域 | 写法 |
|
| 区域 | 写法 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 搜索 | `Input`(`allowClear`、前缀图标)+ `Button`(重置 / 搜索 primary) |
|
| 搜索 | `Input`(`allowClear`、前缀图标)+ `Button`(重置 / 搜索 primary) |
|
||||||
| 筛选 | `Card` 位于结果栏下方、厂商分区上方;仅展示厂商、计费、端点三组可换行 `Button`(`aria-pressed`),隐藏用户分组与模型标签筛选行;不显示计数;“disabled 或计数为 0”时禁用 |
|
| 筛选 | `Card` 位于结果栏下方、厂商分区上方;厂商、计费、分组、标签、端点五组可换行 `Button`(`aria-pressed`);不显示计数;“disabled 或计数为 0”时禁用 |
|
||||||
| 筛选展开 | 默认仅显示厂商行;卡头保留重置与“展开更多 / 收起筛选”`Button`,同步 `aria-expanded` / `aria-controls`,收起不清空条件;装饰品牌图标设 `aria-hidden` |
|
| 筛选展开 | 默认仅显示厂商行;卡头保留重置与“展开更多 / 收起筛选”`Button`,同步 `aria-expanded` / `aria-controls`,收起不清空条件;装饰品牌图标设 `aria-hidden` |
|
||||||
| 分区标题 | `.mm-section-title`:图标框 + h2 + “N 款模型” |
|
| 分区标题 | `.mm-section-title`:图标框 + h2 + “N 款模型” |
|
||||||
| 卡片 | `Card`(`role=button`,Enter / Space 打开);价格格、缓存行、页脚分组与折扣 `Tag`、复制 `Button` + `Tooltip` |
|
| 卡片 | `Card`(`role=button`,Enter / Space 打开);价格格、缓存行、页脚分组与折扣 `Tag`、复制 `Button` + `Tooltip` |
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
## 8. 验收要点
|
## 8. 验收要点
|
||||||
|
|
||||||
- 搜索仅对 `model_name` 做不区分大小写的子串匹配,忽略关键词首尾空格;描述、标签、厂商名称不参与关键词匹配,其他筛选条件仍取交集;保留原前端防抖,不新增搜索请求。
|
- 搜索仅对 `model_name` 做不区分大小写的子串匹配,忽略关键词首尾空格;描述、标签、厂商名称不参与关键词匹配,其他筛选条件仍取交集;保留原前端防抖,不新增搜索请求。
|
||||||
- 视口 1920×1000 与 393×851,浅深主题;交互序列:默认厂商行 → 展开三组条件,确认用户分组与模型标签不显示 → 选择计费或端点 → 收起仍保持筛选与价格 → 重置 → 悬停卡片 → 键盘聚焦卡片 → 关键词搜索 → 选择厂商 → 空结果 → 整页滚动到底与厂商懒渲染 → 打开详情。
|
- 视口 1920×1000 与 393×851,浅深主题;交互序列:默认厂商行 → 展开五组条件 → 选择分组 → 收起仍保持筛选与价格 → 重置 → 悬停卡片 → 键盘聚焦卡片 → 关键词搜索 → 选择厂商 → 空结果 → 整页滚动到底与厂商懒渲染 → 打开详情。
|
||||||
- 响应式补充 3840×2160、2560×1440、1920×1080、中屏及断点两侧、360×800;检查两侧留白、卡片宽度、正文换行、无横向溢出,以及筛选展开和详情在窄屏上的可达性。
|
- 响应式补充 3840×2160、2560×1440、1920×1080、中屏及断点两侧、360×800;检查两侧留白、卡片宽度、正文换行、无横向溢出,以及筛选展开和详情在窄屏上的可达性。
|
||||||
- 与原型比较时使用同构模拟目录并标注;真实后端另行验证;整页 ≤ 0.5%、组件 ≤ 0.2%。
|
- 与原型比较时使用同构模拟目录并标注;真实后端另行验证;整页 ≤ 0.5%、组件 ≤ 0.2%。
|
||||||
- 本地截图回归断言非 GET `/api/` 请求为 0。
|
- 本地截图回归断言非 GET `/api/` 请求为 0。
|
||||||
|
|||||||
+15
-18
@@ -1,6 +1,6 @@
|
|||||||
# 企业中心 UI 规范(/org/\*)
|
# 企业中心 UI 规范(/org/\*)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.5
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.3
|
||||||
|
|
||||||
企业中心 12 个目标页的规范:企业中心变量、通用组件的企业中心变体与各页面规则。
|
企业中心 12 个目标页的规范:企业中心变量、通用组件的企业中心变体与各页面规则。
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
| 关注点 | 规则 |
|
| 关注点 | 规则 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 范围 | 工作台、数据看板、员工管理、项目管理、预算中心、审批中心、令牌管理(原“密钥管理”)、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”不改;“组织架构”页面名称统一为“部门管理”(与权限目录一致,2026-11-23);“角色管理”为统一权限体系新增页面(2026-11-23) |
|
| 范围 | 工作台、数据看板、员工管理、项目管理、预算中心、审批中心、密钥管理、企业充值、消耗明细、审计日志、个人设置、企业设置;“我的 AI 能力”“组织架构”“角色管理”不改 |
|
||||||
| 样式 | `org-center.css`,作用域 `.org-center .oc-page`,颜色只写 `--oc-*`(第 2 节) |
|
| 样式 | `org-center.css`,作用域 `.org-center .oc-page`,颜色只写 `--oc-*`(第 2 节) |
|
||||||
| 组件变体 | 紧凑表格、3 列筛选、无图标行操作、`.oc-list-tabs`、无边框标签(第 3 节) |
|
| 组件变体 | 紧凑表格、3 列筛选、无图标行操作、`.oc-list-tabs`、无边框标签(第 3 节) |
|
||||||
| 弹层 | `OrgModal` / `OrgSideSheet`,原型风格遮罩;密钥抽屉 560px |
|
| 弹层 | `OrgModal` / `OrgSideSheet`,原型风格遮罩;密钥抽屉 560px |
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
- 视觉依据:在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(深色用“切换至暗色主题”),只作视觉依据,不作业务、路由、数据依据。
|
- 视觉依据:在线原型 `http://192.168.0.161:8888` 顶栏“企业中心”(深色用“切换至暗色主题”),只作视觉依据,不作业务、路由、数据依据。
|
||||||
- 只对齐背景、字体、图标、表格、表单、卡片、页签、搜索条件、操作列、弹窗、按钮、颜色、文字、间距与已有交互反馈;不改请求、载荷、状态、路由、权限与触发条件。
|
- 只对齐背景、字体、图标、表格、表单、卡片、页签、搜索条件、操作列、弹窗、按钮、颜色、文字、间距与已有交互反馈;不改请求、载荷、状态、路由、权限与触发条件。
|
||||||
- 原型有而系统无的功能不补建:CSV 导出、在职 / 离职页签、订单号搜索、分组列、发票入口。例外:企业密钥管理的分组列与列设置已按需求实现。
|
- 原型有而系统无的功能不补建:员工筛选卡、CSV 导出、尺寸切换分页、新建员工 / 分配角色 / 离职、角色管理、在职 / 离职筛选、订单号搜索、分组列、发票入口。例外:企业密钥管理的分组列与列设置已按需求实现。
|
||||||
|
|
||||||
## 2. 作用域与变量
|
## 2. 作用域与变量
|
||||||
|
|
||||||
@@ -49,8 +49,8 @@
|
|||||||
通用卡片、筛选栏、表格、分页、弹层、页签、标签样式按 `UI_COMPONENT_STANDARDS.md`;企业中心的差异如下。
|
通用卡片、筛选栏、表格、分页、弹层、页签、标签样式按 `UI_COMPONENT_STANDARDS.md`;企业中心的差异如下。
|
||||||
|
|
||||||
- **页头**:`OrgPageHeader`(内部复用 `UserCenterPageHeader`),规格见 `GLOBAL_UI_BASELINE.md` 4.4;页头不放操作按钮,操作移入列表卡头。面包屑分组见 4.4 第 3 条。
|
- **页头**:`OrgPageHeader`(内部复用 `UserCenterPageHeader`),规格见 `GLOBAL_UI_BASELINE.md` 4.4;页头不放操作按钮,操作移入列表卡头。面包屑分组见 4.4 第 3 条。
|
||||||
- **列表卡 `OrgListCard`**:卡头与表格间距 20px;表格为紧凑变体(正文 13px,表头 12px / 500、底色 `--oc-soft`,行上下内边距 17px);分页按公共组件规范,覆盖页签及表格明细。
|
- **列表卡 `OrgListCard`**:卡头与表格间距 20px;表格为紧凑变体(正文 13px,表头 12px / 500、底色 `--oc-soft`,行上下内边距 17px);分页不提供每页条数切换。
|
||||||
- **筛选卡 `OrgFilterCard`**:默认 3 列。提示词记录和消耗明细的筛选区沿用个人消费记录的布局。筛选取值与生效时机沿用原页面(审计日志为“选择即筛选”,“搜索”以当前条件重新查询)。
|
- **筛选卡 `OrgFilterCard`**:固定 3 列;筛选取值与生效时机沿用原页面(审计日志为“选择即筛选”,“搜索”以当前条件重新查询)。
|
||||||
- **行操作 `OrgRowActions`**:link 按钮 13 / 24px、无内边距、间距 10px,不带图标。
|
- **行操作 `OrgRowActions`**:link 按钮 13 / 24px、无内边距、间距 10px,不带图标。
|
||||||
- **列表页签 `.oc-list-tabs`**:导航高 44px,页签内边距 12px 0,选中与悬停色为 `--oc-brand`;只切换筛选时加 `.oc-tabs-nav-only`。
|
- **列表页签 `.oc-list-tabs`**:导航高 44px,页签内边距 12px 0,选中与悬停色为 `--oc-brand`;只切换筛选时加 `.oc-tabs-nav-only`。
|
||||||
- **标签**:表格与卡片内标签统一无边框(`variant='filled'`);非 antd 预设色改用 `gold` / `purple`。
|
- **标签**:表格与卡片内标签统一无边框(`variant='filled'`);非 antd 预设色改用 `gold` / `purple`。
|
||||||
@@ -64,15 +64,14 @@
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| 工作台 | `OrgHero` 标签化身份与 `oc-wb-*` 卡片(额度、密钥、用量、最近申请);横幅 `.ew-hero` 背景只在 `.org-workbench` 作用域 | 额度周期标签放在重置卡;最近申请无分页 |
|
| 工作台 | `OrgHero` 标签化身份与 `oc-wb-*` 卡片(额度、密钥、用量、最近申请);横幅 `.ew-hero` 背景只在 `.org-workbench` 作用域 | 额度周期标签放在重置卡;最近申请无分页 |
|
||||||
| 数据看板 | `oc-dash-*` hero(健康提示“企业运行正常”、企业名、企业额度、组织概况)+ `OrgAnalyticsPanel`(汇总条、趋势 `Segmented`、分布、明细页签) | 时间范围 7 / 30 / 90 天;企业名来自 `orgInfo.name`,无值时隐藏 |
|
| 数据看板 | `oc-dash-*` hero(健康提示“企业运行正常”、企业名、企业额度、组织概况)+ `OrgAnalyticsPanel`(汇总条、趋势 `Segmented`、分布、明细页签) | 时间范围 7 / 30 / 90 天;企业名来自 `orgInfo.name`,无值时隐藏 |
|
||||||
| 员工管理 | 筛选卡(关键字、分组、组织、状态,服务端筛选)+ 单张列表卡,不分页签;备注独立列;状态 `Switch`;新建 / 编辑用抽屉 | 无在职 / 离职页签 |
|
| 员工管理 | 页签(员工权限 / 员工账号)+ 列表卡;首列与操作列固定;备注独立列;状态 `Switch` | 无筛选卡与在职 / 离职页签 |
|
||||||
| 项目管理 | `OrgListCard` + link 操作(模型 / 分组 / 成员 / 密钥 / 编辑);状态开关 | 操作列不再显示“停用” |
|
| 项目管理 | `OrgListCard` + link 操作(模型 / 分组 / 成员 / 密钥 / 编辑);状态开关 | 操作列不再显示“停用” |
|
||||||
| 预算中心 | `.oc-policy` 固定说明条;列宽 300 / 110 / 260 / 120 / 120 / 130;状态开关 | 已加载数据前端分页 |
|
| 预算中心 | `.oc-policy` 固定说明条;列宽 300 / 110 / 260 / 120 / 120 / 130;状态开关 | 无分页 |
|
||||||
| 审批中心 | 状态页签(回调 `setStatusFilter`)+ 申请列表卡;拒绝弹窗竖排表单项 | — |
|
| 审批中心 | 状态页签(回调 `setStatusFilter`)+ 申请列表卡;拒绝弹窗竖排表单项 | — |
|
||||||
| Agent 任务审计 | 保留页头状态筛选、任务元数据 / 待对账 / 安全策略三个页签。记录按卡片排列,任务状态和计费状态使用独立标签,弹窗使用 `OrgModal` | 正文必须填写有效审计原因并经二次确认。页签计数、操作和焦点使用系统品牌色,状态标签使用语义色。窄屏按单列排列卡片,长编号换行 |
|
| 密钥管理 | 密钥框 + 显隐 / 复制、可用模型 link、分组列、状态开关、绝对时间;列设置用共享组件;创建 / 编辑为 560px `OrgSideSheet` | 列设置只在当前页面生效 |
|
||||||
| 密钥管理 | 密钥框 + 显隐 / 复制、可用模型 link、分组列、状态开关、绝对时间;列设置用共享组件;创建 / 编辑为 560px `OrgSideSheet` | 列设置只在当前页面生效;非操作列整体横向滚动,仅在可见列宽度超过容器时显示滚动条 |
|
|
||||||
| 企业充值 | 企业钱包 + 充值工作区(额度卡 / 自定义 / 支付方式)+ 订单卡 + 记录;订单“立即充值”与支付方式点击同为 `handlePreTopUp` | 档位与折扣来自后台配置;无订单号搜索与发票入口 |
|
| 企业充值 | 企业钱包 + 充值工作区(额度卡 / 自定义 / 支付方式)+ 订单卡 + 记录;订单“立即充值”与支付方式点击同为 `handlePreTopUp` | 档位与折扣来自后台配置;无订单号搜索与发票入口 |
|
||||||
| 消耗明细 | 统计卡 + 页签(明细日志 / 成员排行 / 绘图与视频)+ 消费记录样式筛选卡 + 列表卡;查询按钮为“搜索”(`handleSearch`) | 见第 5 节 |
|
| 消耗明细 | 统计卡 + 页签(明细日志 / 成员排行 / 绘图与视频)+ 三列筛选卡 + 列表卡;查询按钮为“搜索”(`handleSearch`) | 见第 5 节 |
|
||||||
| 审计日志 | 页签 + 筛选卡(操作类型)+ 操作记录卡;“提示词记录”页签沿用原显隐,筛选区参考消费记录;说明条上下与筛选卡至列表卡均间隔 18px | — |
|
| 审计日志 | 页签 + 筛选卡(操作类型)+ 操作记录卡;“提示词记录”页签沿用原显隐 | — |
|
||||||
| 个人设置 | 复用用户中心 `ui-personal-*`、`AvatarSection`、`SectionHeader`;三页签:头像设置 / 个人资料 / 通知设置;企业身份并入资料头 | 昵称在弹窗中修改 |
|
| 个人设置 | 复用用户中心 `ui-personal-*`、`AvatarSection`、`SectionHeader`;三页签:头像设置 / 个人资料 / 通知设置;企业身份并入资料头 | 昵称在弹窗中修改 |
|
||||||
| 企业设置 | 设置卡内页签 + 区块头(刷新 / 保存设置);复制为 14px 无内边距图标按钮 | 保留“数据安全”“危险区域”页签 |
|
| 企业设置 | 设置卡内页签 + 区块头(刷新 / 保存设置);复制为 14px 无内边距图标按钮 | 保留“数据安全”“危险区域”页签 |
|
||||||
|
|
||||||
@@ -80,20 +79,18 @@
|
|||||||
|
|
||||||
- 剩余额度提示按未取整占比判定:> 20% 为“可用额度充足”(`#438568`),0 < 占比 ≤ 20% 为“可用额度偏低”(`#9c6b25`),≤ 0 为“可用额度已用尽”(`#b34c4c`);数据无效时隐藏,仅作提示,不影响计费或拦截。
|
- 剩余额度提示按未取整占比判定:> 20% 为“可用额度充足”(`#438568`),0 < 占比 ≤ 20% 为“可用额度偏低”(`#9c6b25`),≤ 0 为“可用额度已用尽”(`#b34c4c`);数据无效时隐藏,仅作提示,不影响计费或拦截。
|
||||||
- 多维用量分析工具组用原生 `Select` / `Button`:维度 132px、时间 86px、刷新 34px,高 34px、间距 8px。
|
- 多维用量分析工具组用原生 `Select` / `Button`:维度 132px、时间 86px、刷新 34px,高 34px、间距 8px。
|
||||||
- 模型明细使用已加载数据做前端分页(默认每页 10 条),翻页不请求接口,维度、时间或数据变化时回到第一页;表格随页面自然展开,仅窄屏横向滚动。
|
- 模型明细使用已加载数据做前端分页(每页 10 条),翻页不请求接口,维度、时间或数据变化时回到第一页;表格随页面自然展开,仅窄屏横向滚动。
|
||||||
|
|
||||||
## 5. 消耗明细(/org/logs)
|
## 5. 消耗明细(/org/logs)
|
||||||
|
|
||||||
- 三个页签和审计日志下的提示词记录共用个人消费记录的筛选布局:桌面五列,时间范围跨两列;窄屏三列,移动端单列并默认收起。操作区位于右下,“重置”在前,“搜索”在后,点击和回车共用提交入口。
|
- 绘图与视频由 `components/OrgTaskRecords.jsx` 呈现,复用 `useTaskLogsData({ organizationMode: true })`、`TaskLogsFilters`、`getTaskLogsColumns`、`exportTaskLogsPageCsv`、`ColumnSelectorModal`、`ContentModal`;结构为筛选卡 + “任务记录”列表卡(导出本页 / 刷新 / 列设置),不渲染“本页统计”区块,移动端筛选直接展开。
|
||||||
- 绘图与视频由 `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`。
|
||||||
- 任务表列宽 185 / 185 / 110 / 110 / 250 / 330 / 110 / 155 / 145 / 150;模型为行内胶囊,费用主色右对齐;分页沿用公共规范。“刷新”与“搜索”调用同一 `refresh`。
|
|
||||||
- 时间范围为本页签自有的可编辑字段(默认最近 7 天,含快捷预设),与“明细日志”筛选互不影响;起止颠倒沿用原提示。
|
- 时间范围为本页签自有的可编辑字段(默认最近 7 天,含快捷预设),与“明细日志”筛选互不影响;起止颠倒沿用原提示。
|
||||||
- 末列“操作”不固定:视频任务显示“点击预览视频”,失败任务保留失败原因查看,其余显示“-”。
|
- 末列“操作”不固定:视频任务显示“点击预览视频”,失败任务保留失败原因查看,其余显示“-”。
|
||||||
- 预览视频沿用 `ContentModal`:标题栏“视频预览”与关闭按钮、16:9 播放区、加载态、播放失败或无地址时 `Empty` 空态、页脚复制链接 / 新标签页打开 / 关闭;关闭时暂停视频,重开同一视频不残留加载指示。
|
- 预览视频沿用 `ContentModal`:标题栏“视频预览”与关闭按钮、16:9 播放区、加载态、播放失败或无地址时 `Empty` 空态、页脚复制链接 / 新标签页打开 / 关闭;关闭时暂停视频,重开同一视频不残留加载指示。
|
||||||
- 只有具备排行权限并打开「成员排行」时才查询榜单。首次打开使用已生效的成员、模型和时间范围,默认每页 10 人。翻页和更改每页人数均携带服务端返回的 `snapshot`。搜索、重置、刷新及切换企业会重新查询当前条件下的榜单。快照过期时自动按原筛选和页容量回到第 1 页重取一次。
|
- 成员排行行键使用 `user_id-名次序号`,避免后端同一成员多行时出现重复 key。
|
||||||
- 服务端按成员汇总后按消耗额度降序排列,同额按成员 ID 升序。行键使用 `user_id`,名次按返回页码、页容量和行号连续计算。前三名使用当前主题的强调色及三档底色,其余名次使用中性色。
|
|
||||||
- 明细日志查询不写 URL;绘图与视频筛选沿用原有 URL 同步。
|
- 明细日志查询不写 URL;绘图与视频筛选沿用原有 URL 同步。
|
||||||
- 保留差异:明细日志无列设置、分组列、操作列;任务表无渠道 / 用户 ID 筛选、平台列、排序与任务 ID 复制。
|
- 保留差异:明细日志无列设置、分组列、操作列与尺寸切换;任务表无渠道 / 用户 ID 筛选、平台列、排序与任务 ID 复制。
|
||||||
|
|
||||||
## 6. 验收要点
|
## 6. 验收要点
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 服务监控 UI 规范(/user-center/service-dashboard)
|
# 服务监控 UI 规范(/user-center/service-dashboard)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-19 · 版本:v2.3
|
> 状态:有效(页面暂不开放) · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.2
|
||||||
|
|
||||||
服务监控页的规范:分组可用性、历史条与详情弹窗。
|
服务监控页的规范:分组可用性、历史条与详情弹窗。
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
| 关注点 | 规则 |
|
| 关注点 | 规则 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 路由 | `/user-center/service-dashboard`,旧 `/service-dashboard` 重定向;桌面侧栏、移动底栏和页面访问统一受超管“运营设置 → 左侧边栏模块管理 → 用户中心 → 服务监控”开关(`SidebarModulesAdmin.userCenter.serviceDashboard`)及区域 / 功能可见分组控制;关闭或无分组权限时不挂载页面,回到首个可见页面,无可用页面时回到首页;未配置时沿用默认开启 |
|
| 路由 | 桌面侧栏与移动底栏隐藏服务监控;`/user-center/service-dashboard` 及旧 `/service-dashboard` 均回到用户中心首个已开放页面,无可用页面时回到首页;保留页面源码,以下视觉与验收规则供恢复时使用 |
|
||||||
| 组件 | `Card`、`Button`、详情 `Modal` + `Statistic` + `Table`、`Tooltip`、`Spin` / `Empty` |
|
| 组件 | `Card`、`Button`、详情 `Modal` + `Statistic` + `Table`、`Tooltip`、`Spin` / `Empty` |
|
||||||
| 主题 | `theme.useToken()` 注入 `--service-*`;正常态跟随 `colorPrimary`,告警 / 异常用 `colorWarning` / `colorError` |
|
| 主题 | `theme.useToken()` 注入 `--service-*`;正常态跟随 `colorPrimary`,告警 / 异常用 `colorWarning` / `colorError` |
|
||||||
| 业务 | 60 秒自动刷新、逐秒倒计时、分组权限、模型测试与请求不变 |
|
| 业务 | 60 秒自动刷新、逐秒倒计时、分组权限、模型测试与请求不变 |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 技能超市 UI 规范(/skill-market)
|
# 技能超市 UI 规范(/skill-market)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-18 · 版本:v2.3
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-13 · 版本:v2.2
|
||||||
|
|
||||||
个人端技能超市 `/skill-market` 的规范,含真实接口与本地演示两种数据模式。本页为独立视觉页面。
|
个人端技能超市 `/skill-market` 的规范,含真实接口与本地演示两种数据模式。本页为独立视觉页面。
|
||||||
|
|
||||||
@@ -60,7 +60,6 @@
|
|||||||
## 4. 主题与样式
|
## 4. 主题与样式
|
||||||
|
|
||||||
- 不新增 ConfigProvider、主题状态或存储 key;`--sm-brand = colorPrimary`、`--sm-text = colorText`,页面根与详情 Portal(`rootStyle`)共用。
|
- 不新增 ConfigProvider、主题状态或存储 key;`--sm-brand = colorPrimary`、`--sm-text = colorText`,页面根与详情 Portal(`rootStyle`)共用。
|
||||||
- 许可证徽标使用 antd 预设调色板色:待审核 / 未知决策用 `gold`、通过用 `green`、阻止用 `red`;背景与描边使用默认预设,文字取对应主题调色板第 9 档 token,提高小字号可读性;不使用非预设色名 `amber` 或固定浅色背景。卡片与详情复用同一 `LicenseBadge`。
|
|
||||||
- `.sm-theme` / `html.dark .sm-theme` 变量(浅 / 深):页面底 `#f4f6f9` / `#111720`,面板 `#fff` / `#1b232e`,次要字 `#626f80` / `#aab6c5`,边线 `#e0e5ec` / `#344151`,浅金底 `#fff2dc` / `#3c2f1f`,卡片悬停边 `#c39343`;深色文字型主色 `--sm-accent: #f2ad41`。样式规则只引用变量,无 `!important`。
|
- `.sm-theme` / `html.dark .sm-theme` 变量(浅 / 深):页面底 `#f4f6f9` / `#111720`,面板 `#fff` / `#1b232e`,次要字 `#626f80` / `#aab6c5`,边线 `#e0e5ec` / `#344151`,浅金底 `#fff2dc` / `#3c2f1f`,卡片悬停边 `#c39343`;深色文字型主色 `--sm-accent: #f2ad41`。样式规则只引用变量,无 `!important`。
|
||||||
- 侧栏滚动条 6px,悬停或聚焦时显示;卡片列表隐藏滚动条,不写 `scrollbar-width` / `scrollbar-color`。
|
- 侧栏滚动条 6px,悬停或聚焦时显示;卡片列表隐藏滚动条,不写 `scrollbar-width` / `scrollbar-color`。
|
||||||
- 动效:卡片悬停上浮 3px + 光晕;Hero 线路 15s 线性循环,模块 10s 漂浮 7px(延时 0 / -5 / -3 / -7s);仅精确指针设备悬停生效,`prefers-reduced-motion` 时全部停用。
|
- 动效:卡片悬停上浮 3px + 光晕;Hero 线路 15s 线性循环,模块 10s 漂浮 7px(延时 0 / -5 / -3 / -7s);仅精确指针设备悬停生效,`prefers-reduced-motion` 时全部停用。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# 用户中心 UI 规范(/user-center/\*)
|
# 用户中心 UI 规范(/user-center/\*)
|
||||||
|
|
||||||
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-25 · 版本:v2.5
|
> 状态:有效 · 适用:antd 6.7.0 · 更新:2026-11-16 · 版本:v2.3
|
||||||
|
|
||||||
个人登录后用户中心页面的规范,只记录与公共规范不同的部分;密钥管理、服务监控见各自规范。
|
个人登录后用户中心页面的规范,只记录与公共规范不同的部分;密钥管理、服务监控见各自规范。
|
||||||
|
|
||||||
@@ -78,8 +78,7 @@
|
|||||||
- 页签:纯文字页签(公共列表页签样式),与下方 20px,URL `?tab=` 同步并懒挂载。
|
- 页签:纯文字页签(公共列表页签样式),与下方 20px,URL `?tab=` 同步并懒挂载。
|
||||||
- 筛选卡:5 列栅格,时间范围跨 2 列;背景使用 `--surface-card` 纯色(浅色为白色、深色为主题卡片色);操作“重置 / 搜索”右下。
|
- 筛选卡:5 列栅格,时间范围跨 2 列;背景使用 `--surface-card` 纯色(浅色为白色、深色为主题卡片色);操作“重置 / 搜索”右下。
|
||||||
- 列表卡:标题 15px / 600,导出、列设置位于卡头右侧;表头字重 400(公共标准为 500,待收敛)。
|
- 列表卡:标题 15px / 600,导出、列设置位于卡头右侧;表头字重 400(公共标准为 500,待收敛)。
|
||||||
- 消费记录调用明细为固定列宽宽表,横向滚动时“时间”列固定在左侧,“操作”列显示时固定在右侧,中间列可滚动。时间分两行(日期 11px、时间 15px / 600),固定列兼容规则遵循公共规范第 5.2 节。
|
- 消费记录调用明细为固定列宽宽表,时间分两行(日期 11px、时间 15px / 600),操作列文字“查看”,固定在右侧;横向滚动条保留 Ant Design 官方固定列表格行为,固定列兼容规则遵循公共规范第 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)+ 任务记录表。
|
- 绘图与视频:三张统计卡(高 70px、间距 15px)+ 任务记录表。
|
||||||
- Webhook 示例为 `<pre class='ui-notify-code'>` +“复制”链接,复制提示沿用原文案。
|
- Webhook 示例为 `<pre class='ui-notify-code'>` +“复制”链接,复制提示沿用原文案。
|
||||||
|
|
||||||
|
|||||||
@@ -1,407 +0,0 @@
|
|||||||
# 权限重构 · 产品功能验收与切换手册
|
|
||||||
|
|
||||||
| 项 | 内容 |
|
|
||||||
| --- | --- |
|
|
||||||
| 对应需求 | 《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 | | | |
|
|
||||||
| 五、客户企业切换完成 | | | |
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
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,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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';
|
import { defineConfig } from 'i18next-cli';
|
||||||
|
|
||||||
/** @type {import('i18next-cli').I18nextToolkitConfig} */
|
/** @type {import('i18next-cli').I18nextToolkitConfig} */
|
||||||
|
|||||||
Generated
+385
-466
File diff suppressed because it is too large
Load Diff
+7
-6
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "monkey-ai-web",
|
"name": "react-template",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -89,18 +89,19 @@
|
|||||||
"@playwright/test": "1.64.1",
|
"@playwright/test": "1.64.1",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"esbuild": "0.25.12",
|
"esbuild": "0.21.5",
|
||||||
"eslint": "9.39.5",
|
"eslint": "8.57.0",
|
||||||
|
"eslint-plugin-header": "^3.1.1",
|
||||||
"eslint-plugin-react": "^7.37.5",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-unused-imports": "4.4.1",
|
"eslint-plugin-unused-imports": "^3.2.0",
|
||||||
"globals": "16.5.0",
|
|
||||||
"i18next-cli": "^1.10.3",
|
"i18next-cli": "^1.10.3",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"prettier": "^3.0.0",
|
"prettier": "^3.0.0",
|
||||||
"tailwindcss": "^3",
|
"tailwindcss": "^3",
|
||||||
"vite": "6.4.6"
|
"vite": "5.4.21"
|
||||||
},
|
},
|
||||||
|
"proxy": "http://localhost:3000",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22.13.0",
|
"node": ">=22.13.0",
|
||||||
"npm": ">=10"
|
"npm": ">=10"
|
||||||
|
|||||||
+22
-15
@@ -1,24 +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 { defineConfig } from '@playwright/test';
|
import { defineConfig } from '@playwright/test';
|
||||||
import {
|
import {
|
||||||
browserChannel,
|
browserChannel,
|
||||||
contextOptions,
|
contextOptions,
|
||||||
defaultProjectViewports,
|
|
||||||
projectViewports,
|
projectViewports,
|
||||||
} from './scripts/browser-environment.mjs';
|
} from './scripts/browser-environment.mjs';
|
||||||
import { runtimeOptions } from './scripts/playwright-runtime.mjs';
|
import { runtimeOptions } from './scripts/playwright-runtime.mjs';
|
||||||
import { findDevService } from './scripts/dev-service.mjs';
|
|
||||||
|
|
||||||
if (
|
|
||||||
!process.argv.includes('--list') &&
|
|
||||||
!process.env.PW_TARGET &&
|
|
||||||
!process.env.PW_BASE_URL
|
|
||||||
) {
|
|
||||||
const existing = await findDevService();
|
|
||||||
if (existing) {
|
|
||||||
process.env.PW_TARGET = 'remote';
|
|
||||||
process.env.PW_BASE_URL = existing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const runtime = runtimeOptions({ defaultPort: 4176, defaultWorkers: 1 });
|
const runtime = runtimeOptions({ defaultPort: 4176, defaultWorkers: 1 });
|
||||||
const { target, baseURL, isCI, headless, workers, outputDir, reportDir } =
|
const { target, baseURL, isCI, headless, workers, outputDir, reportDir } =
|
||||||
@@ -30,7 +35,9 @@ if (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
throw new Error('CI requires headless non-interactive tests');
|
throw new Error('CI requires headless non-interactive tests');
|
||||||
const viewports = runtime.extended ? projectViewports : defaultProjectViewports;
|
const viewports = runtime.extended
|
||||||
|
? projectViewports
|
||||||
|
: projectViewports.slice(0, 2);
|
||||||
|
|
||||||
// UI_VISUAL_OFFSCREEN=0 仅限人工本地可视化调试时临时使用。
|
// UI_VISUAL_OFFSCREEN=0 仅限人工本地可视化调试时临时使用。
|
||||||
// Agent、CI、无头/自动化环境禁止设置该值,必须保持默认离屏模式
|
// Agent、CI、无头/自动化环境禁止设置该值,必须保持默认离屏模式
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 {
|
export default {
|
||||||
plugins: {
|
plugins: {
|
||||||
tailwindcss: {},
|
tailwindcss: {},
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
// 有头 Chrome 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
||||||
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { readFileSync } from 'node:fs';
|
||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { devices } from '@playwright/test';
|
import { devices } from '@playwright/test';
|
||||||
@@ -13,9 +32,9 @@ const aliases = {
|
|||||||
'laptop-wxga': 'wxga',
|
'laptop-wxga': 'wxga',
|
||||||
};
|
};
|
||||||
export const browserChannel = config.browser.channel;
|
export const browserChannel = config.browser.channel;
|
||||||
export const defaultProjectViewports = ['desktop', 'mobile', 'mobile-393'];
|
|
||||||
export const projectViewports = [
|
export const projectViewports = [
|
||||||
...defaultProjectViewports,
|
'desktop',
|
||||||
|
'mobile',
|
||||||
'tablet',
|
'tablet',
|
||||||
'desktop-boundary',
|
'desktop-boundary',
|
||||||
'laptop-hd',
|
'laptop-hd',
|
||||||
@@ -30,9 +49,7 @@ export function deviceOptions(name) {
|
|||||||
if (!size) throw new Error(`Unknown viewport: ${name}`);
|
if (!size) throw new Error(`Unknown viewport: ${name}`);
|
||||||
const descriptor =
|
const descriptor =
|
||||||
devices[
|
devices[
|
||||||
config.browser[
|
config.browser[key === 'mobile' ? 'mobileDevice' : 'desktopDevice']
|
||||||
key.startsWith('mobile') ? 'mobileDevice' : 'desktopDevice'
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
if (!descriptor) throw new Error(`Unknown device profile for ${name}`);
|
if (!descriptor) throw new Error(`Unknown device profile for ${name}`);
|
||||||
const { defaultBrowserType, ...context } = descriptor;
|
const { defaultBrowserType, ...context } = descriptor;
|
||||||
|
|||||||
@@ -3,28 +3,20 @@ import { createHash } from 'node:crypto';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { Linter } from 'eslint';
|
import { Linter } from 'eslint';
|
||||||
import policy from './ui-dependency-policy.cjs';
|
|
||||||
|
|
||||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||||
const { isForbiddenUiDependency, uiDependencyConfig } = policy;
|
const forbidden = [
|
||||||
const linter = new Linter({ cwd: root });
|
/^@radix-ui\//,
|
||||||
const sourceConfig = [uiDependencyConfig];
|
/^@floating-ui\//,
|
||||||
const sourceDirectories = new Set(['src', 'scripts', 'test', 'tests']);
|
/^@lobehub\/(?:ui|icons)(?:\/|$)/,
|
||||||
const excludedDirectories = new Set([
|
/^@douyinfe\/semi-(?:ui|icons|foundation)(?:\/|$)/,
|
||||||
'node_modules',
|
/^@headlessui\//,
|
||||||
'dist',
|
/^@mui\//,
|
||||||
'dist-ssr',
|
/^@chakra-ui\//,
|
||||||
'build',
|
/^(?:leva|antd-style|react-layout-kit)(?:\/|$)/,
|
||||||
'coverage',
|
];
|
||||||
'report',
|
export const isForbiddenUiDependency = (name) =>
|
||||||
'logs',
|
forbidden.some((pattern) => pattern.test(name));
|
||||||
'test-results',
|
|
||||||
'playwright-report',
|
|
||||||
'blob-report',
|
|
||||||
'kt_batches',
|
|
||||||
'kt_out',
|
|
||||||
]);
|
|
||||||
export { isForbiddenUiDependency };
|
|
||||||
|
|
||||||
export function auditManifest(manifest, lock) {
|
export function auditManifest(manifest, lock) {
|
||||||
const issues = [];
|
const issues = [];
|
||||||
@@ -34,22 +26,14 @@ export function auditManifest(manifest, lock) {
|
|||||||
'optionalDependencies',
|
'optionalDependencies',
|
||||||
'peerDependencies',
|
'peerDependencies',
|
||||||
]) {
|
]) {
|
||||||
for (const [name, specifier] of Object.entries(manifest[section] || {})) {
|
for (const name of Object.keys(manifest[section] || {})) {
|
||||||
const alias = /^npm:((?:@[^/]+\/)?[^@/]+)(?:@|$)/.exec(specifier)?.[1];
|
if (isForbiddenUiDependency(name))
|
||||||
if (isForbiddenUiDependency(name)) {
|
|
||||||
issues.push(`package.json ${section}: ${name}`);
|
issues.push(`package.json ${section}: ${name}`);
|
||||||
} else if (isForbiddenUiDependency(alias)) {
|
|
||||||
issues.push(`package.json ${section}: ${name} -> ${alias}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const [location, entry] of Object.entries(lock.packages || {})) {
|
for (const location of Object.keys(lock.packages || {})) {
|
||||||
const names = location.split(/(?:^|\/)node_modules\//);
|
if (isForbiddenUiDependency(location.split('node_modules/').at(-1))) {
|
||||||
if (names.length === 1) continue;
|
|
||||||
if (isForbiddenUiDependency(names.at(-1))) {
|
|
||||||
issues.push(`package-lock.json: ${location}`);
|
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)
|
if (!lock.packages || lock.lockfileVersion < 2)
|
||||||
@@ -58,26 +42,58 @@ export function auditManifest(manifest, lock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function auditSource(source, filename) {
|
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
|
return linter
|
||||||
.verify(source, sourceConfig, { filename, allowInlineConfig: false })
|
.verify(
|
||||||
|
source,
|
||||||
|
{
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
ecmaFeatures: { jsx: true },
|
||||||
|
},
|
||||||
|
rules: { 'ui-dependencies': 'error' },
|
||||||
|
},
|
||||||
|
{ filename, allowInlineConfig: false },
|
||||||
|
)
|
||||||
.map((issue) => `${filename}:${issue.line}: ${issue.message}`);
|
.map((issue) => `${filename}:${issue.line}: ${issue.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sourceFiles(dir, isRoot = true) {
|
async function sourceFiles(dir) {
|
||||||
const files = [];
|
const files = [];
|
||||||
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
||||||
const name = path.join(dir, entry.name);
|
const name = path.join(dir, entry.name);
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) files.push(...(await sourceFiles(name)));
|
||||||
if (
|
else if (/\.[cm]?[jt]sx?$/.test(entry.name)) files.push(name);
|
||||||
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;
|
return files;
|
||||||
}
|
}
|
||||||
@@ -90,7 +106,7 @@ export async function checkUiDependencies(directory = root) {
|
|||||||
await readFile(path.join(directory, 'package-lock.json'), 'utf8'),
|
await readFile(path.join(directory, 'package-lock.json'), 'utf8'),
|
||||||
);
|
);
|
||||||
const issues = auditManifest(manifest, lock);
|
const issues = auditManifest(manifest, lock);
|
||||||
const files = await sourceFiles(directory);
|
const files = await sourceFiles(path.join(directory, 'src'));
|
||||||
for (const filename of files) {
|
for (const filename of files) {
|
||||||
issues.push(
|
issues.push(
|
||||||
...auditSource(
|
...auditSource(
|
||||||
@@ -127,7 +143,7 @@ export async function checkUiDependencies(directory = root) {
|
|||||||
return {
|
return {
|
||||||
issues,
|
issues,
|
||||||
files: files.length,
|
files: files.length,
|
||||||
packages: Math.max(0, Object.keys(lock.packages || {}).length - 1),
|
packages: Object.keys(lock.packages).length - 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,101 +0,0 @@
|
|||||||
import { readFile, readdir } from 'node:fs/promises';
|
|
||||||
import { execFile } from 'node:child_process';
|
|
||||||
import { promisify } from 'node:util';
|
|
||||||
import path from 'node:path';
|
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
|
|
||||||
const exec = promisify(execFile);
|
|
||||||
const projectRoot = fileURLToPath(new URL('../', import.meta.url));
|
|
||||||
|
|
||||||
export function logAddresses(bytes, encoding) {
|
|
||||||
const text = bytes.toString(
|
|
||||||
encoding || (bytes[0] === 255 && bytes[1] === 254 ? 'utf16le' : 'utf8'),
|
|
||||||
);
|
|
||||||
return [
|
|
||||||
...text
|
|
||||||
.replace(/\x1b\[[0-9;]*m/g, '')
|
|
||||||
.matchAll(/(?:Local:|Network:)\s*(https?:\/\/[^\s]+)/g),
|
|
||||||
]
|
|
||||||
.map((match) => match[1])
|
|
||||||
.reverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function matchesProject(address, root) {
|
|
||||||
try {
|
|
||||||
const url = new URL(address);
|
|
||||||
if (
|
|
||||||
!['http:', 'https:'].includes(url.protocol) ||
|
|
||||||
url.username ||
|
|
||||||
url.password
|
|
||||||
)
|
|
||||||
return false;
|
|
||||||
const source = await readFile(path.join(root, 'src/index.jsx'), 'utf8');
|
|
||||||
const response = await fetch(new URL('src/index.jsx', url), {
|
|
||||||
signal: AbortSignal.timeout(2500),
|
|
||||||
});
|
|
||||||
if (!response.ok) return false;
|
|
||||||
const text = await response.text();
|
|
||||||
const map = text.match(
|
|
||||||
/sourceMappingURL=data:application\/json;base64,([^\s]+)/,
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
!!map &&
|
|
||||||
JSON.parse(
|
|
||||||
Buffer.from(map[1], 'base64').toString(),
|
|
||||||
).sourcesContent?.includes(source)
|
|
||||||
);
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function nodePorts() {
|
|
||||||
if (process.platform !== 'win32') return [];
|
|
||||||
const command =
|
|
||||||
'[Console]::OutputEncoding=[Text.Encoding]::UTF8; $OutputEncoding=[Text.Encoding]::UTF8; ' +
|
|
||||||
'$ids = @(Get-CimInstance Win32_Process -Filter "Name=\'node.exe\'" | Select-Object -ExpandProperty ProcessId); ' +
|
|
||||||
'Get-NetTCPConnection -State Listen -ErrorAction Stop | Where-Object { $_.OwningProcess -in $ids } | Select-Object -ExpandProperty LocalPort -Unique | ConvertTo-Json -Compress';
|
|
||||||
const { stdout } = await exec(
|
|
||||||
'powershell.exe',
|
|
||||||
['-NoProfile', '-Command', command],
|
|
||||||
{ timeout: 15000, windowsHide: true },
|
|
||||||
);
|
|
||||||
const parsed = JSON.parse(stdout.trim() || '[]');
|
|
||||||
return [parsed].flat().filter((port) => Number.isInteger(port) && port > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function findDevService({
|
|
||||||
root = projectRoot,
|
|
||||||
getPorts = nodePorts,
|
|
||||||
} = {}) {
|
|
||||||
const candidates = [];
|
|
||||||
const entries = await readdir(root, { withFileTypes: true });
|
|
||||||
const logs = entries.filter(
|
|
||||||
(entry) => entry.isFile() && /\.log$/i.test(entry.name),
|
|
||||||
);
|
|
||||||
logs.sort(
|
|
||||||
(a, b) => Number(b.name === 'dev.log') - Number(a.name === 'dev.log'),
|
|
||||||
);
|
|
||||||
for (const entry of logs.slice(0, 8)) {
|
|
||||||
const bytes = await readFile(path.join(root, entry.name));
|
|
||||||
candidates.push(
|
|
||||||
...logAddresses(
|
|
||||||
bytes.subarray(Math.max(0, bytes.length - 262144)),
|
|
||||||
bytes[0] === 255 && bytes[1] === 254 ? 'utf16le' : 'utf8',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Only Node listeners are probed; the source map must match this checkout.
|
|
||||||
for (const address of new Set(candidates)) {
|
|
||||||
if (await matchesProject(address, root))
|
|
||||||
return new URL(address).origin + '/';
|
|
||||||
}
|
|
||||||
const ports = await getPorts();
|
|
||||||
for (const address of new Set(
|
|
||||||
ports.map((port) => 'http://127.0.0.1:' + port + '/'),
|
|
||||||
)) {
|
|
||||||
if (await matchesProject(address, root))
|
|
||||||
return new URL(address).origin + '/';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// 找出会溢出的具体位置。控制台是围绕中文两字标签设计的,泰语平均膨胀 3.16x,
|
// 找出会溢出的具体位置。控制台是围绕中文两字标签设计的,泰语平均膨胀 3.16x,
|
||||||
// 短标签最高 9x,密集表格首当其冲。
|
// 短标签最高 9x,密集表格首当其冲。
|
||||||
//
|
//
|
||||||
// 判据:表格列的 `width: N`(px)在 14px 字号下大致可容
|
// 判据:Semi 的 Table column `width: N`(px)在 14px 字号下大致可容
|
||||||
// 中文 ≈ N/14 字,拉丁/泰文 ≈ N/7.5 字符(泰文含上下叠加符号,按拉丁估更保守)。
|
// 中文 ≈ N/14 字,拉丁/泰文 ≈ N/7.5 字符(泰文含上下叠加符号,按拉丁估更保守)。
|
||||||
// 超出即报,按超出比例排序。这是静态估算,不替代真机目视走查。
|
// 超出即报,按超出比例排序。这是静态估算,不替代真机目视走查。
|
||||||
const fs = require('fs');
|
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 = 7.5; // 拼音文字/韩/泰在 14px 下的保守平均字宽
|
||||||
// 日文假名与汉字、繁体中文都是全角,按字号整宽计
|
// 日文假名与汉字、繁体中文都是全角,按字号整宽计
|
||||||
const PX_PER_CHAR_BY_LANG = { ja: 14, 'zh-TW': 14 };
|
const PX_PER_CHAR_BY_LANG = { ja: 14, 'zh-TW': 14 };
|
||||||
const PADDING = 24; // 表头左右内边距及排序图标的估算余量
|
const PADDING = 24; // Semi 表头左右内边距 + 排序图标余量
|
||||||
|
|
||||||
function walk(dir, files = []) {
|
function walk(dir, files = []) {
|
||||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
// 有头 Chrome 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
||||||
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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';
|
const FOCUS_ANNOTATION = 'focus-guard';
|
||||||
|
|
||||||
export default class AcceptanceReporter {
|
export default class AcceptanceReporter {
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 运行时尽最大可能不抢占用户桌面焦点。
|
// 浏览器焦点守护:有头真实 Chrome 运行时尽最大可能不抢占用户桌面焦点。
|
||||||
// - 唯一页面:每个用例只有一个页面,由 CDP Target.createTarget({ background: true }) 后台创建,
|
// - 唯一页面:每个用例只有一个页面,由 CDP Target.createTarget({ background: true }) 后台创建,
|
||||||
// 不走 context.newPage()(Playwright 内部创建时不带 background,会以前台方式打开窗口)。
|
// 不走 context.newPage()(Playwright 内部创建时不带 background,会以前台方式打开窗口)。
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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';
|
import { randomUUID } from 'node:crypto';
|
||||||
|
|
||||||
export const browserStabilityArgs = Object.freeze([
|
export const browserStabilityArgs = Object.freeze([
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { test as base, expect } from '@playwright/test';
|
||||||
import {
|
import {
|
||||||
checkFocus,
|
checkFocus,
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { preview } from 'vite';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { positiveInteger } from './playwright-runtime.mjs';
|
import { positiveInteger } from './playwright-runtime.mjs';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { mkdtemp, rm } from 'node:fs/promises';
|
||||||
import { tmpdir } from 'node:os';
|
import { tmpdir } from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { spawn } from 'node:child_process';
|
||||||
import { readdir, stat, access } from 'node:fs/promises';
|
import { readdir, stat, access } from 'node:fs/promises';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { mkdtemp, writeFile, rm } from 'node:fs/promises';
|
||||||
import { tmpdir } from 'node:os';
|
import { tmpdir } from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { readdir } from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
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,7 +9,6 @@
|
|||||||
"viewports": {
|
"viewports": {
|
||||||
"desktop": [1920, 1080],
|
"desktop": [1920, 1080],
|
||||||
"mobile": [360, 800],
|
"mobile": [360, 800],
|
||||||
"mobile-393": [393, 851],
|
|
||||||
"tablet": [768, 1024],
|
"tablet": [768, 1024],
|
||||||
"laptop": [1024, 768],
|
"laptop": [1024, 768],
|
||||||
"hd": [1366, 768],
|
"hd": [1366, 768],
|
||||||
|
|||||||
+26
-81
@@ -1,77 +1,27 @@
|
|||||||
|
/*
|
||||||
|
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 { readFile, access } from 'node:fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { gzipSync } from 'node:zlib';
|
|
||||||
|
|
||||||
const BOOTSTRAP_GZIP_LIMIT = 820 * 1024;
|
export async function verifyBuild(directory) {
|
||||||
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 root = path.resolve(directory);
|
||||||
const html = await readFile(path.join(root, 'index.html'), 'utf8');
|
const html = await readFile(path.join(root, 'index.html'), 'utf8');
|
||||||
// Inspect actual resource tags, not URLs embedded in comments or inline scripts.
|
// Inspect actual resource tags, not URLs embedded in comments or inline scripts.
|
||||||
@@ -90,22 +40,17 @@ export async function verifyBuild(directory, { startup = false } = {}) {
|
|||||||
if (!assets.some((value) => /\.js$/.test(value)))
|
if (!assets.some((value) => /\.js$/.test(value)))
|
||||||
throw new Error('Build has no JavaScript entry');
|
throw new Error('Build has no JavaScript entry');
|
||||||
for (const asset of assets) {
|
for (const asset of assets) {
|
||||||
await access(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}`);
|
||||||
|
await access(filename);
|
||||||
}
|
}
|
||||||
return {
|
return { root, assets: assets.length };
|
||||||
root,
|
|
||||||
assets: assets.length,
|
|
||||||
...(startup ? await verifyStartup(root) : {}),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
process.argv[1] &&
|
process.argv[1] &&
|
||||||
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
||||||
) {
|
) {
|
||||||
const args = process.argv.slice(2);
|
console.log(await verifyBuild(process.argv[2] || 'dist'));
|
||||||
const directory = args.find((argument) => argument !== '--startup') || 'dist';
|
|
||||||
console.log(
|
|
||||||
await verifyBuild(directory, { startup: args.includes('--startup') }),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+124
-176
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React, { lazy, Suspense, useContext, useMemo } from 'react';
|
||||||
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
import { Route, Routes, Navigate, useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
@@ -5,9 +24,7 @@ import {
|
|||||||
isMiniProgramWebView,
|
isMiniProgramWebView,
|
||||||
} from './helpers/miniProgram';
|
} from './helpers/miniProgram';
|
||||||
import Loading from './components/common/ui/Loading';
|
import Loading from './components/common/ui/Loading';
|
||||||
import { CenterRouteLoading } from './components/layout/components/CenterSidebarLoading';
|
import { AuthRedirect, PrivateRoute, AdminRoute, RootRoute } from './helpers';
|
||||||
import { AuthRedirect, PrivateRoute, RootRoute } from './helpers/auth';
|
|
||||||
import { PermRoute, ConsoleRoute, ConsoleIndexRoute } from './authz';
|
|
||||||
import NotFound from './pages/NotFound';
|
import NotFound from './pages/NotFound';
|
||||||
import Forbidden from './pages/Forbidden';
|
import Forbidden from './pages/Forbidden';
|
||||||
import { StatusContext } from './context/Status';
|
import { StatusContext } from './context/Status';
|
||||||
@@ -71,19 +88,14 @@ const Task = lazy(() => import('./pages/Task'));
|
|||||||
const ModelPage = lazy(() => import('./pages/Model'));
|
const ModelPage = lazy(() => import('./pages/Model'));
|
||||||
const Playground = lazy(() => import('./pages/Playground'));
|
const Playground = lazy(() => import('./pages/Playground'));
|
||||||
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
const MonitorCenter = lazy(() => import('./pages/MonitorCenter'));
|
||||||
|
const PersonalSetting = lazy(
|
||||||
|
() => import('./components/settings/PersonalSetting'),
|
||||||
|
);
|
||||||
const Setup = lazy(() => import('./pages/Setup'));
|
const Setup = lazy(() => import('./pages/Setup'));
|
||||||
const Analytics = lazy(() => import('./pages/Analytics'));
|
const Analytics = lazy(() => import('./pages/Analytics'));
|
||||||
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
|
const SmartRouter = lazy(() => import('./pages/SmartRouter'));
|
||||||
const Organization = lazy(() => import('./pages/Organization'));
|
const Organization = lazy(() => import('./pages/Organization'));
|
||||||
const AdminOrganizations = lazy(() => import('./pages/AdminOrganizations'));
|
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 AdminOrder = lazy(() => import('./pages/AdminOrder'));
|
||||||
const AdminInvoice = lazy(() => import('./pages/AdminInvoice'));
|
const AdminInvoice = lazy(() => import('./pages/AdminInvoice'));
|
||||||
const Subscription = lazy(() => import('./pages/Subscription'));
|
const Subscription = lazy(() => import('./pages/Subscription'));
|
||||||
@@ -118,11 +130,9 @@ const ORG_USER_NAV_PATHS = {
|
|||||||
keyManagement: ['/key-management', '/user-center/key-management'],
|
keyManagement: ['/key-management', '/user-center/key-management'],
|
||||||
userCenter: ['/user-center'],
|
userCenter: ['/user-center'],
|
||||||
};
|
};
|
||||||
const matchesPathPrefix = (pathname, prefix) =>
|
|
||||||
pathname === prefix || pathname.startsWith(`${prefix}/`);
|
|
||||||
const isOrgAllowedPath = (pathname, extraPrefixes = []) =>
|
const isOrgAllowedPath = (pathname, extraPrefixes = []) =>
|
||||||
[...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some((prefix) =>
|
[...ORG_ALLOWED_PREFIXES, ...extraPrefixes].some(
|
||||||
matchesPathPrefix(pathname, prefix),
|
(p) => pathname === p || pathname.startsWith(p + '/'),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 模型超市旧路径 /pricing → /market。用组件而非静态 <Navigate>,
|
// 模型超市旧路径 /pricing → /market。用组件而非静态 <Navigate>,
|
||||||
@@ -137,10 +147,20 @@ const PricingLegacyRedirect = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 用户中心旧地址保留登录回跳、分享链接及书签中的参数。
|
// 密钥管理旧路径 /key-management → /user-center/key-management,同样保留 query/hash
|
||||||
const UserCenterLegacyRedirect = ({ to }) => {
|
// (如创作台 ?from=creation_studio 埋点来源、旧书签与登录回跳带参)
|
||||||
const { search, hash } = useLocation();
|
const KeyManagementLegacyRedirect = () => {
|
||||||
return <Navigate to={{ pathname: to, search, hash }} replace />;
|
const location = useLocation();
|
||||||
|
return (
|
||||||
|
<Navigate
|
||||||
|
to={{
|
||||||
|
pathname: '/user-center/key-management',
|
||||||
|
search: location.search,
|
||||||
|
hash: location.hash,
|
||||||
|
}}
|
||||||
|
replace
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -200,38 +220,27 @@ function App() {
|
|||||||
// /org,从此无任何路径把平台技能加入企业技能库——技能库与分发页永远为空。
|
// /org,从此无任何路径把平台技能加入企业技能库——技能库与分发页永远为空。
|
||||||
// 顶栏开关的本意是收敛"员工浏览目录",不应连带阉割企业治理能力,故对
|
// 顶栏开关的本意是收敛"员工浏览目录",不应连带阉割企业治理能力,故对
|
||||||
// 管理员无条件放行该路由(页面内部仍按 skill_manage 决定是否出现启用按钮)。
|
// 管理员无条件放行该路由(页面内部仍按 skill_manage 决定是否出现启用按钮)。
|
||||||
if (
|
if (isOrgAdmin && !prefixes.includes('/skill-market')) {
|
||||||
orgMembershipLoaded &&
|
|
||||||
isOrgAdmin &&
|
|
||||||
!prefixes.includes('/skill-market')
|
|
||||||
) {
|
|
||||||
prefixes.push('/skill-market');
|
prefixes.push('/skill-market');
|
||||||
}
|
}
|
||||||
return prefixes;
|
return prefixes;
|
||||||
}, [
|
}, [statusState?.status?.HeaderNavModulesOrgUser, isOrgAdmin]);
|
||||||
statusState?.status?.HeaderNavModulesOrgUser,
|
|
||||||
orgMembershipLoaded,
|
|
||||||
isOrgAdmin,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 路由级封锁:org_only 员工访问非企业路由一律回到企业空间。
|
// 路由级封锁:org_only 员工访问非企业路由一律回到企业空间。
|
||||||
// 仅在企业中心可用时启用,避免企业中心被全局关闭时与其内部回退跳转形成重定向死循环。
|
// 仅在企业中心可用时启用,避免企业中心被全局关闭时与其内部回退跳转形成重定向死循环。
|
||||||
// 只有技能超市的企业管理员特例需要等待企业列表;等待时也不挂载受限页面。
|
// 企业列表未到位前不做封锁判定:isOrgAdmin 首帧恒 false,此时若直接重定向,
|
||||||
const routePath = location.pathname.toLowerCase();
|
// 硬刷新/收藏夹直达 /skill-market 的 org_only 管理员会在放行判据还没算出来时
|
||||||
|
// 就被弹回 /org,而重定向不可逆——之后 isOrgAdmin 变 true 也回不去。
|
||||||
const orgConfined =
|
const orgConfined =
|
||||||
userState?.user?.org_only_mode === true &&
|
userState?.user?.org_only_mode === true &&
|
||||||
|
orgMembershipLoaded &&
|
||||||
isOrgCenterAvailable &&
|
isOrgCenterAvailable &&
|
||||||
!isOrgAllowedPath(routePath, orgUserAllowedPrefixes);
|
!isOrgAllowedPath(location.pathname, orgUserAllowedPrefixes);
|
||||||
|
|
||||||
if (orgConfined) {
|
if (orgConfined) {
|
||||||
return (
|
return (
|
||||||
<SetupCheck>
|
<SetupCheck>
|
||||||
{!orgMembershipLoaded &&
|
<Navigate to='/org' replace />
|
||||||
matchesPathPrefix(routePath, '/skill-market') ? (
|
|
||||||
<Loading />
|
|
||||||
) : (
|
|
||||||
<Navigate to='/org' replace />
|
|
||||||
)}
|
|
||||||
</SetupCheck>
|
</SetupCheck>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -272,51 +281,51 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/models'
|
path='/console/models'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.model'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<ModelPage />
|
<ModelPage />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/channel'
|
path='/console/channel'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.channel'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Channel />
|
<Channel />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/token'
|
path='/console/token'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.admin_token'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Token />
|
<Token />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/playground'
|
path='/console/playground'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.playground'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Playground />
|
<Playground />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/monitor'
|
path='/console/monitor'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.monitor'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<MonitorCenter />
|
<MonitorCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@@ -332,11 +341,11 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/analytics'
|
path='/console/analytics'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.analytics'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Analytics />
|
<Analytics />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@@ -363,91 +372,40 @@ function App() {
|
|||||||
/* 分佣管理为 Root 专属:侧边栏一直用 isRoot() 隐藏该入口,后端结算/销售/成本/
|
/* 分佣管理为 Root 专属:侧边栏一直用 isRoot() 隐藏该入口,后端结算/销售/成本/
|
||||||
伙伴管理各路由组也已全部 Root 收口。这里把路由守卫对齐,避免 role=10 直接
|
伙伴管理各路由组也已全部 Root 收口。这里把路由守卫对齐,避免 role=10 直接
|
||||||
输 URL 进到一个读得到、写按钮全 403 的半残页面。 */
|
输 URL 进到一个读得到、写按钮全 403 的半残页面。 */
|
||||||
<ConsoleRoute code='platform.commission' legacy='root'>
|
<RootRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<CommissionV2 />
|
<CommissionV2 />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</RootRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/experience-center-audit'
|
path='/console/experience-center-audit'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.analytics'>
|
<AdminRoute>
|
||||||
<Navigate to='/console/analytics?tab=audit' replace />
|
<Navigate to='/console/analytics?tab=audit' replace />
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/organizations'
|
path='/console/organizations'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.org'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<AdminOrganizations />
|
<AdminOrganizations />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
|
||||||
/>
|
|
||||||
{/* 平台侧权限管理:路由按与侧边栏相同的权限点守卫(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
|
<Route
|
||||||
path='/console/skill-platform'
|
path='/console/skill-platform'
|
||||||
element={
|
element={
|
||||||
CLOUD_BRAIN_UI_ENABLED ? (
|
CLOUD_BRAIN_UI_ENABLED ? (
|
||||||
<ConsoleRoute code='platform.skill'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<SkillPlatform />
|
<SkillPlatform />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
) : (
|
) : (
|
||||||
<Navigate to='/console' replace />
|
<Navigate to='/console' replace />
|
||||||
)
|
)
|
||||||
@@ -457,11 +415,11 @@ function App() {
|
|||||||
path='/console/expert-platform'
|
path='/console/expert-platform'
|
||||||
element={
|
element={
|
||||||
CLOUD_BRAIN_UI_ENABLED ? (
|
CLOUD_BRAIN_UI_ENABLED ? (
|
||||||
<ConsoleRoute code='platform.expert'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<ExpertPlatform />
|
<ExpertPlatform />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
) : (
|
) : (
|
||||||
<Navigate to='/console' replace />
|
<Navigate to='/console' replace />
|
||||||
)
|
)
|
||||||
@@ -470,21 +428,21 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/order'
|
path='/console/order'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.order'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<AdminOrder />
|
<AdminOrder />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/invoice'
|
path='/console/invoice'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.invoice'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<AdminInvoice />
|
<AdminInvoice />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{/* 旧路由重定向到用户中心内的服务监控 */}
|
{/* 旧路由重定向到用户中心内的服务监控 */}
|
||||||
@@ -497,9 +455,7 @@ function App() {
|
|||||||
element={
|
element={
|
||||||
CLOUD_BRAIN_UI_ENABLED ? (
|
CLOUD_BRAIN_UI_ENABLED ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense
|
<Suspense fallback={<Loading />} key={location.pathname}>
|
||||||
fallback={<CenterRouteLoading variant='experience' />}
|
|
||||||
>
|
|
||||||
<ExperienceCenter />
|
<ExperienceCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
@@ -514,13 +470,14 @@ function App() {
|
|||||||
moduleAuthConfig.experienceCenter ? (
|
moduleAuthConfig.experienceCenter ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={<CenterRouteLoading variant='experience' />}
|
fallback={<Loading></Loading>}
|
||||||
|
key={location.pathname}
|
||||||
>
|
>
|
||||||
<ExperienceCenter />
|
<ExperienceCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
) : (
|
) : (
|
||||||
<Suspense fallback={<CenterRouteLoading variant='experience' />}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<ExperienceCenter />
|
<ExperienceCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
@@ -529,31 +486,31 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/redemption'
|
path='/console/redemption'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.redemption'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Redemption />
|
<Redemption />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/user'
|
path='/console/user'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.user'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<User />
|
<User />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/subscription'
|
path='/console/subscription'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.subscription'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Subscription />
|
<Subscription />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@@ -675,78 +632,89 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/setting'
|
path='/console/setting'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.setting'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<Setting />
|
<Setting />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/website-setting'
|
path='/console/website-setting'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute
|
<AdminRoute permission='website-setting'>
|
||||||
code='platform.setting.website_setting'
|
|
||||||
permission='website-setting'
|
|
||||||
>
|
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<WebsiteSettings />
|
<WebsiteSettings />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/demo-reservations'
|
path='/console/demo-reservations'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute
|
<AdminRoute permission='demo-reservations'>
|
||||||
code='platform.setting.demo_reservations'
|
|
||||||
permission='demo-reservations'
|
|
||||||
>
|
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<DemoReservations />
|
<DemoReservations />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path='/console/personal'
|
||||||
|
element={
|
||||||
|
<AdminRoute>
|
||||||
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
|
<PersonalSetting />
|
||||||
|
</Suspense>
|
||||||
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/topup'
|
path='/console/topup'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.topup'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<TopUp />
|
<TopUp />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/log'
|
path='/console/log'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.log'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Log />
|
<Log />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path='/console'
|
||||||
|
element={
|
||||||
|
<AdminRoute>
|
||||||
|
<Navigate to='/console/analytics' replace />
|
||||||
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path='/console' element={<ConsoleIndexRoute />} />
|
|
||||||
<Route
|
<Route
|
||||||
path='/console/midjourney'
|
path='/console/midjourney'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.drawing_log'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<Midjourney />
|
<Midjourney />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/console/task'
|
path='/console/task'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.task_log'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<Task />
|
<Task />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
@@ -792,27 +760,10 @@ 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
|
<Route
|
||||||
path='/key-management'
|
path='/key-management'
|
||||||
element={
|
element={<KeyManagementLegacyRedirect />}
|
||||||
<UserCenterLegacyRedirect to='/user-center/key-management' />
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/user-center/key-management'
|
path='/user-center/key-management'
|
||||||
@@ -820,17 +771,14 @@ function App() {
|
|||||||
moduleAuthConfig.keyManagement ? (
|
moduleAuthConfig.keyManagement ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense
|
<Suspense
|
||||||
fallback={<CenterRouteLoading />}
|
fallback={<Loading></Loading>}
|
||||||
key={location.pathname}
|
key={location.pathname}
|
||||||
>
|
>
|
||||||
<UserCenter keyManagementMode />
|
<UserCenter keyManagementMode />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
) : (
|
) : (
|
||||||
<Suspense
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
fallback={<CenterRouteLoading />}
|
|
||||||
key={location.pathname}
|
|
||||||
>
|
|
||||||
<UserCenter keyManagementMode />
|
<UserCenter keyManagementMode />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
@@ -841,12 +789,12 @@ function App() {
|
|||||||
element={
|
element={
|
||||||
moduleAuthConfig.userCenter ? (
|
moduleAuthConfig.userCenter ? (
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
<Suspense fallback={<CenterRouteLoading />}>
|
<Suspense fallback={<Loading></Loading>}>
|
||||||
<UserCenter />
|
<UserCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</PrivateRoute>
|
</PrivateRoute>
|
||||||
) : (
|
) : (
|
||||||
<Suspense fallback={<CenterRouteLoading />}>
|
<Suspense fallback={<Loading></Loading>}>
|
||||||
<UserCenter />
|
<UserCenter />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
@@ -918,11 +866,11 @@ function App() {
|
|||||||
<Route
|
<Route
|
||||||
path='/console/chat/:id?'
|
path='/console/chat/:id?'
|
||||||
element={
|
element={
|
||||||
<ConsoleRoute code='platform.chat'>
|
<AdminRoute>
|
||||||
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
|
||||||
<Chat />
|
<Chat />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ConsoleRoute>
|
</AdminRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{/* 方便使用chat2link直接跳转聊天... */}
|
{/* 方便使用chat2link直接跳转聊天... */}
|
||||||
@@ -950,7 +898,7 @@ function App() {
|
|||||||
element={
|
element={
|
||||||
<PrivateRoute>
|
<PrivateRoute>
|
||||||
{isOrgCenterAvailable ? (
|
{isOrgCenterAvailable ? (
|
||||||
<Suspense fallback={<CenterRouteLoading variant='org' />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Organization />
|
<Organization />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB |
@@ -1,393 +0,0 @@
|
|||||||
/*
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
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;
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
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;
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
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';
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
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('');
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
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'],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
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,4 +1,21 @@
|
|||||||
import { formatPercent } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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 { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
@@ -101,7 +118,7 @@ const ChannelConsumption = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
width: 80,
|
width: 80,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
render: (val) => (
|
render: (val) => (
|
||||||
<span className='text-gray-500'>{formatPercent(val || 0, 1)}</span>
|
<span className='text-gray-500'>{(val || 0).toFixed(1)}%</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { ChevronDown as ActionChevronDown } from '@/components/common/icons/ActionIcons';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './collapsible-panel.css';
|
import './collapsible-panel.css';
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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 React from 'react';
|
||||||
import { Card, Table, Button } from '@/components/ui';
|
import { Card, Table, Button } from '@/components/ui';
|
||||||
import { IconDownload } from '@/components/ui/icons';
|
import { IconDownload } from '@/components/ui/icons';
|
||||||
import { renderQuota } from '../../helpers';
|
import { renderQuota } from '../../helpers';
|
||||||
import { formatNumber, toFiniteNumber } from '../../helpers/safeDisplay';
|
|
||||||
|
|
||||||
const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
||||||
const columns = [
|
const columns = [
|
||||||
@@ -50,7 +68,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
align: 'right',
|
align: 'right',
|
||||||
render: (val) => (
|
render: (val) => (
|
||||||
<span className='text-yellow-600 font-medium'>
|
<span className='text-yellow-600 font-medium'>
|
||||||
¥{formatNumber(val, 2, '0.00')}
|
¥{(val || 0).toFixed(2)}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -81,7 +99,7 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
width: 120,
|
width: 120,
|
||||||
align: 'right',
|
align: 'right',
|
||||||
render: (val) => {
|
render: (val) => {
|
||||||
const tokens = toFiniteNumber(val) ?? 0;
|
const tokens = val || 0;
|
||||||
if (tokens >= 1000000) {
|
if (tokens >= 1000000) {
|
||||||
return <span>{(tokens / 1000000).toFixed(2)}M</span>;
|
return <span>{(tokens / 1000000).toFixed(2)}M</span>;
|
||||||
} else if (tokens >= 1000) {
|
} else if (tokens >= 1000) {
|
||||||
@@ -180,7 +198,6 @@ const DailyStatsTable = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data || []}
|
dataSource={data || []}
|
||||||
pagination={{
|
pagination={{
|
||||||
preservePage: true,
|
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
showTotal: (total) => t('共 {{total}} 条', { total, count: total }),
|
showTotal: (total) => t('共 {{total}} 条', { total, count: total }),
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
import { formatUserReference } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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 } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -96,9 +113,7 @@ const HighFreqLowCostUsers = ({
|
|||||||
width: 160,
|
width: 160,
|
||||||
render: (v, row) => (
|
render: (v, row) => (
|
||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
<Text strong>
|
<Text strong>{v || row.username || `user_${row.user_id}`}</Text>
|
||||||
{formatUserReference(v || row.username, row.user_id, t('未知用户'))}
|
|
||||||
</Text>
|
|
||||||
{row.username && v && row.username !== v && (
|
{row.username && v && row.username !== v && (
|
||||||
<Text type='tertiary' size='small'>
|
<Text type='tertiary' size='small'>
|
||||||
@{row.username}
|
@{row.username}
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useMemo } from 'react';
|
||||||
import { Card } from '@/components/ui';
|
import { Card } from '@/components/ui';
|
||||||
import { VChart } from '@visactor/react-vchart';
|
import { VChart } from '@visactor/react-vchart';
|
||||||
import { renderQuota } from '../../helpers';
|
import { renderQuota } from '../../helpers';
|
||||||
import { formatPercent } from '../../helpers/safeDisplay';
|
|
||||||
|
|
||||||
const ModelDistribution = ({ data, title, icon, t }) => {
|
const ModelDistribution = ({ data, title, icon, t }) => {
|
||||||
const pieSpec = useMemo(() => {
|
const pieSpec = useMemo(() => {
|
||||||
@@ -101,12 +119,12 @@ const ModelDistribution = ({ data, title, icon, t }) => {
|
|||||||
<span className='text-xs text-gray-500 w-4'>{index + 1}</span>
|
<span className='text-xs text-gray-500 w-4'>{index + 1}</span>
|
||||||
<span
|
<span
|
||||||
className='text-sm flex-1 truncate'
|
className='text-sm flex-1 truncate'
|
||||||
title={item.model_name || t('未知')}
|
title={item.model_name}
|
||||||
>
|
>
|
||||||
{item.model_name || t('未知')}
|
{item.model_name}
|
||||||
</span>
|
</span>
|
||||||
<span className='text-xs text-gray-500'>
|
<span className='text-xs text-gray-500'>
|
||||||
{formatPercent(item.percent, 1)}
|
{item.percent?.toFixed(1)}%
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useMemo, useState, useEffect } from 'react';
|
||||||
import { Button, Empty, Segmented, Skeleton, theme } from 'antd';
|
import { Button, Empty, Segmented, Skeleton, theme } from 'antd';
|
||||||
import { VChart } from '@visactor/react-vchart';
|
import { VChart } from '@visactor/react-vchart';
|
||||||
@@ -6,7 +25,6 @@ import { RefreshCw } from '@/components/common/icons/ActionIcons';
|
|||||||
import { ConsoleDrawer } from '@/components/console/ConsolePrimitives';
|
import { ConsoleDrawer } from '@/components/console/ConsolePrimitives';
|
||||||
import useOrgCacheHourly from '../../hooks/analytics/useOrgCacheHourly';
|
import useOrgCacheHourly from '../../hooks/analytics/useOrgCacheHourly';
|
||||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||||
import { formatIdReference, formatPercent } from '../../helpers/safeDisplay';
|
|
||||||
|
|
||||||
// 图表序列色属于专用图表(VChart)配色,统计块沿用同色以便与图例对应。
|
// 图表序列色属于专用图表(VChart)配色,统计块沿用同色以便与图例对应。
|
||||||
// 千分位缩写。线上单小时 cache_read 能到十亿量级,不缩写轴标签会糊成一片。
|
// 千分位缩写。线上单小时 cache_read 能到十亿量级,不缩写轴标签会糊成一片。
|
||||||
@@ -161,7 +179,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
|||||||
value: (datum) =>
|
value: (datum) =>
|
||||||
datum?.hit_rate === null || datum?.hit_rate === undefined
|
datum?.hit_rate === null || datum?.hit_rate === undefined
|
||||||
? t('无流量')
|
? t('无流量')
|
||||||
: formatPercent(datum.hit_rate, 1),
|
: `${Number(datum.hit_rate).toFixed(1)}%`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: () => t('实际消费'),
|
key: () => t('实际消费'),
|
||||||
@@ -210,15 +228,14 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
|||||||
// 自适应量程会把 76%~87% 的波动拉成满屏振荡,像出了故障。
|
// 自适应量程会把 76%~87% 的波动拉成满屏振荡,像出了故障。
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
label: { formatMethod: (v) => formatPercent(v, 0) },
|
label: { formatMethod: (v) => `${Math.round(v)}%` },
|
||||||
seriesIndex: [1],
|
seriesIndex: [1],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}, [points, hasTraffic, t]);
|
}, [points, hasTraffic, t]);
|
||||||
|
|
||||||
const orgReference = formatIdReference(org?.org_id);
|
const orgTitle = org?.org_name || (org ? `${t('企业')} ${org.org_id}` : '');
|
||||||
const orgTitle = org?.org_name || (org ? `${t('企业')} ${orgReference}` : '');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConsoleDrawer
|
<ConsoleDrawer
|
||||||
@@ -233,7 +250,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
|||||||
</span>
|
</span>
|
||||||
{org?.org_id ? (
|
{org?.org_id ? (
|
||||||
<span className='text-xs font-normal text-[var(--text-secondary)]'>
|
<span className='text-xs font-normal text-[var(--text-secondary)]'>
|
||||||
{orgReference}
|
#{org.org_id}
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -267,7 +284,7 @@ const OrgCacheHourlySheet = ({ visible, org, onClose, t }) => {
|
|||||||
value={
|
value={
|
||||||
totals.hit_rate === null || totals.hit_rate === undefined
|
totals.hit_rate === null || totals.hit_rate === undefined
|
||||||
? '--'
|
? '--'
|
||||||
: formatPercent(totals.hit_rate, 2)
|
: `${Number(totals.hit_rate).toFixed(2)}%`
|
||||||
}
|
}
|
||||||
sub={t('按 token 加权')}
|
sub={t('按 token 加权')}
|
||||||
color={SERIES_COLORS.hitRate}
|
color={SERIES_COLORS.hitRate}
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
import { formatIdReference, formatPercent } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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, { useState, useCallback } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import { Badge, Empty, Progress, Skeleton, Tag, Tooltip, theme } from 'antd';
|
import { Badge, Empty, Progress, Skeleton, Tag, Tooltip, theme } from 'antd';
|
||||||
import { ArrowDown } from 'lucide-react';
|
import { ArrowDown } from 'lucide-react';
|
||||||
@@ -85,19 +103,16 @@ const OrgRealtimeUsage = ({
|
|||||||
key: 'org_name',
|
key: 'org_name',
|
||||||
width: 220,
|
width: 220,
|
||||||
fixed: 'left',
|
fixed: 'left',
|
||||||
render: (text, record) => {
|
render: (text, record) => (
|
||||||
const orgReference = formatIdReference(record.org_id);
|
<div className='flex items-center gap-2 min-w-0'>
|
||||||
return (
|
<span className='text-sm font-medium truncate' title={text || ''}>
|
||||||
<div className='flex items-center gap-2 min-w-0'>
|
{text || `${t('企业')} ${record.org_id}`}
|
||||||
<span className='text-sm font-medium truncate' title={text || ''}>
|
</span>
|
||||||
{text || `${t('企业')} ${orgReference}`}
|
<span className='text-xs text-[var(--text-secondary)] flex-shrink-0'>
|
||||||
</span>
|
#{record.org_id}
|
||||||
<span className='text-xs text-[var(--text-secondary)] flex-shrink-0'>
|
</span>
|
||||||
{orgReference}
|
</div>
|
||||||
</span>
|
),
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: (
|
title: (
|
||||||
@@ -260,7 +275,7 @@ const OrgRealtimeUsage = ({
|
|||||||
className='text-sm font-semibold group-hover:underline'
|
className='text-sm font-semibold group-hover:underline'
|
||||||
style={{ color: cacheRateColor(rate, token) }}
|
style={{ color: cacheRateColor(rate, token) }}
|
||||||
>
|
>
|
||||||
{formatPercent(rate, 1)}
|
{rate.toFixed(1)}%
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
aria-hidden
|
aria-hidden
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
import { formatNumber, formatPercent } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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 React from 'react';
|
||||||
import { Card } from '@/components/ui';
|
import { Card } from '@/components/ui';
|
||||||
@@ -48,7 +65,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('今日充值'),
|
title: t('今日充值'),
|
||||||
value: `¥${formatNumber(overview.today_topup, 2, '0.00')}`,
|
value: `¥${overview.today_topup?.toFixed(2) || '0.00'}`,
|
||||||
change: overview.today_topup_change,
|
change: overview.today_topup_change,
|
||||||
icon: <DollarSign className='w-5 h-5' />,
|
icon: <DollarSign className='w-5 h-5' />,
|
||||||
color: 'yellow',
|
color: 'yellow',
|
||||||
@@ -75,7 +92,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('付费率'),
|
title: t('付费率'),
|
||||||
value: formatPercent(overview.pay_rate, 1, '0.0%'),
|
value: `${overview.pay_rate?.toFixed(1) || '0.0'}%`,
|
||||||
change: null,
|
change: null,
|
||||||
icon: <Percent className='w-5 h-5' />,
|
icon: <Percent className='w-5 h-5' />,
|
||||||
color: 'pink',
|
color: 'pink',
|
||||||
@@ -100,7 +117,7 @@ const OverviewCards = ({ overview, loading = false, t }) => {
|
|||||||
)}
|
)}
|
||||||
<span>
|
<span>
|
||||||
{isPositive ? '+' : ''}
|
{isPositive ? '+' : ''}
|
||||||
{formatPercent(change, 1)}
|
{change.toFixed(1)}%
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
import { formatUserReference } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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 { Trans } from 'react-i18next';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
@@ -229,9 +246,7 @@ const RiskControlBanLogs = ({
|
|||||||
<div>
|
<div>
|
||||||
<Text type='tertiary'>{t('用户:')}</Text>
|
<Text type='tertiary'>{t('用户:')}</Text>
|
||||||
<Text strong>
|
<Text strong>
|
||||||
{unbanRow.user_snapshot ||
|
{unbanRow.user_snapshot || `user_${unbanRow.user_id}`}(ID:
|
||||||
formatUserReference('', unbanRow.user_id, t('未知用户'))}
|
|
||||||
(ID:
|
|
||||||
{unbanRow.user_id})
|
{unbanRow.user_id})
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { Trans } from 'react-i18next';
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
|
/*
|
||||||
|
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 { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||||
import {
|
|
||||||
formatNumber,
|
|
||||||
formatPercent,
|
|
||||||
toFiniteNumber,
|
|
||||||
} from '../../helpers/safeDisplay';
|
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { Card } from '@/components/ui';
|
import { Card } from '@/components/ui';
|
||||||
import { VChart } from '@visactor/react-vchart';
|
import { VChart } from '@visactor/react-vchart';
|
||||||
@@ -34,8 +48,8 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
|||||||
const chartData = data.map((item) => ({
|
const chartData = data.map((item) => ({
|
||||||
name: item.payment_method ? t(item.payment_method) : t('未知'),
|
name: item.payment_method ? t(item.payment_method) : t('未知'),
|
||||||
rawName: item.payment_method,
|
rawName: item.payment_method,
|
||||||
value: toFiniteNumber(item.amount) ?? 0,
|
value: item.amount || 0,
|
||||||
count: toFiniteNumber(item.count) ?? 0,
|
count: item.count || 0,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 根据支付渠道名称生成颜色数组
|
// 根据支付渠道名称生成颜色数组
|
||||||
@@ -64,7 +78,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
|||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
key: (datum) => datum?.name,
|
key: (datum) => datum?.name,
|
||||||
value: (datum) => `¥${formatNumber(datum?.value, 2, '0.00')}`,
|
value: (datum) => `¥${(datum?.value || 0).toFixed(2)}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: () => t('笔数'),
|
key: () => t('笔数'),
|
||||||
@@ -94,7 +108,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
|||||||
// 统计列表
|
// 统计列表
|
||||||
const channelList = data || [];
|
const channelList = data || [];
|
||||||
const totalAmount = channelList.reduce(
|
const totalAmount = channelList.reduce(
|
||||||
(sum, item) => sum + (toFiniteNumber(item.amount) ?? 0),
|
(sum, item) => sum + (item.amount || 0),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -127,10 +141,10 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
|||||||
</span>
|
</span>
|
||||||
<div className='text-right'>
|
<div className='text-right'>
|
||||||
<span className='font-medium'>
|
<span className='font-medium'>
|
||||||
¥{formatNumber(item.amount, 2, '0.00')}
|
¥{(item.amount || 0).toFixed(2)}
|
||||||
</span>
|
</span>
|
||||||
<span className='text-gray-400 text-xs ml-2'>
|
<span className='text-gray-400 text-xs ml-2'>
|
||||||
({formatPercent(item.percent, 1).replace('%', '')}
|
({item.percent?.toFixed(1)}
|
||||||
{I18N_TECHNICAL_TEXT.PERCENT_CLOSE}
|
{I18N_TECHNICAL_TEXT.PERCENT_CLOSE}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -138,7 +152,7 @@ const TopupChannelChart = ({ data, title, icon, t }) => {
|
|||||||
))}
|
))}
|
||||||
<div className='flex items-center justify-between text-sm pt-2 font-semibold'>
|
<div className='flex items-center justify-between text-sm pt-2 font-semibold'>
|
||||||
<span>{t('合计')}</span>
|
<span>{t('合计')}</span>
|
||||||
<span>¥{formatNumber(totalAmount, 2, '0.00')}</span>
|
<span>¥{totalAmount.toFixed(2)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,25 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useMemo } from 'react';
|
||||||
import { Card } from '@/components/ui';
|
import { Card } from '@/components/ui';
|
||||||
import { VChart } from '@visactor/react-vchart';
|
import { VChart } from '@visactor/react-vchart';
|
||||||
import { formatCurrency } from '@/helpers/safeDisplay';
|
|
||||||
|
|
||||||
const TrendCharts = ({ title, icon, data, type, t }) => {
|
const TrendCharts = ({ title, icon, data, type, t }) => {
|
||||||
const spec = useMemo(() => {
|
const spec = useMemo(() => {
|
||||||
@@ -124,7 +142,7 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
|
|||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
key: () => topupKey,
|
key: () => topupKey,
|
||||||
value: (datum) => formatCurrency(datum?.[topupKey]),
|
value: (datum) => `¥${(datum?.[topupKey] || 0).toFixed(2)}`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -156,7 +174,8 @@ const TrendCharts = ({ title, icon, data, type, t }) => {
|
|||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
key: () => consumeKey,
|
key: () => consumeKey,
|
||||||
value: (datum) => formatCurrency(datum?.[consumeKey]),
|
value: (datum) =>
|
||||||
|
`¥${(datum?.[consumeKey] || 0).toFixed(2)}`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,21 @@
|
|||||||
import {
|
/*
|
||||||
formatIdReference,
|
Copyright (C) 2025 QuantumNous
|
||||||
formatUserReference,
|
|
||||||
} from '../../helpers/safeDisplay';
|
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 { Trans } from 'react-i18next';
|
||||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||||
@@ -90,15 +104,11 @@ const UserRanking = ({ data, title, icon, t }) => {
|
|||||||
<div className='flex items-center justify-between'>
|
<div className='flex items-center justify-between'>
|
||||||
<span
|
<span
|
||||||
className='text-sm font-medium truncate'
|
className='text-sm font-medium truncate'
|
||||||
title={`${formatUserReference(item.display_name || item.username, item.user_id, t('未知用户'))}`}
|
title={`${item.display_name || item.username || 'User'} (ID: ${item.user_id})`}
|
||||||
>
|
>
|
||||||
{formatUserReference(
|
{item.display_name || item.username || `User ${item.user_id}`}
|
||||||
item.display_name || item.username,
|
|
||||||
item.user_id,
|
|
||||||
t('未知用户'),
|
|
||||||
)}
|
|
||||||
<span className='text-xs text-gray-400 ml-1'>
|
<span className='text-xs text-gray-400 ml-1'>
|
||||||
{formatIdReference(item.user_id)}
|
#{item.user_id}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span className='text-sm font-semibold text-gray-700 dark:text-gray-300 ml-2'>
|
<span className='text-sm font-semibold text-gray-700 dark:text-gray-300 ml-2'>
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
import { formatPercent, formatRatioPercent } from '../../helpers/safeDisplay';
|
/*
|
||||||
|
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, useCallback } from 'react';
|
import React, { useMemo, useState, useEffect, useCallback } from 'react';
|
||||||
import { Card, Spin, Tag, Progress } from '@/components/ui';
|
import { Card, Spin, Tag, Progress } from '@/components/ui';
|
||||||
@@ -113,7 +130,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: () => t('占比'),
|
key: () => t('占比'),
|
||||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -169,7 +186,7 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: () => t('占比'),
|
key: () => t('占比'),
|
||||||
value: (datum) => formatPercent(datum?.percentage || 0, 1),
|
value: (datum) => `${(datum?.percentage || 0).toFixed(1)}%`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -317,7 +334,10 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
|||||||
{techUsers}
|
{techUsers}
|
||||||
</div>
|
</div>
|
||||||
<div className='text-xs text-gray-400 mt-1'>
|
<div className='text-xs text-gray-400 mt-1'>
|
||||||
{formatRatioPercent(techUsers, totalUsers, 1, '0.0%')}
|
{totalUsers > 0
|
||||||
|
? ((techUsers / totalUsers) * 100).toFixed(1)
|
||||||
|
: 0}
|
||||||
|
%
|
||||||
</div>
|
</div>
|
||||||
</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'>
|
<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'>
|
||||||
@@ -331,12 +351,10 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
|||||||
{activeAIUsers}
|
{activeAIUsers}
|
||||||
</div>
|
</div>
|
||||||
<div className='text-xs text-gray-400 mt-1'>
|
<div className='text-xs text-gray-400 mt-1'>
|
||||||
{formatRatioPercent(
|
{totalUsers > 0
|
||||||
activeAIUsers,
|
? ((activeAIUsers / totalUsers) * 100).toFixed(1)
|
||||||
totalUsers,
|
: 0}
|
||||||
1,
|
%
|
||||||
'0.0%',
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</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'>
|
<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'>
|
||||||
@@ -350,12 +368,10 @@ const UserSurveyStats = ({ title, icon, t }) => {
|
|||||||
{interestedUsers}
|
{interestedUsers}
|
||||||
</div>
|
</div>
|
||||||
<div className='text-xs text-gray-400 mt-1'>
|
<div className='text-xs text-gray-400 mt-1'>
|
||||||
{formatRatioPercent(
|
{totalUsers > 0
|
||||||
interestedUsers,
|
? ((interestedUsers / totalUsers) * 100).toFixed(1)
|
||||||
totalUsers,
|
: 0}
|
||||||
1,
|
%
|
||||||
'0.0%',
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
import {
|
/*
|
||||||
formatNumber,
|
Copyright (C) 2025 QuantumNous
|
||||||
formatIdReference,
|
|
||||||
formatUserReference,
|
This program is free software: you can redistribute it and/or modify
|
||||||
} from '../../helpers/safeDisplay';
|
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 { Trans } from 'react-i18next';
|
||||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||||
@@ -67,12 +80,12 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
<div className='flex flex-col'>
|
<div className='flex flex-col'>
|
||||||
<span
|
<span
|
||||||
className='font-medium text-sm truncate'
|
className='font-medium text-sm truncate'
|
||||||
title={formatUserReference(text, record.user_id, t('未知用户'))}
|
title={text || `User ${record.user_id}`}
|
||||||
>
|
>
|
||||||
{formatUserReference(text, record.user_id, t('未知用户'))}
|
{text || `User ${record.user_id}`}
|
||||||
</span>
|
</span>
|
||||||
<span className='text-xs text-gray-400 truncate'>
|
<span className='text-xs text-gray-400 truncate'>
|
||||||
{I18N_TECHNICAL_TEXT.ID} {formatIdReference(record.user_id)}
|
{I18N_TECHNICAL_TEXT.ID} {record.user_id}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@@ -85,7 +98,7 @@ const UserTopupRanking = ({ data, title, icon, t, embedded = false }) => {
|
|||||||
defaultSortOrder: 'descend',
|
defaultSortOrder: 'descend',
|
||||||
render: (value) => (
|
render: (value) => (
|
||||||
<span className='font-semibold text-red-500'>
|
<span className='font-semibold text-red-500'>
|
||||||
¥{formatNumber(value, 2, '0.00')}
|
¥{(value || 0).toFixed(2)}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -11,7 +30,6 @@ import {
|
|||||||
} from '@/components/ui';
|
} from '@/components/ui';
|
||||||
import { ClipboardList } from 'lucide-react';
|
import { ClipboardList } from 'lucide-react';
|
||||||
import { ChangeText, OrgNameCell, ReasonTags, SectionCard } from './shared';
|
import { ChangeText, OrgNameCell, ReasonTags, SectionCard } from './shared';
|
||||||
import { formatRatioPercent } from '../../../helpers/safeDisplay';
|
|
||||||
import {
|
import {
|
||||||
daysSince,
|
daysSince,
|
||||||
downloadCsv,
|
downloadCsv,
|
||||||
@@ -266,11 +284,7 @@ const columnsFor = (tab, cny, t, atRisk) => {
|
|||||||
{v}/{r.member_count}
|
{v}/{r.member_count}
|
||||||
{r.member_count > 0 ? (
|
{r.member_count > 0 ? (
|
||||||
<span className='text-xs text-gray-400 ml-1'>
|
<span className='text-xs text-gray-400 ml-1'>
|
||||||
{formatRatioPercent(
|
{Math.min(100, (v / r.member_count) * 100).toFixed(0)}%
|
||||||
Math.min(100, Number(v) || 0),
|
|
||||||
r.member_count,
|
|
||||||
0,
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</span>
|
</span>
|
||||||
@@ -499,7 +513,11 @@ export const ActionCenter = ({ lists, activeTab, onTabChange, cny, t }) => (
|
|||||||
rowKey='org_id'
|
rowKey='org_id'
|
||||||
size='small'
|
size='small'
|
||||||
scroll={{ x: 1200 }}
|
scroll={{ x: 1200 }}
|
||||||
pagination={lists[tab].length > 10 ? { pageSize: 10 } : false}
|
pagination={
|
||||||
|
lists[tab].length > 10
|
||||||
|
? { pageSize: 10, showSizeChanger: false }
|
||||||
|
: false
|
||||||
|
}
|
||||||
empty={<Empty description={t('暂无需要跟进的企业')} />}
|
empty={<Empty description={t('暂无需要跟进的企业')} />}
|
||||||
/>
|
/>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
|
|||||||
Binary file not shown.
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { Trans } from 'react-i18next';
|
||||||
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
|
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
|
||||||
import { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
import { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||||
@@ -12,10 +31,6 @@ import {
|
|||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { ChangeText, KpiCard, SectionCard } from './shared';
|
import { ChangeText, KpiCard, SectionCard } from './shared';
|
||||||
import { formatCny, formatCst, pct, SEGMENTS } from './utils';
|
import { formatCny, formatCst, pct, SEGMENTS } from './utils';
|
||||||
import {
|
|
||||||
formatPercent,
|
|
||||||
formatRatioPercent,
|
|
||||||
} from '../../../helpers/safeDisplay';
|
|
||||||
|
|
||||||
// ─── 报表抬头:统计口径 + 数据状态 ─────────────────────────────────
|
// ─── 报表抬头:统计口径 + 数据状态 ─────────────────────────────────
|
||||||
export const ReportHeader = ({ report, onExport, t }) => {
|
export const ReportHeader = ({ report, onExport, t }) => {
|
||||||
@@ -194,7 +209,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
|||||||
n: (k.active_orgs || 0).toLocaleString(),
|
n: (k.active_orgs || 0).toLocaleString(),
|
||||||
count: k.active_orgs || 0,
|
count: k.active_orgs || 0,
|
||||||
}),
|
}),
|
||||||
sub: `${t('活跃率')} ${formatRatioPercent(k.active_orgs, servingOrgs)} · ${t('新增')} ${k.new_orgs || 0}`,
|
sub: `${t('活跃率')} ${pct(k.active_orgs, servingOrgs).toFixed(1)}% · ${t('新增')} ${k.new_orgs || 0}`,
|
||||||
compare: (
|
compare: (
|
||||||
<ChangeText cur={k.active_orgs} prev={k.prev_active_orgs} t={t} />
|
<ChangeText cur={k.active_orgs} prev={k.prev_active_orgs} t={t} />
|
||||||
),
|
),
|
||||||
@@ -214,7 +229,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
|||||||
n: (k.active_members || 0).toLocaleString(),
|
n: (k.active_members || 0).toLocaleString(),
|
||||||
count: k.active_members || 0,
|
count: k.active_members || 0,
|
||||||
}),
|
}),
|
||||||
sub: `${t('渗透率')} ${formatPercent(Math.min(100, pct(k.active_members, k.total_members)))} · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
sub: `${t('渗透率')} ${Math.min(100, pct(k.active_members, k.total_members)).toFixed(1)}% · ${t('成员')} ${(k.total_members || 0).toLocaleString()}`,
|
||||||
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
tip: t('本期通过企业密钥产生调用的去重成员数(按自然日统计)'),
|
||||||
onClick: () => onJump('growth'),
|
onClick: () => onJump('growth'),
|
||||||
},
|
},
|
||||||
@@ -262,7 +277,7 @@ export const KpiGrid = ({ report, lists, cny, onJump, t }) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('企业消耗占平台'),
|
title: t('企业消耗占平台'),
|
||||||
value: formatPercent(share),
|
value: `${share.toFixed(1)}%`,
|
||||||
sub: `${t('个人消耗')} ${formatCny(k.personal_quota, cny)}`,
|
sub: `${t('个人消耗')} ${formatCny(k.personal_quota, cny)}`,
|
||||||
compare:
|
compare:
|
||||||
shareDelta === null ? null : (
|
shareDelta === null ? null : (
|
||||||
@@ -326,7 +341,7 @@ export const HealthSegments = ({ report, cny, activeSegment, onSelect, t }) => {
|
|||||||
{t(meta.label)}
|
{t(meta.label)}
|
||||||
</Tag>
|
</Tag>
|
||||||
<span className='text-xs text-gray-400 tabular-nums'>
|
<span className='text-xs text-gray-400 tabular-nums'>
|
||||||
{formatPercent(pct(s.count, totalCount), 0)}
|
{pct(s.count, totalCount).toFixed(0)}%
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className='mt-2 text-lg font-bold text-gray-800 dark:text-gray-100 tabular-nums'>
|
<div className='mt-2 text-lg font-bold text-gray-800 dark:text-gray-100 tabular-nums'>
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { Download as ActionDownload } from '@/components/common/icons/ActionIcons';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -11,7 +30,6 @@ import {
|
|||||||
} from '@/components/ui';
|
} from '@/components/ui';
|
||||||
import { Search, Table2, UserCog } from 'lucide-react';
|
import { Search, Table2, UserCog } from 'lucide-react';
|
||||||
import { ChangeText, OrgNameCell, SectionCard } from './shared';
|
import { ChangeText, OrgNameCell, SectionCard } from './shared';
|
||||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
|
||||||
import {
|
import {
|
||||||
ALERT_LEVELS,
|
ALERT_LEVELS,
|
||||||
ORG_STATUS,
|
ORG_STATUS,
|
||||||
@@ -123,7 +141,9 @@ export const SalesRepTable = ({ reps, cny, onSelect, t }) => {
|
|||||||
rowKey={(r) => r.sales_rep || '__none__'}
|
rowKey={(r) => r.sales_rep || '__none__'}
|
||||||
size='small'
|
size='small'
|
||||||
scroll={{ x: 920 }}
|
scroll={{ x: 920 }}
|
||||||
pagination={reps.length > 8 ? { pageSize: 10 } : false}
|
pagination={
|
||||||
|
reps.length > 8 ? { pageSize: 8, showSizeChanger: false } : false
|
||||||
|
}
|
||||||
empty={<Empty description={t('暂无数据')} />}
|
empty={<Empty description={t('暂无数据')} />}
|
||||||
/>
|
/>
|
||||||
</SectionCard>
|
</SectionCard>
|
||||||
@@ -246,7 +266,7 @@ export const OrgDetailTable = ({ report, filter, setFilter, cny, t }) => {
|
|||||||
align: 'right',
|
align: 'right',
|
||||||
render: (v) =>
|
render: (v) =>
|
||||||
v > 0 ? (
|
v > 0 ? (
|
||||||
<span className='tabular-nums'>{formatPercent(v, 1)}</span>
|
<span className='tabular-nums'>{v.toFixed(1)}%</span>
|
||||||
) : (
|
) : (
|
||||||
<Text type='tertiary'>—</Text>
|
<Text type='tertiary'>—</Text>
|
||||||
),
|
),
|
||||||
@@ -481,8 +501,8 @@ export const exportOrgDetail = (rows, cny, t) => {
|
|||||||
SEGMENTS[o.segment] ? t(SEGMENTS[o.segment].label) : '',
|
SEGMENTS[o.segment] ? t(SEGMENTS[o.segment].label) : '',
|
||||||
yuan(o.quota),
|
yuan(o.quota),
|
||||||
yuan(o.prev_quota),
|
yuan(o.prev_quota),
|
||||||
rate === null ? '' : formatPercent(rate, 1),
|
rate === null ? '' : `${rate.toFixed(1)}%`,
|
||||||
o.share ? formatPercent(o.share, 2) : '',
|
o.share ? `${o.share.toFixed(2)}%` : '',
|
||||||
o.requests,
|
o.requests,
|
||||||
o.active_members,
|
o.active_members,
|
||||||
o.member_count,
|
o.member_count,
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useCallback, useMemo, useState } from 'react';
|
||||||
import { Button, Card, Typography } from '@/components/ui';
|
import { Button, Card, Typography } from '@/components/ui';
|
||||||
import { ActionCenter, ACTION_TABS } from './ActionCenter';
|
import { ActionCenter, ACTION_TABS } from './ActionCenter';
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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 React from 'react';
|
||||||
import { Card, Tag, Tooltip } from '@/components/ui';
|
import { Card, Tag, Tooltip } from '@/components/ui';
|
||||||
import { TrendingDown, TrendingUp } from 'lucide-react';
|
import { TrendingDown, TrendingUp } from 'lucide-react';
|
||||||
import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils';
|
import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils';
|
||||||
import { formatPercent } from '../../../helpers/safeDisplay';
|
|
||||||
|
|
||||||
export const SectionCard = ({
|
export const SectionCard = ({
|
||||||
id,
|
id,
|
||||||
@@ -72,7 +90,7 @@ export const ChangeText = ({ cur, prev, t, size = 'xs', showNew = true }) => {
|
|||||||
<TrendingDown className='w-3 h-3' />
|
<TrendingDown className='w-3 h-3' />
|
||||||
)}
|
)}
|
||||||
{up ? '+' : ''}
|
{up ? '+' : ''}
|
||||||
{formatPercent(rate, 1)}
|
{rate.toFixed(1)}%
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
import {
|
/*
|
||||||
formatIdReference,
|
Copyright (C) 2025 QuantumNous
|
||||||
formatPercent,
|
|
||||||
toFiniteNumber,
|
This program is free software: you can redistribute it and/or modify
|
||||||
} from '../../../helpers/safeDisplay';
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
// 企业经营决策报表:口径常量、行动清单派生、要点生成、CSV 导出
|
// 企业经营决策报表:口径常量、行动清单派生、要点生成、CSV 导出
|
||||||
|
|
||||||
@@ -14,8 +27,7 @@ export const getCnyParams = () => {
|
|||||||
let usdRate = 1;
|
let usdRate = 1;
|
||||||
try {
|
try {
|
||||||
const s = JSON.parse(localStorage.getItem('status') || '{}');
|
const s = JSON.parse(localStorage.getItem('status') || '{}');
|
||||||
const parsedRate = toFiniteNumber(s?.usd_exchange_rate);
|
usdRate = s?.usd_exchange_rate || 1;
|
||||||
usdRate = parsedRate !== null && parsedRate > 0 ? parsedRate : 1;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
usdRate = 1;
|
usdRate = 1;
|
||||||
}
|
}
|
||||||
@@ -23,7 +35,7 @@ export const getCnyParams = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const quotaToCny = (quota, { quotaPerUnit, usdRate }) =>
|
export const quotaToCny = (quota, { quotaPerUnit, usdRate }) =>
|
||||||
((toFiniteNumber(quota) ?? 0) / quotaPerUnit) * usdRate;
|
((quota || 0) / quotaPerUnit) * usdRate;
|
||||||
|
|
||||||
export const formatCny = (quota, params, digits = 2) =>
|
export const formatCny = (quota, params, digits = 2) =>
|
||||||
`¥${quotaToCny(quota, params).toLocaleString(undefined, {
|
`¥${quotaToCny(quota, params).toLocaleString(undefined, {
|
||||||
@@ -35,22 +47,12 @@ export const formatCny = (quota, params, digits = 2) =>
|
|||||||
export const changeRate = (cur, prev) =>
|
export const changeRate = (cur, prev) =>
|
||||||
prev > 0 ? (((cur || 0) - prev) / prev) * 100 : null;
|
prev > 0 ? (((cur || 0) - prev) / prev) * 100 : null;
|
||||||
|
|
||||||
export const formatRate = (rate) => {
|
export const formatRate = (rate) =>
|
||||||
const number = Number(rate);
|
rate === null || rate === undefined
|
||||||
return rate === null || rate === undefined || !Number.isFinite(number)
|
|
||||||
? '—'
|
? '—'
|
||||||
: `${number >= 0 ? '+' : ''}${number.toFixed(1)}%`;
|
: `${rate >= 0 ? '+' : ''}${rate.toFixed(1)}%`;
|
||||||
};
|
|
||||||
|
|
||||||
export const pct = (part, total) => {
|
export const pct = (part, total) => (total > 0 ? (part / total) * 100 : 0);
|
||||||
const numerator = Number(part);
|
|
||||||
const denominator = Number(total);
|
|
||||||
return Number.isFinite(numerator) &&
|
|
||||||
Number.isFinite(denominator) &&
|
|
||||||
denominator > 0
|
|
||||||
? (numerator / denominator) * 100
|
|
||||||
: 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ─── 时间(报表口径统一为 UTC+8,与浏览器时区无关) ─────────────────
|
// ─── 时间(报表口径统一为 UTC+8,与浏览器时区无关) ─────────────────
|
||||||
const pad = (n) => String(n).padStart(2, '0');
|
const pad = (n) => String(n).padStart(2, '0');
|
||||||
@@ -403,11 +405,11 @@ export const deriveFindings = (report, lists, cny, t) => {
|
|||||||
? t(
|
? t(
|
||||||
'头部依赖较高:Top5 企业贡献 {{share}} 的企业消耗,需关注大客户稳定性',
|
'头部依赖较高:Top5 企业贡献 {{share}} 的企业消耗,需关注大客户稳定性',
|
||||||
{
|
{
|
||||||
share: formatPercent(k.top5_share, 1),
|
share: `${k.top5_share.toFixed(1)}%`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
: t('客户结构较分散:Top5 企业贡献 {{share}} 的企业消耗', {
|
: t('客户结构较分散:Top5 企业贡献 {{share}} 的企业消耗', {
|
||||||
share: formatPercent(k.top5_share, 1),
|
share: `${k.top5_share.toFixed(1)}%`,
|
||||||
}),
|
}),
|
||||||
target: 'tiers',
|
target: 'tiers',
|
||||||
});
|
});
|
||||||
@@ -424,7 +426,7 @@ export const deriveFindings = (report, lists, cny, t) => {
|
|||||||
text: t(
|
text: t(
|
||||||
'企业成员渗透率 {{rate}},{{count}} 家企业成员活跃率低于 30%,存在增量空间',
|
'企业成员渗透率 {{rate}},{{count}} 家企业成员活跃率低于 30%,存在增量空间',
|
||||||
{
|
{
|
||||||
rate: formatPercent(Math.min(100, penetration), 1),
|
rate: `${Math.min(100, penetration).toFixed(1)}%`,
|
||||||
count: lowPen,
|
count: lowPen,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -465,6 +467,4 @@ export const downloadCsv = (filename, headers, rows) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const orgDisplayName = (o, t) =>
|
export const orgDisplayName = (o, t) =>
|
||||||
o.deleted
|
o.deleted ? `${t('已删除企业')} #${o.org_id}` : o.name || `#${o.org_id}`;
|
||||||
? `${t('已删除企业')} ${formatIdReference(o.org_id)}`
|
|
||||||
: o.name || formatIdReference(o.org_id);
|
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { useTranslation } from 'react-i18next';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Sparkles } from 'lucide-react';
|
import { Sparkles } from 'lucide-react';
|
||||||
@@ -23,12 +42,12 @@ const AuthCardHeader = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`auth-card-header flex flex-col items-center justify-center ${wrapperClassName}`}
|
className={`flex flex-col items-center justify-center ${wrapperClassName}`}
|
||||||
>
|
>
|
||||||
<div className={`auth-card-logo relative ${logoWrapperClassName}`}>
|
<div className={`relative ${logoWrapperClassName}`}>
|
||||||
{/* Logo 光环(.auth-login-page 认证页内隐藏,保持克制) */}
|
{/* Logo 光环 */}
|
||||||
<div className='auth-card-logo-halo absolute -inset-1.5 bg-gradient-to-r from-brand-from/30 to-brand-to/30 rounded-xl blur-md opacity-60' />
|
<div className='absolute -inset-1.5 bg-gradient-to-r from-brand-from/30 to-brand-to/30 rounded-xl blur-md opacity-60' />
|
||||||
<div className='auth-card-logo-box relative p-2 bg-white dark:bg-neutral-800 rounded-xl shadow-md'>
|
<div className='relative p-2 bg-white dark:bg-neutral-800 rounded-xl shadow-md'>
|
||||||
{logoNode || (
|
{logoNode || (
|
||||||
<img
|
<img
|
||||||
src={logo}
|
src={logo}
|
||||||
@@ -39,10 +58,10 @@ const AuthCardHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
<Sparkles
|
<Sparkles
|
||||||
size={14}
|
size={14}
|
||||||
className='auth-card-sparkle absolute -top-0.5 -right-0.5 text-amber-400 motion-safe:animate-pulse'
|
className='absolute -top-0.5 -right-0.5 text-amber-400 motion-safe:animate-pulse'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<h4 className='auth-card-title text-xl font-bold text-gray-800 dark:text-white tracking-tight mb-0.5'>
|
<h4 className='text-xl font-bold text-gray-800 dark:text-white tracking-tight mb-0.5'>
|
||||||
{title}
|
{title}
|
||||||
</h4>
|
</h4>
|
||||||
<p className='auth-card-subtitle text-gray-500 dark:text-gray-400 text-xs'>
|
<p className='auth-card-subtitle text-gray-500 dark:text-gray-400 text-xs'>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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 { MessageCircle as ActionMessageCircle } from '@/components/common/icons/ActionIcons';
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Avatar } from '@/components/ui';
|
import { Avatar } from '@/components/ui';
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 认证页统一的「— 文案 —」分隔线(如「或」「还没有企业?」)。
|
|
||||||
* 两侧细线 + 居中弱化文字,不依赖底色遮挡,玻璃卡片与深色模式下都干净。
|
|
||||||
* 样式见 src/styles/prototype.css 的 .auth-divider。
|
|
||||||
*/
|
|
||||||
const AuthDivider = ({ children, className = '' }) => (
|
|
||||||
<div className={`auth-divider ${className}`} role='separator'>
|
|
||||||
<span className='auth-divider-line' aria-hidden='true' />
|
|
||||||
<span className='auth-divider-text'>{children}</span>
|
|
||||||
<span className='auth-divider-line' aria-hidden='true' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default AuthDivider;
|
|
||||||
@@ -1,8 +1,26 @@
|
|||||||
|
/*
|
||||||
|
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 React from 'react';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { isSafePostLoginRedirect } from '../../helpers/data';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。
|
* 认证页「个人 / 企业」分段切换控件(登录与注册两种模式)。
|
||||||
@@ -16,12 +34,6 @@ import { isSafePostLoginRedirect } from '../../helpers/data';
|
|||||||
const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [searchParams] = useSearchParams();
|
|
||||||
const redirect = searchParams.get('redirect');
|
|
||||||
const loginSearch =
|
|
||||||
mode === 'login' && isSafePostLoginRedirect(redirect)
|
|
||||||
? `?${new URLSearchParams({ redirect })}`
|
|
||||||
: '';
|
|
||||||
|
|
||||||
// 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口
|
// 企业入口置于左侧首位:本产品主推企业用户,企业登录/注册是默认入口
|
||||||
const tabs =
|
const tabs =
|
||||||
@@ -45,7 +57,7 @@ const AuthLoginTabs = ({ active = 'personal', mode = 'login' }) => {
|
|||||||
type={isActive ? 'primary' : 'text'}
|
type={isActive ? 'primary' : 'text'}
|
||||||
aria-pressed={isActive}
|
aria-pressed={isActive}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!isActive) navigate(`${tab.to}${loginSearch}`);
|
if (!isActive) navigate(tab.to);
|
||||||
}}
|
}}
|
||||||
className='flex-1 font-medium'
|
className='flex-1 font-medium'
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -182,14 +201,14 @@ const GlassCard = ({
|
|||||||
return (
|
return (
|
||||||
<div className={`w-full max-w-sm relative login-card-float ${className}`}>
|
<div className={`w-full max-w-sm relative login-card-float ${className}`}>
|
||||||
<GlassCardStyles />
|
<GlassCardStyles />
|
||||||
{/* 外环柔光晕(.auth-login-page 认证页内隐藏) */}
|
{/* 外环柔光晕 */}
|
||||||
<div className='login-card-glow absolute -inset-6 bg-gradient-to-br from-brand-from/15 via-brand-via/10 to-brand-to/15 rounded-[2rem] blur-2xl opacity-80 pointer-events-none' />
|
<div className='absolute -inset-6 bg-gradient-to-br from-brand-from/15 via-brand-via/10 to-brand-to/15 rounded-[2rem] blur-2xl opacity-80 pointer-events-none' />
|
||||||
|
|
||||||
{/* 左上 / 右下脉动光晕 */}
|
{/* 左上 / 右下脉动光晕 */}
|
||||||
{withCornerHalos && (
|
{withCornerHalos && (
|
||||||
<>
|
<>
|
||||||
<div className='login-card-halo absolute -top-20 -left-20 w-44 h-44 bg-brand-from/25 dark:bg-brand-from/20 rounded-full blur-3xl pointer-events-none login-halo-pulse' />
|
<div className='absolute -top-20 -left-20 w-44 h-44 bg-brand-from/25 dark:bg-brand-from/20 rounded-full blur-3xl pointer-events-none login-halo-pulse' />
|
||||||
<div className='login-card-halo absolute -bottom-20 -right-20 w-44 h-44 bg-brand-to/25 dark:bg-brand-to/15 rounded-full blur-3xl pointer-events-none login-halo-pulse-delayed' />
|
<div className='absolute -bottom-20 -right-20 w-44 h-44 bg-brand-to/25 dark:bg-brand-to/15 rounded-full blur-3xl pointer-events-none login-halo-pulse-delayed' />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
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,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { ArrowRight as ActionArrowRight } from '@/components/common/icons/ActionIcons';
|
||||||
import React, {
|
import React, {
|
||||||
useContext,
|
useContext,
|
||||||
@@ -52,8 +71,7 @@ import { Shield, Smartphone, QrCode } from 'lucide-react';
|
|||||||
import GlassCard from './GlassCard';
|
import GlassCard from './GlassCard';
|
||||||
import AuthCardHeader from './AuthCardHeader';
|
import AuthCardHeader from './AuthCardHeader';
|
||||||
import AuthLoginTabs from './AuthLoginTabs';
|
import AuthLoginTabs from './AuthLoginTabs';
|
||||||
import AuthDivider from './AuthDivider';
|
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||||
import AgreementModal from './LazyAgreementModal';
|
|
||||||
import {
|
import {
|
||||||
isMiniProgramWebView,
|
isMiniProgramWebView,
|
||||||
withMiniProgramLogins,
|
withMiniProgramLogins,
|
||||||
@@ -75,26 +93,38 @@ const IS_MOBILE_DEVICE =
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 提取OAuthButton到组件外部,避免每次渲染都重建
|
// 提取OAuthButton到组件外部,避免每次渲染都重建
|
||||||
// 第三方登录按钮:统一为 36px 描边按钮,无位移 / 扫光动效(尺寸见 prototype.css .auth-login-page)
|
|
||||||
const OAuthButton = React.memo(
|
const OAuthButton = React.memo(
|
||||||
({ icon, children, onClick, loading, disabled, iconColor }) => (
|
({ icon, children, onClick, loading, disabled, iconColor, t }) => (
|
||||||
<Button
|
<button
|
||||||
block
|
|
||||||
className='auth-oauth-button'
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
loading={loading}
|
disabled={loading || disabled}
|
||||||
disabled={disabled}
|
className={`
|
||||||
icon={
|
group relative w-full h-10 flex items-center justify-center gap-2
|
||||||
<span
|
bg-white/80 dark:bg-white/[0.08] backdrop-blur-sm
|
||||||
className='auth-oauth-icon'
|
border border-gray-200/80 dark:border-white/[0.12]
|
||||||
style={iconColor ? { color: iconColor } : undefined}
|
rounded-xl shadow-sm
|
||||||
>
|
hover:bg-white dark:hover:bg-white/[0.12]
|
||||||
{icon}
|
hover:shadow-md hover:shadow-gray-200/50 dark:hover:shadow-black/30
|
||||||
</span>
|
hover:-translate-y-0.5 hover:border-gray-300 dark:hover:border-white/20
|
||||||
}
|
active:translate-y-0
|
||||||
|
transition-all duration-200 ease-out
|
||||||
|
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0
|
||||||
|
overflow-hidden
|
||||||
|
`}
|
||||||
>
|
>
|
||||||
{children}
|
{/* 悬停光效 */}
|
||||||
</Button>
|
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/30 dark:via-white/10 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
|
||||||
|
|
||||||
|
<span
|
||||||
|
style={iconColor ? { color: iconColor } : undefined}
|
||||||
|
className='relative z-10 flex items-center justify-center w-4 h-4 text-gray-700 dark:text-gray-200'
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
</span>
|
||||||
|
<span className='relative z-10 font-medium text-sm text-gray-700 dark:text-gray-200'>
|
||||||
|
{loading ? (t ? t('加载中...') : '加载中...') : children}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -147,16 +177,6 @@ const LoginForm = () => {
|
|||||||
const [githubButtonText, setGithubButtonText] = useState('');
|
const [githubButtonText, setGithubButtonText] = useState('');
|
||||||
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
|
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
|
||||||
const githubTimeoutRef = useRef(null);
|
const githubTimeoutRef = useRef(null);
|
||||||
// 微信验证码弹窗表单:确定前先做前端必填校验,通过后再走原提交逻辑
|
|
||||||
const wechatFormApi = useRef(null);
|
|
||||||
const submitWeChatCodeWithValidation = async () => {
|
|
||||||
try {
|
|
||||||
await wechatFormApi.current?.validate();
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await onSubmitWeChatVerificationCode();
|
|
||||||
};
|
|
||||||
|
|
||||||
const logo = getLogo();
|
const logo = getLogo();
|
||||||
const systemName = getSystemName();
|
const systemName = getSystemName();
|
||||||
@@ -201,17 +221,12 @@ const LoginForm = () => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const redirect = searchParams.get('redirect');
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
savePostLoginRedirect(redirect);
|
const redirect = searchParams.get('redirect');
|
||||||
}, [redirect]);
|
if (redirect) {
|
||||||
|
savePostLoginRedirect(redirect);
|
||||||
const expiryShown = useRef(false);
|
}
|
||||||
useEffect(() => {
|
if (searchParams.get('expired')) {
|
||||||
if (!searchParams.get('expired')) {
|
|
||||||
expiryShown.current = false;
|
|
||||||
} else if (!expiryShown.current) {
|
|
||||||
expiryShown.current = true;
|
|
||||||
showError(t('未登录或登录已过期,请重新登录'));
|
showError(t('未登录或登录已过期,请重新登录'));
|
||||||
const nextParams = new URLSearchParams(searchParams);
|
const nextParams = new URLSearchParams(searchParams);
|
||||||
nextParams.delete('expired');
|
nextParams.delete('expired');
|
||||||
@@ -220,15 +235,15 @@ const LoginForm = () => {
|
|||||||
}, [searchParams, setSearchParams, t]);
|
}, [searchParams, setSearchParams, t]);
|
||||||
|
|
||||||
const finishLogin = useCallback(
|
const finishLogin = useCallback(
|
||||||
(data) =>
|
(data, successMessage) =>
|
||||||
runLoginFlow({
|
runLoginFlow({
|
||||||
data,
|
data,
|
||||||
userDispatch,
|
userDispatch,
|
||||||
navigate,
|
navigate,
|
||||||
t,
|
t,
|
||||||
redirect,
|
successMessage,
|
||||||
}),
|
}),
|
||||||
[navigate, redirect, t, userDispatch],
|
[navigate, t, userDispatch],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onWeChatLoginClicked = () => {
|
const onWeChatLoginClicked = () => {
|
||||||
@@ -614,7 +629,7 @@ const LoginForm = () => {
|
|||||||
subtitle={t('请选择登录方式')}
|
subtitle={t('请选择登录方式')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className='auth-option-list'>
|
<div className='space-y-2'>
|
||||||
{status.wechat_login && (
|
{status.wechat_login && (
|
||||||
<OAuthButton
|
<OAuthButton
|
||||||
icon={<Icon svg={<WeChatIcon />} />}
|
icon={<Icon svg={<WeChatIcon />} />}
|
||||||
@@ -715,22 +730,39 @@ const LoginForm = () => {
|
|||||||
</OAuthButton>
|
</OAuthButton>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<AuthDivider>{t('或')}</AuthDivider>
|
{/* 分隔线 */}
|
||||||
|
<div className='relative py-3'>
|
||||||
|
<div className='absolute inset-0 flex items-center'>
|
||||||
|
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
|
||||||
|
</div>
|
||||||
|
<div className='relative flex justify-center'>
|
||||||
|
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
|
||||||
|
{t('或')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* 邮箱登录按钮 */}
|
{/* 邮箱登录按钮 */}
|
||||||
<Button
|
<button
|
||||||
theme='solid'
|
|
||||||
block
|
|
||||||
className='auth-login-submit'
|
|
||||||
icon={<IconMail />}
|
|
||||||
onClick={handleEmailLoginClick}
|
onClick={handleEmailLoginClick}
|
||||||
|
className='app-action-button group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 overflow-hidden'
|
||||||
>
|
>
|
||||||
{t('邮箱/用户名 登录')}
|
{/* 闪光效果 */}
|
||||||
</Button>
|
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
|
||||||
|
|
||||||
|
<IconMail className='relative z-10' />
|
||||||
|
<span className='relative z-10 font-medium text-sm'>
|
||||||
|
{t('邮箱/用户名 登录')}
|
||||||
|
</span>
|
||||||
|
<ActionArrowRight
|
||||||
|
size={16}
|
||||||
|
className='relative z-10 group-hover:translate-x-1 transition-transform'
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{(hasUserAgreement || hasPrivacyPolicy) && (
|
{(hasUserAgreement || hasPrivacyPolicy) && (
|
||||||
<div className='auth-login-agreement flex justify-center'>
|
<div className='mt-4 flex justify-center'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={agreedToTerms}
|
checked={agreedToTerms}
|
||||||
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
||||||
@@ -769,7 +801,7 @@ const LoginForm = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{!status.self_use_mode_enabled && (
|
{!status.self_use_mode_enabled && (
|
||||||
<div className='auth-login-register text-center'>
|
<div className='mt-4 text-center'>
|
||||||
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
||||||
{t('没有账户?')}{' '}
|
{t('没有账户?')}{' '}
|
||||||
<Link
|
<Link
|
||||||
@@ -783,7 +815,7 @@ const LoginForm = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 安全提示 */}
|
{/* 安全提示 */}
|
||||||
<div className='auth-login-security'>
|
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
|
||||||
<Shield size={12} />
|
<Shield size={12} />
|
||||||
<span>{t('安全登录')}</span>
|
<span>{t('安全登录')}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -815,17 +847,30 @@ const LoginForm = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{status.passkey_login && passkeySupported && (
|
{status.passkey_login && passkeySupported && (
|
||||||
<AuthDivider>{t('或')}</AuthDivider>
|
<div className='relative py-2'>
|
||||||
|
<div className='absolute inset-0 flex items-center'>
|
||||||
|
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
|
||||||
|
</div>
|
||||||
|
<div className='relative flex justify-center'>
|
||||||
|
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
|
||||||
|
{t('或')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Form className='auth-login-form' onSubmit={handleSubmit}>
|
<Form className='auth-login-form' onSubmit={handleSubmit}>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='username'
|
field='username'
|
||||||
className='auth-login-required-field'
|
className='auth-login-required-field'
|
||||||
rules={[{ required: true, message: t('请输入用户名/邮箱') }]}
|
rules={[{ required: true, message: t('请输入用户名或邮箱') }]}
|
||||||
required
|
required
|
||||||
aria-required='true'
|
aria-required='true'
|
||||||
label={t('用户名/邮箱')}
|
label={
|
||||||
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
|
{t('用户名/邮箱')}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
placeholder={t('请输入用户名或邮箱')}
|
placeholder={t('请输入用户名或邮箱')}
|
||||||
name='username'
|
name='username'
|
||||||
size='default'
|
size='default'
|
||||||
@@ -841,7 +886,11 @@ const LoginForm = () => {
|
|||||||
rules={[{ required: true, message: t('请输入密码') }]}
|
rules={[{ required: true, message: t('请输入密码') }]}
|
||||||
required
|
required
|
||||||
aria-required='true'
|
aria-required='true'
|
||||||
label={t('密码')}
|
label={
|
||||||
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
|
{t('密码')}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
placeholder={t('请输入密码')}
|
placeholder={t('请输入密码')}
|
||||||
name='password'
|
name='password'
|
||||||
mode='password'
|
mode='password'
|
||||||
@@ -852,7 +901,7 @@ const LoginForm = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{(hasUserAgreement || hasPrivacyPolicy) && (
|
{(hasUserAgreement || hasPrivacyPolicy) && (
|
||||||
<div className='auth-login-agree-row flex items-center'>
|
<div className='flex items-center'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={agreedToTerms}
|
checked={agreedToTerms}
|
||||||
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
||||||
@@ -923,15 +972,24 @@ const LoginForm = () => {
|
|||||||
status.wechat_open_oauth ||
|
status.wechat_open_oauth ||
|
||||||
status.linuxdo_oauth ||
|
status.linuxdo_oauth ||
|
||||||
status.telegram_oauth) && (
|
status.telegram_oauth) && (
|
||||||
<div>
|
<div className='mt-1'>
|
||||||
<AuthDivider>{t('或')}</AuthDivider>
|
<div className='relative py-2'>
|
||||||
<Button
|
<div className='absolute inset-0 flex items-center'>
|
||||||
block
|
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
|
||||||
className='auth-oauth-button'
|
</div>
|
||||||
|
<div className='relative flex justify-center'>
|
||||||
|
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
|
||||||
|
{t('或')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
onClick={handleOtherLoginOptionsClick}
|
onClick={handleOtherLoginOptionsClick}
|
||||||
|
className='w-full h-9 flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-300 border border-gray-200/80 dark:border-white/[0.12] rounded-lg hover:bg-gray-50 dark:hover:bg-white/[0.06] hover:border-gray-300 dark:hover:border-white/20 transition-all'
|
||||||
>
|
>
|
||||||
{t('其他登录选项')}
|
{t('其他登录选项')}
|
||||||
</Button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -950,7 +1008,7 @@ const LoginForm = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* 安全提示 */}
|
{/* 安全提示 */}
|
||||||
<div className='auth-login-security'>
|
<div className='mt-3 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
|
||||||
<Shield size={12} />
|
<Shield size={12} />
|
||||||
<span>{t('安全登录')}</span>
|
<span>{t('安全登录')}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -975,14 +1033,14 @@ const LoginForm = () => {
|
|||||||
}
|
}
|
||||||
visible={showWeChatLoginModal}
|
visible={showWeChatLoginModal}
|
||||||
maskClosable={true}
|
maskClosable={true}
|
||||||
onOk={submitWeChatCodeWithValidation}
|
onOk={onSubmitWeChatVerificationCode}
|
||||||
onCancel={() => setShowWeChatLoginModal(false)}
|
onCancel={() => setShowWeChatLoginModal(false)}
|
||||||
okText={t('登录')}
|
okText={t('登录')}
|
||||||
centered={true}
|
centered={true}
|
||||||
okButtonProps={{
|
okButtonProps={{
|
||||||
loading: wechatCodeSubmitLoading,
|
loading: wechatCodeSubmitLoading,
|
||||||
}}
|
}}
|
||||||
className='wechat-login-modal auth-login-modal'
|
className='wechat-login-modal'
|
||||||
>
|
>
|
||||||
{/* 移动端提示 */}
|
{/* 移动端提示 */}
|
||||||
{isMobileView && !isInWeChat && (
|
{isMobileView && !isInWeChat && (
|
||||||
@@ -1036,16 +1094,16 @@ const LoginForm = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form getFormApi={(api) => (wechatFormApi.current = api)}>
|
<Form>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='wechat_verification_code'
|
field='wechat_verification_code'
|
||||||
placeholder={t('请输入验证码')}
|
placeholder={t('请输入验证码')}
|
||||||
label={t('验证码')}
|
label={t('验证码')}
|
||||||
rules={[{ required: true, message: t('请输入验证码') }]}
|
|
||||||
value={inputs.wechat_verification_code}
|
value={inputs.wechat_verification_code}
|
||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
handleChange('wechat_verification_code', value)
|
handleChange('wechat_verification_code', value)
|
||||||
}
|
}
|
||||||
|
className='!rounded-xl'
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -1134,11 +1192,11 @@ const LoginForm = () => {
|
|||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
<div className='flex items-center gap-3'>
|
<div className='flex items-center gap-3'>
|
||||||
<div className='auth-modal-title-icon'>
|
<div className='w-10 h-10 rounded-xl bg-gradient-to-br from-green-400 to-emerald-500 flex items-center justify-center shadow-lg shadow-green-500/30'>
|
||||||
<Shield size={18} />
|
<Shield size={20} className='text-white' />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className='font-semibold'>{t('两步验证')}</div>
|
<div className='font-bold'>{t('两步验证')}</div>
|
||||||
<div className='text-xs text-gray-500 dark:text-gray-400 font-normal'>
|
<div className='text-xs text-gray-500 dark:text-gray-400 font-normal'>
|
||||||
{t('请输入验证码完成登录')}
|
{t('请输入验证码完成登录')}
|
||||||
</div>
|
</div>
|
||||||
@@ -1150,7 +1208,6 @@ const LoginForm = () => {
|
|||||||
footer={null}
|
footer={null}
|
||||||
width={450}
|
width={450}
|
||||||
centered
|
centered
|
||||||
className='auth-login-modal'
|
|
||||||
>
|
>
|
||||||
<TwoFAVerification
|
<TwoFAVerification
|
||||||
onSuccess={handle2FASuccess}
|
onSuccess={handle2FASuccess}
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { useEffectEvent } from '../../hooks/common/useEffectEvent';
|
||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
@@ -36,7 +55,7 @@ const OAuth2Callback = (props) => {
|
|||||||
|
|
||||||
if (message === 'bind') {
|
if (message === 'bind') {
|
||||||
showSuccess(t('绑定成功!'));
|
showSuccess(t('绑定成功!'));
|
||||||
navigate('/user/center', { replace: true });
|
navigate('/console/personal');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +93,7 @@ const OAuth2Callback = (props) => {
|
|||||||
// 参数缺失直接返回
|
// 参数缺失直接返回
|
||||||
if (!code) {
|
if (!code) {
|
||||||
showError(t('未获取到授权码'));
|
showError(t('未获取到授权码'));
|
||||||
navigate('/user/center', { replace: true });
|
navigate('/console/personal');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { Copy as ActionCopy } from '@/components/common/icons/ActionIcons';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
API,
|
API,
|
||||||
@@ -8,14 +27,11 @@ import {
|
|||||||
getSystemName,
|
getSystemName,
|
||||||
} from '../../helpers';
|
} from '../../helpers';
|
||||||
import { useSearchParams, Link } from 'react-router-dom';
|
import { useSearchParams, Link } from 'react-router-dom';
|
||||||
import { Button, Form, Typography, Banner } from '@/components/ui';
|
import { Button, Card, Form, Typography, Banner } from '@/components/ui';
|
||||||
import { IconMail, IconLock, IconCopy } from '@/components/ui/icons';
|
import { IconMail, IconLock, IconCopy } from '@/components/ui/icons';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import AuthBackground from '../common/AuthBackground';
|
|
||||||
import GlassCard from './GlassCard';
|
|
||||||
import AuthCardHeader from './AuthCardHeader';
|
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text, Title } = Typography;
|
||||||
|
|
||||||
const PasswordResetConfirm = () => {
|
const PasswordResetConfirm = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -92,100 +108,121 @@ const PasswordResetConfirm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className='relative overflow-hidden bg-gray-100 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'>
|
||||||
className='auth-login-page relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
|
{/* 背景模糊晕染球 */}
|
||||||
// 与登录页一致:抵扣 PageLayout 跑马灯占位高度,避免幽灵滚动
|
<div
|
||||||
style={{ minHeight: 'calc(100vh - var(--content-top-offset, 0px))' }}
|
className='blur-ball blur-ball-indigo'
|
||||||
>
|
style={{ top: '-80px', right: '-80px', transform: 'none' }}
|
||||||
<AuthBackground />
|
/>
|
||||||
<div className='w-full max-w-md z-10 flex flex-col items-center'>
|
<div
|
||||||
<GlassCard>
|
className='blur-ball blur-ball-teal'
|
||||||
<AuthCardHeader
|
style={{ top: '50%', left: '-120px' }}
|
||||||
logo={logo}
|
/>
|
||||||
title={systemName}
|
<div className='w-full max-w-sm mt-[60px]'>
|
||||||
subtitle={t('密码重置确认')}
|
<div className='flex flex-col items-center'>
|
||||||
/>
|
<div className='w-full max-w-md'>
|
||||||
|
<div className='flex items-center justify-center mb-6 gap-2'>
|
||||||
{!isValidResetLink && (
|
<img
|
||||||
<Banner
|
src={logo}
|
||||||
type='danger'
|
alt={t('网站标志')}
|
||||||
description={t('无效的重置链接,请重新发起密码重置请求')}
|
className='h-10 rounded-full'
|
||||||
className='auth-login-banner'
|
|
||||||
closeIcon={null}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Form
|
|
||||||
className='auth-login-form'
|
|
||||||
getFormApi={(api) => setFormApi(api)}
|
|
||||||
initValues={{
|
|
||||||
email: email || '',
|
|
||||||
newPassword: newPassword || '',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Form.Input
|
|
||||||
field='email'
|
|
||||||
label={t('邮箱')}
|
|
||||||
name='email'
|
|
||||||
disabled={true}
|
|
||||||
prefix={<IconMail />}
|
|
||||||
placeholder={email ? '' : t('等待获取邮箱信息...')}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{newPassword && (
|
|
||||||
<Form.Input
|
|
||||||
field='newPassword'
|
|
||||||
label={t('新密码')}
|
|
||||||
name='newPassword'
|
|
||||||
disabled={true}
|
|
||||||
prefix={<IconLock />}
|
|
||||||
suffix={
|
|
||||||
<Button
|
|
||||||
icon={<IconCopy />}
|
|
||||||
type='tertiary'
|
|
||||||
theme='borderless'
|
|
||||||
size='small'
|
|
||||||
onClick={async () => {
|
|
||||||
if (await copy(newPassword)) {
|
|
||||||
showNotice(
|
|
||||||
`${t('密码已复制到剪贴板:')} ${newPassword}`,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
showError(t('复制失败,请手动复制'));
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t('复制')}
|
|
||||||
</Button>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
<Title heading={3} className='!text-gray-800'>
|
||||||
|
{systemName}
|
||||||
<div className='auth-login-actions'>
|
</Title>
|
||||||
<Button
|
|
||||||
theme='solid'
|
|
||||||
block
|
|
||||||
className='auth-login-submit'
|
|
||||||
htmlType='submit'
|
|
||||||
onClick={handleSubmit}
|
|
||||||
loading={loading}
|
|
||||||
disabled={disableButton || newPassword || !isValidResetLink}
|
|
||||||
>
|
|
||||||
{newPassword ? t('密码重置完成') : t('确认重置密码')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
|
||||||
|
|
||||||
<div className='auth-login-register text-center'>
|
<Card className='border-0 !rounded-2xl overflow-hidden'>
|
||||||
<Text className='text-xs'>
|
<div className='flex justify-center pt-6 pb-2'>
|
||||||
<Link
|
<Title heading={3} className='text-gray-800 dark:text-gray-200'>
|
||||||
to='/login'
|
{t('密码重置确认')}
|
||||||
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
|
</Title>
|
||||||
>
|
</div>
|
||||||
{t('返回登录')}
|
<div className='px-2 py-8'>
|
||||||
</Link>
|
{!isValidResetLink && (
|
||||||
</Text>
|
<Banner
|
||||||
|
type='danger'
|
||||||
|
description={t('无效的重置链接,请重新发起密码重置请求')}
|
||||||
|
className='mb-4 !rounded-lg'
|
||||||
|
closeIcon={null}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Form
|
||||||
|
getFormApi={(api) => setFormApi(api)}
|
||||||
|
initValues={{
|
||||||
|
email: email || '',
|
||||||
|
newPassword: newPassword || '',
|
||||||
|
}}
|
||||||
|
className='space-y-4'
|
||||||
|
>
|
||||||
|
<Form.Input
|
||||||
|
field='email'
|
||||||
|
label={t('邮箱')}
|
||||||
|
name='email'
|
||||||
|
disabled={true}
|
||||||
|
prefix={<IconMail />}
|
||||||
|
placeholder={email ? '' : t('等待获取邮箱信息...')}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{newPassword && (
|
||||||
|
<Form.Input
|
||||||
|
field='newPassword'
|
||||||
|
label={t('新密码')}
|
||||||
|
name='newPassword'
|
||||||
|
disabled={true}
|
||||||
|
prefix={<IconLock />}
|
||||||
|
suffix={
|
||||||
|
<Button
|
||||||
|
icon={<IconCopy />}
|
||||||
|
type='tertiary'
|
||||||
|
theme='borderless'
|
||||||
|
onClick={async () => {
|
||||||
|
if (await copy(newPassword)) {
|
||||||
|
showNotice(
|
||||||
|
`${t('密码已复制到剪贴板:')} ${newPassword}`,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showError(t('复制失败,请手动复制'));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('复制')}
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className='space-y-2 pt-2'>
|
||||||
|
<Button
|
||||||
|
theme='solid'
|
||||||
|
className='w-full !rounded-full'
|
||||||
|
type='primary'
|
||||||
|
htmlType='submit'
|
||||||
|
onClick={handleSubmit}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disableButton || newPassword || !isValidResetLink
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{newPassword ? t('密码重置完成') : t('确认重置密码')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
<div className='mt-6 text-center text-sm'>
|
||||||
|
<Text>
|
||||||
|
<Link
|
||||||
|
to='/login'
|
||||||
|
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-medium transition-colors'
|
||||||
|
>
|
||||||
|
{t('返回登录')}
|
||||||
|
</Link>
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</GlassCard>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
API,
|
API,
|
||||||
@@ -8,15 +27,12 @@ import {
|
|||||||
getSystemName,
|
getSystemName,
|
||||||
} from '../../helpers';
|
} from '../../helpers';
|
||||||
import Turnstile from 'react-turnstile';
|
import Turnstile from 'react-turnstile';
|
||||||
import { Button, Form, Typography } from '@/components/ui';
|
import { Button, Card, Form, Typography } from '@/components/ui';
|
||||||
import { IconMail } from '@/components/ui/icons';
|
import { IconMail } from '@/components/ui/icons';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import AuthBackground from '../common/AuthBackground';
|
|
||||||
import GlassCard from './GlassCard';
|
|
||||||
import AuthCardHeader from './AuthCardHeader';
|
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text, Title } = Typography;
|
||||||
|
|
||||||
const PasswordResetForm = () => {
|
const PasswordResetForm = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -88,78 +104,91 @@ const PasswordResetForm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className='relative overflow-hidden bg-gray-100 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'>
|
||||||
className='auth-login-page relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
|
{/* 背景模糊晕染球 */}
|
||||||
// 与登录页一致:抵扣 PageLayout 跑马灯占位高度,避免幽灵滚动
|
<div
|
||||||
style={{ minHeight: 'calc(100vh - var(--content-top-offset, 0px))' }}
|
className='blur-ball blur-ball-indigo'
|
||||||
>
|
style={{ top: '-80px', right: '-80px', transform: 'none' }}
|
||||||
<AuthBackground />
|
/>
|
||||||
<div className='w-full max-w-md z-10 flex flex-col items-center'>
|
<div
|
||||||
<GlassCard>
|
className='blur-ball blur-ball-teal'
|
||||||
<AuthCardHeader
|
style={{ top: '50%', left: '-120px' }}
|
||||||
logo={logo}
|
/>
|
||||||
title={systemName}
|
<div className='w-full max-w-sm mt-[60px]'>
|
||||||
subtitle={t('密码重置')}
|
<div className='flex flex-col items-center'>
|
||||||
/>
|
<div className='w-full max-w-md'>
|
||||||
|
<div className='flex items-center justify-center mb-6 gap-2'>
|
||||||
{/* 前端校验(必填 + 邮箱格式)通过后才调用原 handleSubmit */}
|
<img
|
||||||
<Form className='auth-login-form' onSubmit={() => handleSubmit()}>
|
src={logo}
|
||||||
<Form.Input
|
alt={t('网站标志')}
|
||||||
field='email'
|
className='h-10 rounded-full'
|
||||||
label={t('邮箱')}
|
/>
|
||||||
rules={[
|
<Title heading={3} className='!text-gray-800'>
|
||||||
{ required: true, message: t('请输入邮箱') },
|
{systemName}
|
||||||
{
|
</Title>
|
||||||
type: 'email',
|
|
||||||
transform: (v) => v?.trim(),
|
|
||||||
message: t('邮箱格式不正确'),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
trigger='blur'
|
|
||||||
placeholder={t('请输入您的邮箱地址')}
|
|
||||||
name='email'
|
|
||||||
value={email}
|
|
||||||
onChange={handleChange}
|
|
||||||
prefix={<IconMail />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className='auth-login-actions'>
|
|
||||||
<Button
|
|
||||||
theme='solid'
|
|
||||||
block
|
|
||||||
className='auth-login-submit'
|
|
||||||
htmlType='submit'
|
|
||||||
loading={loading}
|
|
||||||
disabled={disableButton}
|
|
||||||
>
|
|
||||||
{disableButton ? `${t('重试')} (${countdown})` : t('提交')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
|
||||||
|
|
||||||
<div className='auth-login-register text-center'>
|
<Card className='border-0 !rounded-2xl overflow-hidden'>
|
||||||
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
<div className='flex justify-center pt-6 pb-2'>
|
||||||
{t('想起来了?')}{' '}
|
<Title heading={3} className='text-gray-800 dark:text-gray-200'>
|
||||||
<Link
|
{t('密码重置')}
|
||||||
to='/login'
|
</Title>
|
||||||
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-semibold transition-colors'
|
</div>
|
||||||
>
|
<div className='px-2 py-8'>
|
||||||
{t('登录')}
|
<Form className='space-y-3'>
|
||||||
</Link>
|
<Form.Input
|
||||||
</Text>
|
field='email'
|
||||||
</div>
|
label={t('邮箱')}
|
||||||
</GlassCard>
|
placeholder={t('请输入您的邮箱地址')}
|
||||||
|
name='email'
|
||||||
|
value={email}
|
||||||
|
onChange={handleChange}
|
||||||
|
prefix={<IconMail />}
|
||||||
|
/>
|
||||||
|
|
||||||
{turnstileEnabled && (
|
<div className='space-y-2 pt-2'>
|
||||||
<div className='flex justify-center mt-6'>
|
<Button
|
||||||
<Turnstile
|
theme='solid'
|
||||||
sitekey={turnstileSiteKey}
|
className='w-full !rounded-full'
|
||||||
onVerify={(token) => {
|
type='primary'
|
||||||
setTurnstileToken(token);
|
htmlType='submit'
|
||||||
}}
|
onClick={handleSubmit}
|
||||||
/>
|
loading={loading}
|
||||||
|
disabled={disableButton}
|
||||||
|
>
|
||||||
|
{disableButton
|
||||||
|
? `${t('重试')} (${countdown})`
|
||||||
|
: t('提交')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
<div className='mt-6 text-center text-sm'>
|
||||||
|
<Text>
|
||||||
|
{t('想起来了?')}{' '}
|
||||||
|
<Link
|
||||||
|
to='/login'
|
||||||
|
className='!text-brand-deep dark:!text-brand-from hover:!text-brand dark:hover:!text-brand-from font-medium transition-colors'
|
||||||
|
>
|
||||||
|
{t('登录')}
|
||||||
|
</Link>
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{turnstileEnabled && (
|
||||||
|
<div className='flex justify-center mt-6'>
|
||||||
|
<Turnstile
|
||||||
|
sitekey={turnstileSiteKey}
|
||||||
|
onVerify={(token) => {
|
||||||
|
setTurnstileToken(token);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { ArrowRight as ActionArrowRight } from '@/components/common/icons/ActionIcons';
|
||||||
import React, {
|
import React, {
|
||||||
useContext,
|
useContext,
|
||||||
@@ -46,9 +65,8 @@ import AuthBackground from '../common/AuthBackground';
|
|||||||
import GlassCard from './GlassCard';
|
import GlassCard from './GlassCard';
|
||||||
import AuthCardHeader from './AuthCardHeader';
|
import AuthCardHeader from './AuthCardHeader';
|
||||||
import AuthLoginTabs from './AuthLoginTabs';
|
import AuthLoginTabs from './AuthLoginTabs';
|
||||||
import AuthDivider from './AuthDivider';
|
|
||||||
import { Shield, Smartphone, QrCode } from 'lucide-react';
|
import { Shield, Smartphone, QrCode } from 'lucide-react';
|
||||||
import AgreementModal from './LazyAgreementModal';
|
import AgreementModal from '../common/DocumentRenderer/AgreementModal';
|
||||||
import {
|
import {
|
||||||
isMiniProgramWebView,
|
isMiniProgramWebView,
|
||||||
withMiniProgramLogins,
|
withMiniProgramLogins,
|
||||||
@@ -125,26 +143,6 @@ const RegisterForm = () => {
|
|||||||
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
|
const [githubButtonDisabled, setGithubButtonDisabled] = useState(false);
|
||||||
const [showWeChatOpenTipModal, setShowWeChatOpenTipModal] = useState(false);
|
const [showWeChatOpenTipModal, setShowWeChatOpenTipModal] = useState(false);
|
||||||
const githubTimeoutRef = useRef(null);
|
const githubTimeoutRef = useRef(null);
|
||||||
// 注册表单 / 微信验证码弹窗的表单实例:用于在原逻辑执行前做前端校验
|
|
||||||
const registerFormApi = useRef(null);
|
|
||||||
const wechatFormApi = useRef(null);
|
|
||||||
// 获取验证码前先校验邮箱必填与格式,通过后走原发送逻辑
|
|
||||||
const sendVerificationCodeWithValidation = async () => {
|
|
||||||
try {
|
|
||||||
await registerFormApi.current?.validate(['email']);
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await sendVerificationCode();
|
|
||||||
};
|
|
||||||
const submitWeChatCodeWithValidation = async () => {
|
|
||||||
try {
|
|
||||||
await wechatFormApi.current?.validate();
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await onSubmitWeChatVerificationCode();
|
|
||||||
};
|
|
||||||
|
|
||||||
const logo = getLogo();
|
const logo = getLogo();
|
||||||
const systemName = getSystemName();
|
const systemName = getSystemName();
|
||||||
@@ -461,7 +459,7 @@ const RegisterForm = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 第三方注册按钮:与登录页一致的 36px 描边按钮,无位移 / 扫光动效
|
// 注册按钮样式组件
|
||||||
const OAuthButton = ({
|
const OAuthButton = ({
|
||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
@@ -470,23 +468,36 @@ const RegisterForm = () => {
|
|||||||
disabled,
|
disabled,
|
||||||
iconColor,
|
iconColor,
|
||||||
}) => (
|
}) => (
|
||||||
<Button
|
<button
|
||||||
block
|
|
||||||
className='auth-oauth-button'
|
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
loading={loading}
|
disabled={loading || disabled}
|
||||||
disabled={disabled}
|
className={`
|
||||||
icon={
|
group relative w-full h-10 flex items-center justify-center gap-2
|
||||||
<span
|
bg-white/80 dark:bg-white/[0.08] backdrop-blur-sm
|
||||||
className='auth-oauth-icon'
|
border border-gray-200/80 dark:border-white/[0.12]
|
||||||
style={iconColor ? { color: iconColor } : undefined}
|
rounded-xl shadow-sm
|
||||||
>
|
hover:bg-white dark:hover:bg-white/[0.12]
|
||||||
{icon}
|
hover:shadow-md hover:shadow-gray-200/50 dark:hover:shadow-black/30
|
||||||
</span>
|
hover:-translate-y-0.5 hover:border-gray-300 dark:hover:border-white/20
|
||||||
}
|
active:translate-y-0
|
||||||
|
transition-all duration-200 ease-out
|
||||||
|
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0
|
||||||
|
overflow-hidden
|
||||||
|
`}
|
||||||
>
|
>
|
||||||
{children}
|
{/* 悬停光效 */}
|
||||||
</Button>
|
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/30 dark:via-white/10 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
|
||||||
|
|
||||||
|
<span
|
||||||
|
style={iconColor ? { color: iconColor } : undefined}
|
||||||
|
className='relative z-10 flex items-center justify-center w-4 h-4 text-gray-700 dark:text-gray-200'
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
</span>
|
||||||
|
<span className='relative z-10 font-medium text-sm text-gray-700 dark:text-gray-200'>
|
||||||
|
{loading ? t('加载中...') : children}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderOAuthOptions = () => {
|
const renderOAuthOptions = () => {
|
||||||
@@ -498,7 +509,7 @@ const RegisterForm = () => {
|
|||||||
subtitle={t('创建您的账户')}
|
subtitle={t('创建您的账户')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className='auth-option-list'>
|
<div className='space-y-2'>
|
||||||
{status.wechat_login && (
|
{status.wechat_login && (
|
||||||
<OAuthButton
|
<OAuthButton
|
||||||
icon={<Icon svg={<WeChatIcon />} />}
|
icon={<Icon svg={<WeChatIcon />} />}
|
||||||
@@ -580,23 +591,40 @@ const RegisterForm = () => {
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<AuthDivider>{t('或')}</AuthDivider>
|
{/* 分隔线 */}
|
||||||
|
<div className='relative py-3'>
|
||||||
|
<div className='absolute inset-0 flex items-center'>
|
||||||
|
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
|
||||||
|
</div>
|
||||||
|
<div className='relative flex justify-center'>
|
||||||
|
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
|
||||||
|
{t('或')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* 用户名注册按钮 */}
|
{/* 用户名注册按钮 */}
|
||||||
<Button
|
<button
|
||||||
theme='solid'
|
|
||||||
block
|
|
||||||
className='auth-login-submit'
|
|
||||||
icon={<IconMail />}
|
|
||||||
onClick={handleEmailRegisterClick}
|
onClick={handleEmailRegisterClick}
|
||||||
disabled={emailRegisterLoading}
|
disabled={emailRegisterLoading}
|
||||||
|
className='app-action-button group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 overflow-hidden'
|
||||||
>
|
>
|
||||||
{t('使用 用户名 注册')}
|
{/* 闪光效果 */}
|
||||||
</Button>
|
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
|
||||||
|
|
||||||
|
<IconMail className='relative z-10' />
|
||||||
|
<span className='relative z-10 font-medium text-sm'>
|
||||||
|
{t('使用 用户名 注册')}
|
||||||
|
</span>
|
||||||
|
<ActionArrowRight
|
||||||
|
size={16}
|
||||||
|
className='relative z-10 group-hover:translate-x-1 transition-transform'
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{(hasUserAgreement || hasPrivacyPolicy) && (
|
{(hasUserAgreement || hasPrivacyPolicy) && (
|
||||||
<div className='auth-login-agreement flex justify-center'>
|
<div className='mt-4 flex justify-center'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={agreedToTerms}
|
checked={agreedToTerms}
|
||||||
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
||||||
@@ -634,7 +662,7 @@ const RegisterForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className='auth-login-register text-center'>
|
<div className='mt-4 text-center'>
|
||||||
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
||||||
{t('已有账户?')}{' '}
|
{t('已有账户?')}{' '}
|
||||||
<Link
|
<Link
|
||||||
@@ -647,7 +675,7 @@ const RegisterForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 安全提示 */}
|
{/* 安全提示 */}
|
||||||
<div className='auth-login-security'>
|
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
|
||||||
<Shield size={12} />
|
<Shield size={12} />
|
||||||
<span>{t('安全注册')}</span>
|
<span>{t('安全注册')}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -666,35 +694,35 @@ const RegisterForm = () => {
|
|||||||
logoWrapperClassName='mb-2'
|
logoWrapperClassName='mb-2'
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 前端校验通过后才调用原 handleSubmit;其内协议 / 长度 / 一致性判断原样保留 */}
|
<Form className='register-compact-form auth-glass-form'>
|
||||||
<Form
|
{/* 用户名输入框 —— 玻璃观感统一由 .auth-glass-form(GlassCard 内置样式)驱动 */}
|
||||||
className='auth-login-form'
|
|
||||||
getFormApi={(api) => (registerFormApi.current = api)}
|
|
||||||
onSubmit={() => handleSubmit()}
|
|
||||||
>
|
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='username'
|
field='username'
|
||||||
label={t('用户名')}
|
label={
|
||||||
rules={[{ required: true, message: t('请输入用户名') }]}
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
|
{t('用户名')}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
placeholder={t('请输入用户名')}
|
placeholder={t('请输入用户名')}
|
||||||
name='username'
|
name='username'
|
||||||
|
size='large'
|
||||||
autoComplete='username'
|
autoComplete='username'
|
||||||
onChange={(value) => handleChange('username', value)}
|
onChange={(value) => handleChange('username', value)}
|
||||||
prefix={<IconUser size='small' />}
|
prefix={<IconUser size='small' />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 密码输入框:长度 8-20 与占位提示、后端约束一致 */}
|
{/* 密码输入框 */}
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='password'
|
field='password'
|
||||||
label={t('密码')}
|
label={
|
||||||
rules={[
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
{ required: true, message: t('请输入密码') },
|
{t('密码')}
|
||||||
{ min: 8, max: 20, message: t('密码长度需为 8-20 位') },
|
</span>
|
||||||
]}
|
}
|
||||||
trigger='blur'
|
|
||||||
placeholder={t('输入密码,最短 8 位,最长 20 位')}
|
placeholder={t('输入密码,最短 8 位,最长 20 位')}
|
||||||
name='password'
|
name='password'
|
||||||
mode='password'
|
mode='password'
|
||||||
|
size='large'
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
onChange={(value) => handleChange('password', value)}
|
onChange={(value) => handleChange('password', value)}
|
||||||
prefix={<IconLock size='small' />}
|
prefix={<IconLock size='small' />}
|
||||||
@@ -703,17 +731,15 @@ const RegisterForm = () => {
|
|||||||
{/* 确认密码输入框 */}
|
{/* 确认密码输入框 */}
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='password2'
|
field='password2'
|
||||||
label={t('确认密码')}
|
label={
|
||||||
required
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
validate={(value, values) => {
|
{t('确认密码')}
|
||||||
if (!value) return t('请输入确认密码');
|
</span>
|
||||||
if (value !== values.password) return t('两次输入的密码不一致');
|
}
|
||||||
return '';
|
|
||||||
}}
|
|
||||||
trigger='blur'
|
|
||||||
placeholder={t('确认密码')}
|
placeholder={t('确认密码')}
|
||||||
name='password2'
|
name='password2'
|
||||||
mode='password'
|
mode='password'
|
||||||
|
size='large'
|
||||||
autoComplete='new-password'
|
autoComplete='new-password'
|
||||||
onChange={(value) => handleChange('password2', value)}
|
onChange={(value) => handleChange('password2', value)}
|
||||||
prefix={<IconLock size='small' />}
|
prefix={<IconLock size='small' />}
|
||||||
@@ -723,26 +749,22 @@ const RegisterForm = () => {
|
|||||||
<>
|
<>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='email'
|
field='email'
|
||||||
label={t('邮箱')}
|
label={
|
||||||
rules={[
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
{ required: true, message: t('请输入邮箱') },
|
{t('邮箱')}
|
||||||
{
|
</span>
|
||||||
type: 'email',
|
}
|
||||||
transform: (v) => v?.trim(),
|
|
||||||
message: t('邮箱格式不正确'),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
trigger='blur'
|
|
||||||
placeholder={t('输入邮箱地址')}
|
placeholder={t('输入邮箱地址')}
|
||||||
name='email'
|
name='email'
|
||||||
type='email'
|
type='email'
|
||||||
|
size='large'
|
||||||
autoComplete='email'
|
autoComplete='email'
|
||||||
onChange={(value) => handleChange('email', value)}
|
onChange={(value) => handleChange('email', value)}
|
||||||
prefix={<IconMail size='small' />}
|
prefix={<IconMail size='small' />}
|
||||||
suffix={
|
suffix={
|
||||||
<Button
|
<Button
|
||||||
size='small'
|
size='small'
|
||||||
onClick={sendVerificationCodeWithValidation}
|
onClick={sendVerificationCode}
|
||||||
loading={verificationCodeLoading}
|
loading={verificationCodeLoading}
|
||||||
disabled={disableButton || verificationCodeLoading}
|
disabled={disableButton || verificationCodeLoading}
|
||||||
className='!rounded-lg'
|
className='!rounded-lg'
|
||||||
@@ -755,10 +777,14 @@ const RegisterForm = () => {
|
|||||||
/>
|
/>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='verification_code'
|
field='verification_code'
|
||||||
label={t('验证码')}
|
label={
|
||||||
rules={[{ required: true, message: t('请输入验证码') }]}
|
<span className='text-xs font-medium text-gray-600 dark:text-gray-300'>
|
||||||
|
{t('验证码')}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
placeholder={t('输入验证码')}
|
placeholder={t('输入验证码')}
|
||||||
name='verification_code'
|
name='verification_code'
|
||||||
|
size='large'
|
||||||
onChange={(value) => handleChange('verification_code', value)}
|
onChange={(value) => handleChange('verification_code', value)}
|
||||||
prefix={<IconKey size='small' />}
|
prefix={<IconKey size='small' />}
|
||||||
/>
|
/>
|
||||||
@@ -766,7 +792,7 @@ const RegisterForm = () => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{(hasUserAgreement || hasPrivacyPolicy) && (
|
{(hasUserAgreement || hasPrivacyPolicy) && (
|
||||||
<div className='auth-login-agree-row flex items-center'>
|
<div className='flex items-center mt-3'>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={agreedToTerms}
|
checked={agreedToTerms}
|
||||||
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
onChange={(e) => setAgreedToTerms(e.target.checked)}
|
||||||
@@ -801,22 +827,34 @@ const RegisterForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className='auth-login-actions'>
|
<div className='space-y-2 mt-3'>
|
||||||
{/* 注册按钮:提交经表单校验后调用原 handleSubmit,禁用条件不变 */}
|
{/* 注册按钮 */}
|
||||||
<Button
|
<button
|
||||||
theme='solid'
|
type='submit'
|
||||||
htmlType='submit'
|
onClick={handleSubmit}
|
||||||
block
|
|
||||||
className='auth-login-submit'
|
|
||||||
loading={registerLoading}
|
|
||||||
disabled={
|
disabled={
|
||||||
registerLoading ||
|
registerLoading ||
|
||||||
((hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms)
|
((hasUserAgreement || hasPrivacyPolicy) && !agreedToTerms)
|
||||||
}
|
}
|
||||||
|
className='app-action-button group relative w-full h-10 flex items-center justify-center gap-2 bg-gradient-to-r from-brand-from to-brand-to hover:from-brand-from hover:to-brand-to disabled:from-gray-400 disabled:to-gray-500 text-white rounded-xl shadow-md shadow-brand/25 dark:shadow-brand/15 hover:shadow-lg hover:shadow-brand/30 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-200 disabled:cursor-not-allowed disabled:hover:translate-y-0 overflow-hidden'
|
||||||
>
|
>
|
||||||
<span className='font-semibold'>{t('注 册')}</span>
|
{/* 闪光效果 */}
|
||||||
<ActionArrowRight size={16} />
|
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-500' />
|
||||||
</Button>
|
|
||||||
|
{registerLoading ? (
|
||||||
|
<div className='w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin' />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<span className='relative z-10 font-semibold'>
|
||||||
|
{t('注 册')}
|
||||||
|
</span>
|
||||||
|
<ActionArrowRight
|
||||||
|
size={16}
|
||||||
|
className='relative z-10 group-hover:translate-x-1 transition-transform'
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
@@ -827,20 +865,29 @@ const RegisterForm = () => {
|
|||||||
status.wechat_open_oauth ||
|
status.wechat_open_oauth ||
|
||||||
status.linuxdo_oauth ||
|
status.linuxdo_oauth ||
|
||||||
status.telegram_oauth) && (
|
status.telegram_oauth) && (
|
||||||
<div>
|
<div className='mt-2'>
|
||||||
<AuthDivider>{t('或')}</AuthDivider>
|
<div className='relative py-3'>
|
||||||
<Button
|
<div className='absolute inset-0 flex items-center'>
|
||||||
block
|
<div className='w-full border-t border-gray-200/80 dark:border-white/[0.08]'></div>
|
||||||
className='auth-oauth-button'
|
</div>
|
||||||
|
<div className='relative flex justify-center'>
|
||||||
|
<span className='px-3 text-xs text-gray-400 dark:text-gray-500 bg-white/60 dark:bg-neutral-900/70 backdrop-blur-md rounded-full'>
|
||||||
|
{t('或')}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
onClick={handleOtherRegisterOptionsClick}
|
onClick={handleOtherRegisterOptionsClick}
|
||||||
disabled={otherRegisterOptionsLoading}
|
disabled={otherRegisterOptionsLoading}
|
||||||
|
className='w-full h-9 flex items-center justify-center gap-2 text-sm text-gray-600 dark:text-gray-300 border border-gray-200/80 dark:border-white/[0.12] rounded-lg hover:bg-gray-50 dark:hover:bg-white/[0.06] hover:border-gray-300 dark:hover:border-white/20 transition-all'
|
||||||
>
|
>
|
||||||
{t('其他注册选项')}
|
{t('其他注册选项')}
|
||||||
</Button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className='auth-login-register text-center'>
|
<div className='mt-4 text-center'>
|
||||||
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
<Text className='text-gray-500 dark:text-gray-400 text-xs'>
|
||||||
{t('已有账户?')}{' '}
|
{t('已有账户?')}{' '}
|
||||||
<Link
|
<Link
|
||||||
@@ -853,7 +900,7 @@ const RegisterForm = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 安全提示 */}
|
{/* 安全提示 */}
|
||||||
<div className='auth-login-security'>
|
<div className='mt-4 flex items-center justify-center gap-1.5 text-[10px] text-gray-400 dark:text-gray-500'>
|
||||||
<Shield size={12} />
|
<Shield size={12} />
|
||||||
<span>{t('安全注册')}</span>
|
<span>{t('安全注册')}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -878,14 +925,14 @@ const RegisterForm = () => {
|
|||||||
}
|
}
|
||||||
visible={showWeChatLoginModal}
|
visible={showWeChatLoginModal}
|
||||||
maskClosable={true}
|
maskClosable={true}
|
||||||
onOk={submitWeChatCodeWithValidation}
|
onOk={onSubmitWeChatVerificationCode}
|
||||||
onCancel={() => setShowWeChatLoginModal(false)}
|
onCancel={() => setShowWeChatLoginModal(false)}
|
||||||
okText={t('登录')}
|
okText={t('登录')}
|
||||||
centered={true}
|
centered={true}
|
||||||
okButtonProps={{
|
okButtonProps={{
|
||||||
loading: wechatCodeSubmitLoading,
|
loading: wechatCodeSubmitLoading,
|
||||||
}}
|
}}
|
||||||
className='wechat-login-modal auth-login-modal'
|
className='wechat-login-modal'
|
||||||
>
|
>
|
||||||
{/* 移动端提示 */}
|
{/* 移动端提示 */}
|
||||||
{isMobileView && !isInWeChat && (
|
{isMobileView && !isInWeChat && (
|
||||||
@@ -939,16 +986,16 @@ const RegisterForm = () => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form getFormApi={(api) => (wechatFormApi.current = api)}>
|
<Form>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field='wechat_verification_code'
|
field='wechat_verification_code'
|
||||||
placeholder={t('请输入验证码')}
|
placeholder={t('请输入验证码')}
|
||||||
label={t('验证码')}
|
label={t('验证码')}
|
||||||
rules={[{ required: true, message: t('请输入验证码') }]}
|
|
||||||
value={inputs.wechat_verification_code}
|
value={inputs.wechat_verification_code}
|
||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
handleChange('wechat_verification_code', value)
|
handleChange('wechat_verification_code', value)
|
||||||
}
|
}
|
||||||
|
className='!rounded-xl'
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -1042,7 +1089,7 @@ const RegisterForm = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className='auth-login-page relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
|
className='relative overflow-hidden flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8'
|
||||||
// 抵扣 PageLayout 跑马灯占位高度,保证占位+容器恰为一屏,避免幽灵滚动
|
// 抵扣 PageLayout 跑马灯占位高度,保证占位+容器恰为一屏,避免幽灵滚动
|
||||||
style={{ minHeight: 'calc(100vh - var(--content-top-offset, 0px))' }}
|
style={{ minHeight: 'calc(100vh - var(--content-top-offset, 0px))' }}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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 React from 'react';
|
||||||
import TelegramLoginButton from 'react-telegram-login';
|
import TelegramLoginButton from 'react-telegram-login';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
|
/*
|
||||||
|
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 { Trans } from 'react-i18next';
|
||||||
import { API, showError } from '../../helpers';
|
import { API, showError, showSuccess } from '../../helpers';
|
||||||
import { Button, Card, Divider, Form, Typography } from '@/components/ui';
|
import { Button, Card, Divider, Form, Typography } from '@/components/ui';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -33,6 +51,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res.data.success) {
|
if (res.data.success) {
|
||||||
|
showSuccess(t('登录成功'));
|
||||||
if (onSuccess) {
|
if (onSuccess) {
|
||||||
onSuccess(res.data.data);
|
onSuccess(res.data.data);
|
||||||
}
|
}
|
||||||
@@ -52,21 +71,6 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 前端校验:与 handleSubmit 内原有判断一致,改为在输入框下方就地提示
|
|
||||||
const codeRules = [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: useBackupCode ? t('请输入备用码') : t('请输入验证码'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
validator: (_, value) => {
|
|
||||||
if (!value) return true;
|
|
||||||
if (useBackupCode) return value.length === 8 || t('备用码必须是8位');
|
|
||||||
return /^\d{6}$/.test(value) || t('验证码必须是6位数字');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
if (isModal) {
|
if (isModal) {
|
||||||
return (
|
return (
|
||||||
<div className='space-y-4'>
|
<div className='space-y-4'>
|
||||||
@@ -84,8 +88,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
value={verificationCode}
|
value={verificationCode}
|
||||||
onChange={setVerificationCode}
|
onChange={setVerificationCode}
|
||||||
onKeyPress={handleKeyPress}
|
onKeyPress={handleKeyPress}
|
||||||
rules={codeRules}
|
size='large'
|
||||||
trigger='blur'
|
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
@@ -95,6 +98,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
type='primary'
|
type='primary'
|
||||||
loading={loading}
|
loading={loading}
|
||||||
block
|
block
|
||||||
|
size='large'
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
>
|
>
|
||||||
{t('验证并登录')}
|
{t('验证并登录')}
|
||||||
@@ -111,8 +115,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
setUseBackupCode(!useBackupCode);
|
setUseBackupCode(!useBackupCode);
|
||||||
setVerificationCode('');
|
setVerificationCode('');
|
||||||
}}
|
}}
|
||||||
style={{ marginRight: 16, padding: 0 }}
|
style={{ marginRight: 16, color: '#1890ff', padding: 0 }}
|
||||||
className='!text-brand'
|
|
||||||
>
|
>
|
||||||
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -122,8 +125,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
theme='borderless'
|
theme='borderless'
|
||||||
type='tertiary'
|
type='tertiary'
|
||||||
onClick={onBack}
|
onClick={onBack}
|
||||||
style={{ padding: 0 }}
|
style={{ color: '#1890ff', padding: 0 }}
|
||||||
className='!text-brand'
|
|
||||||
>
|
>
|
||||||
{t('返回登录')}
|
{t('返回登录')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -175,8 +177,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
value={verificationCode}
|
value={verificationCode}
|
||||||
onChange={setVerificationCode}
|
onChange={setVerificationCode}
|
||||||
onKeyPress={handleKeyPress}
|
onKeyPress={handleKeyPress}
|
||||||
rules={codeRules}
|
size='large'
|
||||||
trigger='blur'
|
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
@@ -186,6 +187,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
type='primary'
|
type='primary'
|
||||||
loading={loading}
|
loading={loading}
|
||||||
block
|
block
|
||||||
|
size='large'
|
||||||
style={{ marginBottom: 16 }}
|
style={{ marginBottom: 16 }}
|
||||||
>
|
>
|
||||||
{t('验证并登录')}
|
{t('验证并登录')}
|
||||||
@@ -202,8 +204,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
setUseBackupCode(!useBackupCode);
|
setUseBackupCode(!useBackupCode);
|
||||||
setVerificationCode('');
|
setVerificationCode('');
|
||||||
}}
|
}}
|
||||||
style={{ marginRight: 16, padding: 0 }}
|
style={{ marginRight: 16, color: '#1890ff', padding: 0 }}
|
||||||
className='!text-brand'
|
|
||||||
>
|
>
|
||||||
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
{useBackupCode ? t('使用认证器验证码') : t('使用备用码')}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -213,8 +214,7 @@ const TwoFAVerification = ({ onSuccess, onBack, isModal = false }) => {
|
|||||||
theme='borderless'
|
theme='borderless'
|
||||||
type='tertiary'
|
type='tertiary'
|
||||||
onClick={onBack}
|
onClick={onBack}
|
||||||
style={{ padding: 0 }}
|
style={{ color: '#1890ff', padding: 0 }}
|
||||||
className='!text-brand'
|
|
||||||
>
|
>
|
||||||
{t('返回登录')}
|
{t('返回登录')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,300 +0,0 @@
|
|||||||
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,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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 React, { Suspense, lazy, useContext } from 'react';
|
||||||
import { StatusContext } from '../../../context/Status';
|
import { StatusContext } from '../../../context/Status';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useEffect, useRef } from 'react';
|
||||||
import './CinematicTokenFactory.css';
|
import './CinematicTokenFactory.css';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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 React, { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 i18next from 'i18next';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Loading from './ui/Loading';
|
import Loading from './ui/Loading';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 { X as ActionX } from '@/components/common/icons/ActionIcons';
|
||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback } from 'react';
|
||||||
import { Modal } from '@/components/ui';
|
import { Modal } from '@/components/ui';
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 {
|
import {
|
||||||
ChevronUp as ActionChevronUp,
|
ChevronUp as ActionChevronUp,
|
||||||
ArrowLeft as ActionArrowLeft,
|
ArrowLeft as ActionArrowLeft,
|
||||||
|
|||||||
@@ -1,3 +1,22 @@
|
|||||||
|
/*
|
||||||
|
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 {
|
import {
|
||||||
OpenAI,
|
OpenAI,
|
||||||
Claude,
|
Claude,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user