主人要求:AList 已由钉盘文件替代、钉钉知识库改为按当前账号发现 ⇒ 这两类不再出现在 数据源配置里,只保留 PP 资料与「可加入的来源」(按当前钉钉账号列出可访问的知识库与钉盘空间)。 实现(非破坏、可逆): - 新增纯函数 splitSourceConnections(connections, showLegacy):把 alist 与 dingtalk 归为 legacy,默认只返回 PP/手工等其余来源;showLegacy=true 时原样返回(顺序不变、一条不少)。 - 「数据源配置」新增一行折叠开关「显示 AList/钉钉知识库来源(N)」:默认收起,只显示 PP 资料(+手动导入);展开后这 N 个来源照旧可改刷新周期、启停、看修订历史。 **没有删除任何来源,也没有动它们的调度与目录快照。** - 区块文案说明登记路径:新来源只从「可加入的来源」勾选登记(钉盘文件已替代 AList)。 - 测试:splitSourceConnections 直测(默认折起 a/d、展开 a/b/c/d)+ SSR 断言默认视图只含 PP、 折叠项不在默认视图(原断言的 dingtalk 卡片标记改为折叠后的期望)。 验证:make verify 15/15;SystemSettings 用例 7/7。
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
- 新增迁移 `000046_version_history`(提交记录 + 同步状态):`commit_sha` 是唯一身份,**版本号不是唯一键** —— 两个提交算出同一个开发号时各占一行,用 SHA 区分。
|
||||
- 「当前运行」只认运行产物注入的**完整 SHA 精确匹配**:匹配到就标该条;开发构建显式标注"开发构建";拿不到标识就显示"当前运行版本未知",**不拿最新 main 或最新 tag 顶替**;CI 成功不等于已部署。
|
||||
|
||||
### Changed
|
||||
|
||||
- 「系统设置 → 数据源配置」默认只列 PP 资料与「可加入的来源」:AList 来源(已由钉盘文件替代)与静态登记的钉钉知识库来源(改为按当前钉钉账号发现)**不再默认列出**,收进「显示 AList/钉钉知识库来源(N)」折叠开关 —— **来源一个都没删**,展开后照旧可改刷新周期与启停,「来源与目录」里的内容不变。手动导入来源(本地手工验收)不在这次范围内,照旧显示。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 前端入口与静态资源的缓存语义("新功能看起来没上线"与"页面偶尔裸奔/空白"的根因):
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
# DobotAI 2.0 知识运营报表数据链路分析
|
||||
|
||||
> 调查日期:2026-10-14(Asia/Shanghai)
|
||||
> 阶段:只读现状调查与架构建议,未实施开发。
|
||||
> 结论等级:**线上已核实**=本轮 DWS 真实响应;**源码已核实**=本地实现/迁移证据;**待确认**=生产部署或数据不可访问,不能用源码代替线上事实。
|
||||
> 本文不含员工原始记录、问答原文、密码或 Token。
|
||||
|
||||
## 0. 摘要与调查边界
|
||||
|
||||
### 0.1 核心结论
|
||||
|
||||
1. **现有数据不是一条统一链路。** 至少有 DobotAI Go 后端问答/规则覆盖判定、钉钉 AI 表格标签、Python 离线统计三套实现;目前不能把它们的“覆盖/正确”视为同一指标。
|
||||
2. DWS 核实 `w0nYx0a` 为 **问题流水表 (2.0)**,`jQ6oevs` 为 **问题流水表**。截至本轮聚合,分别为 **2,121 / 13,275 条**;两表日期重叠,不能简单拼接后当作去重后的总使用量。
|
||||
3. **2.0 表覆盖、正确性、产品、部门、区域填值数均为 0。** 因而仅依赖这张表,当前不能生成可信的质量与维度周报。后端源码另有 `coverage_decisions`,但生产数据完整率尚未核实。
|
||||
4. 后端覆盖器是**确定性规则**,不是 LLM 正确性评测;引用存在不等于回答正确。源码未发现对应的 AI 正确性评估存储/服务。
|
||||
5. 现有流水统计脚本正确率为“正确=是 /(正确=是+否)”,**不要求该行已覆盖**;与用户本轮期望口径不同。
|
||||
6. 推荐先确认生产源、评估来源与分母,再新增一个轻量统计模块;报表 API 和邮件均复用它。**不重建问答日志,不把监控任务成功率当作回答正确率。**
|
||||
|
||||
### 0.2 已检查范围与限制
|
||||
|
||||
| 范围 | 检查方式 | 证据级别 / 限制 |
|
||||
|---|---|---|
|
||||
| 两张指定 AI 表格 | DWS `table get`、`field get`、`record stats`、`record group-stats` | 线上已核实;不全量读取问答,不导出员工记录 |
|
||||
| `/home/zheromiku/dobotai-platform` | Go 源码、数据库迁移、HTTP 路由、导出流程 | 源码已核实;HEAD `0fc73c415245073a7a94aa9afb1fe35ca9c1fb3e`,工作区有已有未提交改动,HEAD 不代表线上版本 |
|
||||
| `/home/zheromiku/knowledge-governance` | API、监控、工作流及目录结构 | 源码已核实;HEAD `b7f7e4f12101569db5bb76af9d836043eefc342b`,工作区有已有未提交改动 |
|
||||
| `/home/zheromiku/knowledge-adapter-service` | 检索模型、API、日志实现 | 源码已核实;未检查 live 检索/问答系统 |
|
||||
| `/home/zheromiku/DOBOTAI/{weekly_report,kb_ops,knowledge_ai_report}` | 现有 Python 统计、清洗和映射代码 | 源码已核实;没有运行会写 Excel/日志的流水线 |
|
||||
| 后端 live PostgreSQL | 尝试使用本地既有连接配置,只读连接 | **连接失败,未能执行任何查询**;不能确认 live 表、迁移、行数及版本 |
|
||||
| 运行服务版本 | 本地候选服务 `/version` 只读探测 | 未成功取得 DobotAI 版本响应;生产地址、部署 SHA 待确认 |
|
||||
| 表格重复事件 | DWS PostgreSQL 聚合探测 | 返回 `Invalid PostgreSQL query`;**未得到重复率,不能宣称已完成去重核验** |
|
||||
|
||||
DWS 大请求曾出现下游 `code: 800`,拆成单字段聚合后成功。覆盖分组响应没有提供可解释的选项值,改按 `field get` 取得的稳定 option ID 分别计数,避免猜测分组对应关系。所有下述主要计数的响应数据版本均为 **23215**;这是表格数据版本,**不是评估器版本**。
|
||||
|
||||
## 1. 当前系统架构与数据流
|
||||
|
||||
### 1.1 问答后端:源码链路
|
||||
|
||||
```text
|
||||
钉钉消息(群聊须 @) / POST /v1/qa
|
||||
→ 身份与会话解析、Agent 绑定
|
||||
→ BeginTurn:channel_actors / channel_conversations / messages / turns
|
||||
→ WeKnora Agent Chat:生成答案与引用
|
||||
→ FinishTurn:更新 turns,保存出站 messages
|
||||
├→ 成功轮次 observer:coverage.Service
|
||||
│ → coverage_decisions
|
||||
│ → 若未覆盖,同时创建 support_cases
|
||||
├→ 钉钉实际送达:单独记录 messages 送达状态
|
||||
└→ 可选 question_table_exports outbox
|
||||
→ 异步写入 AI 表格基础问答和人员快照
|
||||
→ 本地记录 external_record_id
|
||||
```
|
||||
|
||||
证据:`DP/internal/store/postgres/store.go:50–129,196–283`;`DP/internal/qa/service.go:166–177,285–298`;`DP/cmd/dobotai/main.go:84–95,188–203`。
|
||||
|
||||
**边界:**`turns.status=succeeded` 表示答案生成成功,不等同于用户成功收到答案。覆盖评估保存失败不会把成功问答改为失败,故成功轮次可能没有覆盖记录;成功请求重放提前返回,不自动补评估。
|
||||
|
||||
### 1.2 表格和离线报表:已核实链路与断点
|
||||
|
||||
```text
|
||||
AI 表格:问题、答案、人员、时间 + 覆盖/正确/产品等标签
|
||||
→ 本地 Excel / 离线流水与问题主表
|
||||
→ 人员部门映射(08) → 部门区域映射(09)
|
||||
→ 月区域使用统计(10) / 知识指标统计(12)
|
||||
→ Excel 汇总
|
||||
```
|
||||
|
||||
- 后端 `internal/questiontable/row.go:40–41` 明确**省略** `是否覆盖/是否正确/产品分类/问题类型/根因分析` 五个 select 字段;导出 SQL 也未读取 `coverage_decisions`。
|
||||
- 两张表有评估字段,不代表已查明谁填写、何时填写、是否由 AI 自动评估;完整字段读取未返回 AI 配置证据。
|
||||
- Base 工作流列表返回 3 个工作流、`runningCount=0`。这只说明本次列表中没有运行中的 Base 工作流,**不能排除外部自动化、定时脚本或人工评估**。
|
||||
- 本轮未核实“线上 AI 表格 → 本地 Excel”的自动同步和执行调度,也未核实当前正式周报调用哪份脚本。
|
||||
|
||||
### 1.3 知识治理和检索适配的边界
|
||||
|
||||
知识治理当前负责知识源、解析、发布及监控;Adapter 提供检索,不生成最终答案。现有监控 API 的 `success_rate` 来源是 `jobs` 的 completed/failed,**不是回答正确率**。
|
||||
|
||||
证据:`KG/internal/monitoring/metrics.go:25–44,73–86`;`KG/internal/monitoring/real.go:109–181`;`KA/src/knowledge_adapter/app.py:131–160`、`models.py:27–33`。
|
||||
|
||||
## 2. 实际数据表、字段及关联关系
|
||||
|
||||
### 2.1 线上 AI 表格
|
||||
|
||||
共同 Base:`KGZLxjv9VG37o9N6IYvYGBl9V6EDybno`。
|
||||
|
||||
| 表 | tableId | viewId | 本轮记录数 | 提问时间最小值 — 最大值 |
|
||||
|---|---|---|---:|---|
|
||||
| 问题流水表 (2.0) | `w0nYx0a` | `Qr19nXJ` | 2,121 | 2026-09-12 19:43:30 — 2026-10-14 11:45:30 +08:00 |
|
||||
| 问题流水表(旧表) | `jQ6oevs` | `TE2xi1m` | 13,275 | 2026-04-01 03:02:00 — 2026-10-14 11:44:23 +08:00 |
|
||||
|
||||
以上是 `COUNT` 聚合的记录数,**不是有效提问数或去重问题数**。两个 URL 的版本归属以真实表名为证据,不根据链接排列顺序推断。
|
||||
|
||||
| 字段名 | fieldId | 类型 | 用途 / 关联 |
|
||||
|---|---|---|---|
|
||||
| 中文问题 | `ZaMZF6j` | text | 中文文本,不能拿其非空作为所有语言的有效问题条件 |
|
||||
| 原始问题 | `bETcL3r` | text | 原始提问 |
|
||||
| AI答案 | `Y4cpmxU` | text | 答案正文 |
|
||||
| 提问时间 | `SCug9My` | date | 时间筛选;字段 formatter 为 `YYYY-MM-DD HH:mm:ss` |
|
||||
| 提问人 | `S2XA1uZ` | user | 人员实体;跨系统 ID 关系待确认 |
|
||||
| 流程触发人员信息 | `JgY2f1z` | text | 触发身份,文本格式不可假定始终为结构化 JSON |
|
||||
| 语言 | `DNIV3mQ` | text | 后端导出以 Han/Latin 字符启发式判断,不是语言模型识别 |
|
||||
| 部门 | `eBc6a6b` | text | 部门名称,不是部门外键 |
|
||||
| 区域 | `fPNLeVW` | text | 区域名称 |
|
||||
| 是否覆盖 | `QMn9UoU` | singleSelect | `是 / 否 / 否但不计入` |
|
||||
| 是否正确 | `H3gtTuv` | singleSelect | `是 / 否 / 待确认` |
|
||||
| 产品分类 | `nFvv8OR` | singleSelect | 产品标签;其中 DobotStudio Pro 是产品选项,不是渠道证据 |
|
||||
| 问题类型 | `UMqUPAG` | singleSelect | 问题业务分类 |
|
||||
| 根因分析 | `lnF7gF9` | singleSelect | 知识缺失/过期/检索不到等标签 |
|
||||
| 父记录 | 2.0:`C7kZIHz`;旧表:`qgyb5Df` | unidirectionalLink | 两字段 config 都指向 `w0nYx0a`,且允许 multiple;不能当作已建立的 1.0→2.0 迁移去重关系 |
|
||||
|
||||
**同一行存问答和评估标签**,没有本轮可见的独立评估表外键,也没有 `turn_id`、渠道、评估状态、评估时间、评估器版本业务列。DWS 有记录历史读取能力,但“单元格变更历史”不能直接等价于有状态、有版本的评估执行流水。
|
||||
|
||||
#### 线上标签和维度填值情况
|
||||
|
||||
| 计数项 | 2.0 | 旧表 | 解释 |
|
||||
|---|---:|---:|---|
|
||||
| 记录数 | 2,121 | 13,275 | 原始行数 |
|
||||
| 提问时间有值 | 2,121 | 13,275 | 已可做日期筛选 |
|
||||
| AI答案有值 | 2,121 | 13,256 | 有值不等于正确或成功送达 |
|
||||
| 覆盖标签有值 | 0 | 13,205 | 有值不等于评估完成 |
|
||||
| 覆盖=是 | 0 | 8,627 | 按 option ID 筛选 |
|
||||
| 覆盖=否 | 0 | 4,481 | 按 option ID 筛选 |
|
||||
| 覆盖=否但不计入 | 0 | 97 | 不计入的实际原因/标准待确认 |
|
||||
| 覆盖为空 | 2,121 | 70 | 用记录数减已知三个选项数量计算 |
|
||||
| 正确性有值 | 0 | 13,035 | 包括“待确认” |
|
||||
| 正确性=待确认 | 0 | 4,791 | 不能当作正确性评估已完成 |
|
||||
| 覆盖与正确性同时有值 | 0 | 12,965 | 仅为标签填值交集,不是正式完成量 |
|
||||
| 覆盖=是且正确=是 | 0 | 7,887 | 未排除测试人员、去重或筛有效问题 |
|
||||
| 部门有值 | 0 | 10,814 | 缺失会影响部门分析 |
|
||||
| 区域有值 | 0 | 8,556 | 缺失会影响区域分析 |
|
||||
| 产品分类有值 | 0 | 12,969 | 缺失或“未知”仍需区分 |
|
||||
|
||||
DWS 对提问人字段的 `DISTINCT` 返回 2.0 为 153、旧表为 418;这是**该人员字段的不同值计数**,尚未确认一行单人约束、ID 域及跨渠道合并,不发布为正式活跃人数。
|
||||
|
||||
日期过滤实测:`2026-10-05 ≤ 提问时间 < 2026-10-12`,2.0 为 **465 行**,旧表为 **80 行**。这证明已有时间范围查询能力,但不是“每周有效提问量”。
|
||||
|
||||
### 2.2 后端关系模型:迁移与写入代码证据,live 待确认
|
||||
|
||||
以下是真实源码中的表/列,不是猜测表名;但本轮 live DB 未连通,**不能宣称已核实生产表结构**。
|
||||
|
||||
| 实际表名 | 关键字段 | 用途 / 关联 | 证据 |
|
||||
|---|---|---|---|
|
||||
| `turns` | `id, tenant_key, channel, external_message_id, session_key, weknora_session_id, weknora_request_id, question, answer, references_json, status, created_at, updated_at, request_message_id, answer_message_id, agent_id, media_json` | 一个问答轮次;唯一 `(tenant_key,channel,external_message_id)` | DP 迁移 000001:16–35;000002;000003:77–84 |
|
||||
| `messages` | `id, tenant_key, channel, conversation_id, actor_id, correlation_id, direction, role, message_type, text_content, status, provider_created_at, created_at` | 入站/出站/内部消息;不要混合计为问题 | DP 迁移 000003:39–64 |
|
||||
| `messages` 人员/送达扩展 | `actor_name_snapshot, department_snapshot, region_snapshot, trigger_person_snapshot, actor_union_id_snapshot, delivered_at, delivery_method, provider_message_id, failure_code` | 提问时人员维度与独立送达状态 | DP 迁移 000003/000004/000009/000010 |
|
||||
| `coverage_decisions` | `id,tenant_key,channel,turn_id,evaluator_version,verdict,reason_code,reference_count,top_score,created_at,updated_at` | 覆盖决策;`turn_id → turns.id`,唯一 `(tenant_key,channel,turn_id)` | DP 迁移 000007:4–27 |
|
||||
| `support_cases` | `id,tenant_key,channel,turn_id,coverage_decision_id,status`;通知及 FAQ 导出字段 | 未覆盖支持单;不是正确性评估结果 | DP 迁移 000007:29–49;000011 |
|
||||
| `channel_actors` | `id,tenant_key,channel,external_actor_id,actor_type,display_name` | 渠道内人员;唯一 `(tenant_key,channel,external_actor_id)` | DP 迁移 000003:8–18 |
|
||||
| `channel_conversations` | `id,tenant_key,channel,external_conversation_id,conversation_type` | 对话;群聊对话不等于个人 | DP 迁移 000003:23–34 |
|
||||
| `session_mappings` | `session_key,tenant_key,channel,agent_id,conversation_type,external_subject_id,weknora_session_id` | 外部会话与 WeKnora 会话映射 | DP 迁移 000001:1–14;000008 |
|
||||
| `directory_profiles` | `tenant_key,staff_id,union_id,name,nickname,job_title,department_ids,department_name,main_department_name,region,employment_status,source,synced_at,updated_at` | 当前通讯录,主键 `(tenant_key,staff_id)` | DP 迁移 000009:1–20 |
|
||||
| `question_table_exports` | `id,tenant_key,channel,turn_id,status,attempts,last_attempt_at,next_attempt_at,exported_at,failure_code,external_record_id` | 表格同步 outbox;远端记录 ID 可用于对照,但当前表没有可见反向 turn ID | DP 迁移 000010:11–40 |
|
||||
| `answer_feedback` | `answer_message_id,turn_id,actor_id,value,reason_code,source,created_at,updated_at` | 用户点赞/点踩当前状态,不能等价为 AI 正确性评估 | DP 迁移 000005:6–19 |
|
||||
|
||||
建议调查/聚合连接顺序:`turns → request_message_id → messages → actor_id → channel_actors`;覆盖决策按 `turn_id` 加租户/渠道校验关联,避免跨租户。目录按渠道身份与 `staff_id/union_id` 解析,**不能统一按姓名 JOIN**。来自回调的 `external_actor_id` 可能有回退 ID,不应假定总是 staff ID。
|
||||
|
||||
### 2.3 评估状态、时间、版本与重新评估
|
||||
|
||||
| 问题 | 已有实现 | 边界 |
|
||||
|---|---|---|
|
||||
| 是否有评估状态 | `turns.status` 是问答状态;`coverage_decisions` 有最终 verdict,但没有独立 pending/running/failed 评估状态列 | 无决策只能视为缺评估,无法区分等待/失败/未接入 |
|
||||
| 是否有评估时间 | 覆盖决策 `created_at/updated_at` 为 DB 写入时间 | 不是独立的 AI 评估任务开始/完成时间;表格没有对应业务列 |
|
||||
| 是否有评估器版本 | 源码 `EvaluatorVersion="v3"`,写入 `evaluator_version` | 迁移默认 `v1`;线上版本分布待确认;版本不是 LLM 型号 |
|
||||
| 是否保存多次评估 | 覆盖唯一键不含版本;冲突仅 `DO UPDATE SET id=coverage_decisions.id` | 保留原有决策,不取“最新一次”;没有多版本历史 |
|
||||
| AI 正确性版本/时间 | 表格只见标签;后端未找到该评估模型 | 实际 AI 批处理/人工标注系统待定位 |
|
||||
|
||||
证据:`DP/internal/coverage/types.go:33–50`;`DP/internal/store/postgres/coverage.go:33–55`。
|
||||
|
||||
### 2.4 已有 API 与服务
|
||||
|
||||
| 实际 API / 服务 | 当前用途 | 是否可直接提供目标周报 |
|
||||
|---|---|---|
|
||||
| `POST /v1/qa` | 发起问答,接收 channel 等基础参数;不接收部门/区域/union ID,也未调用目录补全 | 否,且本轮未调用该写接口 |
|
||||
| `GET /v1/admin/audit/turns`;`GET /v1/admin/audit/turns/{id}` | 可选管理审计;列表筛选只允许 limit/cursor/channel/status | 否,无日期区间聚合、coverage JOIN 或质量统计 |
|
||||
| `coverage.Service.EvaluateAndPersist` | 成功轮次覆盖评估和保存 | 可复用已有决策,不是统计服务 |
|
||||
| `questiontable.Dispatcher` | outbox 异步表格插入 | 是同步服务,不是评估和统计服务 |
|
||||
| DWS `record stats/group-stats` | 表格服务端计数、筛选、分组、去重聚合 | 可复用数据读取能力;仍需统一业务口径 |
|
||||
| `GET /api/v1/monitor/overview`;`GET /api/v1/monitor/metrics` | 知识治理资源/入库/任务监控 | 不可替代问答运营指标 |
|
||||
| `POST /retrieval` | Adapter 外部知识检索,返回片段/score/元数据 | 不保存此处所需最终答案正确性 |
|
||||
|
||||
证据:DP `internal/httpapi/server.go:86–92,130–165`;KG `internal/httpapi/server.go:322–342`;KA `src/knowledge_adapter/app.py:131–160`。
|
||||
|
||||
### 2.5 钉钉、Studio Pro、Wiki 入口如何区分
|
||||
|
||||
- 后端已有 `turns.channel`、`messages.channel`、`channel_actors.channel`,可作为现有入口维度基础。
|
||||
- 钉钉 handler 已实现;HTTP `/v1/qa` 允许调用方传 channel。**未查明线上 Studio Pro/Wiki 是否经过该接口、传入什么 channel,不能编造渠道枚举。**
|
||||
- 表格没有显式入口字段;旧/新表名表达版本,不表达全部业务入口。
|
||||
- “产品分类=DobotStudio Pro”描述问题涉及产品,不表示用户从 Studio Pro 发起。
|
||||
- 知识治理的 `internal/external` 是知识可见范围,文档中 PG/ES/OSS 是发布运输通道,不能替代问答业务入口。
|
||||
- Wiki 资料检索/页面访问与 Wiki 问答必须分开定义,不能把知识访问数直接加入提问量。
|
||||
|
||||
## 3. 现有覆盖率、正确率计算逻辑
|
||||
|
||||
### 3.1 后端单次覆盖判断:不是统计覆盖率
|
||||
|
||||
当前 `coverage.Evaluator` 只接受 `succeeded`:
|
||||
|
||||
1. 答案命中明确无答案措辞,或同时出现“检索缺口+联系人工”措辞 → `uncovered_explicit_no_answer`。
|
||||
2. 未命中上述规则,且引用数量为 0 → `uncovered_no_references`。
|
||||
3. 有引用 → `covered_has_references`。
|
||||
|
||||
记录最高引用 score,但**没有分数阈值**,也不核对答案事实是否正确。该规则无法等价于表格 AI 对知识覆盖与回答正确性的评估。
|
||||
|
||||
证据:`DP/internal/coverage/evaluator.go:12–38,62–119,131–138`。
|
||||
|
||||
### 3.2 离线脚本实际口径
|
||||
|
||||
| 代码入口 | 实际公式 / 样本 | 与本轮目标差异 |
|
||||
|---|---|---|
|
||||
| `WR/scripts/12_calc_kb_metrics.py:153–179`;KB 同名脚本 | 严格覆盖率=覆盖“是” /(覆盖“是”+“否”);另算含部分覆盖率 | 空值、待确认、不计入、非法标签不进分母;没有统一有效问题判定 |
|
||||
| 同上正确率 | 正确“是” /(正确“是”+“否”),独立统计正确列 | **没有先限定覆盖=是**;待确认不进分母 |
|
||||
| `KB/scripts/06_calc_metrics.py:139–159` | 主表覆盖=(是+部分覆盖)/全部输入行;正确率=是/(是+否) | 主表是归并问题,非事件频次;空值等仍进覆盖分母 |
|
||||
| `KR/backup/calculate_metrics.py:182–211` | 先筛 `is_real_question=True`,覆盖总和 / 非空 question 数 | 另一套“真实问题”口径;实际正式入口待确认 |
|
||||
|
||||
`12_calc_kb_metrics.py` 先排除代码内置的测试/指定人员名单,再算指标;人员列缺失则不排除。本文不公开名单。它没有时间过滤、事件去重、非空问题检查;分母为 0 时返回 `0.0`,容易把“没有评估样本”显示成“表现为零”。
|
||||
|
||||
证据:`WR/scripts/12_calc_kb_metrics.py:128–146,282–308`。
|
||||
|
||||
### 3.3 有效问题、未评估、多次评估与历史变化
|
||||
|
||||
| 调查点 | 真实现状 |
|
||||
|---|---|
|
||||
| 有效问题如何判定 | 没有一套所有入口共用定义;主表、流水脚本、旧清洗分别采用不同过滤。`KB/scripts/01_import_raw.py:82–110,180–193` 按说明类关键词过滤,规则可能误排业务问题;旧清洗还按答案排除词过滤 |
|
||||
| 未完成评估 | 流水指标脚本不把空值/待确认计入对应分母;正确性“待确认”不是完成。后端成功但无决策的轮次无专门评估状态 |
|
||||
| 多次评估取哪一次 | 后端保留首次成功持久化决策,不覆盖原判定;表格/Excel 统计读取当前单元格,不查询历史最新完成任务 |
|
||||
| 历史是否变化 | 离线重跑使用当前标签、映射和人员名单;修改标签/通讯录/区域规则或文件会改变过去统计。后端规则决策不会仅因升级版本自动改写,但后续补评估或统计过滤调整仍会影响历史结果 |
|
||||
| 时间范围 | AI 表格已实测可以;后端审计列表没有时间参数;12脚本本身没有时间过滤,10脚本支持自然月 |
|
||||
| 产品/部门/区域 | 字段基础存在;当前10脚本有区域月使用统计,未发现目标产品×部门×区域质量聚合服务。2.0 的这些字段实际为空 |
|
||||
|
||||
**流水线时间错位:**`WR/scripts/12_run_08_09_10_pipeline.py:154–180` 把 `--month` 传给区域统计,知识指标读取完整输入,故同次产物可能混合“某月使用”与“全量质量”。
|
||||
|
||||
### 3.4 月使用与技术人员至少5次
|
||||
|
||||
- 当前 `WR/scripts/10_calc_region_usage_metrics.py:286–342,418–448` 按指定自然月;未指定时取数据中最大可解析日期所在月。区域总次数是流水行数,使用人数是人员文本 `nunique()`,不是统一稳定 ID。
|
||||
- 通讯录人员分母按 ID/姓名回退去重,再按区域展开;并未严格筛选技术人员、纳入范围和在职状态。多区域可能重复计数,汇总与人员明细身份口径也不同。
|
||||
- 旧 `KR/backup/calculate_metrics.py:214–290` 有“真实问题+内部技术支持+纳入范围+在职+周期≥5”的实现;`KR/backup/usage/region_usage.py:135–195` 则按 user ID,但在职/有效问题筛选不同。
|
||||
- **可以复用旧算法思路,不能称为当前已上线的统一≥5次指标。** 技术人员范围、人员 ID 唯一性、计次单位与离职处理均待确认。
|
||||
|
||||
### 3.5 重复计数风险
|
||||
|
||||
| 风险来源 | 已有保护 | 仍存在的风险 |
|
||||
|---|---|---|
|
||||
| 回调重复 | 后端 external_message_id 复合唯一键;成功请求返回原结果 | 新 ID 重发同内容是不同事件,不应按相同文本盲目去重 |
|
||||
| 多轮对话 | 后端一个 turn 一个问答轮次 | 一个会话多个 turn;若把会话、message、turn混合汇总会重复;默认群聊共享会话不是一个用户 |
|
||||
| 覆盖重评 | 一个 turn 一份持久化覆盖决策 | 不是多版本评估历史;新的 uncovered 输入可能创建支持单,但指向原有 covered 决策,需单独处理重评一致性 |
|
||||
| 表格同步重试 | 本地 outbox 一个 turn 唯一 | 远端插入后本地 MarkExported 失败可重试插入,未证明远端 exactly-once |
|
||||
| 旧数据导入 | 01脚本 SHA1(对话人\|规范时间\|原始问题),保留首条/跳过历史 ID | 不是官方消息 ID;时间缺失或规范化冲突会错误合并;12统计入口自身不去重 |
|
||||
| 1.0 / 2.0 合并 | 有两张表和父记录字段 | 日期重叠但无可证实迁移键;本轮 SQL 重复探测失败,重复量待确认 |
|
||||
| 通讯录及区域映射 | 已有离线别名/区域规则 | 重名保留首条、多区域 explode、目录规则分叉,可能放大或错归属 |
|
||||
|
||||
证据:DP `internal/store/postgres/coverage.go:33–55`;`internal/questiontable/dispatcher.go:168–185`;KB `scripts/01_import_raw.py:180–230`;WR `scripts/10_calc_region_usage_metrics.py:336–375`。
|
||||
|
||||
## 4. 报表指标可用性清单
|
||||
|
||||
分级针对**当前完整业务指标**,不把“有字段”当作“已有可信接口”。原始计数已支持的部分单独注明;所有后端数据实际填值仍待 live 核实。
|
||||
|
||||
| 目标指标 | 分级 | 现有可复用基础 | 必须补齐 / 验证 |
|
||||
|---|---|---|---|
|
||||
| 每周有效提问数量 | **部分支持,需要补充字段或逻辑** | 表格日期计数已支持,可直接查原始周行数;后端 turn 唯一键 | 有效问题、测试排除、失败是否纳入、双表去重和入口范围 |
|
||||
| 知识覆盖率 | **部分支持,需要补充字段或逻辑** | 后端规则决策;旧表覆盖标签;离线覆盖公式 | 选择权威覆盖源、统一分母;2.0表标签为空,不能出质量结论 |
|
||||
| 回答正确率 | **部分支持,需要补充字段或逻辑** | 旧表正确性标签、脚本 | 核实 AI 评估写入源及版本;限定已覆盖交集;2.0无正确性标签 |
|
||||
| 有效解答率 | **部分支持,需要补充字段或逻辑** | 旧表可筛覆盖=是且正确=是,已实测交集计数 | 没有找到正式有效解答率实现;需同一有效样本分母与缺评估处理 |
|
||||
| 与上周对比 | **部分支持,需要补充字段或逻辑** | 日期范围已支持,两期可查原始计数 | 统一两期口径与 as-of;没有核实不可变历史统计快照 |
|
||||
| 活跃用户数量 | **部分支持,需要补充字段或逻辑** | 人员字段 DISTINCT、后端 actors/union ID | 稳定 ID、单人行、跨入口合并、机器人/测试排除;字段不同值不是可靠人数 |
|
||||
| 按部门、区域、产品统计 | **部分支持,需要补充字段或逻辑** | 旧表标签、人员快照、目录和区域脚本 | 2.0全部为空;补关联与未知桶;产品分类不是渠道 |
|
||||
| 月使用次数≥5的技术人员数量 | **部分支持,需要补充字段或逻辑** | 历史 backup 有≥5次逻辑;目录有职位/任职字段 | 当前入口未实现该指标;统一技术人员名单、有效事件与稳定ID、自然月 |
|
||||
| 未覆盖问题 Top N | **部分支持,需要补充字段或逻辑** | 旧表覆盖=否,后端 uncovered/support_cases | 选择按事件还是归并问题;归并键、排序、授权与脱敏;未找到正式排名API |
|
||||
| AI 评估完成率 | **部分支持,需要补充字段或逻辑** | 当前标签非空/待确认可统计;后端决策存在性 | 非空不等于完成,规则覆盖不等于AI评估;执行状态、应评样本、正确性终态定义待补 |
|
||||
| 自动邮件周报(交付能力) | **暂不支持,需要开发** | 可复用统一统计结果;DWS 有 mail 服务但不代表项目已有邮件周报 | 本轮未找到项目邮件周报任务、投递去重、失败重试与发送审计实现 |
|
||||
|
||||
**当前可以直接查询的内容:**原始记录量、时间范围行数、标签分布、字段填值量和字段 DISTINCT。这些查询能力已经实测,不等价于完整目标指标已验收。
|
||||
|
||||
## 5. 当前的数据缺口和技术风险
|
||||
|
||||
### 5.1 P0:先澄清,避免做出“看起来正确”的错误周报
|
||||
|
||||
1. **生产证据缺口:**live DB 不可达,部署 SHA 未取得;需提供只读访问或由运维导出脱敏 schema/聚合。不能拿本地迁移证明生产已具备全部字段。
|
||||
2. **评估来源不明:**用户描述的“AI 自动覆盖与正确性评估”尚未定位到实际执行代码;表格字段配置未证明其自动化机制,后端现有覆盖器不是 AI 评测。
|
||||
3. **2.0标签断点:**质量、产品、部门和区域字段无填值。先查真实数据是否在别处,避免重新建设已有评估器。
|
||||
4. **无统一分母:**归并问题主表、流水事件、规则成功问答、旧真实问题过滤不一致。
|
||||
5. **双表版本不是入口:**同时写入/迁移关系未知,直接相加有重复风险。
|
||||
|
||||
### 5.2 P1:实现前要纳入验收
|
||||
|
||||
- 状态缺失:后端成功问答可缺覆盖评估,表格“待确认”无法区分进行中/人工待审/失败。
|
||||
- 评估更新:后端首次决策幂等与“取最新评估”目标不兼容;不能静默变更现有策略。
|
||||
- 用户反馈不等于正确性:点踩理由 incorrect 是用户反馈,不是统一 AI 评估标注。
|
||||
- 维度漂移:提问时快照与当前目录应分开;按当前部门重算历史会变动。
|
||||
- 人员去重:不同渠道 external ID、staff ID、union ID 不等价;姓名只能作低可信回退。
|
||||
- 产品归类:后端未见相应字段,旧脚本同名问题回退可能跨产品误配。
|
||||
- 区域规则分叉:weekly_report 与 kb_ops 的09/10已有不同别名规则,不应复制两套继续演化。
|
||||
- 时间口径:提问时间、系统入站时间、评估写入时间不同;周窗口必须选定一种,评估完成作为另一个 as-of。
|
||||
- 分母为零:现有脚本输出零,新的正式报表宜输出 null/not_available,并给缺失原因,不能暗示正确率为0%。
|
||||
- 性能与权限:避免每周全量读入问答正文;服务端聚合、固定窗口、只读凭据、超时及租户校验优先。
|
||||
- 邮件数据泄露:默认仅汇总;Top N需脱敏、权限和明确授权,不嵌入员工个人明细。
|
||||
|
||||
## 6. 最小改造方案及预估工作量(建议,未实施)
|
||||
|
||||
### 6.1 推荐方案 / 备选方案 / 不推荐
|
||||
|
||||
| 方案 | 内容 | 评价 |
|
||||
|---|---|---|
|
||||
| **推荐** | 在现有知识治理后端增加一个轻量运营统计模块;读现有问答/目录/评估源,统一归一化与计算;API及邮件共享结果 | 一个开发者可维护,不增微服务,不重建日志;先以 live 权威源核实为前提 |
|
||||
| **备选** | 表格作为权威源时,先用 DWS 聚合/窄字段读取生成可复核统计,再接入同一模块 | 出数快,但目前2.0标签缺失,评估追踪/远端去重仍弱;不能据此承诺全指标可用 |
|
||||
| **不推荐** | 新建问答日志系统、另做邮件专用公式、长期全量导出大表、拿检索score/监控成功率冒充正确率 | 重复建设、口径漂移、隐私与维护成本高 |
|
||||
|
||||
若生产问答库不可安全跨库读取,可将同一统计模块部署到已有 DobotAI 服务并通过只读聚合接口供治理平台消费。**二选一落地,不先创建两个同义统计实现。**
|
||||
|
||||
### 6.2 模块边界与复用点
|
||||
|
||||
| 模块(建议) | 输入 / 输出 | 边界与复用 |
|
||||
|---|---|---|
|
||||
| 只读来源适配 | 原问答记录、当前评估、人员快照 → 归一化事件 | 复用 turns/messages/coverage_decisions;正确性先定位原系统,禁止新增替代评测器;旧表仅作明确授权历史源 |
|
||||
| 口径与统计 | 同一范围内事件+已批准规则 → 总量、分子分母、维度、两期对比、缺失诊断 | 复用12脚本标签规范化/异常计数和10脚本区域规则;**不直接沿用有冲突的分母/姓名去重** |
|
||||
| V1只读API | 授权过滤 → 统一统计结果 | 复用治理HTTP、鉴权、日志;不复用 monitor 的任务成功率 |
|
||||
| 周报快照/渲染 | 同一统计结果 → 报表摘要/邮件内容 | 复用现有持久任务设施(jobs),但先核实扩展点;快照持久化位置需批准后设计 |
|
||||
| 邮件投递 | 已批准收件范围+快照 → 发送/失败审计 | 不在发送环节重新计算;定时、重试、投递幂等单独处理 |
|
||||
|
||||
后续涉及页面/UI时,**先移交 prototype Agent** 做数据缺失、口径说明、筛选及对比状态原型;原型确认后才进入正式开发。本轮没有启动 prototype、coder、tester或CI/CD任务。
|
||||
|
||||
### 6.3 归一化数据模型草案(DTO,不是新增数据库表)
|
||||
|
||||
| 建议字段 | 来源与规则 |
|
||||
|---|---|
|
||||
| `source / source_record_id` | 后端 turn ID 或表格record ID+表ID,保持来源命名空间 |
|
||||
| `tenant / channel / occurred_at` | 优先现有租户/渠道/选定提问时间;未知渠道不得伪造 |
|
||||
| `person_key / identity_quality` | 来源稳定ID及映射置信等级;报告不返回原始人员ID |
|
||||
| `department / region / product` | 快照/标签,缺失进入unknown;产品由现有分类来源提供 |
|
||||
| `is_valid / exclusion_reason` | 用户确认的统一规则;与是否已评估分开 |
|
||||
| `coverage_value / coverage_source / coverage_version` | 后端规则和表格AI标签必须标注来源,不能无说明混合 |
|
||||
| `correctness_value / correctness_source` | 原正确性评估;unknown/pending与incorrect分开 |
|
||||
| `evaluation_state / evaluated_at` | 有证据才填写;不能把问答成功时间当评估完成时间 |
|
||||
|
||||
没有证据的状态/版本保持 unknown,报表附质量诊断。若需要正式评估历史,优先评估已有原系统能力,再决定是否加小型关联/快照存储;**本轮不提供DDL,不变更数据库**。
|
||||
|
||||
### 6.4 指标口径草案(待用户确认,不是现状)
|
||||
|
||||
设同一范围内:`V`=有效事件数;`C`=有效且已覆盖事件数;`R`=有效且已覆盖且回答正确事件数。
|
||||
|
||||
- 期望覆盖率=`C/V`;正确率=`R/C`;有效解答率=`R/V`。
|
||||
- 同时返回未评估、正确性待确认、评估失败/未知、测试排除等数量;是否将未评估有效事件保留在V和已覆盖待正确性评估事件保留在C,**须明确确认**。不能把暂缺标签暗中视为“否”。
|
||||
- 若另提供“已评估样本表现”,必须使用不同指标名与分母说明,不冒充上述业务覆盖率。
|
||||
- 周范围推荐 Asia/Shanghai 周一00:00起、下周一00:00止,半开区间;月≥5按自然月及有效事件数计算。
|
||||
- 计次单位推荐问答turn;会话、答案消息和重复回调不额外计次。正常多轮各turn是否算一次由业务确认。
|
||||
- 比较两周时同一rule_version与as-of策略;可冻结已发布结果并提供明确重算版本,不能悄然修改已发送邮件的历史值。
|
||||
|
||||
### 6.5 V1 API草案(新建议,尚不存在)
|
||||
|
||||
建议仅新增一个端点:`GET /api/v1/operations/report`,参数 `start/end/timezone`、可选 `channel/department/region/product`、`compare=previous_period`、`top_n`。最终路由名称待仓库规范确认。
|
||||
|
||||
响应逻辑字段:
|
||||
|
||||
- `period, timezone, generated_at, as_of, rule_version, sources, source_versions`。
|
||||
- `counts`:原始量、有效量、已覆盖量、已覆盖且正确量、各类未评估/排除量。
|
||||
- `metrics`:每项 value/numerator/denominator/status,缺证据时not_available,不用假零。
|
||||
- `comparison`:上期计数及指标;率差用百分点,量变化可用百分比;上期分母为零时显式不可比。
|
||||
- `dimensions`:已授权维度聚合与unknown桶;避免多区域展开使总计膨胀。
|
||||
- `top_uncovered`:脱敏题目/归并标识/次数;默认不输出员工信息,权限不足不返回明细。
|
||||
- `data_quality`:缺标签、身份未匹配、维度缺失、重复待查、来源/评估版本差异。
|
||||
|
||||
自动邮件调用**同一内部统计入口**,使用其结果快照渲染,不另外写SQL或复刻公式。发送幂等建议由“周期+规则/快照版本+收件组”组成;未知投递结果不能盲目重发。
|
||||
|
||||
### 6.6 安全、日志、部署与CI/CD影响
|
||||
|
||||
- 数据源使用只读身份,设置查询超时,禁止写入、DDL或将秘密放入Git;报告和邮件仅输出授权范围聚合。
|
||||
- 复用治理鉴权与租户边界;报表访问、导出和邮件投递留审计,日志只含周期、规则版、计数、耗时、稳定失败码。
|
||||
- 默认不引入新微服务、消息队列或独立运行栈;新增统计模块随现有API部署,邮件复用已核实后的任务框架。
|
||||
- 后续CI增加纯统计契约测试:空样本、待确认、重复事件、多轮、双表来源、跨租户、跨区域、零分母、两期版本一致性。
|
||||
- 本轮未改变工作流、Runner、生产部署和数据库。后续数据库/索引/调度变更均需单独批准与回滚方案。
|
||||
|
||||
### 6.7 工作量估计
|
||||
|
||||
以下为架构估算,不是实测工时或已批准开发排期;单位为单人工作日,不含UI正式实现、重新建设AI评估器及历史数据大规模回填。
|
||||
|
||||
| 后续工作 | 预估 | 前提 / 验收 |
|
||||
|---|---:|---|
|
||||
| 生产只读核验与口径确认 | 1天 | 取得真实schema、部署SHA、渠道枚举、评估来源和填值聚合 |
|
||||
| 只读来源适配+统一统计核心 | 2–3天 | 对拍固定范围的分子分母、异常/未知桶、去重规则 |
|
||||
| V1接口+对比+基础维度/Top N | 1–2天 | API和独立核对结果一致,无未授权个人明细 |
|
||||
| 周报快照/调度/邮件复用 | 1–2天 | 同一快照与API数值一致;批准测试收件人;失败重试不重复发送 |
|
||||
| 回归与验收证据整理 | 1–2天 | 边界测试、固定范围对拍、性能和权限记录完整 |
|
||||
|
||||
**基础范围估计合计6–10工作日**。若正确性原系统不可接入、缺turn↔record映射或要回填2.0维度/历史评估,需调查后另估,不能承诺上述时间覆盖所有缺口。
|
||||
|
||||
### 6.8 Gitea Issue规划(草案,未创建,不建DEV任务)
|
||||
|
||||
| 标题 / 类型 | 交付与验收标准 | 依赖 |
|
||||
|---|---|---|
|
||||
| `[ARCH] 核实生产问答与评估数据源` | 脱敏live schema、部署SHA、实际渠道值、成功turn与缺决策量、评估版本分布;明确AI正确性来源;全部只读 | 只读访问/运维证据 |
|
||||
| `[DECISION] 确认有效问题和三个质量指标口径` | 批准V/C/R、测试排除、未评估处理、turn计次、时区窗口、技术人员范围与历史重算规则 | 来源核验 |
|
||||
| `[ARCH] 运营统计模块与V1接口契约` | 单一计算入口、来源映射、API草案、unknown/不可用状态、对拍及权限验收标准 | 口径确认 |
|
||||
| `[ARCH] 邮件周报复用与投递幂等设计` | 同一快照供API/邮件使用;收件权限、重试、未知投递处理与审计方案 | V1契约 |
|
||||
| `[UI] 运营报表V1原型交接prototype` | 筛选、两期对比、缺失数据提示、指标分母/来源说明;用户批准原型,不写正式UI业务代码 | 口径和契约 |
|
||||
|
||||
## 7. 需要用户确认的问题
|
||||
|
||||
1. **生产部署在哪里?** 本地 DobotAI 连接配置对应DB不可达,请提供生产项目路径/只读访问方式,或让运维输出无个人信息的schema与聚合;不要在聊天发送密码或Token。
|
||||
2. **AI自动评估由什么执行?** 是钉钉AI字段、外部工作流、离线批处理还是另一系统?请给执行代码/配置所在位置及其结果目标表;现有后端v3规则不是该正确性评估。
|
||||
3. **哪份评估是权威?** 表格覆盖标签与后端规则决策是否刻意分别保留?若不一致,以哪份为正式周报口径?
|
||||
4. **两个流水表的关系?** 为什么时间同时延伸到本轮当天?是否双写、试点/正式用户分流或历史迁移?是否有现有消息ID/turn ID映射文件或表?
|
||||
5. **有效提问范围?** 是否排除测试人员、无效/范围外问题、纯寒暄、失败问答、图片问题和设置指令?内置排除名单是否仍有效?
|
||||
6. **未评估与待确认如何进入分母?** 正式业务率与已评估样本率是否同时展示?零样本是否显示“暂无可用评估”,而不是0%?
|
||||
7. **入口范围和人员定义?** Studio Pro/Wiki是否问答入口、实际渠道值是什么?“技术人员”是技术支持岗位还是更大名单?≥5次是否按有效turn和自然月?
|
||||
8. **历史归属与发布策略?** 按提问时部门/区域还是当前通讯录?周报冻结还是自动随评估更新重算?周窗口是否采用周一至周一、北京时间?
|
||||
9. **Top N语义与邮件权限?** 排名按重复提问频次还是每条未覆盖事件?哪些人员能看脱敏问题?收件人范围、发送日/时间和重发策略是什么?
|
||||
10. **正式离线报表入口是哪份?** weekly_report、kb_ops还是knowledge_ai_report旧流程?确认后保留一套权威规则,避免三份实现互相冲突。
|
||||
|
||||
## 附录:证据定位与复核方式
|
||||
|
||||
路径缩写:DP=`/home/zheromiku/dobotai-platform`;KG=`/home/zheromiku/knowledge-governance`;KA=`/home/zheromiku/knowledge-adapter-service`;WR=`/home/zheromiku/DOBOTAI/weekly_report`;KB=`/home/zheromiku/DOBOTAI/kb_ops`;KR=`/home/zheromiku/DOBOTAI/knowledge_ai_report`。迁移简称均在DP `db/migrations/`,例如000007对应 `000007_coverage_decisions.up.sql`。
|
||||
|
||||
### A. DWS只读命令示例
|
||||
|
||||
```sh
|
||||
# 明确限定两表,读取字段/视图目录
|
||||
dws aitable table get --base-id KGZLxjv9VG37o9N6IYvYGBl9V6EDybno --table-ids w0nYx0a,jQ6oevs
|
||||
# 完整表头;按字段展开配置前先确认ID
|
||||
dws aitable field get --base-id KGZLxjv9VG37o9N6IYvYGBl9V6EDybno --table-id w0nYx0a
|
||||
# COUNT统计匹配记录,不加limit避免仅统计子集
|
||||
dws aitable record stats --base-id KGZLxjv9VG37o9N6IYvYGBl9V6EDybno --table-id w0nYx0a --stats '[{"fieldId":"ZaMZF6j","statsType":"COUNT"}]'
|
||||
```
|
||||
|
||||
实际标签筛选使用field get取得的option ID:覆盖“是”=`MPfK0hpGNX`,“否”=`rZT6tj41Je`,“否但不计入”=`1IJOik1qP8`;正确“是”=`p1jnsxEU3R`,“待确认”=`VGER9DlTkn`。日期范围使用 `not_before` 与 `before`,而非通用数值比较运算符。
|
||||
|
||||
本轮字段/聚合JSON保存在调查用scratch目录下 `dobotai-investigation/`;其中 `sanitized-summary.json` 含聚合摘要,不含原始问答或人员记录。失败响应未伪造成结果。
|
||||
|
||||
### B. 关键源码索引
|
||||
|
||||
| 文件 | 用途 |
|
||||
|---|---|
|
||||
| DP `internal/core/types.go:39–56,91–122` | 请求和turn模型 |
|
||||
| DP `internal/store/postgres/store.go:50–129,196–283` | 问答/消息事务写入,送达分离 |
|
||||
| DP `internal/qa/service.go:166–177,285–298` | 重放、成功评估observer、错误边界 |
|
||||
| DP `internal/coverage/{types,evaluator,service}.go` | 覆盖版本、规则及持久化服务 |
|
||||
| DP `internal/store/postgres/coverage.go:33–55` | 决策幂等和支持单关联 |
|
||||
| DP `internal/questiontable/row.go:36–87` | 实际表格字段映射、select省略 |
|
||||
| DP `internal/store/postgres/question_table_exports.go:80–98` | 导出数据来源,未关联评估 |
|
||||
| DP `internal/questiontable/dispatcher.go:168–185` | 远端写入后标记本地,重复窗口 |
|
||||
| DP `internal/httpapi/server.go:86–92,130–188` | 现有问答/审计API契约 |
|
||||
| DP `internal/channels/dingtalk/handler.go:189–265` | 入口、人员补全和请求 |
|
||||
| DP `internal/directory/resolver.go:35–64` | 通讯录缓存与故障回退 |
|
||||
| WR `scripts/12_calc_kb_metrics.py:128–179,282–308` | 当前流水统计样本与真实公式 |
|
||||
| WR `scripts/12_run_08_09_10_pipeline.py:154–180` | 月份只传区域统计的时间错位 |
|
||||
| WR `scripts/10_calc_region_usage_metrics.py:286–342,345–448` | 自然月、区域展开、人数与次数统计 |
|
||||
| KB `scripts/06_calc_metrics.py:139–159` | 问题主表不同分母 |
|
||||
| KB `scripts/01_import_raw.py:82–110,180–230` | 清洗/事件哈希去重 |
|
||||
| KR `backup/calculate_metrics.py:182–290` | 旧真实问题与技术人员≥5逻辑 |
|
||||
| KR `backup/usage/region_usage.py:135–195` | 另一份按ID的月≥5逻辑 |
|
||||
| KG `internal/monitoring/{real,metrics}.go` | 知识运行监控,不是问答质量统计 |
|
||||
| KA `src/knowledge_adapter/{app,models,observability}.py` | 外部检索、请求边界及脱敏日志 |
|
||||
|
||||
**下一步门槛:先确认数据源与口径,再批准实现;本报告不代表已批准开发、数据回填、结构变更或邮件发送。**
|
||||
+616
-98
@@ -1,108 +1,626 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe,expect,it,vi } from 'vitest'
|
||||
import { SystemSettingsView, visibleSaveMessage } from './SystemSettings'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { SystemSettingsView, splitSourceConnections, visibleSaveMessage } from './SystemSettings'
|
||||
import { AuthContext } from './auth'
|
||||
import type { MonitorOverview } from './monitor'
|
||||
import type { CatalogSource } from './sourceCatalog'
|
||||
import type { UISettings } from './uiSettings'
|
||||
import type { SourceConnectionListItem } from './sourceConnections'
|
||||
const monitor:MonitorOverview={mode:'simulation',simulated:true,observed_at:'2026-09-08T12:00:00Z',host:{cpu_percent:42,memory_used_bytes:1,memory_total_bytes:2,disk_used_bytes:1,disk_total_bytes:2,gpu_state:'unknown',gpu_detail:'未接入真实GPU监控',simulated:true},services:[{key:'mineru',name:'MinerU',state:'healthy',detail:'模拟',latency_ms:1,observed_at:'2026-09-08T12:00:00Z',simulated:true}],knowledge_bases:[],health:[{key:'mineru',name:'MinerU',liveness:'up',readiness:'blocked',reason:'服务可达但容量已满(429),暂时不可接单',latency_ms:30,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:2,configured:true,applicable:true}]}
|
||||
const sources:CatalogSource[]=[{connection_id:'ding-1',source_type:'dingtalk',name:'公司级技术支持知识库',root_node_id:'root-1',folder_count:1079,file_count:3444,observed_at:'2026-09-09T09:30:32Z',snapshot_only:true,snapshot_status:'ready',last_refresh_duration_ms:0}]
|
||||
const connections:SourceConnectionListItem[]=[{id:'conn-ding',source_type:'dingtalk',name:'公司级技术支持知识库',enabled:true,schedule_configured:true,health_status:'healthy',item_count:3444,updated_at:'2026-09-09T09:30:32Z',next_refresh_at:'2026-09-12T10:00:00Z'},{id:'conn-man',source_type:'manual',name:'本地手工验收',enabled:false,schedule_configured:false,health_status:'unknown',item_count:5,updated_at:'2026-09-09T09:30:32Z',next_refresh_at:null}]
|
||||
const settings:UISettings={id:'settings-default',state:'active',document_refresh_seconds:15,resource_refresh_seconds:30,stalled_after_seconds:1800,finalizing_after_seconds:7200,ingestion_concurrency:2,test_weknora_base_url:'',production_weknora_base_url:'',production_tenant_id:'',production_knowledge_base_id:'',updated_by:'system:migration',created_at:'2026-09-10T08:00:00Z',activated_at:'2026-09-10T08:00:00Z',retired_at:null,error_code:''}
|
||||
const authValue=(role:'admin'|'engineer')=>({identity:{id:`${role}-1`,username:role,display_name:role,role,must_change_password:false},ready:true,login:async()=>null,logout:async()=>{},changePassword:async()=>null,signedOut:0,notifySignedOut:()=>{}})
|
||||
describe('SystemSettingsView service configuration',()=>{
|
||||
it('lets an administrator edit exactly the four service fields in the web console',()=>{
|
||||
const configured:UISettings={...settings,test_weknora_base_url:'https://weknora.test.example',production_weknora_base_url:'https://weknora.prod.example',production_tenant_id:'10000',production_knowledge_base_id:'kb-abc123'}
|
||||
const view=(role:'admin'|'engineer')=>renderToStaticMarkup(<AuthContext.Provider value={authValue(role)}><SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={configured} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" /></AuthContext.Provider>)
|
||||
const adminHtml=view('admin')
|
||||
for(const text of ['测试地址','生产地址','生产 ID','知识库 ID','保存并启用服务配置','https://weknora.test.example','https://weknora.prod.example','10000','kb-abc123','四项留空即表示未配置'])expect(adminHtml).toContain(text)
|
||||
expect(adminHtml).not.toContain('仅管理员可修改')
|
||||
// 界面只剩这四项:依赖探活矩阵与对内/对外绑定下拉不再出现在服务配置页。
|
||||
for(const removed of ['MinerU','Embedding','Redis / MQ','PostgreSQL','测试知识库映射'])expect(adminHtml).not.toContain(removed)
|
||||
const engineerHtml=view('engineer')
|
||||
expect(engineerHtml).toContain('仅管理员可修改')
|
||||
expect(engineerHtml).not.toContain('保存并启用服务配置')
|
||||
})
|
||||
const monitor: MonitorOverview = {
|
||||
mode: 'simulation',
|
||||
simulated: true,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
host: {
|
||||
cpu_percent: 42,
|
||||
memory_used_bytes: 1,
|
||||
memory_total_bytes: 2,
|
||||
disk_used_bytes: 1,
|
||||
disk_total_bytes: 2,
|
||||
gpu_state: 'unknown',
|
||||
gpu_detail: '未接入真实GPU监控',
|
||||
simulated: true,
|
||||
},
|
||||
services: [
|
||||
{
|
||||
key: 'mineru',
|
||||
name: 'MinerU',
|
||||
state: 'healthy',
|
||||
detail: '模拟',
|
||||
latency_ms: 1,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
simulated: true,
|
||||
},
|
||||
],
|
||||
knowledge_bases: [],
|
||||
health: [
|
||||
{
|
||||
key: 'mineru',
|
||||
name: 'MinerU',
|
||||
liveness: 'up',
|
||||
readiness: 'blocked',
|
||||
reason: '服务可达但容量已满(429),暂时不可接单',
|
||||
latency_ms: 30,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 2,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
const sources: CatalogSource[] = [
|
||||
{
|
||||
connection_id: 'ding-1',
|
||||
source_type: 'dingtalk',
|
||||
name: '公司级技术支持知识库',
|
||||
root_node_id: 'root-1',
|
||||
folder_count: 1079,
|
||||
file_count: 3444,
|
||||
observed_at: '2026-09-09T09:30:32Z',
|
||||
snapshot_only: true,
|
||||
snapshot_status: 'ready',
|
||||
last_refresh_duration_ms: 0,
|
||||
},
|
||||
]
|
||||
const connections: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'conn-ding',
|
||||
source_type: 'dingtalk',
|
||||
name: '公司级技术支持知识库',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 3444,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: '2026-09-12T10:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 'conn-man',
|
||||
source_type: 'manual',
|
||||
name: '本地手工验收',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 5,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
const settings: UISettings = {
|
||||
id: 'settings-default',
|
||||
state: 'active',
|
||||
document_refresh_seconds: 15,
|
||||
resource_refresh_seconds: 30,
|
||||
stalled_after_seconds: 1800,
|
||||
finalizing_after_seconds: 7200,
|
||||
ingestion_concurrency: 2,
|
||||
test_weknora_base_url: '',
|
||||
production_weknora_base_url: '',
|
||||
production_tenant_id: '',
|
||||
production_knowledge_base_id: '',
|
||||
updated_by: 'system:migration',
|
||||
created_at: '2026-09-10T08:00:00Z',
|
||||
activated_at: '2026-09-10T08:00:00Z',
|
||||
retired_at: null,
|
||||
error_code: '',
|
||||
}
|
||||
const authValue = (role: 'admin' | 'engineer') => ({
|
||||
identity: { id: `${role}-1`, username: role, display_name: role, role, must_change_password: false },
|
||||
ready: true,
|
||||
login: async () => null,
|
||||
logout: async () => {},
|
||||
changePassword: async () => null,
|
||||
signedOut: 0,
|
||||
notifySignedOut: () => {},
|
||||
})
|
||||
describe('SystemSettingsView',()=>{
|
||||
it('separates document-engineer settings from locked administrator and production controls',()=>{
|
||||
const html=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时" onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} />)
|
||||
for(const text of ['系统设置','数据源配置','服务配置','存储与备份','刷新策略','设置服务已启用','当前活动版本','公司级技术支持知识库','钉钉知识库','认证方式','端点与凭据','文档工程师可调整','管理员设置已锁定'])expect(html).toContain(text)
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
for(const removed of ['文件格式筛选','未勾选的一律不取件','保存保留格式','恢复继承上级规则'])expect(html).not.toContain(removed)
|
||||
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
|
||||
for(const removed of ['+ 新增钉钉知识库','新增钉钉知识库'])expect(html).not.toContain(removed)
|
||||
const servicesHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
for(const text of ['测试 WeKnora','生产 WeKnora','测试地址','生产地址','生产 ID','知识库 ID'])expect(servicesHtml).toContain(text)
|
||||
const storageHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="storage" />)
|
||||
// 存储与备份分区已换成真实功能(整库逻辑备份的定时计划),静态占位文案不再存在。
|
||||
expect(storageHtml).toContain('存储与备份')
|
||||
expect(storageHtml).toContain('正在读取备份计划…')
|
||||
expect(storageHtml).not.toContain('仅保存凭据引用,不可回读')
|
||||
const refreshHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时" onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="refresh" />)
|
||||
for(const text of ['刷新与告警参数已验证并启用','停滞30分钟','finalizing 2小时','文档状态刷新间隔','15秒','解析停滞判定','30分钟','保存并应用刷新与告警参数'])expect(refreshHtml).toContain(text)
|
||||
expect(visibleSaveMessage('已保存',true)).toBeNull();expect(visibleSaveMessage('已保存',false)).toBe('已保存')
|
||||
expect(html).not.toContain('本地模拟');expect(html).not.toContain('保存模拟设置')
|
||||
for(const forbidden of ['DATABASE_URL','RELEASE_CONFIG_FILE','API Key明文','secret_ref'])expect(html).not.toContain(forbidden)
|
||||
// 两个环境卡仍由真实探测驱动(依赖矩阵搬到总览页,本页不再渲染)。
|
||||
expect(servicesHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
|
||||
expect(servicesHtml).not.toContain('PostgreSQL')
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
expect(html).toContain('下次自动刷新')
|
||||
expect(html).toContain('仅手动刷新')
|
||||
expect(html).toContain('查看修订历史')
|
||||
expect(html).toContain('保存并启用调度')
|
||||
expect(html).toContain('停用来源')
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
})
|
||||
it('lets an administrator bind the internal/external import knowledge bases from 系统设置',()=>{
|
||||
// 组件一直在(RoutingBindingsSection),但从未挂到任何页面 —— 导入目标库只能靠
|
||||
// 部署 env 钉死,换库必须重建容器。
|
||||
const view=(section:'sources'|'bindings'|'production-bindings')=>renderToStaticMarkup(<AuthContext.Provider value={authValue('admin')}><SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection={section} /></AuthContext.Provider>)
|
||||
expect(view('sources')).toContain('测试知识库绑定')
|
||||
expect(view('sources')).toContain('生产知识库绑定')
|
||||
const bound=view('bindings')
|
||||
expect(bound).toContain('id="settings-routing-bindings"')
|
||||
expect(bound).toContain('分发到对应的测试 WeKnora 知识库')
|
||||
// 未读到绑定数据时(SSR 不跑 effect)面板也要如实存在,而不是空白。
|
||||
expect(bound).toContain('读取中…')
|
||||
// 发布目标(源库 → 目标库)是独立分区,与测试端收件库分开。
|
||||
const target=view('production-bindings')
|
||||
expect(target).toContain('id="settings-production-bindings"')
|
||||
expect(target).toContain('新发布的对内 / 对外内容按这里的绑定写入生产 WeKnora 的对应知识库')
|
||||
describe('SystemSettingsView service configuration', () => {
|
||||
it('lets an administrator edit exactly the four service fields in the web console', () => {
|
||||
const configured: UISettings = {
|
||||
...settings,
|
||||
test_weknora_base_url: 'https://weknora.test.example',
|
||||
production_weknora_base_url: 'https://weknora.prod.example',
|
||||
production_tenant_id: '10000',
|
||||
production_knowledge_base_id: 'kb-abc123',
|
||||
}
|
||||
const view = (role: 'admin' | 'engineer') =>
|
||||
renderToStaticMarkup(
|
||||
<AuthContext.Provider value={authValue(role)}>
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={configured}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
const adminHtml = view('admin')
|
||||
for (const text of [
|
||||
'测试地址',
|
||||
'生产地址',
|
||||
'生产 ID',
|
||||
'知识库 ID',
|
||||
'保存并启用服务配置',
|
||||
'https://weknora.test.example',
|
||||
'https://weknora.prod.example',
|
||||
'10000',
|
||||
'kb-abc123',
|
||||
'四项留空即表示未配置',
|
||||
])
|
||||
expect(adminHtml).toContain(text)
|
||||
expect(adminHtml).not.toContain('仅管理员可修改')
|
||||
// 界面只剩这四项:依赖探活矩阵与对内/对外绑定下拉不再出现在服务配置页。
|
||||
for (const removed of ['MinerU', 'Embedding', 'Redis / MQ', 'PostgreSQL', '测试知识库映射'])
|
||||
expect(adminHtml).not.toContain(removed)
|
||||
const engineerHtml = view('engineer')
|
||||
expect(engineerHtml).toContain('仅管理员可修改')
|
||||
expect(engineerHtml).not.toContain('保存并启用服务配置')
|
||||
})
|
||||
})
|
||||
it('does not show healthy simulation when the settings data failed to load',()=>{
|
||||
const html=renderToStaticMarkup(<SystemSettingsView sources={[]} connections={[]} monitor={null} settings={null} productionEnabled={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error="加载失败" saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} />)
|
||||
expect(html).toContain('加载失败');expect(html).not.toContain('模拟运行中')
|
||||
})
|
||||
it('renders the WeKnora cards and production channel from live probe and the real production gate',()=>{
|
||||
const probed:MonitorOverview={...monitor,health:[
|
||||
{key:'weknora',name:'WeKnora API',liveness:'up',readiness:'ready',reason:'',latency_ms:86,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:0,configured:true,applicable:true},
|
||||
{key:'weknora-production',name:'生产 WeKnora',liveness:'up',readiness:'ready',reason:'',latency_ms:41,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:0,configured:true,applicable:true},
|
||||
{key:'embedding',name:'Embedding',liveness:'up',readiness:'not_applicable',reason:'未部署:本平台不使用该依赖',latency_ms:0,observed_at:'2026-09-08T12:00:00Z',last_success_at:null,consecutive_failures:0,configured:false,applicable:false}]}
|
||||
const view=(enabled:boolean,verified:boolean)=>renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={probed} settings={settings} productionEnabled={enabled} productionBackupRestoreVerified={verified} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
const on=view(true,true)
|
||||
expect(on).toContain('测试 WeKnora')
|
||||
expect(on).toContain('可达 · 可接单');expect(on).toContain('延迟 86ms')
|
||||
expect(on).toContain('已启用 · 可提交生产请求');expect(on).toContain('生产写入:开启');expect(on).toContain('发布目标与凭据:管理员受限配置')
|
||||
const off=view(false,false)
|
||||
expect(off).toContain('未启用');expect(off).toContain('生产写入:关闭')
|
||||
// 卡片状态由真实探测/门禁驱动,写死的“已连接 / 未连接 / 生产映射:未配置”必须消失。
|
||||
for(const removed of ['本地真实连接','生产映射:未配置'])expect(off).not.toContain(removed)
|
||||
// 生产端点可达性来自真实探活,且只说真话:探活不等于验证过接单能力。
|
||||
expect(on).toContain('端点探测:端点可达 · 未做接单验证')
|
||||
const blocked=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={true} productionBackupRestoreVerified={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
expect(blocked).toContain('已启用 · 被阻断')
|
||||
// 未配置生产端点时必须显式说「未配置」,不得靠文案含糊过去。
|
||||
expect(blocked).toContain('端点探测:暂无真实探测结果')
|
||||
const unconfigured=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={{...monitor,health:[{key:'weknora-production',name:'生产 WeKnora',liveness:'unknown',readiness:'not_configured',reason:'已部署但未配置探测参数',latency_ms:0,observed_at:'2026-09-08T12:00:00Z',last_success_at:null,consecutive_failures:0,configured:false,applicable:false}]}} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
expect(unconfigured).toContain('端点探测:未配置')
|
||||
expect(unconfigured).not.toContain('端点可达')
|
||||
describe('SystemSettingsView', () => {
|
||||
it('separates document-engineer settings from locked administrator and production controls', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时"
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
for (const text of [
|
||||
'系统设置',
|
||||
'数据源配置',
|
||||
'服务配置',
|
||||
'存储与备份',
|
||||
'刷新策略',
|
||||
'设置服务已启用',
|
||||
'当前活动版本',
|
||||
'端点与凭据',
|
||||
'文档工程师可调整',
|
||||
'管理员设置已锁定',
|
||||
])
|
||||
expect(html).toContain(text)
|
||||
// 需求(2026-10-14):数据源配置默认只列 PP 资料 + 「可加入的来源」;AList 与钉钉知识库来源
|
||||
// 不删除,收进折叠开关,展开后才渲染(原来它们默认就在列表里)。
|
||||
// 折叠开关自己的文案里就含“钉钉知识库”,所以只核对来源卡片才有的标记。
|
||||
for (const folded of ['公司级技术支持知识库', '专用浏览器扫码会话', '直连 API Token'])
|
||||
expect(html).not.toContain(folded)
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(1)')
|
||||
expect(html).toContain('这 1 个已接入来源未删除,数据不变')
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
for (const removed of ['文件格式筛选', '未勾选的一律不取件', '保存保留格式', '恢复继承上级规则'])
|
||||
expect(html).not.toContain(removed)
|
||||
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
|
||||
for (const removed of ['+ 新增钉钉知识库', '新增钉钉知识库']) expect(html).not.toContain(removed)
|
||||
const servicesHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
for (const text of ['测试 WeKnora', '生产 WeKnora', '测试地址', '生产地址', '生产 ID', '知识库 ID'])
|
||||
expect(servicesHtml).toContain(text)
|
||||
const storageHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="storage"
|
||||
/>
|
||||
)
|
||||
// 存储与备份分区已换成真实功能(整库逻辑备份的定时计划),静态占位文案不再存在。
|
||||
expect(storageHtml).toContain('存储与备份')
|
||||
expect(storageHtml).toContain('正在读取备份计划…')
|
||||
expect(storageHtml).not.toContain('仅保存凭据引用,不可回读')
|
||||
const refreshHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时"
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="refresh"
|
||||
/>
|
||||
)
|
||||
for (const text of [
|
||||
'刷新与告警参数已验证并启用',
|
||||
'停滞30分钟',
|
||||
'finalizing 2小时',
|
||||
'文档状态刷新间隔',
|
||||
'15秒',
|
||||
'解析停滞判定',
|
||||
'30分钟',
|
||||
'保存并应用刷新与告警参数',
|
||||
])
|
||||
expect(refreshHtml).toContain(text)
|
||||
expect(visibleSaveMessage('已保存', true)).toBeNull()
|
||||
expect(visibleSaveMessage('已保存', false)).toBe('已保存')
|
||||
expect(html).not.toContain('本地模拟')
|
||||
expect(html).not.toContain('保存模拟设置')
|
||||
for (const forbidden of ['DATABASE_URL', 'RELEASE_CONFIG_FILE', 'API Key明文', 'secret_ref'])
|
||||
expect(html).not.toContain(forbidden)
|
||||
// 两个环境卡仍由真实探测驱动(依赖矩阵搬到总览页,本页不再渲染)。
|
||||
expect(servicesHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
|
||||
expect(servicesHtml).not.toContain('PostgreSQL')
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
expect(html).toContain('查看修订历史')
|
||||
expect(html).toContain('保存并启用')
|
||||
expect(html).toContain('停用中(不入队)')
|
||||
// 卡片级调度/停用按钮仍在,只是默认只对可见来源渲染(钉钉/AList 卡片已折起)。
|
||||
for (const foldedControl of ['下次自动刷新', '保存并启用调度', '停用来源'])
|
||||
expect(html).not.toContain(foldedControl)
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
})
|
||||
it('lets an administrator bind the internal/external import knowledge bases from 系统设置', () => {
|
||||
// 组件一直在(RoutingBindingsSection),但从未挂到任何页面 —— 导入目标库只能靠
|
||||
// 部署 env 钉死,换库必须重建容器。
|
||||
const view = (section: 'sources' | 'bindings' | 'production-bindings') =>
|
||||
renderToStaticMarkup(
|
||||
<AuthContext.Provider value={authValue('admin')}>
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection={section}
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
expect(view('sources')).toContain('测试知识库绑定')
|
||||
expect(view('sources')).toContain('生产知识库绑定')
|
||||
const bound = view('bindings')
|
||||
expect(bound).toContain('id="settings-routing-bindings"')
|
||||
expect(bound).toContain('分发到对应的测试 WeKnora 知识库')
|
||||
// 未读到绑定数据时(SSR 不跑 effect)面板也要如实存在,而不是空白。
|
||||
expect(bound).toContain('读取中…')
|
||||
// 发布目标(源库 → 目标库)是独立分区,与测试端收件库分开。
|
||||
const target = view('production-bindings')
|
||||
expect(target).toContain('id="settings-production-bindings"')
|
||||
expect(target).toContain('新发布的对内 / 对外内容按这里的绑定写入生产 WeKnora 的对应知识库')
|
||||
})
|
||||
it('does not show healthy simulation when the settings data failed to load', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={[]}
|
||||
monitor={null}
|
||||
settings={null}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error="加载失败"
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
expect(html).toContain('加载失败')
|
||||
expect(html).not.toContain('模拟运行中')
|
||||
})
|
||||
it('renders the WeKnora cards and production channel from live probe and the real production gate', () => {
|
||||
const probed: MonitorOverview = {
|
||||
...monitor,
|
||||
health: [
|
||||
{
|
||||
key: 'weknora',
|
||||
name: 'WeKnora API',
|
||||
liveness: 'up',
|
||||
readiness: 'ready',
|
||||
reason: '',
|
||||
latency_ms: 86,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 0,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
{
|
||||
key: 'weknora-production',
|
||||
name: '生产 WeKnora',
|
||||
liveness: 'up',
|
||||
readiness: 'ready',
|
||||
reason: '',
|
||||
latency_ms: 41,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 0,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
{
|
||||
key: 'embedding',
|
||||
name: 'Embedding',
|
||||
liveness: 'up',
|
||||
readiness: 'not_applicable',
|
||||
reason: '未部署:本平台不使用该依赖',
|
||||
latency_ms: 0,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: null,
|
||||
consecutive_failures: 0,
|
||||
configured: false,
|
||||
applicable: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
const view = (enabled: boolean, verified: boolean) =>
|
||||
renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={probed}
|
||||
settings={settings}
|
||||
productionEnabled={enabled}
|
||||
productionBackupRestoreVerified={verified}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
const on = view(true, true)
|
||||
expect(on).toContain('测试 WeKnora')
|
||||
expect(on).toContain('可达 · 可接单')
|
||||
expect(on).toContain('延迟 86ms')
|
||||
expect(on).toContain('已启用 · 可提交生产请求')
|
||||
expect(on).toContain('生产写入:开启')
|
||||
expect(on).toContain('发布目标与凭据:管理员受限配置')
|
||||
const off = view(false, false)
|
||||
expect(off).toContain('未启用')
|
||||
expect(off).toContain('生产写入:关闭')
|
||||
// 卡片状态由真实探测/门禁驱动,写死的“已连接 / 未连接 / 生产映射:未配置”必须消失。
|
||||
for (const removed of ['本地真实连接', '生产映射:未配置']) expect(off).not.toContain(removed)
|
||||
// 生产端点可达性来自真实探活,且只说真话:探活不等于验证过接单能力。
|
||||
expect(on).toContain('端点探测:端点可达 · 未做接单验证')
|
||||
const blocked = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={true}
|
||||
productionBackupRestoreVerified={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
expect(blocked).toContain('已启用 · 被阻断')
|
||||
// 未配置生产端点时必须显式说「未配置」,不得靠文案含糊过去。
|
||||
expect(blocked).toContain('端点探测:暂无真实探测结果')
|
||||
const unconfigured = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={{
|
||||
...monitor,
|
||||
health: [
|
||||
{
|
||||
key: 'weknora-production',
|
||||
name: '生产 WeKnora',
|
||||
liveness: 'unknown',
|
||||
readiness: 'not_configured',
|
||||
reason: '已部署但未配置探测参数',
|
||||
latency_ms: 0,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: null,
|
||||
consecutive_failures: 0,
|
||||
configured: false,
|
||||
applicable: false,
|
||||
},
|
||||
],
|
||||
}}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
expect(unconfigured).toContain('端点探测:未配置')
|
||||
expect(unconfigured).not.toContain('端点可达')
|
||||
})
|
||||
})
|
||||
describe('SystemSettingsView 数据源配置的默认清单', () => {
|
||||
const withPP: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'conn-pp',
|
||||
source_type: 'pp',
|
||||
name: 'PP资料下载中心',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 613,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'conn-alist',
|
||||
source_type: 'alist',
|
||||
name: '国内工业',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 3027,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'conn-ding2',
|
||||
source_type: 'dingtalk',
|
||||
name: 'ATOM知识库',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 109,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
const view = () =>
|
||||
renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={withPP}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
it('默认只列 PP 资料:AList 与钉钉知识库来源折起来但没删', () => {
|
||||
const html = view()
|
||||
expect(html).toContain('PP资料下载中心')
|
||||
expect(html).toContain('PP 资料下载中心')
|
||||
expect(html).not.toContain('国内工业')
|
||||
expect(html).not.toContain('ATOM知识库')
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(2)')
|
||||
// 登记路径说清楚:新来源一律走「可加入的来源」;格式筛选与旧的新增入口继续不存在。
|
||||
expect(html).toContain('可加入的来源')
|
||||
expect(html).toContain('钉盘文件已替代 AList')
|
||||
for (const removed of ['+ 新增钉钉知识库', '文件格式筛选']) expect(html).not.toContain(removed)
|
||||
})
|
||||
})
|
||||
describe('splitSourceConnections(数据源配置的默认清单规则)', () => {
|
||||
const rows: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'a',
|
||||
source_type: 'pp',
|
||||
name: 'PP资料下载中心',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 1,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
source_type: 'alist',
|
||||
name: '国内工业',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 2,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'c',
|
||||
source_type: 'dingtalk',
|
||||
name: 'ATOM知识库',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 3,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'd',
|
||||
source_type: 'manual',
|
||||
name: '本地手工验收',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 4,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
it('默认折起 AList 与钉钉知识库,展开后原样返回(顺序不变、一个不少)', () => {
|
||||
const folded = splitSourceConnections(rows, false)
|
||||
expect(folded.visible.map((item) => item.id)).toEqual(['a', 'd'])
|
||||
expect(folded.legacy.map((item) => item.id)).toEqual(['b', 'c'])
|
||||
const expanded = splitSourceConnections(rows, true)
|
||||
expect(expanded.visible.map((item) => item.id)).toEqual(['a', 'b', 'c', 'd'])
|
||||
expect(expanded.legacy.length).toBe(2)
|
||||
})
|
||||
})
|
||||
|
||||
+646
-121
@@ -12,9 +12,21 @@ import type { MonitorOverview } from './monitor'
|
||||
import { fetchReleaseCapabilities } from './reviewRelease'
|
||||
import { fetchCatalogRoutingCapabilities, fetchCatalogSources } from './sourceCatalog'
|
||||
import type { CatalogRoutingCapabilities, CatalogSource } from './sourceCatalog'
|
||||
import { activateSourceSettingsRevision, createSourceSettingsRevision, fetchSourceConnectionList, fetchSourceSettingsRevisions } from './sourceConnections'
|
||||
import {
|
||||
activateSourceSettingsRevision,
|
||||
createSourceSettingsRevision,
|
||||
fetchSourceConnectionList,
|
||||
fetchSourceSettingsRevisions,
|
||||
} from './sourceConnections'
|
||||
import type { SourceConnectionListItem, SourceSettingsRevision } from './sourceConnections'
|
||||
import { activateUISettings, createUISettingsCandidate, fetchActiveUISettings, validKnowledgeBaseID, validProductionTenantID, validServiceEndpoint } from './uiSettings'
|
||||
import {
|
||||
activateUISettings,
|
||||
createUISettingsCandidate,
|
||||
fetchActiveUISettings,
|
||||
validKnowledgeBaseID,
|
||||
validProductionTenantID,
|
||||
validServiceEndpoint,
|
||||
} from './uiSettings'
|
||||
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
||||
import './systemSettings.css'
|
||||
|
||||
@@ -48,17 +60,37 @@ const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [
|
||||
{ key: 'members', label: '成员与角色', adminOnly: true },
|
||||
] as { key: SectionKey; label: string; adminOnly?: boolean }[]
|
||||
|
||||
const sourceTypeLabels: Record<string, string> = { dingtalk: '钉钉知识库', pp: 'PP 资料下载中心', alist: 'AList 文件源', manual: '本地手工导入' }
|
||||
const sourceAuthLabels: Record<string, string> = { dingtalk: '专用浏览器扫码会话', pp: '公开只读访问', alist: '直连 API Token', manual: '离线导入,无在线认证' }
|
||||
const secondsLabel = (value: number) => value < 60 ? `${value}秒` : value < 3600 ? `${value / 60}分钟` : `${value / 3600}小时`
|
||||
export const visibleSaveMessage = (message: string | null, dirty: boolean) => dirty ? null : message
|
||||
const sourceTypeLabels: Record<string, string> = {
|
||||
dingtalk: '钉钉知识库',
|
||||
pp: 'PP 资料下载中心',
|
||||
alist: 'AList 文件源',
|
||||
manual: '本地手工导入',
|
||||
}
|
||||
|
||||
// 已由钉盘文件替代 / 改为按当前钉钉账号发现的来源类型:数据不删,只是在「数据源配置」默认折起来。
|
||||
export const legacySourceTypes = ['alist', 'dingtalk'] as const
|
||||
export const splitSourceConnections = (connections: SourceConnectionListItem[], showLegacy: boolean) => {
|
||||
const legacy = connections.filter((item) => (legacySourceTypes as readonly string[]).includes(item.source_type))
|
||||
const legacyIDs = new Set(legacy.map((item) => item.id))
|
||||
return { legacy, visible: showLegacy ? connections : connections.filter((item) => !legacyIDs.has(item.id)) }
|
||||
}
|
||||
const sourceAuthLabels: Record<string, string> = {
|
||||
dingtalk: '专用浏览器扫码会话',
|
||||
pp: '公开只读访问',
|
||||
alist: '直连 API Token',
|
||||
manual: '离线导入,无在线认证',
|
||||
}
|
||||
const secondsLabel = (value: number) =>
|
||||
value < 60 ? `${value}秒` : value < 3600 ? `${value / 60}分钟` : `${value / 3600}小时`
|
||||
export const visibleSaveMessage = (message: string | null, dirty: boolean) => (dirty ? null : message)
|
||||
|
||||
type ServiceHealthView = MonitorOverview['health'][number]
|
||||
type ServiceView = MonitorOverview['services'][number]
|
||||
|
||||
// 服务配置只保留四项可写值(测试地址、生产地址、生产 ID、知识库 ID),
|
||||
// 依赖与解析队列的状态仍按真实探测呈现,不写死。
|
||||
const findHealth = (monitor: MonitorOverview | null, name: string): ServiceHealthView | undefined => (monitor?.health || []).find((item) => item.name === name || item.name.startsWith(name))
|
||||
const findHealth = (monitor: MonitorOverview | null, name: string): ServiceHealthView | undefined =>
|
||||
(monitor?.health || []).find((item) => item.name === name || item.name.startsWith(name))
|
||||
export const healthStateLabel = (health: ServiceHealthView | undefined, service: ServiceView | undefined): string => {
|
||||
if (!health) {
|
||||
if (!service) return '待配置'
|
||||
@@ -71,7 +103,9 @@ export const healthStateLabel = (health: ServiceHealthView | undefined, service:
|
||||
}
|
||||
export const healthStateDetail = (health: ServiceHealthView | undefined, service: ServiceView | undefined): string => {
|
||||
if (!health) return service?.detail || '真实 Provider 未接入'
|
||||
const success = health.last_success_at ? `最近成功 ${new Date(health.last_success_at).toLocaleTimeString('zh-CN', { hour12: false })}` : ''
|
||||
const success = health.last_success_at
|
||||
? `最近成功 ${new Date(health.last_success_at).toLocaleTimeString('zh-CN', { hour12: false })}`
|
||||
: ''
|
||||
if (health.readiness === 'ready') return [`延迟 ${health.latency_ms}ms`, success].filter(Boolean).join(';')
|
||||
const failures = health.consecutive_failures ? `连续失败${health.consecutive_failures}次` : ''
|
||||
return [health.reason, success, failures].filter(Boolean).join(';')
|
||||
@@ -84,7 +118,12 @@ export const productionWeKnoraProbe = (monitor: MonitorOverview | null): string
|
||||
const health = findHealth(monitor, '生产 WeKnora')
|
||||
if (!health) return '端点探测:暂无真实探测结果'
|
||||
if (!health.configured) return '端点探测:未配置'
|
||||
const label = health.liveness === 'up' ? (health.readiness === 'ready' ? '端点可达 · 未做接单验证' : '端点可达 · 不可接单') : '端点不可达'
|
||||
const label =
|
||||
health.liveness === 'up'
|
||||
? health.readiness === 'ready'
|
||||
? '端点可达 · 未做接单验证'
|
||||
: '端点可达 · 不可接单'
|
||||
: '端点不可达'
|
||||
const detail = healthStateDetail(health, undefined)
|
||||
return `端点探测:${label}${detail ? `(${detail})` : ''}`
|
||||
}
|
||||
@@ -103,7 +142,13 @@ function formatHorizon(value: string | null): string {
|
||||
return `下次自动刷新 ${at.toLocaleString('zh-CN', { hour12: false })}`
|
||||
}
|
||||
|
||||
function SourceSettingsCard({ connection, onSourcesChanged }: { connection: SourceConnectionListItem; onSourcesChanged: () => void }) {
|
||||
function SourceSettingsCard({
|
||||
connection,
|
||||
onSourcesChanged,
|
||||
}: {
|
||||
connection: SourceConnectionListItem
|
||||
onSourcesChanged: () => void
|
||||
}) {
|
||||
const auth = useOptionalAuth()
|
||||
const isAdmin = auth?.identity?.role === 'admin'
|
||||
const [interval, setInterval] = useState<number>(() => {
|
||||
@@ -121,15 +166,23 @@ function SourceSettingsCard({ connection, onSourcesChanged }: { connection: Sour
|
||||
const scheduled = connection.source_type !== 'manual'
|
||||
|
||||
const submit = async (nextEnabled: boolean) => {
|
||||
setBusy(true); setMessage(null); setFailure(null)
|
||||
setBusy(true)
|
||||
setMessage(null)
|
||||
setFailure(null)
|
||||
try {
|
||||
const draft = {
|
||||
source_type: connection.source_type, name: connection.name, endpoint: '', credential_ref: '',
|
||||
enabled: nextEnabled, schedule: { refresh_interval_seconds: nextEnabled && interval > 0 ? interval : null },
|
||||
source_type: connection.source_type,
|
||||
name: connection.name,
|
||||
endpoint: '',
|
||||
credential_ref: '',
|
||||
enabled: nextEnabled,
|
||||
schedule: { refresh_interval_seconds: nextEnabled && interval > 0 ? interval : null },
|
||||
}
|
||||
const created = await createSourceSettingsRevision(connection.id, draft)
|
||||
const activated = await activateSourceSettingsRevision(connection.id, created.id)
|
||||
setMessage(`${connection.name}:调度设置已验证并启用${activated.operation === 'replayed' ? '(沿用上次结果)' : ''};${nextEnabled ? formatHorizon(new Date(Date.now() + interval * 1000).toISOString()) : '已停用,新的自动扫描与刷新任务不再入队,历史记录全部保留'}。`)
|
||||
setMessage(
|
||||
`${connection.name}:调度设置已验证并启用${activated.operation === 'replayed' ? '(沿用上次结果)' : ''};${nextEnabled ? formatHorizon(new Date(Date.now() + interval * 1000).toISOString()) : '已停用,新的自动扫描与刷新任务不再入队,历史记录全部保留'}。`
|
||||
)
|
||||
onSourcesChanged()
|
||||
} catch (cause) {
|
||||
setFailure(cause instanceof Error ? cause.message : '保存来源设置失败')
|
||||
@@ -142,42 +195,150 @@ function SourceSettingsCard({ connection, onSourcesChanged }: { connection: Sour
|
||||
const loadHistory = async () => {
|
||||
setShowHistory(true)
|
||||
if (history) return
|
||||
try { setHistory(await fetchSourceSettingsRevisions(connection.id)) }
|
||||
catch (cause) { setFailure(cause instanceof Error ? cause.message : '加载修订历史失败') }
|
||||
try {
|
||||
setHistory(await fetchSourceSettingsRevisions(connection.id))
|
||||
} catch (cause) {
|
||||
setFailure(cause instanceof Error ? cause.message : '加载修订历史失败')
|
||||
}
|
||||
}
|
||||
|
||||
const canApply = !busy
|
||||
|
||||
return <article className="settings-source-row">
|
||||
<div className="settings-source-name"><strong>{connection.name}</strong><span>{sourceTypeLabels[connection.source_type] ?? connection.source_type}{connection.enabled ? '' : ' · 已停用'}</span></div>
|
||||
<dl>
|
||||
<div><dt>认证方式</dt><dd>{sourceAuthLabels[connection.source_type] ?? '按连接配置'}</dd></div>
|
||||
<div><dt>端点与凭据</dt><dd>已保存,不可回读(草稿留空即沿用现值)</dd></div>
|
||||
<div><dt>当前调度</dt><dd>{connection.enabled ? formatHorizon(connection.next_refresh_at) : '停用中(不入队)'}</dd></div>
|
||||
</dl>
|
||||
<div className="source-schedule-form">
|
||||
{scheduled ? <label>自动刷新周期<select value={interval} onChange={(event) => setInterval(Number(event.target.value))}>{intervalChoices.map((choice) => <option key={choice.value} value={choice.value}>{choice.label}</option>)}</select></label>
|
||||
: <small className="manual-source-note">本地手工导入来源不支持定时刷新,只能手动触发扫描。</small>}
|
||||
{connection.enabled
|
||||
? <div className="source-schedule-actions"><button className="secondary" disabled={!canApply || (scheduled && interval === 0 && !connection.schedule_configured)} onClick={() => void submit(true)}>{busy ? '正在验证并启用…' : '保存并启用调度'}</button>
|
||||
<button className="danger" disabled={!canApply} onClick={() => setPendingDisable(true)}>停用来源</button></div>
|
||||
: <div className="source-schedule-actions"><button className="secondary" disabled={!canApply} onClick={() => void submit(true)}>保存并启用</button></div>}
|
||||
{connection.source_type === "dingtalk" && isAdmin ? <DingtalkSessionControl /> : null}
|
||||
<button className="link" onClick={() => void loadHistory()}>{showHistory ? '收起修订历史' : '查看修订历史'}</button>
|
||||
</div>
|
||||
{message ? <p className="success-message" role="status">{message}</p> : null}
|
||||
{failure ? <p className="error-message" role="alert">{failure}</p> : null}
|
||||
{showHistory && history ? <ul className="revision-list">{history.map((item) => <li key={item.id}><b>修订 {item.revision_number}</b><span>{item.state === 'active' ? '当前启用' : item.state === 'validated' ? '待启用' : item.state === 'retired' ? '已退休' : '失败'}</span><small>{item.created_by} · {new Date(item.created_at).toLocaleString('zh-CN', { hour12: false })} · {item.refresh_interval_seconds ? `每${secondsLabel(Number(item.refresh_interval_seconds))}` : '仅手动'}</small></li>)}</ul> : null}
|
||||
{showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{pendingDisable ? <div className="modal-backdrop" role="dialog" aria-modal="true"><div className="modal-card">
|
||||
<h3>停用「{connection.name}」?</h3>
|
||||
<p>停用会立即停止该来源的自动扫描与新刷新任务入队;历史快照、标注和审计全部保留,随时可以重新启用。此操作会先由后端再次校验权限。</p>
|
||||
<div className="modal-actions"><button className="danger" disabled={busy} onClick={() => void submit(false)}>{busy ? '正在停用…' : '确认停用'}</button><button className="secondary" disabled={busy} onClick={() => setPendingDisable(false)}>取消</button></div>
|
||||
</div></div> : null}
|
||||
</article>
|
||||
return (
|
||||
<article className="settings-source-row">
|
||||
<div className="settings-source-name">
|
||||
<strong>{connection.name}</strong>
|
||||
<span>
|
||||
{sourceTypeLabels[connection.source_type] ?? connection.source_type}
|
||||
{connection.enabled ? '' : ' · 已停用'}
|
||||
</span>
|
||||
</div>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>认证方式</dt>
|
||||
<dd>{sourceAuthLabels[connection.source_type] ?? '按连接配置'}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>端点与凭据</dt>
|
||||
<dd>已保存,不可回读(草稿留空即沿用现值)</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>当前调度</dt>
|
||||
<dd>{connection.enabled ? formatHorizon(connection.next_refresh_at) : '停用中(不入队)'}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div className="source-schedule-form">
|
||||
{scheduled ? (
|
||||
<label>
|
||||
自动刷新周期
|
||||
<select value={interval} onChange={(event) => setInterval(Number(event.target.value))}>
|
||||
{intervalChoices.map((choice) => (
|
||||
<option key={choice.value} value={choice.value}>
|
||||
{choice.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
) : (
|
||||
<small className="manual-source-note">本地手工导入来源不支持定时刷新,只能手动触发扫描。</small>
|
||||
)}
|
||||
{connection.enabled ? (
|
||||
<div className="source-schedule-actions">
|
||||
<button
|
||||
className="secondary"
|
||||
disabled={!canApply || (scheduled && interval === 0 && !connection.schedule_configured)}
|
||||
onClick={() => void submit(true)}
|
||||
>
|
||||
{busy ? '正在验证并启用…' : '保存并启用调度'}
|
||||
</button>
|
||||
<button className="danger" disabled={!canApply} onClick={() => setPendingDisable(true)}>
|
||||
停用来源
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="source-schedule-actions">
|
||||
<button className="secondary" disabled={!canApply} onClick={() => void submit(true)}>
|
||||
保存并启用
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{connection.source_type === 'dingtalk' && isAdmin ? <DingtalkSessionControl /> : null}
|
||||
<button className="link" onClick={() => void loadHistory()}>
|
||||
{showHistory ? '收起修订历史' : '查看修订历史'}
|
||||
</button>
|
||||
</div>
|
||||
{message ? (
|
||||
<p className="success-message" role="status">
|
||||
{message}
|
||||
</p>
|
||||
) : null}
|
||||
{failure ? (
|
||||
<p className="error-message" role="alert">
|
||||
{failure}
|
||||
</p>
|
||||
) : null}
|
||||
{showHistory && history ? (
|
||||
<ul className="revision-list">
|
||||
{history.map((item) => (
|
||||
<li key={item.id}>
|
||||
<b>修订 {item.revision_number}</b>
|
||||
<span>
|
||||
{item.state === 'active'
|
||||
? '当前启用'
|
||||
: item.state === 'validated'
|
||||
? '待启用'
|
||||
: item.state === 'retired'
|
||||
? '已退休'
|
||||
: '失败'}
|
||||
</span>
|
||||
<small>
|
||||
{item.created_by} · {new Date(item.created_at).toLocaleString('zh-CN', { hour12: false })} ·{' '}
|
||||
{item.refresh_interval_seconds ? `每${secondsLabel(Number(item.refresh_interval_seconds))}` : '仅手动'}
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
{showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{pendingDisable ? (
|
||||
<div className="modal-backdrop" role="dialog" aria-modal="true">
|
||||
<div className="modal-card">
|
||||
<h3>停用「{connection.name}」?</h3>
|
||||
<p>
|
||||
停用会立即停止该来源的自动扫描与新刷新任务入队;历史快照、标注和审计全部保留,随时可以重新启用。此操作会先由后端再次校验权限。
|
||||
</p>
|
||||
<div className="modal-actions">
|
||||
<button className="danger" disabled={busy} onClick={() => void submit(false)}>
|
||||
{busy ? '正在停用…' : '确认停用'}
|
||||
</button>
|
||||
<button className="secondary" disabled={busy} onClick={() => setPendingDisable(false)}>
|
||||
取消
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
export function SystemSettingsView({ sources, connections, monitor, settings, productionEnabled, productionBackupRestoreVerified = false, routingCapabilities, loading, saving, error, saveMessage, onSave, onSourcesChanged, onRefresh, initialSection = 'sources' }: Props) {
|
||||
export function SystemSettingsView({
|
||||
sources,
|
||||
connections,
|
||||
monitor,
|
||||
settings,
|
||||
productionEnabled,
|
||||
productionBackupRestoreVerified = false,
|
||||
routingCapabilities,
|
||||
loading,
|
||||
saving,
|
||||
error,
|
||||
saveMessage,
|
||||
onSave,
|
||||
onSourcesChanged,
|
||||
onRefresh,
|
||||
initialSection = 'sources',
|
||||
}: Props) {
|
||||
const auth = useOptionalAuth()
|
||||
const identity = auth?.identity ?? null
|
||||
const [section, setSection] = useState<SectionKey>(initialSection)
|
||||
@@ -189,9 +350,19 @@ export function SystemSettingsView({ sources, connections, monitor, settings, pr
|
||||
const [endpoint, setEndpoint] = useState<string>(settings?.production_weknora_base_url ?? '')
|
||||
const [testEndpoint, setTestEndpoint] = useState<string>(settings?.test_weknora_base_url ?? '')
|
||||
const [productionTenantID, setProductionTenantID] = useState<string>(settings?.production_tenant_id ?? '')
|
||||
const [productionKnowledgeBaseID, setProductionKnowledgeBaseID] = useState<string>(settings?.production_knowledge_base_id ?? '')
|
||||
const [productionKnowledgeBaseID, setProductionKnowledgeBaseID] = useState<string>(
|
||||
settings?.production_knowledge_base_id ?? ''
|
||||
)
|
||||
const [dirty, setDirty] = useState(false)
|
||||
|
||||
// 「数据源配置」默认只列 PP 资料:AList 已被钉盘文件替代、钉钉知识库一律走当前账号发现
|
||||
//(见下方「可加入的来源」)。这 9 个已接入来源**不删除**,收进折叠开关里,随时可展开管理。
|
||||
const [showLegacySources, setShowLegacySources] = useState(false)
|
||||
const { legacy: legacyConnections, visible: visibleConnections } = splitSourceConnections(
|
||||
connections,
|
||||
showLegacySources
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!settings) return
|
||||
setDocumentRefresh(settings.document_refresh_seconds)
|
||||
@@ -212,76 +383,375 @@ export function SystemSettingsView({ sources, connections, monitor, settings, pr
|
||||
const testEndpointValid = validServiceEndpoint(testEndpoint)
|
||||
const productionTenantIDValid = validProductionTenantID(productionTenantID)
|
||||
const productionKnowledgeBaseIDValid = validKnowledgeBaseID(productionKnowledgeBaseID)
|
||||
const serviceSettingsValid = endpointValid && testEndpointValid && productionTenantIDValid && productionKnowledgeBaseIDValid
|
||||
const serviceSettingsDirty = Boolean(settings && (
|
||||
testEndpoint.trim() !== settings.test_weknora_base_url ||
|
||||
endpoint.trim() !== settings.production_weknora_base_url ||
|
||||
productionTenantID.trim() !== settings.production_tenant_id ||
|
||||
productionKnowledgeBaseID.trim() !== settings.production_knowledge_base_id))
|
||||
const serviceSettingsValid =
|
||||
endpointValid && testEndpointValid && productionTenantIDValid && productionKnowledgeBaseIDValid
|
||||
const serviceSettingsDirty = Boolean(
|
||||
settings &&
|
||||
(testEndpoint.trim() !== settings.test_weknora_base_url ||
|
||||
endpoint.trim() !== settings.production_weknora_base_url ||
|
||||
productionTenantID.trim() !== settings.production_tenant_id ||
|
||||
productionKnowledgeBaseID.trim() !== settings.production_knowledge_base_id)
|
||||
)
|
||||
const candidateInput = (overrides: Partial<UISettingsCandidateInput> = {}): UISettingsCandidateInput => ({
|
||||
document_refresh_seconds: documentRefresh, resource_refresh_seconds: resourceRefresh,
|
||||
stalled_after_seconds: stalled, finalizing_after_seconds: finalizing, ingestion_concurrency: concurrency,
|
||||
test_weknora_base_url: testEndpoint.trim(), production_weknora_base_url: endpoint.trim(),
|
||||
production_tenant_id: productionTenantID.trim(), production_knowledge_base_id: productionKnowledgeBaseID.trim(), ...overrides,
|
||||
document_refresh_seconds: documentRefresh,
|
||||
resource_refresh_seconds: resourceRefresh,
|
||||
stalled_after_seconds: stalled,
|
||||
finalizing_after_seconds: finalizing,
|
||||
ingestion_concurrency: concurrency,
|
||||
test_weknora_base_url: testEndpoint.trim(),
|
||||
production_weknora_base_url: endpoint.trim(),
|
||||
production_tenant_id: productionTenantID.trim(),
|
||||
production_knowledge_base_id: productionKnowledgeBaseID.trim(),
|
||||
...overrides,
|
||||
})
|
||||
const saveEndpoint = () => { setDirty(false); onSave(candidateInput()) }
|
||||
return <main className="page-shell system-settings">
|
||||
<header className="hero compact"><div><h1>系统设置</h1><p className="subtitle">查看内容源、服务与备份状态;来源调度与刷新参数采用版本化保存。</p></div><button onClick={onRefresh} disabled={loading}>{loading ? '刷新中…' : '刷新状态'}</button></header>
|
||||
{error ? <div className="error-banner" role="alert">{error}</div> : null}
|
||||
{monitor && settings ? <div className="settings-layout">
|
||||
<nav className="settings-nav" aria-label="系统设置分区">{sections.filter((item) => !item.adminOnly || identity?.role === 'admin').map((item) => <button key={item.key} className={section === item.key ? 'active' : ''} onClick={() => setSection(item.key)}>{item.label}</button>)}</nav>
|
||||
<div className="settings-content">
|
||||
<div className="settings-role-strip"><span className="engineer-role">文档工程师可调整:来源调度周期、刷新间隔、停滞判断</span><span className="admin-role">管理员设置已锁定:端点、凭据、映射、生产开关</span></div>
|
||||
<div className="simulation-banner server-settings-banner"><strong>设置服务已启用</strong><span>当前活动版本 · 启用人 {settings.updated_by} · 启用时间 {settings.activated_at ? new Date(settings.activated_at).toLocaleString('zh-CN') : '待激活'};新设置先验证,再原子切换。</span></div>
|
||||
{section === 'sources' ? <section className="settings-panel wide source-settings-panel" id="settings-sources">
|
||||
<div className="settings-section-heading"><div><h2>数据源配置</h2><p>从下方「可加入的来源」勾选即可登记新来源;逐来源设置自动刷新周期或保持仅手动,保存会先生成修订、验证后原子启用。</p></div></div>
|
||||
{identity?.role === 'admin' ? <DingtalkSourceDiscovery registeredNames={connections.map((item) => item.name)} onRegistered={onSourcesChanged} /> : null}
|
||||
{connections.length ? <div className="settings-source-list">
|
||||
{connections.map((connection) => <SourceSettingsCard key={connection.id} connection={connection} onSourcesChanged={onSourcesChanged}/>)}
|
||||
{sources.length ? null : <small className="empty-inline">尚无快照数据;快照将在来源首次刷新完成后出现。</small>}
|
||||
</div> : <div className="empty-state">尚无可显示的来源连接。</div>}
|
||||
</section> : null}
|
||||
{section === 'services' ? <section className="settings-panel wide" id="settings-services">
|
||||
<div className="settings-section-heading"><div><h2>服务配置</h2><p>只配四项:测试地址、生产地址、生产 ID、知识库 ID。保存会先生成修订、验证后原子启用,旧版本保留用于审计;凭据只写不读。</p></div></div>
|
||||
<div className="environment-cards"><article><b>测试 WeKnora</b><span>{healthStateLabel(findHealth(monitor, 'WeKnora API'), undefined)}</span><small>{`${healthStateDetail(findHealth(monitor, 'WeKnora API'), undefined) || '端点探测:未配置'};解析队列 对内 ${routingCapabilities.internal_enabled ? '已配置' : '未配置'} · 对外 ${routingCapabilities.external_enabled ? '已配置' : '未配置'}`}</small></article><article className="production"><b>生产 WeKnora</b><span>{!productionEnabled ? '未启用' : productionBackupRestoreVerified ? '已启用 · 可提交生产请求' : '已启用 · 被阻断'}</span><small>{`${productionWeKnoraProbe(monitor)};生产写入:${productionEnabled ? '开启' : '关闭'};发布目标与凭据:管理员受限配置,本页不可回读`}</small></article></div>
|
||||
<div className="safe-setting-grid production-endpoint-form">
|
||||
{isAdmin ? <>
|
||||
<label>测试地址<input value={testEndpoint} onChange={(event) => { setTestEndpoint(event.target.value); setDirty(true) }} placeholder="https://weknora.test.example" aria-invalid={!testEndpointValid} /></label>
|
||||
<label>生产地址<input value={endpoint} onChange={(event) => { setEndpoint(event.target.value); setDirty(true) }} placeholder="https://weknora.prod.example" aria-invalid={!endpointValid} /></label>
|
||||
<label>生产 ID<input value={productionTenantID} onChange={(event) => { setProductionTenantID(event.target.value); setDirty(true) }} placeholder="10000" aria-invalid={!productionTenantIDValid} /></label>
|
||||
<label>知识库 ID<input value={productionKnowledgeBaseID} onChange={(event) => { setProductionKnowledgeBaseID(event.target.value); setDirty(true) }} placeholder="生产知识库 ID" aria-invalid={!productionKnowledgeBaseIDValid} /></label>
|
||||
</> : <>
|
||||
<label>测试地址<input value={settings.test_weknora_base_url || '未配置'} readOnly disabled /></label>
|
||||
<label>生产地址<input value={settings.production_weknora_base_url || '未配置'} readOnly disabled /></label>
|
||||
<label>生产 ID<input value={settings.production_tenant_id || '未配置'} readOnly disabled /></label>
|
||||
<label>知识库 ID<input value={settings.production_knowledge_base_id || '未配置'} readOnly disabled /></label>
|
||||
</>}
|
||||
const saveEndpoint = () => {
|
||||
setDirty(false)
|
||||
onSave(candidateInput())
|
||||
}
|
||||
return (
|
||||
<main className="page-shell system-settings">
|
||||
<header className="hero compact">
|
||||
<div>
|
||||
<h1>系统设置</h1>
|
||||
<p className="subtitle">查看内容源、服务与备份状态;来源调度与刷新参数采用版本化保存。</p>
|
||||
</div>
|
||||
<button onClick={onRefresh} disabled={loading}>
|
||||
{loading ? '刷新中…' : '刷新状态'}
|
||||
</button>
|
||||
</header>
|
||||
{error ? (
|
||||
<div className="error-banner" role="alert">
|
||||
{error}
|
||||
</div>
|
||||
) : null}
|
||||
{monitor && settings ? (
|
||||
<div className="settings-layout">
|
||||
<nav className="settings-nav" aria-label="系统设置分区">
|
||||
{sections
|
||||
.filter((item) => !item.adminOnly || identity?.role === 'admin')
|
||||
.map((item) => (
|
||||
<button
|
||||
key={item.key}
|
||||
className={section === item.key ? 'active' : ''}
|
||||
onClick={() => setSection(item.key)}
|
||||
>
|
||||
{item.label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<div className="settings-content">
|
||||
<div className="settings-role-strip">
|
||||
<span className="engineer-role">文档工程师可调整:来源调度周期、刷新间隔、停滞判断</span>
|
||||
<span className="admin-role">管理员设置已锁定:端点、凭据、映射、生产开关</span>
|
||||
</div>
|
||||
<div className="simulation-banner server-settings-banner">
|
||||
<strong>设置服务已启用</strong>
|
||||
<span>
|
||||
当前活动版本 · 启用人 {settings.updated_by} · 启用时间{' '}
|
||||
{settings.activated_at ? new Date(settings.activated_at).toLocaleString('zh-CN') : '待激活'}
|
||||
;新设置先验证,再原子切换。
|
||||
</span>
|
||||
</div>
|
||||
{section === 'sources' ? (
|
||||
<section className="settings-panel wide source-settings-panel" id="settings-sources">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>数据源配置</h2>
|
||||
<p>
|
||||
新来源只从下方「可加入的来源」勾选登记(按当前钉钉账号列出可访问的知识库与钉盘空间,钉盘文件已替代
|
||||
AList);本页保留 PP 资料。逐来源设置自动刷新周期或保持仅手动,保存会先生成修订、验证后原子启用。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{identity?.role === 'admin' ? (
|
||||
<DingtalkSourceDiscovery
|
||||
registeredNames={connections.map((item) => item.name)}
|
||||
onRegistered={onSourcesChanged}
|
||||
/>
|
||||
) : null}
|
||||
{legacyConnections.length ? (
|
||||
<div className="settings-legacy-toggle">
|
||||
<button type="button" className="secondary" onClick={() => setShowLegacySources((value) => !value)}>
|
||||
{showLegacySources
|
||||
? `收起 AList/钉钉知识库来源(${legacyConnections.length})`
|
||||
: `显示 AList/钉钉知识库来源(${legacyConnections.length})`}
|
||||
</button>
|
||||
<small>
|
||||
{showLegacySources
|
||||
? '这些来源已在两处保留:本列表可改刷新周期与启停,「来源与目录」里照旧浏览它们的内容。'
|
||||
: `AList 来源已由钉盘文件替代,钉钉知识库来源改为按当前账号发现;这 ${legacyConnections.length} 个已接入来源未删除,数据不变。`}
|
||||
</small>
|
||||
</div>
|
||||
) : null}
|
||||
{visibleConnections.length ? (
|
||||
<div className="settings-source-list">
|
||||
{visibleConnections.map((connection) => (
|
||||
<SourceSettingsCard
|
||||
key={connection.id}
|
||||
connection={connection}
|
||||
onSourcesChanged={onSourcesChanged}
|
||||
/>
|
||||
))}
|
||||
{sources.length ? null : (
|
||||
<small className="empty-inline">尚无快照数据;快照将在来源首次刷新完成后出现。</small>
|
||||
)}
|
||||
</div>
|
||||
) : legacyConnections.length ? (
|
||||
<div className="empty-state">
|
||||
本页只列 PP 资料;AList/钉钉知识库来源已收在上方开关里(共 {legacyConnections.length}{' '}
|
||||
个,未删除)。
|
||||
</div>
|
||||
) : (
|
||||
<div className="empty-state">尚无可显示的来源连接。</div>
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
{section === 'services' ? (
|
||||
<section className="settings-panel wide" id="settings-services">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>服务配置</h2>
|
||||
<p>
|
||||
只配四项:测试地址、生产地址、生产 ID、知识库
|
||||
ID。保存会先生成修订、验证后原子启用,旧版本保留用于审计;凭据只写不读。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="environment-cards">
|
||||
<article>
|
||||
<b>测试 WeKnora</b>
|
||||
<span>{healthStateLabel(findHealth(monitor, 'WeKnora API'), undefined)}</span>
|
||||
<small>{`${healthStateDetail(findHealth(monitor, 'WeKnora API'), undefined) || '端点探测:未配置'};解析队列 对内 ${routingCapabilities.internal_enabled ? '已配置' : '未配置'} · 对外 ${routingCapabilities.external_enabled ? '已配置' : '未配置'}`}</small>
|
||||
</article>
|
||||
<article className="production">
|
||||
<b>生产 WeKnora</b>
|
||||
<span>
|
||||
{!productionEnabled
|
||||
? '未启用'
|
||||
: productionBackupRestoreVerified
|
||||
? '已启用 · 可提交生产请求'
|
||||
: '已启用 · 被阻断'}
|
||||
</span>
|
||||
<small>{`${productionWeKnoraProbe(monitor)};生产写入:${productionEnabled ? '开启' : '关闭'};发布目标与凭据:管理员受限配置,本页不可回读`}</small>
|
||||
</article>
|
||||
</div>
|
||||
<div className="safe-setting-grid production-endpoint-form">
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<label>
|
||||
测试地址
|
||||
<input
|
||||
value={testEndpoint}
|
||||
onChange={(event) => {
|
||||
setTestEndpoint(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="https://weknora.test.example"
|
||||
aria-invalid={!testEndpointValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
生产地址
|
||||
<input
|
||||
value={endpoint}
|
||||
onChange={(event) => {
|
||||
setEndpoint(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="https://weknora.prod.example"
|
||||
aria-invalid={!endpointValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
生产 ID
|
||||
<input
|
||||
value={productionTenantID}
|
||||
onChange={(event) => {
|
||||
setProductionTenantID(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="10000"
|
||||
aria-invalid={!productionTenantIDValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
知识库 ID
|
||||
<input
|
||||
value={productionKnowledgeBaseID}
|
||||
onChange={(event) => {
|
||||
setProductionKnowledgeBaseID(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="生产知识库 ID"
|
||||
aria-invalid={!productionKnowledgeBaseIDValid}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<label>
|
||||
测试地址
|
||||
<input value={settings.test_weknora_base_url || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
生产地址
|
||||
<input value={settings.production_weknora_base_url || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
生产 ID
|
||||
<input value={settings.production_tenant_id || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
知识库 ID
|
||||
<input value={settings.production_knowledge_base_id || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<button
|
||||
onClick={saveEndpoint}
|
||||
disabled={!canSave || !serviceSettingsValid || !serviceSettingsDirty}
|
||||
>
|
||||
{saving ? '正在验证并启用…' : '保存并启用服务配置'}
|
||||
</button>
|
||||
<small>
|
||||
四项留空即表示未配置。地址只接受 http(s) 源地址(不能带用户名密码、查询串或 #
|
||||
片段,凭据一律走文件引用);生产 ID 是发布契约里的租户 ID,十进制数字;知识库 ID
|
||||
是生产知识库标识,粘贴 URL 不会通过。保存写入服务器活动版本(版本化 + 审计 +
|
||||
原子切换);后端同时对测试地址/生产地址做真实探活,并用生产地址真查这两个 ID(WeKnora
|
||||
列库接口):端点回答"没有这个知识库"或租户不符会拒绝保存,端点抖动、鉴权失败或未配置生产凭据只警告不拦,核验原话与知识库名在保存后显示。
|
||||
</small>
|
||||
{serviceSettingsValid ? null : (
|
||||
<p className="error-message" role="alert">
|
||||
格式不合法:地址需 http:// 或 https:// 开头的纯地址,不能带用户名密码、? 查询串或 # 片段;生产
|
||||
ID 需为十进制数字;知识库 ID 不能含空格、/、?、# 或 \。
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<small>
|
||||
服务配置仅管理员可修改;当前值:测试地址 {settings.test_weknora_base_url || '未配置'} · 生产地址{' '}
|
||||
{settings.production_weknora_base_url || '未配置'} · 生产 ID{' '}
|
||||
{settings.production_tenant_id || '未配置'} · 知识库 ID{' '}
|
||||
{settings.production_knowledge_base_id || '未配置'}。
|
||||
</small>
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
{section === 'bindings' ? <RoutingBindingsSection /> : null}
|
||||
{section === 'production-bindings' ? <ProductionBindingsSection /> : null}
|
||||
{section === 'storage' ? <BackupScheduleSection /> : null}
|
||||
{section === 'members' && identity?.role === 'admin' ? <MembersSection /> : null}
|
||||
{section === 'refresh' ? (
|
||||
<section className="settings-panel wide" id="settings-refresh">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>刷新策略</h2>
|
||||
<p>这些值保存在服务器活动版本中;保存不会修改端点、凭据或生产开关。</p>
|
||||
</div>
|
||||
<span className="safe-badge">当前活动版本</span>
|
||||
</div>
|
||||
<div className="safe-setting-grid">
|
||||
<label>
|
||||
文档状态刷新间隔
|
||||
<select
|
||||
value={documentRefresh}
|
||||
onChange={(event) => {
|
||||
setDocumentRefresh(Number(event.target.value) as 15 | 30 | 60)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={15}>15秒</option>
|
||||
<option value={30}>30秒</option>
|
||||
<option value={60}>1分钟</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
资源刷新间隔
|
||||
<select
|
||||
value={resourceRefresh}
|
||||
onChange={(event) => {
|
||||
setResourceRefresh(Number(event.target.value) as 30 | 60)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={30}>30秒</option>
|
||||
<option value={60}>1分钟</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
解析停滞判定
|
||||
<select
|
||||
value={stalled}
|
||||
onChange={(event) => {
|
||||
setStalled(Number(event.target.value) as 1800 | 3600)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={1800}>30分钟</option>
|
||||
<option value={3600}>1小时</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
finalizing 告警
|
||||
<select
|
||||
value={finalizing}
|
||||
onChange={(event) => {
|
||||
setFinalizing(Number(event.target.value) as 7200 | 14400)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={7200}>2小时</option>
|
||||
<option value={14400}>4小时</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
入库并发上限
|
||||
<select
|
||||
value={concurrency}
|
||||
onChange={(event) => {
|
||||
setConcurrency(Number(event.target.value))
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={1}>1(谨慎,MinerU 并发 1)</option>
|
||||
<option value={2}>2</option>
|
||||
<option value={3}>3</option>
|
||||
<option value={4}>4</option>
|
||||
<option value={6}>6</option>
|
||||
<option value={8}>8</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
setDirty(false)
|
||||
onSave(candidateInput())
|
||||
}}
|
||||
disabled={!canSave}
|
||||
>
|
||||
{saving ? '正在验证并应用…' : '保存并应用刷新与告警参数'}
|
||||
</button>
|
||||
{visibleSaveMessage(saveMessage, dirty) ? (
|
||||
<p className="success-message" role="status">
|
||||
{saveMessage}
|
||||
</p>
|
||||
) : null}
|
||||
<small>
|
||||
当前:文档 {secondsLabel(settings.document_refresh_seconds)}、资源{' '}
|
||||
{secondsLabel(settings.resource_refresh_seconds)}、停滞 {secondsLabel(settings.stalled_after_seconds)}
|
||||
、finalizing {secondsLabel(settings.finalizing_after_seconds)}、入库并发{' '}
|
||||
{settings.ingestion_concurrency}。
|
||||
</small>
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
{isAdmin ? <><button onClick={saveEndpoint} disabled={!canSave || !serviceSettingsValid || !serviceSettingsDirty}>{saving ? '正在验证并启用…' : '保存并启用服务配置'}</button>
|
||||
<small>四项留空即表示未配置。地址只接受 http(s) 源地址(不能带用户名密码、查询串或 # 片段,凭据一律走文件引用);生产 ID 是发布契约里的租户 ID,十进制数字;知识库 ID 是生产知识库标识,粘贴 URL 不会通过。保存写入服务器活动版本(版本化 + 审计 + 原子切换);后端同时对测试地址/生产地址做真实探活,并用生产地址真查这两个 ID(WeKnora 列库接口):端点回答"没有这个知识库"或租户不符会拒绝保存,端点抖动、鉴权失败或未配置生产凭据只警告不拦,核验原话与知识库名在保存后显示。</small>
|
||||
{serviceSettingsValid ? null : <p className="error-message" role="alert">格式不合法:地址需 http:// 或 https:// 开头的纯地址,不能带用户名密码、? 查询串或 # 片段;生产 ID 需为十进制数字;知识库 ID 不能含空格、/、?、# 或 \。</p>}</>
|
||||
: <small>服务配置仅管理员可修改;当前值:测试地址 {settings.test_weknora_base_url || '未配置'} · 生产地址 {settings.production_weknora_base_url || '未配置'} · 生产 ID {settings.production_tenant_id || '未配置'} · 知识库 ID {settings.production_knowledge_base_id || '未配置'}。</small>}
|
||||
</section> : null}
|
||||
{section === 'bindings' ? <RoutingBindingsSection /> : null}
|
||||
{section === 'production-bindings' ? <ProductionBindingsSection /> : null}
|
||||
{section === 'storage' ? <BackupScheduleSection /> : null}
|
||||
{section === 'members' && identity?.role === 'admin' ? <MembersSection /> : null}
|
||||
{section === 'refresh' ? <section className="settings-panel wide" id="settings-refresh">
|
||||
<div className="settings-section-heading"><div><h2>刷新策略</h2><p>这些值保存在服务器活动版本中;保存不会修改端点、凭据或生产开关。</p></div><span className="safe-badge">当前活动版本</span></div>
|
||||
<div className="safe-setting-grid">
|
||||
<label>文档状态刷新间隔<select value={documentRefresh} onChange={(event) => { setDocumentRefresh(Number(event.target.value) as 15 | 30 | 60); setDirty(true) }}><option value={15}>15秒</option><option value={30}>30秒</option><option value={60}>1分钟</option></select></label>
|
||||
<label>资源刷新间隔<select value={resourceRefresh} onChange={(event) => { setResourceRefresh(Number(event.target.value) as 30 | 60); setDirty(true) }}><option value={30}>30秒</option><option value={60}>1分钟</option></select></label>
|
||||
<label>解析停滞判定<select value={stalled} onChange={(event) => { setStalled(Number(event.target.value) as 1800 | 3600); setDirty(true) }}><option value={1800}>30分钟</option><option value={3600}>1小时</option></select></label>
|
||||
<label>finalizing 告警<select value={finalizing} onChange={(event) => { setFinalizing(Number(event.target.value) as 7200 | 14400); setDirty(true) }}><option value={7200}>2小时</option><option value={14400}>4小时</option></select></label>
|
||||
<label>入库并发上限<select value={concurrency} onChange={(event) => { setConcurrency(Number(event.target.value)); setDirty(true) }}><option value={1}>1(谨慎,MinerU 并发 1)</option><option value={2}>2</option><option value={3}>3</option><option value={4}>4</option><option value={6}>6</option><option value={8}>8</option></select></label>
|
||||
</div>
|
||||
<button onClick={() => { setDirty(false); onSave(candidateInput()) }} disabled={!canSave}>{saving ? '正在验证并应用…' : '保存并应用刷新与告警参数'}</button>
|
||||
{visibleSaveMessage(saveMessage, dirty) ? <p className="success-message" role="status">{saveMessage}</p> : null}
|
||||
<small>当前:文档 {secondsLabel(settings.document_refresh_seconds)}、资源 {secondsLabel(settings.resource_refresh_seconds)}、停滞 {secondsLabel(settings.stalled_after_seconds)}、finalizing {secondsLabel(settings.finalizing_after_seconds)}、入库并发 {settings.ingestion_concurrency}。</small>
|
||||
</section> : null}
|
||||
</div>
|
||||
</div> : null}
|
||||
</main>
|
||||
</div>
|
||||
) : null}
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export function SystemSettings() {
|
||||
@@ -291,7 +761,10 @@ export function SystemSettings() {
|
||||
const [settings, setSettings] = useState<UISettings | null>(null)
|
||||
const [productionEnabled, setProductionEnabled] = useState(false)
|
||||
const [productionBackupRestoreVerified, setProductionBackupRestoreVerified] = useState(false)
|
||||
const [routingCapabilities, setRoutingCapabilities] = useState<CatalogRoutingCapabilities>({ internal_enabled: false, external_enabled: false })
|
||||
const [routingCapabilities, setRoutingCapabilities] = useState<CatalogRoutingCapabilities>({
|
||||
internal_enabled: false,
|
||||
external_enabled: false,
|
||||
})
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
@@ -299,24 +772,76 @@ export function SystemSettings() {
|
||||
const [revision, setRevision] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController(); setLoading(true)
|
||||
void Promise.all([fetchCatalogSources(controller.signal), fetchSourceConnectionList(controller.signal), fetchMonitorOverview(controller.signal), fetchReleaseCapabilities(controller.signal), fetchCatalogRoutingCapabilities(controller.signal), fetchActiveUISettings(controller.signal)]).then(([nextSources, nextConnections, overview, capabilities, routing, active]) => { if (!controller.signal.aborted) { setSources(nextSources); setConnections(nextConnections); setMonitor(overview); setProductionEnabled(capabilities.production_release_requests_enabled); setProductionBackupRestoreVerified(capabilities.production_backup_restore_verified); setRoutingCapabilities(routing); setSettings(active); setError(null) } }).catch((cause) => { if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : '加载系统设置失败') }).finally(() => { if (!controller.signal.aborted) setLoading(false) })
|
||||
const controller = new AbortController()
|
||||
setLoading(true)
|
||||
void Promise.all([
|
||||
fetchCatalogSources(controller.signal),
|
||||
fetchSourceConnectionList(controller.signal),
|
||||
fetchMonitorOverview(controller.signal),
|
||||
fetchReleaseCapabilities(controller.signal),
|
||||
fetchCatalogRoutingCapabilities(controller.signal),
|
||||
fetchActiveUISettings(controller.signal),
|
||||
])
|
||||
.then(([nextSources, nextConnections, overview, capabilities, routing, active]) => {
|
||||
if (!controller.signal.aborted) {
|
||||
setSources(nextSources)
|
||||
setConnections(nextConnections)
|
||||
setMonitor(overview)
|
||||
setProductionEnabled(capabilities.production_release_requests_enabled)
|
||||
setProductionBackupRestoreVerified(capabilities.production_backup_restore_verified)
|
||||
setRoutingCapabilities(routing)
|
||||
setSettings(active)
|
||||
setError(null)
|
||||
}
|
||||
})
|
||||
.catch((cause) => {
|
||||
if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : '加载系统设置失败')
|
||||
})
|
||||
.finally(() => {
|
||||
if (!controller.signal.aborted) setLoading(false)
|
||||
})
|
||||
return () => controller.abort()
|
||||
}, [revision])
|
||||
|
||||
const save = async (input: UISettingsCandidateInput) => {
|
||||
setSaving(true); setSaveMessage(null); setError(null)
|
||||
setSaving(true)
|
||||
setSaveMessage(null)
|
||||
setError(null)
|
||||
try {
|
||||
const candidate = await createUISettingsCandidate(input)
|
||||
const activated = await activateUISettings(candidate.settings.id)
|
||||
const active = activated.settings
|
||||
const verification = activated.verification ?? candidate.verification
|
||||
setSettings(active)
|
||||
setSaveMessage(`设置已验证并启用:文档${secondsLabel(active.document_refresh_seconds)}、资源${secondsLabel(active.resource_refresh_seconds)}、停滞${secondsLabel(active.stalled_after_seconds)}、finalizing ${secondsLabel(active.finalizing_after_seconds)}、入库并发 ${active.ingestion_concurrency}、测试地址 ${active.test_weknora_base_url || '未配置'}、生产地址 ${active.production_weknora_base_url || '未配置'}、生产 ID ${active.production_tenant_id || '未配置'}、知识库 ID ${active.production_knowledge_base_id || '未配置'};旧版本已保留用于审计。${verification ? `核验:${verification.message}` : ''}`)
|
||||
setSaveMessage(
|
||||
`设置已验证并启用:文档${secondsLabel(active.document_refresh_seconds)}、资源${secondsLabel(active.resource_refresh_seconds)}、停滞${secondsLabel(active.stalled_after_seconds)}、finalizing ${secondsLabel(active.finalizing_after_seconds)}、入库并发 ${active.ingestion_concurrency}、测试地址 ${active.test_weknora_base_url || '未配置'}、生产地址 ${active.production_weknora_base_url || '未配置'}、生产 ID ${active.production_tenant_id || '未配置'}、知识库 ID ${active.production_knowledge_base_id || '未配置'};旧版本已保留用于审计。${verification ? `核验:${verification.message}` : ''}`
|
||||
)
|
||||
} catch (cause) {
|
||||
setError(cause instanceof Error ? cause.message : '保存系统设置失败')
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
catch (cause) { setError(cause instanceof Error ? cause.message : '保存系统设置失败') }
|
||||
finally { setSaving(false) }
|
||||
}
|
||||
const reloadSources = useCallback(() => { setSaveMessage(null); setRevision((value) => value + 1) }, [])
|
||||
return <SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={productionEnabled} productionBackupRestoreVerified={productionBackupRestoreVerified} routingCapabilities={routingCapabilities} loading={loading} saving={saving} error={error} saveMessage={saveMessage} onSave={(input) => void save(input)} onSourcesChanged={reloadSources} onRefresh={reloadSources}/>
|
||||
const reloadSources = useCallback(() => {
|
||||
setSaveMessage(null)
|
||||
setRevision((value) => value + 1)
|
||||
}, [])
|
||||
return (
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={productionEnabled}
|
||||
productionBackupRestoreVerified={productionBackupRestoreVerified}
|
||||
routingCapabilities={routingCapabilities}
|
||||
loading={loading}
|
||||
saving={saving}
|
||||
error={error}
|
||||
saveMessage={saveMessage}
|
||||
onSave={(input) => void save(input)}
|
||||
onSourcesChanged={reloadSources}
|
||||
onRefresh={reloadSources}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
+841
-62
@@ -1,64 +1,843 @@
|
||||
.system-settings{max-width:1500px}.settings-role-strip{display:flex;gap:10px;margin-bottom:12px}.settings-role-strip span{border-radius:8px;padding:8px 11px;font-size:10px}.engineer-role{background:var(--c-run-bg);color:var(--c-run)}.admin-role{background:var(--bg-soft);color:var(--ink-mute)}.settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.settings-panel{min-width:0;border:1px solid var(--border-base);border-radius:12px;padding:15px;background:var(--bg-panel)}.settings-panel.wide{grid-column:1/-1}.settings-panel h2{margin:0 0 12px;color:var(--ink-base);font-size:14px}.settings-panel dl{display:grid;grid-template-columns:1fr auto;gap:8px;margin:0;color:var(--ink-mute);font-size:10px}.settings-panel dd{margin:0;color:var(--ink-base);font-weight:700}.settings-panel dd.ok{color:var(--c-done)}.settings-panel dd.off,.settings-panel .production span{color:var(--c-fail)}.environment-cards{display:grid;grid-template-columns:1fr 1fr;gap:10px}.environment-cards article{display:grid;grid-template-columns:1fr auto;gap:6px;border:1px solid var(--border-base);border-radius:9px;padding:11px;background:var(--bg-soft)}.environment-cards b{color:var(--ink-base);font-size:11px}.environment-cards span{color:var(--c-done);font-size:10px}.environment-cards small{grid-column:1/-1;color:var(--ink-mute);font-size:9px}.environment-cards button{grid-column:2;padding:5px 7px}.mapping-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}.mapping-row>*{border-radius:6px;padding:6px 8px;background:var(--border-soft);color:var(--ink-mute);font-size:9px}.dependency-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px}.dependency-grid article{display:grid;gap:4px;border-radius:8px;padding:9px;background:var(--bg-soft)}.dependency-grid span{color:var(--ink-mute);font-size:9px}.dependency-grid b{color:var(--ink-base);font-size:10px}.dependency-grid small{color:var(--ink-mute);font-size:8px;line-height:1.5}.target-list{display:grid;gap:7px;margin:0;padding:0;list-style:none}.target-list li{display:flex;justify-content:space-between;gap:10px;color:var(--ink-mute);font-size:10px}.target-list b{color:var(--c-fail)}.settings-panel>button{margin-top:12px;padding:7px 10px}.settings-panel>small{display:block;margin-top:7px;color:var(--ink-mute);font-size:8px}.safe-setting-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.safe-setting-grid label{display:grid;gap:6px;color:var(--ink-mute);font-size:10px}.safe-setting-grid select{border:1px solid var(--border-strong);border-radius:7px;padding:8px;background:var(--bg-panel);color:var(--ink-base)}.locked-gates{display:flex;flex-wrap:wrap;gap:7px;margin-top:11px}.locked-gates span{border-radius:6px;padding:6px 8px;background:var(--c-fail-bg);color:var(--c-fail);font-size:9px}@media(max-width:900px){.dependency-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.safe-setting-grid{grid-template-columns:1fr 1fr}}@media(max-width:650px){.settings-grid,.environment-cards{grid-template-columns:1fr}.settings-panel.wide{grid-column:auto}.dependency-grid,.safe-setting-grid{grid-template-columns:1fr}.settings-role-strip{flex-direction:column}}
|
||||
.settings-section-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}.settings-section-heading h2{margin-bottom:4px}.settings-section-heading p{margin:0;color:var(--ink-mute);font-size:10px}.settings-section-heading button{padding:7px 10px;box-shadow:none}.settings-source-list{display:grid;gap:9px}.settings-source-row{display:grid;grid-template-columns:minmax(170px,.8fr) minmax(420px,2fr) minmax(130px,.55fr) auto;align-items:center;gap:14px;border:1px solid var(--border-base);border-radius:10px;padding:12px;background:var(--bg-page)}.settings-source-name{display:grid;gap:4px}.settings-source-name strong{color:var(--ink-base);font-size:12px}.settings-source-name span{color:var(--ink-mute);font-size:9px}.settings-source-row dl{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.settings-source-row dl div{display:grid;gap:3px}.settings-source-row dt{color:var(--ink-mute);font-size:8px}.settings-source-row dd{overflow-wrap:anywhere;color:var(--ink-base);font-size:9px;font-weight:650}.settings-source-row label{display:grid;gap:5px;color:var(--ink-mute);font-size:9px}.settings-source-row select{border:1px solid #c9d9e4;border-radius:7px;padding:7px;background:var(--bg-panel);color:var(--ink-base)}.settings-source-row>button{padding:7px 9px;box-shadow:none}.dependency-grid{margin-top:12px}.storage-settings-grid{display:grid;grid-template-columns:1fr 1fr minmax(220px,.8fr);gap:14px}.storage-settings-grid>dl,.storage-settings-grid>.target-list{border:1px solid var(--border-base);border-radius:9px;padding:12px;background:var(--bg-soft)}@media(max-width:1100px){.settings-source-row{grid-template-columns:1fr 1fr}.settings-source-row dl{grid-column:1/-1}.storage-settings-grid{grid-template-columns:1fr 1fr}.storage-settings-grid>.target-list{grid-column:1/-1}}@media(max-width:700px){.settings-section-heading{flex-direction:column}.settings-source-row,.settings-source-row dl,.storage-settings-grid{grid-template-columns:1fr}.settings-source-row dl{grid-column:auto}.storage-settings-grid>.target-list{grid-column:auto}}.settings-layout{display:grid;grid-template-columns:200px minmax(0,1fr);gap:18px;align-items:start}
|
||||
.settings-nav{display:flex;flex-direction:column;gap:6px;position:sticky;top:16px}
|
||||
.settings-nav button{border:1px solid transparent;background:transparent;text-align:left;padding:9px 12px;border-radius:8px;font:inherit;cursor:pointer;color:var(--ink-base)}
|
||||
.settings-nav button:hover{background:var(--border-soft)}
|
||||
.settings-nav button.active{background:var(--c-run);color:var(--bg-panel);font-weight:600}
|
||||
.settings-content{display:flex;flex-direction:column;gap:14px;min-width:0}
|
||||
.source-schedule-form{display:flex;flex-wrap:wrap;gap:10px;align-items:end;padding-top:6px}
|
||||
.source-schedule-form label{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--ink-base)}
|
||||
.source-schedule-form select,.source-schedule-form input{padding:6px 8px;border:1px solid var(--border-strong);border-radius:6px;font:inherit;background:var(--bg-panel)}
|
||||
.source-schedule-actions{display:flex;gap:8px;align-items:end}
|
||||
button.danger{background:var(--c-fail);color:var(--bg-panel);border:none;padding:8px 14px;border-radius:8px;font:inherit;cursor:pointer}
|
||||
button.danger:hover{background:var(--c-fail)}
|
||||
button.danger:disabled{background:var(--c-fail-border);cursor:not-allowed}
|
||||
button.link{background:none;border:none;color:var(--c-run);cursor:pointer;text-decoration:underline;font:inherit;padding:4px}
|
||||
.manual-source-note{color:var(--ink-mute);font-size:13px}
|
||||
.error-message{color:var(--c-fail);font-size:13px;margin:4px 0}
|
||||
.revision-list{list-style:none;margin:8px 0 0;padding:8px 10px;background:var(--bg-soft);border-radius:8px;display:flex;flex-direction:column;gap:6px;font-size:13px}
|
||||
.revision-list li{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
|
||||
.revision-list span{color:var(--c-run);font-weight:600}
|
||||
.revision-list small{color:var(--ink-mute)}
|
||||
.empty-inline{color:var(--ink-mute);font-size:13px}
|
||||
.modal-backdrop{position:fixed;inset:0;background:rgba(10,25,40,.45);display:flex;align-items:center;justify-content:center;z-index:50;padding:16px}
|
||||
.modal-card{background:var(--bg-panel);border-radius:12px;padding:20px;max-width:420px;box-shadow:0 18px 48px rgba(9,28,46,.35)}
|
||||
.modal-card h3{margin:0 0 8px}
|
||||
.modal-card p{color:var(--ink-base);font-size:14px;line-height:1.6}
|
||||
.modal-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:14px}
|
||||
@media (max-width:900px){.settings-layout{grid-template-columns:1fr}.settings-nav{position:static;flex-direction:row;flex-wrap:wrap}}
|
||||
.kb-binding-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px 0}.kb-binding-side{display:grid;gap:4px;border:1px solid var(--border-base);border-radius:9px;padding:11px;background:var(--bg-soft)}.kb-binding-side.bound{border-color:var(--c-done)}.kb-binding-side.warn{border-color:var(--c-fail)}.kb-binding-side b{color:var(--ink-base);font-size:11px}.kb-binding-side span{color:var(--c-done);font-size:11px;word-break:break-all}.kb-binding-side.warn span{color:var(--c-fail)}.kb-binding-side small{color:var(--ink-mute);font-size:9px}.kb-binding-editor{display:grid;gap:10px;border-top:1px dashed var(--border-base);margin-top:8px;padding-top:12px}.kb-binding-editor label{display:grid;gap:6px;color:var(--ink-mute);font-size:10px}.kb-binding-editor select,.kb-binding-editor input{border:1px solid var(--border-strong);border-radius:7px;padding:8px;background:var(--bg-panel);color:var(--ink-base)}.kb-binding-editor button{justify-self:start;padding:7px 10px}@media(max-width:650px){.kb-binding-grid{grid-template-columns:1fr}}.hint{color:var(--ink-mute);font-size:10px;margin:4px 0}
|
||||
.dingtalk-session-control{display:flex;flex-direction:column;gap:4px;align-self:end}
|
||||
.dingtalk-qr-card{max-width:440px;text-align:center}
|
||||
.dingtalk-qr-hint{color:var(--ink-mute);font-size:13px;min-height:20px}
|
||||
.dingtalk-qr-image{display:block;margin:12px auto;width:320px;height:320px;image-rendering:pixelated;border:12px solid #fff;border-radius:4px;background:#fff;box-sizing:content-box}
|
||||
.dingtalk-qr-loading{display:grid;place-items:center;margin:12px auto;width:320px;height:320px;max-width:80vw;max-height:80vw;border:12px solid #fff;border-radius:4px;background:#fff;box-sizing:content-box}
|
||||
.dingtalk-qr-loading span{width:42px;height:42px;border:4px solid #dbe4ee;border-top-color:var(--brand);border-radius:50%;animation:dingtalk-qr-spin .8s linear infinite}
|
||||
@keyframes dingtalk-qr-spin{to{transform:rotate(360deg)}}
|
||||
.dingtalk-qr-card .modal-actions{justify-content:center}
|
||||
.filename-filter-editor{flex-basis:100%;margin-top:10px;padding:12px;border:1px solid var(--border-base);border-radius:10px;background:var(--bg-soft)}
|
||||
.filename-filter-heading{display:flex;justify-content:space-between;gap:10px;margin-bottom:7px}.filename-filter-heading div{display:grid;gap:3px}.filename-filter-heading small{color:var(--ink-mute)}
|
||||
.filename-filter-inherited,.filename-filter-direct{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:6px 0}.filename-filter-inherited span,.filename-filter-direct span{font-size:10px;color:var(--ink-mute)}
|
||||
.filename-filter-editor code{padding:2px 7px;border-radius:999px;background:#eaf2ff;color:#2456a6;font-family:inherit;font-size:11px}
|
||||
.filename-filter-form{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:9px 0}.filename-filter-form input{min-width:220px;flex:1;padding:7px 9px;border:1px solid var(--border-strong);border-radius:7px;background:var(--bg-panel)}
|
||||
.filename-filter-modes{display:flex;gap:12px;align-self:center;font-size:11px;color:var(--ink-base)}.filename-filter-modes label{display:flex;gap:4px;align-items:center;cursor:pointer}
|
||||
.filename-filter-groups{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px 14px;margin:8px 0}.filename-filter-group{display:grid;gap:4px}.filename-filter-group>span{color:var(--ink-mute);font-size:9px}
|
||||
.filename-filter-group>div{display:flex;flex-wrap:wrap;gap:4px}.filename-filter-group button{border:1px solid var(--border-base);background:var(--bg-panel);color:var(--ink-base);border-radius:999px;padding:2px 8px;font-size:10px;font-family:inherit;cursor:pointer}
|
||||
.filename-filter-group button.picked{background:var(--c-run);border-color:var(--c-run);color:var(--bg-panel);font-weight:650}.filename-filter-group button.blocked{color:var(--c-fail)}
|
||||
@media(max-width:900px){.filename-filter-groups{grid-template-columns:1fr 1fr}}
|
||||
.system-settings {
|
||||
max-width: 1500px;
|
||||
}
|
||||
.settings-role-strip {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.settings-role-strip span {
|
||||
border-radius: 8px;
|
||||
padding: 8px 11px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.engineer-role {
|
||||
background: var(--c-run-bg);
|
||||
color: var(--c-run);
|
||||
}
|
||||
.admin-role {
|
||||
background: var(--bg-soft);
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.settings-panel {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 12px;
|
||||
padding: 15px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.settings-panel.wide {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.settings-panel h2 {
|
||||
margin: 0 0 12px;
|
||||
color: var(--ink-base);
|
||||
font-size: 14px;
|
||||
}
|
||||
.settings-panel dl {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.settings-panel dd {
|
||||
margin: 0;
|
||||
color: var(--ink-base);
|
||||
font-weight: 700;
|
||||
}
|
||||
.settings-panel dd.ok {
|
||||
color: var(--c-done);
|
||||
}
|
||||
.settings-panel dd.off,
|
||||
.settings-panel .production span {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.environment-cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
.environment-cards article {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 6px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.environment-cards b {
|
||||
color: var(--ink-base);
|
||||
font-size: 11px;
|
||||
}
|
||||
.environment-cards span {
|
||||
color: var(--c-done);
|
||||
font-size: 10px;
|
||||
}
|
||||
.environment-cards small {
|
||||
grid-column: 1/-1;
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.environment-cards button {
|
||||
grid-column: 2;
|
||||
padding: 5px 7px;
|
||||
}
|
||||
.mapping-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.mapping-row > * {
|
||||
border-radius: 6px;
|
||||
padding: 6px 8px;
|
||||
background: var(--border-soft);
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.dependency-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.dependency-grid article {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
border-radius: 8px;
|
||||
padding: 9px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.dependency-grid span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.dependency-grid b {
|
||||
color: var(--ink-base);
|
||||
font-size: 10px;
|
||||
}
|
||||
.dependency-grid small {
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.target-list {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.target-list li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.target-list b {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.settings-panel > button {
|
||||
margin-top: 12px;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
.settings-panel > small {
|
||||
display: block;
|
||||
margin-top: 7px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
}
|
||||
.safe-setting-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.safe-setting-grid label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.safe-setting-grid select {
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
padding: 8px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.locked-gates {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 7px;
|
||||
margin-top: 11px;
|
||||
}
|
||||
.locked-gates span {
|
||||
border-radius: 6px;
|
||||
padding: 6px 8px;
|
||||
background: var(--c-fail-bg);
|
||||
color: var(--c-fail);
|
||||
font-size: 9px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.dependency-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
.safe-setting-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 650px) {
|
||||
.settings-grid,
|
||||
.environment-cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-panel.wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
.dependency-grid,
|
||||
.safe-setting-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-role-strip {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
.settings-section-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.settings-section-heading h2 {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.settings-section-heading p {
|
||||
margin: 0;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.settings-section-heading button {
|
||||
padding: 7px 10px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.settings-source-list {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
}
|
||||
.settings-source-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(170px, 0.8fr) minmax(420px, 2fr) minmax(130px, 0.55fr) auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
background: var(--bg-page);
|
||||
}
|
||||
.settings-source-name {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.settings-source-name strong {
|
||||
color: var(--ink-base);
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-source-name span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.settings-source-row dl div {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
.settings-source-row dt {
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
}
|
||||
.settings-source-row dd {
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--ink-base);
|
||||
font-size: 9px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.settings-source-row label {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.settings-source-row select {
|
||||
border: 1px solid #c9d9e4;
|
||||
border-radius: 7px;
|
||||
padding: 7px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.settings-source-row > button {
|
||||
padding: 7px 9px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.dependency-grid {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.storage-settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr minmax(220px, 0.8fr);
|
||||
gap: 14px;
|
||||
}
|
||||
.storage-settings-grid > dl,
|
||||
.storage-settings-grid > .target-list {
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 12px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.settings-source-row {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.storage-settings-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.storage-settings-grid > .target-list {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.settings-section-heading {
|
||||
flex-direction: column;
|
||||
}
|
||||
.settings-source-row,
|
||||
.settings-source-row dl,
|
||||
.storage-settings-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
grid-column: auto;
|
||||
}
|
||||
.storage-settings-grid > .target-list {
|
||||
grid-column: auto;
|
||||
}
|
||||
}
|
||||
.settings-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 200px minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
}
|
||||
.settings-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
position: sticky;
|
||||
top: 16px;
|
||||
}
|
||||
.settings-nav button {
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
padding: 9px 12px;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.settings-nav button:hover {
|
||||
background: var(--border-soft);
|
||||
}
|
||||
.settings-nav button.active {
|
||||
background: var(--c-run);
|
||||
color: var(--bg-panel);
|
||||
font-weight: 600;
|
||||
}
|
||||
.settings-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
.source-schedule-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
padding-top: 6px;
|
||||
}
|
||||
.source-schedule-form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.source-schedule-form select,
|
||||
.source-schedule-form input {
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
font: inherit;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.source-schedule-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: end;
|
||||
}
|
||||
button.danger {
|
||||
background: var(--c-fail);
|
||||
color: var(--bg-panel);
|
||||
border: none;
|
||||
padding: 8px 14px;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
button.danger:hover {
|
||||
background: var(--c-fail);
|
||||
}
|
||||
button.danger:disabled {
|
||||
background: var(--c-fail-border);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
button.link {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--c-run);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
font: inherit;
|
||||
padding: 4px;
|
||||
}
|
||||
.manual-source-note {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
}
|
||||
.error-message {
|
||||
color: var(--c-fail);
|
||||
font-size: 13px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.revision-list {
|
||||
list-style: none;
|
||||
margin: 8px 0 0;
|
||||
padding: 8px 10px;
|
||||
background: var(--bg-soft);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.revision-list li {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.revision-list span {
|
||||
color: var(--c-run);
|
||||
font-weight: 600;
|
||||
}
|
||||
.revision-list small {
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.empty-inline {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
}
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(10, 25, 40, 0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 50;
|
||||
padding: 16px;
|
||||
}
|
||||
.modal-card {
|
||||
background: var(--bg-panel);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
max-width: 420px;
|
||||
box-shadow: 0 18px 48px rgba(9, 28, 46, 0.35);
|
||||
}
|
||||
.modal-card h3 {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.modal-card p {
|
||||
color: var(--ink-base);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 14px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.settings-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-nav {
|
||||
position: static;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
.kb-binding-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
.kb-binding-side {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.kb-binding-side.bound {
|
||||
border-color: var(--c-done);
|
||||
}
|
||||
.kb-binding-side.warn {
|
||||
border-color: var(--c-fail);
|
||||
}
|
||||
.kb-binding-side b {
|
||||
color: var(--ink-base);
|
||||
font-size: 11px;
|
||||
}
|
||||
.kb-binding-side span {
|
||||
color: var(--c-done);
|
||||
font-size: 11px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.kb-binding-side.warn span {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.kb-binding-side small {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.kb-binding-editor {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
border-top: 1px dashed var(--border-base);
|
||||
margin-top: 8px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
.kb-binding-editor label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.kb-binding-editor select,
|
||||
.kb-binding-editor input {
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
padding: 8px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.kb-binding-editor button {
|
||||
justify-self: start;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
@media (max-width: 650px) {
|
||||
.kb-binding-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
.hint {
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.dingtalk-session-control {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
align-self: end;
|
||||
}
|
||||
.dingtalk-qr-card {
|
||||
max-width: 440px;
|
||||
text-align: center;
|
||||
}
|
||||
.dingtalk-qr-hint {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
min-height: 20px;
|
||||
}
|
||||
.dingtalk-qr-image {
|
||||
display: block;
|
||||
margin: 12px auto;
|
||||
width: 320px;
|
||||
height: 320px;
|
||||
image-rendering: pixelated;
|
||||
border: 12px solid #fff;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.dingtalk-qr-loading {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin: 12px auto;
|
||||
width: 320px;
|
||||
height: 320px;
|
||||
max-width: 80vw;
|
||||
max-height: 80vw;
|
||||
border: 12px solid #fff;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.dingtalk-qr-loading span {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border: 4px solid #dbe4ee;
|
||||
border-top-color: var(--brand);
|
||||
border-radius: 50%;
|
||||
animation: dingtalk-qr-spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes dingtalk-qr-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
.dingtalk-qr-card .modal-actions {
|
||||
justify-content: center;
|
||||
}
|
||||
.filename-filter-editor {
|
||||
flex-basis: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.filename-filter-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
.filename-filter-heading div {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
.filename-filter-heading small {
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.filename-filter-inherited,
|
||||
.filename-filter-direct {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin: 6px 0;
|
||||
}
|
||||
.filename-filter-inherited span,
|
||||
.filename-filter-direct span {
|
||||
font-size: 10px;
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.filename-filter-editor code {
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
background: #eaf2ff;
|
||||
color: #2456a6;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
}
|
||||
.filename-filter-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin: 9px 0;
|
||||
}
|
||||
.filename-filter-form input {
|
||||
min-width: 220px;
|
||||
flex: 1;
|
||||
padding: 7px 9px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.filename-filter-modes {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-self: center;
|
||||
font-size: 11px;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.filename-filter-modes label {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.filename-filter-groups {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 6px 14px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
.filename-filter-group {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.filename-filter-group > span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.filename-filter-group > div {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
.filename-filter-group button {
|
||||
border: 1px solid var(--border-base);
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
border-radius: 999px;
|
||||
padding: 2px 8px;
|
||||
font-size: 10px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.filename-filter-group button.picked {
|
||||
background: var(--c-run);
|
||||
border-color: var(--c-run);
|
||||
color: var(--bg-panel);
|
||||
font-weight: 650;
|
||||
}
|
||||
.filename-filter-group button.blocked {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.filename-filter-groups {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* 数据源发现(系统设置 → 数据源配置):列出可勾选为来源的钉钉知识库与钉盘空间。 */
|
||||
.dingtalk-discovery { display: flex; flex-direction: column; gap: 10px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--border, #e3e8ec); border-radius: 10px; background: var(--card, #fff); }
|
||||
.dingtalk-discovery-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
||||
.dingtalk-discovery-heading strong { display: block; font-size: 14px; }
|
||||
.dingtalk-discovery-heading small { display: block; color: var(--muted-foreground, #5b6773); font-size: 12px; }
|
||||
.dingtalk-discovery-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
||||
.discovery-group h4 { margin: 0 0 6px; font-size: 13px; }
|
||||
.discovery-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
|
||||
.discovery-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 6px; }
|
||||
.discovery-row:hover { background: var(--accent, #f2f5f8); }
|
||||
.discovery-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
||||
.discovery-row.registered label { cursor: default; color: var(--muted-foreground, #5b6773); }
|
||||
.discovery-row strong { font-size: 13px; font-weight: 500; }
|
||||
.discovery-row small { display: block; font-size: 11px; color: var(--muted-foreground, #5b6773); }
|
||||
.dingtalk-discovery-actions { display: flex; align-items: center; gap: 10px; }
|
||||
.dingtalk-discovery-actions small { color: var(--muted-foreground, #5b6773); font-size: 12px; }
|
||||
.dingtalk-discovery {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
margin-bottom: 14px;
|
||||
border: 1px solid var(--border, #e3e8ec);
|
||||
border-radius: 10px;
|
||||
background: var(--card, #fff);
|
||||
}
|
||||
.dingtalk-discovery-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.dingtalk-discovery-heading strong {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dingtalk-discovery-heading small {
|
||||
display: block;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
font-size: 12px;
|
||||
}
|
||||
.dingtalk-discovery-groups {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
.discovery-group h4 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.discovery-group ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
max-height: 220px;
|
||||
overflow: auto;
|
||||
}
|
||||
.discovery-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.discovery-row:hover {
|
||||
background: var(--accent, #f2f5f8);
|
||||
}
|
||||
.discovery-row label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.discovery-row.registered label {
|
||||
cursor: default;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
}
|
||||
.discovery-row strong {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.discovery-row small {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
}
|
||||
.dingtalk-discovery-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.dingtalk-discovery-actions small {
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 折叠的 AList/钉钉知识库来源开关:默认收起,只露一行说明,不抢 PP 资料的视线。 */
|
||||
.settings-legacy-toggle {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 0.75rem;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
.settings-legacy-toggle small {
|
||||
color: #5a6572;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user