diff --git a/web/src/ProductionBindingsSection.tsx b/web/src/ProductionBindingsSection.tsx index 3d02a66..79b8f5d 100644 --- a/web/src/ProductionBindingsSection.tsx +++ b/web/src/ProductionBindingsSection.tsx @@ -6,7 +6,7 @@ import type { ProductionBindings } from './productionBindings' import type { KnowledgeBaseOption } from './routingBindings' // 「生产知识库绑定」:发布链路的 源库 → 目标库 映射。这里选的是发布要写入的 -// 生产(目标)知识库,与上面的「知识库绑定」(测试端收件库)是两件事。 +// 生产(目标)知识库,与上面的「测试知识库绑定」(测试端收件库)是两件事。 export function ProductionBindingsSection() { const auth = useOptionalAuth() const isAdmin = auth?.identity?.role === 'admin' diff --git a/web/src/RoutingBindingsSection.tsx b/web/src/RoutingBindingsSection.tsx index 1dc8252..3b5322d 100644 --- a/web/src/RoutingBindingsSection.tsx +++ b/web/src/RoutingBindingsSection.tsx @@ -24,7 +24,7 @@ export function RoutingBindingsSection() { setInternalDraft(next.internal_bound_by_ui ? next.internal_kb_id : '') setExternalDraft(next.external_bound_by_ui ? next.external_kb_id : '') try { setOptions(await fetchRoutingBindingOptions()) } catch { setOptions([]) } - } catch (cause) { setError(cause instanceof Error ? cause.message : '读取知识库绑定失败') } + } catch (cause) { setError(cause instanceof Error ? cause.message : '读取测试知识库绑定失败') } finally { setLoading(false) } }, []) useEffect(() => { void load() }, [load]) @@ -41,7 +41,7 @@ export function RoutingBindingsSection() { ? `;同时把 ${next.replanned} 项还没上传的待入库重新指向新库${next.retired_duplicates ? `,${next.retired_duplicates} 项因新库里已有同篇而被退休` : ''}` : '' setMessage(`绑定已生效:对内 ${next.internal_kb_name || next.internal_kb_id.slice(0, 8) || '未绑定'} · 对外 ${next.external_kb_name || next.external_kb_id.slice(0, 8) || '未绑定'}。此后“来源与目录”的标记按新绑定路由${replan}。`) - } catch (cause) { setError(cause instanceof Error ? cause.message : '保存知识库绑定失败') } + } catch (cause) { setError(cause instanceof Error ? cause.message : '保存测试知识库绑定失败') } finally { setSaving(false) } } @@ -63,7 +63,7 @@ export function RoutingBindingsSection() { ) return - 知识库绑定“来源与目录”里的对内 / 对外标记按这里的绑定分发到对应 WeKnora 知识库;保存后立即生效,无需重启。 void load()} disabled={loading}>{loading ? '读取中…' : '重新读取'} + 测试知识库绑定“来源与目录”里的对内 / 对外标记按这里的绑定分发到对应的测试 WeKnora 知识库;保存后立即生效,无需重启。发布写入的生产知识库见「生产知识库绑定」。 void load()} disabled={loading}>{loading ? '读取中…' : '重新读取'} {error ? {error} : null} {bindings ? {renderSide('对内知识库', bindings.internal_kb_id, bindings.internal_kb_name, bindings.internal_env_fallback, bindings.internal_bound_by_ui)} @@ -78,6 +78,6 @@ export function RoutingBindingsSection() { void save()} disabled={saving || !dirty || sameSelection}>{saving ? '正在校验并保存…' : '保存绑定'} {message ? {message} : null} : null} - {!isAdmin ? 仅管理员可修改知识库绑定。 : null} + {!isAdmin ? 仅管理员可修改测试知识库绑定。 : null} } diff --git a/web/src/SystemSettings.test.tsx b/web/src/SystemSettings.test.tsx index 24e1a8e..1c00b22 100644 --- a/web/src/SystemSettings.test.tsx +++ b/web/src/SystemSettings.test.tsx @@ -58,14 +58,19 @@ describe('SystemSettingsView',()=>{ it('lets an administrator bind the internal/external import knowledge bases from 系统设置',()=>{ // 组件一直在(RoutingBindingsSection),但从未挂到任何页面 —— 导入目标库只能靠 // 部署 env 钉死,换库必须重建容器。 - const view=(section:'sources'|'bindings')=>renderToStaticMarkup() - 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 view=(section:'sources'|'bindings'|'production-bindings')=>renderToStaticMarkup() + 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() expect(html).toContain('加载失败');expect(html).not.toContain('模拟运行中') diff --git a/web/src/SystemSettings.tsx b/web/src/SystemSettings.tsx index 07b0bc0..2bb4177 100644 --- a/web/src/SystemSettings.tsx +++ b/web/src/SystemSettings.tsx @@ -41,7 +41,7 @@ type SectionKey = 'sources' | 'services' | 'bindings' | 'production-bindings' | const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [ { key: 'sources', label: '数据源配置' }, { key: 'services', label: '服务配置' }, - { key: 'bindings', label: '知识库绑定' }, + { key: 'bindings', label: '测试知识库绑定' }, { key: 'production-bindings', label: '生产知识库绑定' }, { key: 'storage', label: '存储与备份' }, { key: 'refresh', label: '刷新策略' }, diff --git a/web/src/routingBindings.ts b/web/src/routingBindings.ts index b360455..7424f5b 100644 --- a/web/src/routingBindings.ts +++ b/web/src/routingBindings.ts @@ -43,9 +43,9 @@ function bindingProjection(item: Record): RoutingBindings { export async function fetchRoutingBindings(signal?: AbortSignal): Promise { const response = await fetch('/api/v1/routing-bindings', { signal, headers: { Accept: 'application/json' } }) - if (!response.ok) throw new Error(`读取知识库绑定失败(HTTP ${response.status})`) + if (!response.ok) throw new Error(`读取测试知识库绑定失败(HTTP ${response.status})`) const value = await response.json() as unknown - if (!record(value) || !record(value.data)) throw new Error('知识库绑定响应无效') + if (!record(value) || !record(value.data)) throw new Error('测试知识库绑定响应无效') return bindingProjection(value.data) } @@ -68,11 +68,11 @@ export async function saveRoutingBindings(input: { internal_kb_id: string; exter body: JSON.stringify(input), }) if (!response.ok) { - let reason = `保存知识库绑定失败(HTTP ${response.status})` + let reason = `保存测试知识库绑定失败(HTTP ${response.status})` try { const body = await response.json() as unknown; if (record(body) && typeof body.error === 'string') reason = body.error } catch { /* keep status text */ } throw new Error(reason) } const value = await response.json() as unknown - if (!record(value) || !record(value.data)) throw new Error('知识库绑定响应无效') + if (!record(value) || !record(value.data)) throw new Error('测试知识库绑定响应无效') return bindingProjection(value.data) }
“来源与目录”里的对内 / 对外标记按这里的绑定分发到对应 WeKnora 知识库;保存后立即生效,无需重启。
“来源与目录”里的对内 / 对外标记按这里的绑定分发到对应的测试 WeKnora 知识库;保存后立即生效,无需重启。发布写入的生产知识库见「生产知识库绑定」。
{error}
{message}
仅管理员可修改知识库绑定。
仅管理员可修改测试知识库绑定。