- 入口与页面标题由「刷新策略」改为「参数设置」,移除旧入口 - 按产品归属分组:来源与目录(文档/资源刷新间隔)、解析监控(停滞阈值/入库并发) - 保留单位、调大调小后果与 worker 生效说明,收尾超时仍不展示 - 字段名/单位收敛到 REFRESH_FIELD_META,避免视图与校验文案各写一份后漂移 - 新增挂载测试覆盖非法值禁用保存、不发请求、保留其他输入与原样回传隐藏字段 - 同步 CHANGELOG、验收清单与运维手册
This commit is contained in:
+9
-6
@@ -1,17 +1,20 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 开发快照 0.1.415(系统设置:刷新策略改为刷新与入库)
|
## 开发快照 0.1.415(系统设置:刷新策略改为按模块分组的参数设置)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **参数按真实消费者展示**:系统设置「刷新策略」改为「刷新与入库」,保留文档状态刷新间隔
|
- **入口改为「参数设置」**:系统设置左侧子导航与页面标题由「刷新策略」替换为「参数设置」,
|
||||||
(15/30/60 秒)、资源刷新间隔(30/60 秒)、解析停滞判定(30/60 分钟)与入库并发上限
|
旧入口不再出现。
|
||||||
(1..16);每项带单位与用途提示,说明前两项只驱动解析监控轮询。
|
- **参数按模块分组**:按产品归属固定为「来源与目录」(文档状态刷新间隔 15/30/60 秒、
|
||||||
|
资源刷新间隔 30/60 秒)与「解析监控」(解析停滞阈值 30/60 分钟、入库并发上限 1..16);
|
||||||
|
分组标题下不叠加说明段。
|
||||||
- **数值输入与就地校验**:四个下拉改为文本数值输入;空值、非整数、`+15`/`1e1`、全角数字
|
- **数值输入与就地校验**:四个下拉改为文本数值输入;空值、非整数、`+15`/`1e1`、全角数字
|
||||||
与越界值当场红字提示并禁用保存,不发请求;并发不再受旧下拉六档限制。
|
与越界值当场红字提示并禁用保存,不发请求;并发不再受旧下拉六档限制。
|
||||||
|
- **保留现状说明与保存边界**:每项保留单位与调大/调小后果;解析停滞阈值保留 worker 1 分钟
|
||||||
|
内生效说明;保存仍只提交参数分区,且原样回传未展示的 `finalizing_after_seconds` 与连接字段。
|
||||||
- **去掉无消费者的收尾超时展示**:本页不再展示「收尾超时告警」,成功消息与底部摘要也不再
|
- **去掉无消费者的收尾超时展示**:本页不再展示「收尾超时告警」,成功消息与底部摘要也不再
|
||||||
播报它;`finalizing_after_seconds` 仍按服务器当前值随保存回传(API/DB/worker 与
|
播报它;API/DB/worker 与 `finalizing` 处理状态均未改动。
|
||||||
`finalizing` 处理状态均未改动)。
|
|
||||||
|
|
||||||
## 开发快照 0.1.414(知识库绑定:私网 http 可录入 Key)
|
## 开发快照 0.1.414(知识库绑定:私网 http 可录入 Key)
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ bash scripts/target_kb_snapshot.sh # 默认云内执行;PG 8 表 +
|
|||||||
| 知识库绑定(测试 090 / 生产 090) | 管理员 | 每个环境:服务地址 + API Key(服务器真实列库)→ 选对外/对内库 → 一次保存;密钥不回显,换地址须重录 |
|
| 知识库绑定(测试 090 / 生产 090) | 管理员 | 每个环境:服务地址 + API Key(服务器真实列库)→ 选对外/对内库 → 一次保存;密钥不回显,换地址须重录 |
|
||||||
| 绑定诊断(折叠) | 管理员 | 探活、封存源对照、整库发布目标(只读,由部署配置决定)与旧文档级目标 |
|
| 绑定诊断(折叠) | 管理员 | 探活、封存源对照、整库发布目标(只读,由部署配置决定)与旧文档级目标 |
|
||||||
| **存储与备份** **【新】** | 管理员 | **定时时间 + 储存天数**(+每月归档、启用开关)→ `保存并下发到主机`;另有 `重新下发当前设置`、`立即备份一次`;页面显示主机上**实际生效**的计划、cron 条目、最近一次结果与"已一致/待下发" |
|
| **存储与备份** **【新】** | 管理员 | **定时时间 + 储存天数**(+每月归档、启用开关)→ `保存并下发到主机`;另有 `重新下发当前设置`、`立即备份一次`;页面显示主机上**实际生效**的计划、cron 条目、最近一次结果与"已一致/待下发" |
|
||||||
| 刷新与入库 | 文档工程师 | 文档/资源刷新间隔、停滞判定、入库并发上限(1..16,版本化 + 原子切换);finalizing 设置仅在 API/DB 保留,页面不展示 |
|
| 参数设置 | 文档工程师 | 「来源与目录」文档/资源刷新间隔;「解析监控」停滞阈值、入库并发上限(1..16,版本化 + 原子切换);finalizing 设置仅在 API/DB 保留,页面不展示 |
|
||||||
| 成员与角色 | 管理员 | 成员与 viewer/engineer/admin |
|
| 成员与角色 | 管理员 | 成员与 viewer/engineer/admin |
|
||||||
|
|
||||||
## 9. 备份与恢复运维 **【新】**
|
## 9. 备份与恢复运维 **【新】**
|
||||||
|
|||||||
@@ -284,12 +284,13 @@
|
|||||||
- 立即备份:按钮变"备份进行中…"→ 约 50 秒后自动刷出新结果(异步 202 + 在途单飞,重复点击不会跑两次)
|
- 立即备份:按钮变"备份进行中…"→ 约 50 秒后自动刷出新结果(异步 202 + 在途单飞,重复点击不会跑两次)
|
||||||
- 状态:✅ 2026-10-09 面板实测(写操作仅管理员:`PUT/POST /api/v1/backup-schedule*`)
|
- 状态:✅ 2026-10-09 面板实测(写操作仅管理员:`PUT/POST /api/v1/backup-schedule*`)
|
||||||
|
|
||||||
### D5 刷新与入库
|
### D5 参数设置
|
||||||
- 入口:**系统设置 → 刷新与入库**(文档工程师可改)
|
- 入口:**系统设置 → 参数设置**(文档工程师可改)
|
||||||
- 期望:文档状态刷新间隔(15/30/60 秒)、资源刷新间隔(30/60 秒)、解析停滞判定
|
- 期望:按「来源与目录」「解析监控」两组呈现。来源与目录:文档状态刷新间隔(15/30/60 秒)、
|
||||||
(30/60 分钟)、入库并发上限(1..16)以数值输入呈现,单位与用途提示常驻,越界就地提示
|
资源刷新间隔(30/60 秒);解析监控:解析停滞阈值(30/60 分钟)、入库并发上限(1..16)。
|
||||||
并禁用保存;保存先验证再原子启用、旧版本留审计。收尾超时告警不再在本页展示;
|
四项以数值输入呈现,单位与调大/调小后果常驻,越界就地提示并禁用保存;保存先验证再原子
|
||||||
API/DB 的 `finalizing_after_seconds` 与 `finalizing` 处理状态不变。
|
启用、旧版本留审计。收尾超时告警不再在页面任何位置出现;API/DB 的
|
||||||
|
`finalizing_after_seconds` 与 `finalizing` 处理状态不变。
|
||||||
- 状态:✅(`ui_settings` 版本化激活测试;本任务补数值校验与浏览器实测)
|
- 状态:✅(`ui_settings` 版本化激活测试;本任务补数值校验与浏览器实测)
|
||||||
|
|
||||||
### D6 成员与角色
|
### D6 成员与角色
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
// @vitest-environment jsdom
|
||||||
|
import { act } from 'react'
|
||||||
|
import { createRoot, type Root } from 'react-dom/client'
|
||||||
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import { SystemSettingsView } from './SystemSettings'
|
||||||
|
import type { UISettings } from './uiSettings'
|
||||||
|
|
||||||
|
let root: Root, host: HTMLDivElement
|
||||||
|
|
||||||
|
const settings: UISettings = {
|
||||||
|
id: 'uis-active',
|
||||||
|
state: 'active',
|
||||||
|
document_refresh_seconds: 30,
|
||||||
|
resource_refresh_seconds: 30,
|
||||||
|
stalled_after_seconds: 1800,
|
||||||
|
finalizing_after_seconds: 7200,
|
||||||
|
ingestion_concurrency: 8,
|
||||||
|
test_weknora_base_url: '',
|
||||||
|
production_weknora_base_url: '',
|
||||||
|
production_tenant_id: '',
|
||||||
|
production_knowledge_base_id: '',
|
||||||
|
updated_by: 'admin',
|
||||||
|
created_at: '2026-11-24T04:15:00Z',
|
||||||
|
activated_at: '2026-11-24T04:15:00Z',
|
||||||
|
retired_at: null,
|
||||||
|
error_code: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
||||||
|
host = document.createElement('div')
|
||||||
|
document.body.append(host)
|
||||||
|
root = createRoot(host)
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await act(async () => root.unmount())
|
||||||
|
host.remove()
|
||||||
|
})
|
||||||
|
|
||||||
|
const renderView = async (onSave: (input: unknown) => void) => {
|
||||||
|
await act(async () =>
|
||||||
|
root.render(
|
||||||
|
<SystemSettingsView
|
||||||
|
sources={[]}
|
||||||
|
connections={[]}
|
||||||
|
monitor={null}
|
||||||
|
settings={settings}
|
||||||
|
productionEnabled={false}
|
||||||
|
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||||
|
loading={false}
|
||||||
|
saving={false}
|
||||||
|
error={null}
|
||||||
|
saveMessage={null}
|
||||||
|
onSave={onSave}
|
||||||
|
onSourcesChanged={() => {}}
|
||||||
|
onRefresh={() => {}}
|
||||||
|
initialSection="refresh"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const input = (label: string) => {
|
||||||
|
const found = [...host.querySelectorAll('label')]
|
||||||
|
.find((item) => item.textContent?.startsWith(label))
|
||||||
|
?.querySelector('input')
|
||||||
|
expect(found, label).toBeTruthy()
|
||||||
|
return found!
|
||||||
|
}
|
||||||
|
|
||||||
|
const type = async (label: string, value: string) => {
|
||||||
|
const target = input(label)
|
||||||
|
await act(async () => {
|
||||||
|
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!.call(target, value)
|
||||||
|
target.dispatchEvent(new Event('input', { bubbles: true }))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveButton = () =>
|
||||||
|
[...host.querySelectorAll('button')].find((item) => item.textContent?.trim() === '保存参数设置')!
|
||||||
|
|
||||||
|
describe('参数设置保存边界', () => {
|
||||||
|
it('keeps other inputs, blocks invalid saves and sends the hidden contract fields unchanged', async () => {
|
||||||
|
const onSave = vi.fn()
|
||||||
|
await renderView(onSave)
|
||||||
|
expect(saveButton().disabled).toBe(true)
|
||||||
|
|
||||||
|
await type('解析停滞阈值', '45')
|
||||||
|
expect(host.textContent).toContain('解析停滞阈值只能是 30/60 分钟;当前 45')
|
||||||
|
expect(input('解析停滞阈值').getAttribute('aria-invalid')).toBe('true')
|
||||||
|
expect(saveButton().disabled).toBe(true)
|
||||||
|
// 直接点击禁用按钮也不能绕过校验触发保存。
|
||||||
|
await act(async () => saveButton().click())
|
||||||
|
expect(onSave).not.toHaveBeenCalled()
|
||||||
|
|
||||||
|
// 同组和另一组的已填值都不因单个字段非法被清空。
|
||||||
|
expect(input('文档状态刷新间隔').value).toBe('30')
|
||||||
|
expect(input('资源刷新间隔').value).toBe('30')
|
||||||
|
expect(input('入库并发上限').value).toBe('8')
|
||||||
|
|
||||||
|
await type('解析停滞阈值', '60')
|
||||||
|
expect(input('解析停滞阈值').getAttribute('aria-invalid')).toBe('false')
|
||||||
|
expect(saveButton().disabled).toBe(false)
|
||||||
|
await act(async () => saveButton().click())
|
||||||
|
expect(onSave).toHaveBeenCalledWith({
|
||||||
|
document_refresh_seconds: 30,
|
||||||
|
resource_refresh_seconds: 30,
|
||||||
|
stalled_after_seconds: 3600,
|
||||||
|
finalizing_after_seconds: 7200,
|
||||||
|
ingestion_concurrency: 8,
|
||||||
|
test_weknora_base_url: '',
|
||||||
|
production_weknora_base_url: '',
|
||||||
|
production_tenant_id: '',
|
||||||
|
production_knowledge_base_id: '',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -182,7 +182,7 @@ describe('SystemSettingsView', () => {
|
|||||||
onRefresh={vi.fn()}
|
onRefresh={vi.fn()}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
for (const text of ['系统设置', '数据源配置', 'AI 模型连接', '知识库绑定', '存储与备份', '刷新与入库'])
|
for (const text of ['系统设置', '数据源配置', 'AI 模型连接', '知识库绑定', '存储与备份', '参数设置'])
|
||||||
expect(html).toContain(text)
|
expect(html).toContain(text)
|
||||||
// 主人 2026-10-26 要求去掉的噪声:页头副标题、刷新状态、权限条、活动版本横幅。
|
// 主人 2026-10-26 要求去掉的噪声:页头副标题、刷新状态、权限条、活动版本横幅。
|
||||||
for (const removed of [
|
for (const removed of [
|
||||||
@@ -282,21 +282,36 @@ describe('SystemSettingsView', () => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
for (const text of [
|
for (const text of [
|
||||||
'刷新与入库',
|
'参数设置',
|
||||||
|
'来源与目录',
|
||||||
|
'解析监控',
|
||||||
'文档状态刷新间隔',
|
'文档状态刷新间隔',
|
||||||
'解析监控按此周期刷新文档状态',
|
'解析监控按此周期刷新文档状态;调小更及时、请求更频繁,调大更省请求、更新更慢',
|
||||||
'资源刷新间隔',
|
'资源刷新间隔',
|
||||||
'解析监控按此周期刷新资源与服务状态',
|
'解析监控按此周期刷新资源与服务状态;调小更及时、请求更频繁,调大更省请求、更新更慢',
|
||||||
'解析停滞判定',
|
'解析停滞阈值',
|
||||||
'超过此时长没有进展就标记停滞;worker 1 分钟内生效',
|
'超过此时长没有进展就标记停滞;调大更容忍长解析,调小更快标记停滞',
|
||||||
'入库并发上限',
|
'入库并发上限',
|
||||||
'调大:入库更快,知识库写入压力更高',
|
'调大入库更快、写入压力更高;调小更稳,排队更久',
|
||||||
'保存刷新策略',
|
'保存参数设置',
|
||||||
'当前:文档 15 秒、资源 30 秒、停滞 30 分钟、入库并发 2。',
|
'当前:文档 15 秒、资源 30 秒、停滞 30 分钟、入库并发 2。',
|
||||||
])
|
])
|
||||||
expect(refreshHtml).toContain(text)
|
expect(refreshHtml).toContain(text)
|
||||||
for (const removed of ['收尾超时告警', 'finalizing', '解析停滞阈值', '保存刷新与告警参数'])
|
for (const removed of ['收尾超时告警', 'finalizing', '刷新与入库', '保存刷新与告警参数'])
|
||||||
expect(refreshHtml).not.toContain(removed)
|
expect(refreshHtml).not.toContain(removed)
|
||||||
|
const sourcesGroup = refreshHtml.slice(
|
||||||
|
refreshHtml.indexOf('data-refresh-group="sources"'),
|
||||||
|
refreshHtml.indexOf('data-refresh-group="parsing"')
|
||||||
|
)
|
||||||
|
const parsingGroup = refreshHtml.slice(refreshHtml.indexOf('data-refresh-group="parsing"'))
|
||||||
|
expect(sourcesGroup).toContain('文档状态刷新间隔')
|
||||||
|
expect(sourcesGroup).toContain('资源刷新间隔')
|
||||||
|
expect(sourcesGroup).not.toContain('解析停滞阈值')
|
||||||
|
expect(sourcesGroup).not.toContain('入库并发上限')
|
||||||
|
expect(parsingGroup).toContain('解析停滞阈值')
|
||||||
|
expect(parsingGroup).toContain('入库并发上限')
|
||||||
|
expect(parsingGroup).not.toContain('文档状态刷新间隔')
|
||||||
|
expect(parsingGroup).not.toContain('资源刷新间隔')
|
||||||
expect(refreshHtml).toContain('aria-invalid="false"')
|
expect(refreshHtml).toContain('aria-invalid="false"')
|
||||||
expect(refreshHtml).toContain('inputMode="numeric"')
|
expect(refreshHtml).toContain('inputMode="numeric"')
|
||||||
expect(visibleSaveMessage('已保存', true)).toBeNull()
|
expect(visibleSaveMessage('已保存', true)).toBeNull()
|
||||||
@@ -681,7 +696,7 @@ describe('保存边界(F03)', () => {
|
|||||||
production_knowledge_base_id: 'kb-server',
|
production_knowledge_base_id: 'kb-server',
|
||||||
} as unknown as UISettings
|
} as unknown as UISettings
|
||||||
|
|
||||||
it('保存刷新策略时忽略服务分区里未保存的地址,并原样回传 finalizing', () => {
|
it('保存参数设置时忽略服务分区里未保存的地址,并原样回传 finalizing', () => {
|
||||||
const input = refreshSettingsInput(server, {
|
const input = refreshSettingsInput(server, {
|
||||||
documentRefresh: 60,
|
documentRefresh: 60,
|
||||||
resourceRefresh: 60,
|
resourceRefresh: 60,
|
||||||
@@ -698,7 +713,7 @@ describe('保存边界(F03)', () => {
|
|||||||
expect(input.ingestion_concurrency).toBe(7)
|
expect(input.ingestion_concurrency).toBe(7)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('保存服务配置时忽略刷新分区里未保存的参数', () => {
|
it('保存服务配置时忽略参数分区里未保存的参数', () => {
|
||||||
const input = serviceSettingsInput(server, {
|
const input = serviceSettingsInput(server, {
|
||||||
testEndpoint: 'https://draft.test',
|
testEndpoint: 'https://draft.test',
|
||||||
endpoint: 'https://draft.prod',
|
endpoint: 'https://draft.prod',
|
||||||
@@ -711,7 +726,7 @@ describe('保存边界(F03)', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('刷新与入库的文本草稿解析', () => {
|
describe('参数设置的文本草稿解析', () => {
|
||||||
const drafts = (patch: Record<string, string> = {}) => ({ ...refreshDraftText(settings), ...patch })
|
const drafts = (patch: Record<string, string> = {}) => ({ ...refreshDraftText(settings), ...patch })
|
||||||
|
|
||||||
it('把活动设置转成带单位的草稿(停滞用分钟)', () => {
|
it('把活动设置转成带单位的草稿(停滞用分钟)', () => {
|
||||||
@@ -773,6 +788,13 @@ describe('刷新与入库的文本草稿解析', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('错误文案使用完整字段名', () => {
|
||||||
|
expect(parseRefreshDrafts(drafts({ documentRefresh: '1' })).errors.documentRefresh).toContain(
|
||||||
|
'文档状态刷新间隔只能是 15/30/60 秒'
|
||||||
|
)
|
||||||
|
expect(parseRefreshDrafts(drafts({ stalled: '45' })).errors.stalled).toContain('解析停滞阈值只能是 30/60 分钟')
|
||||||
|
})
|
||||||
|
|
||||||
it('任一字段非法时整体 values 为 null,避免夹带默认值保存', () => {
|
it('任一字段非法时整体 values 为 null,避免夹带默认值保存', () => {
|
||||||
const parsed = parseRefreshDrafts(drafts({ concurrency: '99' }))
|
const parsed = parseRefreshDrafts(drafts({ concurrency: '99' }))
|
||||||
expect(parsed.values).toBeNull()
|
expect(parsed.values).toBeNull()
|
||||||
|
|||||||
+67
-66
@@ -22,7 +22,13 @@ import { archiveSourceConnection, fetchSourceConnectionList } from './sourceConn
|
|||||||
import type { SourceConnectionListItem } from './sourceConnections'
|
import type { SourceConnectionListItem } from './sourceConnections'
|
||||||
import { activateUISettings, createUISettingsCandidate, fetchActiveUISettings } from './uiSettings'
|
import { activateUISettings, createUISettingsCandidate, fetchActiveUISettings } from './uiSettings'
|
||||||
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
||||||
import { parseRefreshDrafts, refreshDraftText, refreshSettingsDirty, refreshSettingsInput } from './settingsInputs'
|
import {
|
||||||
|
parseRefreshDrafts,
|
||||||
|
REFRESH_FIELD_META,
|
||||||
|
refreshDraftText,
|
||||||
|
refreshSettingsDirty,
|
||||||
|
refreshSettingsInput,
|
||||||
|
} from './settingsInputs'
|
||||||
import type { RefreshDrafts, RefreshField } from './settingsInputs'
|
import type { RefreshDrafts, RefreshField } from './settingsInputs'
|
||||||
import './systemSettings.css'
|
import './systemSettings.css'
|
||||||
|
|
||||||
@@ -64,35 +70,21 @@ const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [
|
|||||||
{ key: 'services', label: 'AI 模型连接' },
|
{ key: 'services', label: 'AI 模型连接' },
|
||||||
{ key: 'knowledge-bindings', label: '知识库绑定' },
|
{ key: 'knowledge-bindings', label: '知识库绑定' },
|
||||||
{ key: 'storage', label: '存储与备份' },
|
{ key: 'storage', label: '存储与备份' },
|
||||||
{ key: 'refresh', label: '刷新与入库' },
|
{ key: 'refresh', label: '参数设置' },
|
||||||
{ key: 'members', label: '成员与角色', adminOnly: true },
|
{ key: 'members', label: '成员与角色', adminOnly: true },
|
||||||
] as { key: SectionKey; label: string; adminOnly?: boolean }[]
|
] as { key: SectionKey; label: string; adminOnly?: boolean }[]
|
||||||
|
|
||||||
const refreshFields: { key: RefreshField; label: string; unit: string; hint: string }[] = [
|
const refreshHints: Record<RefreshField, string> = {
|
||||||
{
|
documentRefresh: '解析监控按此周期刷新文档状态;调小更及时、请求更频繁,调大更省请求、更新更慢',
|
||||||
key: 'documentRefresh',
|
resourceRefresh: '解析监控按此周期刷新资源与服务状态;调小更及时、请求更频繁,调大更省请求、更新更慢',
|
||||||
label: '文档状态刷新间隔',
|
stalled: '超过此时长没有进展就标记停滞;调大更容忍长解析,调小更快标记停滞',
|
||||||
unit: '秒',
|
concurrency: '调大入库更快、写入压力更高;调小更稳,排队更久',
|
||||||
hint: '解析监控按此周期刷新文档状态',
|
}
|
||||||
},
|
|
||||||
{
|
// 产品定义的分组与归属,顺序即页面呈现顺序。
|
||||||
key: 'resourceRefresh',
|
const refreshGroups: { key: string; title: string; fields: RefreshField[] }[] = [
|
||||||
label: '资源刷新间隔',
|
{ key: 'sources', title: '来源与目录', fields: ['documentRefresh', 'resourceRefresh'] },
|
||||||
unit: '秒',
|
{ key: 'parsing', title: '解析监控', fields: ['stalled', 'concurrency'] },
|
||||||
hint: '解析监控按此周期刷新资源与服务状态',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'stalled',
|
|
||||||
label: '解析停滞判定',
|
|
||||||
unit: '分钟',
|
|
||||||
hint: '超过此时长没有进展就标记停滞;worker 1 分钟内生效',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'concurrency',
|
|
||||||
label: '入库并发上限',
|
|
||||||
unit: '个',
|
|
||||||
hint: '调大:入库更快,知识库写入压力更高',
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const sourceTypeLabels: Record<string, string> = {
|
const sourceTypeLabels: Record<string, string> = {
|
||||||
@@ -156,8 +148,8 @@ export function SystemSettingsView({
|
|||||||
const refreshDirty = settings ? refreshSettingsDirty(refreshDrafts, settings) : false
|
const refreshDirty = settings ? refreshSettingsDirty(refreshDrafts, settings) : false
|
||||||
const canSave = Boolean(settings && !saving && parsedRefresh.values)
|
const canSave = Boolean(settings && !saving && parsedRefresh.values)
|
||||||
const isAdmin = identity?.role === 'admin'
|
const isAdmin = identity?.role === 'admin'
|
||||||
// 保存边界:刷新分区只带刷新草稿;知识库绑定的连接/选库草稿在独立组件内一次保存,
|
// 保存边界:参数分区只带参数草稿;知识库绑定的连接/选库草稿在独立组件内一次保存,
|
||||||
// 互不夹带(未保存的地址不会因为保存刷新策略被写进去)。
|
// 互不夹带(未保存的地址不会因为保存参数设置被写进去)。
|
||||||
const refreshInput = (): UISettingsCandidateInput =>
|
const refreshInput = (): UISettingsCandidateInput =>
|
||||||
settings && parsedRefresh.values
|
settings && parsedRefresh.values
|
||||||
? refreshSettingsInput(settings, parsedRefresh.values)
|
? refreshSettingsInput(settings, parsedRefresh.values)
|
||||||
@@ -270,54 +262,63 @@ export function SystemSettingsView({
|
|||||||
<section className="settings-panel wide" id="settings-refresh">
|
<section className="settings-panel wide" id="settings-refresh">
|
||||||
<div className="settings-section-heading">
|
<div className="settings-section-heading">
|
||||||
<div>
|
<div>
|
||||||
<h2>刷新与入库</h2>
|
<h2>参数设置</h2>
|
||||||
<p>保存只改这一组参数,不会带上「知识库绑定」里未保存的连接地址。</p>
|
|
||||||
</div>
|
</div>
|
||||||
<span className="safe-badge">当前活动版本</span>
|
<span className="safe-badge">当前活动版本</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="safe-setting-grid">
|
<div className="settings-param-groups">
|
||||||
{refreshFields.map((field) => {
|
{refreshGroups.map((group) => (
|
||||||
const error = parsedRefresh.errors[field.key]
|
<section className="settings-param-group" key={group.key} data-refresh-group={group.key}>
|
||||||
const hintID = `refresh-${field.key}-hint`
|
<h3>{group.title}</h3>
|
||||||
const errorID = `refresh-${field.key}-error`
|
<div className="safe-setting-grid">
|
||||||
return (
|
{group.fields.map((key) => {
|
||||||
<label key={field.key}>
|
const meta = REFRESH_FIELD_META[key]
|
||||||
{field.label}
|
const hint = refreshHints[key]
|
||||||
<span className="settings-field-control">
|
const error = parsedRefresh.errors[key]
|
||||||
<input
|
const hintID = `refresh-${key}-hint`
|
||||||
type="text"
|
const errorID = `refresh-${key}-error`
|
||||||
inputMode="numeric"
|
return (
|
||||||
autoComplete="off"
|
<label key={key}>
|
||||||
value={refreshDrafts[field.key]}
|
{meta.label}
|
||||||
aria-invalid={error ? 'true' : 'false'}
|
<span className="settings-field-control">
|
||||||
aria-describedby={error ? `${hintID} ${errorID}` : hintID}
|
<input
|
||||||
onChange={(event) =>
|
type="text"
|
||||||
setRefreshDrafts((drafts) => ({ ...drafts, [field.key]: event.target.value }))
|
inputMode="numeric"
|
||||||
}
|
autoComplete="off"
|
||||||
/>
|
value={refreshDrafts[key]}
|
||||||
<span className="settings-field-unit">{field.unit}</span>
|
aria-invalid={error ? 'true' : 'false'}
|
||||||
</span>
|
aria-describedby={error ? `${hintID} ${errorID}` : hintID}
|
||||||
<small className="settings-field-hint" id={hintID}>
|
onChange={(event) =>
|
||||||
{field.hint}
|
setRefreshDrafts((drafts) => ({ ...drafts, [key]: event.target.value }))
|
||||||
</small>
|
}
|
||||||
{error ? (
|
/>
|
||||||
<span className="settings-field-error" id={errorID} role="alert">
|
<span className="settings-field-unit">{meta.unit}</span>
|
||||||
{error}
|
</span>
|
||||||
</span>
|
<small className="settings-field-hint" id={hintID}>
|
||||||
) : null}
|
{hint}
|
||||||
</label>
|
</small>
|
||||||
)
|
{error ? (
|
||||||
})}
|
<span className="settings-field-error" id={errorID} role="alert">
|
||||||
|
{error}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
<button onClick={() => onSave(refreshInput())} disabled={!canSave || !refreshDirty}>
|
<button onClick={() => onSave(refreshInput())} disabled={!canSave || !refreshDirty}>
|
||||||
{saving ? '正在验证并应用…' : '保存刷新策略'}
|
{saving ? '正在验证并应用…' : '保存参数设置'}
|
||||||
</button>
|
</button>
|
||||||
{visibleSaveMessage(saveMessage, refreshDirty) ? (
|
{visibleSaveMessage(saveMessage, refreshDirty) ? (
|
||||||
<p className="success-message" role="status">
|
<p className="success-message" role="status">
|
||||||
{saveMessage}
|
{saveMessage}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
) : null}
|
||||||
<p className="settings-warn">解析停滞判定保存后由 worker 在 1 分钟内生效。</p>
|
<p className="settings-warn">解析停滞阈值保存后由 worker 在 1 分钟内生效。</p>
|
||||||
|
<p className="settings-hint">保存只改这组参数,不会带上「知识库绑定」里未保存的连接地址。</p>
|
||||||
<small>
|
<small>
|
||||||
{`当前:文档 ${settings.document_refresh_seconds} 秒、资源 ${settings.resource_refresh_seconds} 秒、停滞 ${settings.stalled_after_seconds / 60} 分钟、入库并发 ${settings.ingestion_concurrency}。`}
|
{`当前:文档 ${settings.document_refresh_seconds} 秒、资源 ${settings.resource_refresh_seconds} 秒、停滞 ${settings.stalled_after_seconds / 60} 分钟、入库并发 ${settings.ingestion_concurrency}。`}
|
||||||
</small>
|
</small>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
||||||
|
|
||||||
// 保存边界是纯函数:连接分区只取连接草稿,刷新分区只取刷新草稿,
|
// 保存边界是纯函数:连接分区只取连接草稿,参数分区只取参数草稿,
|
||||||
// 另一侧一律用服务器当前值。组件与测试共用同一实现。
|
// 另一侧一律用服务器当前值。组件与测试共用同一实现。
|
||||||
export interface ServiceDrafts {
|
export interface ServiceDrafts {
|
||||||
testEndpoint: string
|
testEndpoint: string
|
||||||
@@ -16,9 +16,12 @@ export type RefreshParseResult = {
|
|||||||
errors: Record<RefreshField, string | null>
|
errors: Record<RefreshField, string | null>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RefreshRule {
|
export interface RefreshFieldMeta {
|
||||||
label: string
|
label: string
|
||||||
unit?: '秒' | '分钟'
|
unit: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RefreshRule extends RefreshFieldMeta {
|
||||||
allowed?: number[]
|
allowed?: number[]
|
||||||
min?: number
|
min?: number
|
||||||
max?: number
|
max?: number
|
||||||
@@ -26,11 +29,19 @@ interface RefreshRule {
|
|||||||
toStored: (value: number) => number
|
toStored: (value: number) => number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 展示与错误文案共用同一份字段名/单位,避免两处各写一遍后漂移。
|
||||||
|
export const REFRESH_FIELD_META: Record<RefreshField, RefreshFieldMeta> = {
|
||||||
|
documentRefresh: { label: '文档状态刷新间隔', unit: '秒' },
|
||||||
|
resourceRefresh: { label: '资源刷新间隔', unit: '秒' },
|
||||||
|
stalled: { label: '解析停滞阈值', unit: '分钟' },
|
||||||
|
concurrency: { label: '入库并发上限', unit: '个' },
|
||||||
|
}
|
||||||
|
|
||||||
const REFRESH_RULES: Record<RefreshField, RefreshRule> = {
|
const REFRESH_RULES: Record<RefreshField, RefreshRule> = {
|
||||||
documentRefresh: { label: '文档刷新间隔', unit: '秒', allowed: [15, 30, 60], toStored: (value) => value },
|
documentRefresh: { ...REFRESH_FIELD_META.documentRefresh, allowed: [15, 30, 60], toStored: (value) => value },
|
||||||
resourceRefresh: { label: '资源刷新间隔', unit: '秒', allowed: [30, 60], toStored: (value) => value },
|
resourceRefresh: { ...REFRESH_FIELD_META.resourceRefresh, allowed: [30, 60], toStored: (value) => value },
|
||||||
stalled: { label: '解析停滞判定', unit: '分钟', allowed: [30, 60], toStored: (value) => value * 60 },
|
stalled: { ...REFRESH_FIELD_META.stalled, allowed: [30, 60], toStored: (value) => value * 60 },
|
||||||
concurrency: { label: '入库并发上限', min: 1, max: 16, toStored: (value) => value },
|
concurrency: { ...REFRESH_FIELD_META.concurrency, min: 1, max: 16, toStored: (value) => value },
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseField = (field: RefreshField, rawDraft: string): { value: number | null; error: string | null } => {
|
const parseField = (field: RefreshField, rawDraft: string): { value: number | null; error: string | null } => {
|
||||||
@@ -94,7 +105,7 @@ export const refreshSettingsInput = (settings: UISettings, values: RefreshValues
|
|||||||
document_refresh_seconds: values.documentRefresh as UISettings['document_refresh_seconds'],
|
document_refresh_seconds: values.documentRefresh as UISettings['document_refresh_seconds'],
|
||||||
resource_refresh_seconds: values.resourceRefresh as UISettings['resource_refresh_seconds'],
|
resource_refresh_seconds: values.resourceRefresh as UISettings['resource_refresh_seconds'],
|
||||||
stalled_after_seconds: values.stalled as UISettings['stalled_after_seconds'],
|
stalled_after_seconds: values.stalled as UISettings['stalled_after_seconds'],
|
||||||
// 刷新分区不展示收尾超时,但契约必填且写侧按服务器值判权限:原样回传,绝不置空。
|
// 参数分区不展示收尾超时,但契约必填且写侧按服务器值判权限:原样回传,绝不置空。
|
||||||
finalizing_after_seconds: settings.finalizing_after_seconds,
|
finalizing_after_seconds: settings.finalizing_after_seconds,
|
||||||
ingestion_concurrency: values.concurrency,
|
ingestion_concurrency: values.concurrency,
|
||||||
test_weknora_base_url: settings.test_weknora_base_url,
|
test_weknora_base_url: settings.test_weknora_base_url,
|
||||||
|
|||||||
@@ -155,10 +155,28 @@
|
|||||||
color: var(--ink-mute);
|
color: var(--ink-mute);
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
}
|
}
|
||||||
|
.settings-param-groups {
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
.settings-param-group + .settings-param-group {
|
||||||
|
border-top: 1px solid var(--border-base);
|
||||||
|
padding-top: 14px;
|
||||||
|
}
|
||||||
|
.settings-param-group h3 {
|
||||||
|
margin: 0 0 10px;
|
||||||
|
color: var(--ink-base);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.settings-hint {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
color: var(--ink-mute);
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
.safe-setting-grid {
|
.safe-setting-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
gap: 10px;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
.safe-setting-grid label {
|
.safe-setting-grid label {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -166,7 +184,6 @@
|
|||||||
color: var(--ink-mute);
|
color: var(--ink-mute);
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
.safe-setting-grid select,
|
|
||||||
.safe-setting-grid input {
|
.safe-setting-grid input {
|
||||||
border: 1px solid var(--border-strong);
|
border: 1px solid var(--border-strong);
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
|
|||||||
Reference in New Issue
Block a user