diff --git a/web/src/SourceCatalogBrowser.test.tsx b/web/src/SourceCatalogBrowser.test.tsx index 5c41155..c5d7610 100644 --- a/web/src/SourceCatalogBrowser.test.tsx +++ b/web/src/SourceCatalogBrowser.test.tsx @@ -27,6 +27,7 @@ describe('SourceCatalogBrowserView',()=>{ expect(html).toContain('aria-label="返回上一级"') expect(html).not.toContain('role="tree"') expect(html).not.toContain('目录树') + for(const text of ['禁止导入即生效','大小','大小未提供','总大小','已知合计'])expect(html).not.toContain(text) expect(html).toContain('
') expect(html).toContain('文件格式筛选') expect(html).not.toMatch(/]*class="catalog-format-filter"[^>]*open/) @@ -104,7 +105,7 @@ describe('SourceCatalogBrowserView',()=>{ it('shows policy as a read-only table state and offers top-level policy buttons',()=>{ const nested={...page,current:{...page.current,node_id:'folder-1',parent_node_id:'root-1',name:'01|产品总览与定位'},breadcrumbs:[...page.breadcrumbs,{node_id:'folder-1',name:'01|产品总览与定位'}],items:[node('可入队.pdf','file','file-ready'),node('已知目录','folder','folder-known'),{...node('大小未知目录','folder','folder-unknown'),subtree_bytes:0},{...node('只有元数据.pdf','file','file-meta'),size_bytes:undefined,routable_count:0}],total:4} const html=renderToStaticMarkup() - for(const text of ['名称','处理策略','全选当前页','对内','对外','禁止导入','禁止导入即生效:待入库条目自动撤销','aria-label="选择可入队.pdf"','大小未提供','已知合计 1.0 KB'])expect(html).toContain(text) + for(const text of ['名称','处理策略','全选当前页','对内','对外','禁止导入','aria-label="选择可入队.pdf"'])expect(html).toContain(text) for(const text of ['class="catalog-policy-actions"','class="internal-policy-button"','class="external-policy-button"','class="blocked-policy-button"','class="selected-count"'])expect(html).toContain(text) for(const text of ['操作人','判断原因','名称与处理策略','当前策略','选择策略','批量处理策略','应用策略','对内 + 对外','={dingtalk:'钉钉知识库',pp:'PP资料下载中心',alist:'AList文件源'} -const bytes=(value:number)=>value>=1073741824?`${(value/1073741824).toFixed(1)} GB`:value>=1048576?`${(value/1048576).toFixed(1)} MB`:value>=1024?`${(value/1024).toFixed(1)} KB`:`${value} B` const duration=(milliseconds:number)=>milliseconds<=0?'未记录':milliseconds<1000?`${milliseconds}毫秒`:milliseconds<60000?`${Math.round(milliseconds/1000)}秒`:`${Math.floor(milliseconds/60000)}分${Math.round(milliseconds%60000/1000)}秒` const scope=(value:string)=>value==='internal'?'对内':value==='external'?'对外':value==='both'?'对内 + 对外':value==='blocked'?'禁止导入':value==='mixed'?'混合':'未选择' const progress=(node:CatalogNode)=>node.imported_count?`已解析 ${node.parsed_count} / 已导入 ${node.imported_count}`:'尚未导入' @@ -70,7 +69,7 @@ export function SourceCatalogBrowserView({sources,selectedSource,page,loading,er -
{page.current.name}{selectedSource.snapshot_only?'本地只读快照,不代表实时连接':'实时目录'}
{atSourceRoot?`第一层目录 ${page.items.filter(node=>node.node_type==='folder').length}`:`当前子项 ${page.total}`}含所有子目录文件 {page.current.subtree_file_count}总大小 {bytes(page.current.subtree_bytes)}
+
{page.current.name}{selectedSource.snapshot_only?'本地只读快照,不代表实时连接':'实时目录'}
{atSourceRoot?`第一层目录 ${page.items.filter(node=>node.node_type==='folder').length}`:`当前子项 ${page.total}`}含所有子目录文件 {page.current.subtree_file_count}
文件格式筛选 item.name).join('/')} label={atSourceRoot?'整个来源':'当前目录'} onChanged={onFiltersChanged} /> @@ -81,10 +80,9 @@ export function SourceCatalogBrowserView({sources,selectedSource,page,loading,er
已选 {selectedCount} 项
- 禁止导入即生效:待入库条目自动撤销;仍在测试库里的文件会出现在“解析监控 → 需下架”暴露差异,移除走 test.remove 工作流;不删除来源文件,也不操作生产知识库。 {routingMessage?

{routingMessage}

:null} :null} - {visibleItems.length?
{visibleItems.map(node=>{const visibility=appliedPolicies[node.node_id]||node.visibility;const size=node.node_type==='folder'?(node.subtree_bytes>0?`已知合计 ${bytes(node.subtree_bytes)}`:'大小未提供'):typeof node.size_bytes==='number'?bytes(node.size_bytes):'大小未提供';return })}
名称类型处理策略文件数量导入与解析大小更新时间
{node.node_type==='folder'?
toggleNode(node.node_id)} />
:}
{node.node_type==='folder'?'文件夹':'文件'}
{scope(visibility)}
{node.node_type==='folder'?`${node.subtree_file_count} 份`:'—'}{progress(node)}{node.active_count?处理中 {node.active_count}:null}{node.failed_count?失败 {node.failed_count}:null}{size}{node.modified_at?new Date(node.modified_at).toLocaleString('zh-CN',{hour12:false}):'—'}
:
当前目录为空。
} + {visibleItems.length?
{visibleItems.map(node=>{const visibility=appliedPolicies[node.node_id]||node.visibility;return })}
名称类型处理策略文件数量导入与解析更新时间
{node.node_type==='folder'?
toggleNode(node.node_id)} />
:}
{node.node_type==='folder'?'文件夹':'文件'}
{scope(visibility)}
{node.node_type==='folder'?`${node.subtree_file_count} 份`:'—'}{progress(node)}{node.active_count?处理中 {node.active_count}:null}{node.failed_count?失败 {node.failed_count}:null}{node.modified_at?new Date(node.modified_at).toLocaleString('zh-CN',{hour12:false}):'—'}
:
当前目录为空。
} {page.total>page.limit?
第 {Math.floor(page.offset/page.limit)+1} / {Math.max(1,Math.ceil(page.total/page.limit))} 页
:null}
快照就绪快照时间:{new Date(selectedSource.observed_at).toLocaleString('zh-CN',{hour12:false})}上次刷新耗时 {duration(selectedSource.last_refresh_duration_ms)}{history?:null}
{history&&history.open?:null} diff --git a/web/src/sourceCatalogBrowser.css b/web/src/sourceCatalogBrowser.css index a411943..25fd460 100644 --- a/web/src/sourceCatalogBrowser.css +++ b/web/src/sourceCatalogBrowser.css @@ -4,10 +4,10 @@ .catalog-back-row{border-bottom:1px solid var(--border-base);padding:8px 16px}.catalog-back-row button{border:0;padding:6px 8px;background:transparent;box-shadow:none;color:var(--c-run)}.snapshot-timestamp{padding:10px 16px;color:var(--ink-mute);font-size:10px;text-align:right} .catalog-routing{display:grid;gap:9px;border-bottom:1px solid var(--border-base);padding:11px 16px;background:var(--bg-soft)}.routing-fields,.routing-actions{display:flex;flex-wrap:wrap;align-items:end;gap:9px}.routing-fields label{display:grid;gap:4px;color:var(--ink-mute);font-size:9px}.routing-fields input{border:1px solid var(--border-strong);border-radius:6px;padding:7px}.routing-check{display:flex!important;align-items:center;gap:5px;padding-bottom:7px}.routing-actions span{margin-right:auto;color:var(--ink-mute);font-size:10px}.routing-actions button{padding:7px 9px}.catalog-routing p{margin:0;border-radius:6px;padding:7px;background:var(--c-done-bg);color:var(--c-done);font-size:10px}.catalog-file-routing{display:grid;gap:6px}.catalog-file-routing .catalog-file{align-items:center}.catalog-file-routing select{width:max-content;max-width:100%;border:1px solid var(--border-strong);border-radius:6px;padding:5px;background:var(--bg-panel);color:var(--ink-base);font-size:9px}.catalog-file-routing small{color:var(--c-warn);font-size:9px} .catalog-refresh-progress{display:grid;grid-template-columns:minmax(220px,1fr) minmax(180px,2fr) auto;align-items:center;gap:12px;margin-bottom:14px;border:1px solid var(--c-run-border);border-radius:10px;padding:10px 14px;background:var(--c-run-bg)}.catalog-refresh-progress>div{display:grid;gap:3px}.catalog-refresh-progress strong{color:var(--c-run);font-size:11px}.catalog-refresh-progress span,.catalog-refresh-progress small{color:var(--ink-mute);font-size:9px}.catalog-refresh-progress progress{width:100%;height:12px}.catalog-refresh-progress.completed{border-color:var(--c-done-border);background:var(--c-done-bg)}.catalog-refresh-progress.failed{border-color:var(--c-fail-border);background:var(--c-fail-bg)}@media(max-width:700px){.catalog-refresh-progress{grid-template-columns:1fr}.routing-fields{align-items:stretch;flex-direction:column}} -.routing-actions button:disabled,.catalog-file-routing select:disabled{cursor:not-allowed;border-color:var(--border-base);background:var(--bg-soft);color:var(--ink-faint);box-shadow:none}.snapshot-timestamp{color:var(--ink-base);font-size:11px;font-weight:600}.catalog-table tbody tr{scroll-margin-top:42px}.catalog-table{width:100%;table-layout:fixed}.catalog-table thead th{position:sticky;z-index:2;top:0;background:var(--bg-soft)}.catalog-table th,.catalog-table td{padding:12px 10px;white-space:normal;overflow-wrap:anywhere;font-size:11px}.catalog-table th:nth-child(1){width:31%}.catalog-table th:nth-child(2){width:8%}.catalog-table th:nth-child(3){width:11%}.catalog-table th:nth-child(4){width:10%}.catalog-table th:nth-child(5){width:16%}.catalog-table th:nth-child(6){width:10%}.catalog-table th:nth-child(7){width:14%}.catalog-name{display:flex;align-items:flex-start;gap:7px;border:0;padding:0;background:transparent;box-shadow:none;color:var(--c-run);text-align:left;line-height:1.5}.catalog-name:hover{text-decoration:underline}.catalog-file{display:flex;align-items:flex-start;gap:7px;color:var(--ink-base);line-height:1.5}.catalog-table td>span:not(.scope-badge){display:block}.catalog-table td small{display:block;margin-top:4px;color:var(--ink-mute)}.problem-text{color:var(--c-warn)!important}.scope-badge.mixed{background:var(--c-run-bg);color:var(--c-run)}.scope-badge.unknown{background:var(--bg-soft);color:var(--ink-mute)}@media(max-width:1100px){.catalog-layout{grid-template-columns:220px minmax(0,1fr)}.catalog-summary{flex-wrap:wrap}.catalog-summary>div{width:100%;margin:0}.catalog-table{min-width:800px}}@media(max-width:800px){.catalog-layout{grid-template-columns:1fr}.catalog-sources{max-height:240px}.catalog-table-wrap{max-height:520px}} +.routing-actions button:disabled,.catalog-file-routing select:disabled{cursor:not-allowed;border-color:var(--border-base);background:var(--bg-soft);color:var(--ink-faint);box-shadow:none}.snapshot-timestamp{color:var(--ink-base);font-size:11px;font-weight:600}.catalog-table tbody tr{scroll-margin-top:42px}.catalog-table{width:100%;table-layout:fixed}.catalog-table thead th{position:sticky;z-index:2;top:0;background:var(--bg-soft)}.catalog-table th,.catalog-table td{padding:12px 10px;white-space:normal;overflow-wrap:anywhere;font-size:11px}.catalog-table th:nth-child(1){width:32%}.catalog-table th:nth-child(2){width:8%}.catalog-table th:nth-child(3){width:15%}.catalog-table th:nth-child(4){width:9%}.catalog-table th:nth-child(5){width:16%}.catalog-table th:nth-child(6){width:20%}.catalog-name{display:flex;align-items:flex-start;gap:7px;border:0;padding:0;background:transparent;box-shadow:none;color:var(--c-run);text-align:left;line-height:1.5}.catalog-name:hover{text-decoration:underline}.catalog-file{display:flex;align-items:flex-start;gap:7px;color:var(--ink-base);line-height:1.5}.catalog-table td>span:not(.scope-badge){display:block}.catalog-table td small{display:block;margin-top:4px;color:var(--ink-mute)}.problem-text{color:var(--c-warn)!important}.scope-badge.mixed{background:var(--c-run-bg);color:var(--c-run)}.scope-badge.unknown{background:var(--bg-soft);color:var(--ink-mute)}@media(max-width:1100px){.catalog-layout{grid-template-columns:220px minmax(0,1fr)}.catalog-summary{flex-wrap:wrap}.catalog-summary>div{width:100%;margin:0}.catalog-table{min-width:800px}}@media(max-width:800px){.catalog-layout{grid-template-columns:1fr}.catalog-sources{max-height:240px}.catalog-table-wrap{max-height:520px}} .routing-actions label{display:flex;align-items:center;gap:7px;color:var(--ink-mute);font-size:10px;font-weight:700}.routing-actions select,.catalog-folder-routing select{border:1px solid var(--border-strong);border-radius:7px;padding:7px 9px;background:var(--bg-panel);color:var(--ink-base);font:inherit}.blocked-policy-note{color:var(--c-warn);font-size:10px;line-height:1.5}.catalog-folder-routing{display:grid;gap:7px}.catalog-folder-routing select{width:max-content;max-width:100%;font-size:9px}.catalog-folder-routing small{color:var(--ink-mute)!important;font-size:9px}.scope-badge.both{background:var(--c-run-bg);color:var(--c-run)}.scope-badge.blocked{background:var(--c-fail-bg);color:var(--c-fail)} .catalog-pathbar{display:flex;align-items:center;gap:10px;min-height:48px;border-bottom:1px solid var(--border-base);padding:8px 16px;background:var(--bg-panel)}.catalog-back-button{display:grid;flex:0 0 auto;width:30px;height:30px;place-items:center;border:1px solid var(--border-strong);border-radius:7px;padding:0;background:var(--bg-panel);color:var(--c-run);box-shadow:none;font-size:18px}.catalog-back-button:hover:not(:disabled){background:var(--c-run-bg)}.catalog-pathbar nav{display:flex;min-width:0;align-items:center;gap:4px;overflow-x:auto;white-space:nowrap}.catalog-pathbar nav span{display:flex;min-width:0;align-items:center;gap:4px}.catalog-pathbar nav i{color:var(--ink-faint);font-style:normal}.catalog-pathbar nav button{overflow:hidden;border:0;border-radius:6px;padding:6px 7px;background:transparent;color:var(--c-run);box-shadow:none;text-overflow:ellipsis;white-space:nowrap}.catalog-pathbar nav button:hover:not(:disabled){background:var(--c-run-bg)}.catalog-pathbar nav button.current{color:var(--ink-base);font-weight:700}.catalog-pathbar nav button:disabled{cursor:default;background:transparent;color:var(--ink-base)} -.catalog-policy-cell{display:grid;gap:6px;justify-items:start}.catalog-policy-cell select{max-width:100%;border:1px solid var(--border-strong);border-radius:7px;padding:6px 8px;background:var(--bg-panel);color:var(--ink-base);font-size:10px}.catalog-policy-cell small{min-height:14px;color:var(--ink-mute);font-size:9px}.catalog-table th:nth-child(1){width:22%}.catalog-table th:nth-child(2){width:8%}.catalog-table th:nth-child(3){width:15%}.catalog-table th:nth-child(4){width:9%}.catalog-table th:nth-child(5){width:16%}.catalog-table th:nth-child(6){width:16%}.catalog-table th:nth-child(7){width:14%} +.catalog-policy-cell{display:grid;gap:6px;justify-items:start}.catalog-policy-cell select{max-width:100%;border:1px solid var(--border-strong);border-radius:7px;padding:6px 8px;background:var(--bg-panel);color:var(--ink-base);font-size:10px}.catalog-policy-cell small{min-height:14px;color:var(--ink-mute);font-size:9px}.catalog-table th:nth-child(1){width:32%}.catalog-table th:nth-child(2){width:8%}.catalog-table th:nth-child(3){width:15%}.catalog-table th:nth-child(4){width:9%}.catalog-table th:nth-child(5){width:16%}.catalog-table th:nth-child(6){width:20%} .routing-actions .blocked-policy-button{border-color:var(--c-fail-border);background:var(--c-fail-bg);color:var(--c-fail)}.routing-actions .blocked-policy-button:hover:not(:disabled){background:var(--c-fail-bg)} .catalog-node-control{display:flex;align-items:flex-start;gap:7px}.catalog-node-control input{margin-top:4px;flex:0 0 auto} .routing-actions .internal-policy-button{border-color:var(--c-done);background:var(--c-done);color:var(--bg-panel)}.routing-actions .internal-policy-button:hover:not(:disabled){background:var(--c-done)}.routing-actions .external-policy-button{border-color:var(--c-warn);background:var(--c-warn);color:var(--bg-panel)}.routing-actions .external-policy-button:hover:not(:disabled){background:var(--c-warn)}.routing-actions .blocked-policy-button{border-color:var(--c-fail);background:var(--c-fail);color:var(--bg-panel)}.routing-actions .blocked-policy-button:hover:not(:disabled){background:var(--c-fail)}