diff --git a/web/src/ReleaseTargets.tsx b/web/src/ReleaseTargets.tsx index b64e40d..a287e74 100644 --- a/web/src/ReleaseTargets.tsx +++ b/web/src/ReleaseTargets.tsx @@ -32,6 +32,7 @@ import { useOptionalAuth } from './auth' import './releaseTargets.css' import { RestoreVerificationSection } from './RestoreVerificationSection' import { fetchSnapshotVerification } from './restoreVerification' +import { fetchRoutingBindings } from './routingBindings' // 一个知识库对应一个发布工作区。主操作随封存、授权、执行状态推进; // 诊断按需展开,维护占用与失败恢复始终可见。 @@ -106,6 +107,8 @@ interface ViewProps { notice: string | null scope: Scope onScope: (scope: Scope) => void + // 真实库名(来自测试知识库绑定):scope 是业务名,光看"对内知识库"对不上 WeKnora 里的库。 + kbNames?: Record drawerOpen: boolean onDrawer: (open: boolean) => void expandedSnapshot: string | null @@ -175,6 +178,11 @@ function scopeView( } const scopeName = (scope: Scope) => (scope === 'internal' ? '对内知识库' : '对外知识库') +// 绑定里拿不到库名时只显示业务名,不编一个名字出来。 +const scopeTitle = (scope: Scope, kbName?: string) => { + const kb = kbName?.trim() + return kb ? `${scopeName(scope)} · ${kb}` : scopeName(scope) +} // 生产目标必须按接口的四类状态原样呈现:把"已读且为空"和"读不到"都写成"未知", // 会让人去点一个必然被拒绝的"建立基线"(后端对空目标返回 409 library_baseline_target_empty, @@ -1794,6 +1802,8 @@ function Drawer({ ) } +const viewScopeLabel = (scope: Scope, kbNames?: Record) => scopeTitle(scope, kbNames?.[scope]) + export function ReleaseTargetsView(props: ViewProps) { const { page, @@ -1805,6 +1815,7 @@ export function ReleaseTargetsView(props: ViewProps) { notice, scope, onScope, + kbNames, drawerOpen, onDrawer, expandedSnapshot, @@ -1932,7 +1943,7 @@ export function ReleaseTargetsView(props: ViewProps) { className={isSelected ? 'rel-tab selected' : 'rel-tab'} onClick={() => onScope(item.scope)} > - {scopeName(item.scope)} + {viewScopeLabel(item.scope, kbNames)} {status.text} ) @@ -1956,7 +1967,7 @@ export function ReleaseTargetsView(props: ViewProps) {

- {scopeName(scope)} ·{' '} + {viewScopeLabel(scope, kbNames)} ·{' '} {active ? `${jobKindText(view.job?.kind)}进行中` : view.snapshot @@ -2191,6 +2202,8 @@ export function ReleaseTargets() { const [drawerOpen, setDrawerOpen] = useState(false) const [expandedSnapshot, setExpandedSnapshot] = useState(null) const [pendingCapture, setPendingCapture] = useState(false) + // 真实库名只用于显示:读不到就退回业务名,不让它影响发布状态。 + const [kbNames, setKbNames] = useState>({ internal: '', external: '' }) const [pendingReconcileCapture, setPendingReconcileCapture] = useState('') const [now, setNow] = useState(() => Date.now()) @@ -2198,15 +2211,24 @@ export function ReleaseTargets() { const seq = ++loadSeq.current setLoading(true) try { - const [snapshots, captures, internalOverview, externalOverview, internalMaintenance, externalMaintenance] = - await Promise.all([ - fetchLibrarySnapshots(signal), - fetchLibraryCaptures(signal), - fetchLibraryOverview('internal', signal), - fetchLibraryOverview('external', signal), - fetchLibraryMaintenance('internal', signal), - fetchLibraryMaintenance('external', signal), - ]) + const [ + snapshots, + captures, + internalOverview, + externalOverview, + internalMaintenance, + externalMaintenance, + bindings, + ] = await Promise.all([ + fetchLibrarySnapshots(signal), + fetchLibraryCaptures(signal), + fetchLibraryOverview('internal', signal), + fetchLibraryOverview('external', signal), + fetchLibraryMaintenance('internal', signal), + fetchLibraryMaintenance('external', signal), + // 库名只是展示用:读不到(未登录/WeKnora 未连接)不能让整页报错。 + fetchRoutingBindings(signal).catch(() => null), + ]) // 只读既有作业详情接口,按维护记录的 owner_job_id 精确取;读不到就记下来, // 不用 overview 的最新作业兜底(那是另一件事,会把失败窗口显示成已完成)。 const ownerIDs = { @@ -2228,6 +2250,9 @@ export function ReleaseTargets() { setOverviews({ internal: internalOverview, external: externalOverview }) setMaintenances({ internal: internalMaintenance, external: externalMaintenance }) setMaintenanceJobs({ internal: internalOwnerJob, external: externalOwnerJob }) + if (bindings) { + setKbNames({ internal: bindings.internal_kb_name, external: bindings.external_kb_name }) + } setNow(Date.now()) setError(null) } catch (loadError) { @@ -2486,6 +2511,7 @@ export function ReleaseTargets() { // F10: 旧操作通知属于旧作业/旧对象,切范围后不得继续挂在页顶。 setNotice(null) }} + kbNames={kbNames} drawerOpen={drawerOpen} onDrawer={setDrawerOpen} expandedSnapshot={expandedSnapshot}