From 5b6e154459d510a26e8434ad521f5009b803a0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Tue, 27 Oct 2026 09:40:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(settings):=20=E5=A2=9E=E5=8A=A0=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=A7=BB=E9=99=A4=E7=A1=AE=E8=AE=A4=E5=B9=B6=E6=94=B6?= =?UTF-8?q?=E6=8B=A2=E6=95=B0=E6=8D=AE=E6=BA=90=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/SourceManagement.css | 21 ++++++++ web/src/SourceManagement.tsx | 98 ++++++++++++++++++++++++++++++++---- web/src/SystemSettings.tsx | 9 ++-- 3 files changed, 112 insertions(+), 16 deletions(-) diff --git a/web/src/SourceManagement.css b/web/src/SourceManagement.css index d6007b4..c62d777 100644 --- a/web/src/SourceManagement.css +++ b/web/src/SourceManagement.css @@ -1,3 +1,24 @@ +.source-management-details { + margin-top: 18px; + border-top: 1px solid var(--border-base); +} +.source-management-details > details { + padding: 12px 0; +} +.source-management-details summary { + cursor: pointer; + color: var(--ink-mute); + font-size: 12px; +} +.source-management-details summary:focus-visible { + outline: 2px solid #2978bd; + outline-offset: 3px; +} +.source-management-details .source-policy-panel { + margin-top: 16px; + margin-bottom: 0; + border-bottom: 0; +} .source-account { margin: 0 0 14px; font-size: 12px; diff --git a/web/src/SourceManagement.tsx b/web/src/SourceManagement.tsx index 9dd4fc4..b39eea1 100644 --- a/web/src/SourceManagement.tsx +++ b/web/src/SourceManagement.tsx @@ -2,7 +2,8 @@ import './SourceManagement.css' import { useEffect, useState } from 'react' import { DingtalkSessionControl } from './DingtalkSessionControl' import { fetchAvailableDingtalkSources } from './dingtalkSources' -import { fetchSourceConnectionList, fetchSourceSettingsRevisions } from './sourceConnections' +import { archiveSourceConnection, fetchSourceConnectionList, fetchSourceSettingsRevisions } from './sourceConnections' +import { useOptionalAuth } from './auth' import type { SourceConnectionListItem, SourceSettingsRevision } from './sourceConnections' import { configuredInterval, saveSourceRefresh } from './sourceRefreshPolicy' @@ -70,6 +71,8 @@ export function SourceSettingsCard({ }) { const [open, setOpen] = useState(false) const [confirm, setConfirm] = useState(false) + const [confirmRemove, setConfirmRemove] = useState(false) + const isAdmin = useOptionalAuth()?.identity?.role === 'admin' const [busy, setBusy] = useState(false) const [message, setMessage] = useState('') const [error, setError] = useState('') @@ -88,6 +91,20 @@ export function SourceSettingsCard({ setBusy(false) } } + const remove = async () => { + if (!isAdmin || busy) return + setBusy(true) + setError('') + try { + await archiveSourceConnection(connection.id) + setConfirmRemove(false) + onSourcesChanged() + } catch (cause) { + setError(errorText(cause)) + } finally { + setBusy(false) + } + } const manual = connection.source_type === 'manual' return (
@@ -106,7 +123,7 @@ export function SourceSettingsCard({ : '仅手动刷新'} - {!manual ? ( + {!manual || isAdmin ? ( - 仅控制自动扫描,不下架或删除已有知识。 + {!manual ? ( + + ) : null} + {isAdmin ? ( + + ) : null} + 仅管理平台连接,不删除源端文件或已入库知识。 ) : null} {message ? ( @@ -138,6 +169,30 @@ export function SourceSettingsCard({ {error}

) : null} + {confirmRemove ? ( +
+
+

移除「{connection.name}」的连接?

+

移除后将不再展示该来源,也不再安排新的自动扫描。

+

+ 源端文件和已入库知识不会删除,历史记录保留。 +

+ {error ? ( +

+ {error} +

+ ) : null} +
+ + +
+
+
+ ) : null} {confirm ? (
@@ -158,6 +213,29 @@ export function SourceSettingsCard({ ) } +export function SourceManagementDetails({ + connections, + onSourcesChanged, +}: { + connections: SourceConnectionListItem[] + onSourcesChanged: () => void +}) { + const [policyOpen, setPolicyOpen] = useState(false) + const [auditOpen, setAuditOpen] = useState(false) + return ( +
+
setPolicyOpen(event.currentTarget.open)}> + 刷新设置 + {policyOpen ? : null} +
+
setAuditOpen(event.currentTarget.open)}> + 数据源设置审计 + {auditOpen ? : null} +
+
+ ) +} + export function SourceRefreshPolicy({ connections, onSourcesChanged, diff --git a/web/src/SystemSettings.tsx b/web/src/SystemSettings.tsx index a29e668..1853e39 100644 --- a/web/src/SystemSettings.tsx +++ b/web/src/SystemSettings.tsx @@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react' import { BackupScheduleSection } from './BackupScheduleSection' import { QAModelSettings } from './QAModelSettings' import { MembersSection } from './MembersSection' -import { DingtalkAccountStatus, SourceRefreshPolicy, SourceSettingsAudit, SourceSettingsCard } from './SourceManagement' +import { DingtalkAccountStatus, SourceManagementDetails, SourceSettingsCard } from './SourceManagement' import { RoutingBindingsSection } from './RoutingBindingsSection' import { ProductionBindingsSection } from './ProductionBindingsSection' import { SourceWizard } from './SourceWizard' @@ -44,8 +44,7 @@ interface Props { initialSection?: SectionKey } -type SectionKey = - 'sources' | 'services' | 'bindings' | 'production-bindings' | 'storage' | 'refresh' | 'members' | 'source-audit' +type SectionKey = 'sources' | 'services' | 'bindings' | 'production-bindings' | 'storage' | 'refresh' | 'members' const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [ { key: 'sources', label: '数据源配置' }, @@ -55,7 +54,6 @@ const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [ { key: 'storage', label: '存储与备份' }, { key: 'refresh', label: '刷新策略' }, { key: 'members', label: '成员与角色', adminOnly: true }, - { key: 'source-audit', label: '数据源设置审计' }, ] as { key: SectionKey; label: string; adminOnly?: boolean }[] const sourceTypeLabels: Record = { @@ -256,6 +254,7 @@ export function SystemSettingsView({
还没有已接入的来源:用上面的「+ 添加数据源」加入。
)}
+ ) : null} {section === 'services' ? ( @@ -397,10 +396,8 @@ export function SystemSettingsView({ {section === 'production-bindings' ? : null} {section === 'storage' ? : null} {section === 'members' && identity?.role === 'admin' ? : null} - {section === 'source-audit' ? : null} {section === 'refresh' ? (
-

刷新策略