主人要求:AList 已由钉盘文件替代、钉钉知识库改为按当前账号发现 ⇒ 这两类不再出现在 数据源配置里,只保留 PP 资料与「可加入的来源」(按当前钉钉账号列出可访问的知识库与钉盘空间)。 实现(非破坏、可逆): - 新增纯函数 splitSourceConnections(connections, showLegacy):把 alist 与 dingtalk 归为 legacy,默认只返回 PP/手工等其余来源;showLegacy=true 时原样返回(顺序不变、一条不少)。 - 「数据源配置」新增一行折叠开关「显示 AList/钉钉知识库来源(N)」:默认收起,只显示 PP 资料(+手动导入);展开后这 N 个来源照旧可改刷新周期、启停、看修订历史。 **没有删除任何来源,也没有动它们的调度与目录快照。** - 区块文案说明登记路径:新来源只从「可加入的来源」勾选登记(钉盘文件已替代 AList)。 - 测试:splitSourceConnections 直测(默认折起 a/d、展开 a/b/c/d)+ SSR 断言默认视图只含 PP、 折叠项不在默认视图(原断言的 dingtalk 卡片标记改为折叠后的期望)。 验证:make verify 15/15;SystemSettings 用例 7/7。
This commit is contained in:
+616
-98
@@ -1,108 +1,626 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe,expect,it,vi } from 'vitest'
|
||||
import { SystemSettingsView, visibleSaveMessage } from './SystemSettings'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { SystemSettingsView, splitSourceConnections, visibleSaveMessage } from './SystemSettings'
|
||||
import { AuthContext } from './auth'
|
||||
import type { MonitorOverview } from './monitor'
|
||||
import type { CatalogSource } from './sourceCatalog'
|
||||
import type { UISettings } from './uiSettings'
|
||||
import type { SourceConnectionListItem } from './sourceConnections'
|
||||
const monitor:MonitorOverview={mode:'simulation',simulated:true,observed_at:'2026-09-08T12:00:00Z',host:{cpu_percent:42,memory_used_bytes:1,memory_total_bytes:2,disk_used_bytes:1,disk_total_bytes:2,gpu_state:'unknown',gpu_detail:'未接入真实GPU监控',simulated:true},services:[{key:'mineru',name:'MinerU',state:'healthy',detail:'模拟',latency_ms:1,observed_at:'2026-09-08T12:00:00Z',simulated:true}],knowledge_bases:[],health:[{key:'mineru',name:'MinerU',liveness:'up',readiness:'blocked',reason:'服务可达但容量已满(429),暂时不可接单',latency_ms:30,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:2,configured:true,applicable:true}]}
|
||||
const sources:CatalogSource[]=[{connection_id:'ding-1',source_type:'dingtalk',name:'公司级技术支持知识库',root_node_id:'root-1',folder_count:1079,file_count:3444,observed_at:'2026-09-09T09:30:32Z',snapshot_only:true,snapshot_status:'ready',last_refresh_duration_ms:0}]
|
||||
const connections:SourceConnectionListItem[]=[{id:'conn-ding',source_type:'dingtalk',name:'公司级技术支持知识库',enabled:true,schedule_configured:true,health_status:'healthy',item_count:3444,updated_at:'2026-09-09T09:30:32Z',next_refresh_at:'2026-09-12T10:00:00Z'},{id:'conn-man',source_type:'manual',name:'本地手工验收',enabled:false,schedule_configured:false,health_status:'unknown',item_count:5,updated_at:'2026-09-09T09:30:32Z',next_refresh_at:null}]
|
||||
const settings:UISettings={id:'settings-default',state:'active',document_refresh_seconds:15,resource_refresh_seconds:30,stalled_after_seconds:1800,finalizing_after_seconds:7200,ingestion_concurrency:2,test_weknora_base_url:'',production_weknora_base_url:'',production_tenant_id:'',production_knowledge_base_id:'',updated_by:'system:migration',created_at:'2026-09-10T08:00:00Z',activated_at:'2026-09-10T08:00:00Z',retired_at:null,error_code:''}
|
||||
const authValue=(role:'admin'|'engineer')=>({identity:{id:`${role}-1`,username:role,display_name:role,role,must_change_password:false},ready:true,login:async()=>null,logout:async()=>{},changePassword:async()=>null,signedOut:0,notifySignedOut:()=>{}})
|
||||
describe('SystemSettingsView service configuration',()=>{
|
||||
it('lets an administrator edit exactly the four service fields in the web console',()=>{
|
||||
const configured:UISettings={...settings,test_weknora_base_url:'https://weknora.test.example',production_weknora_base_url:'https://weknora.prod.example',production_tenant_id:'10000',production_knowledge_base_id:'kb-abc123'}
|
||||
const view=(role:'admin'|'engineer')=>renderToStaticMarkup(<AuthContext.Provider value={authValue(role)}><SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={configured} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" /></AuthContext.Provider>)
|
||||
const adminHtml=view('admin')
|
||||
for(const text of ['测试地址','生产地址','生产 ID','知识库 ID','保存并启用服务配置','https://weknora.test.example','https://weknora.prod.example','10000','kb-abc123','四项留空即表示未配置'])expect(adminHtml).toContain(text)
|
||||
expect(adminHtml).not.toContain('仅管理员可修改')
|
||||
// 界面只剩这四项:依赖探活矩阵与对内/对外绑定下拉不再出现在服务配置页。
|
||||
for(const removed of ['MinerU','Embedding','Redis / MQ','PostgreSQL','测试知识库映射'])expect(adminHtml).not.toContain(removed)
|
||||
const engineerHtml=view('engineer')
|
||||
expect(engineerHtml).toContain('仅管理员可修改')
|
||||
expect(engineerHtml).not.toContain('保存并启用服务配置')
|
||||
})
|
||||
const monitor: MonitorOverview = {
|
||||
mode: 'simulation',
|
||||
simulated: true,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
host: {
|
||||
cpu_percent: 42,
|
||||
memory_used_bytes: 1,
|
||||
memory_total_bytes: 2,
|
||||
disk_used_bytes: 1,
|
||||
disk_total_bytes: 2,
|
||||
gpu_state: 'unknown',
|
||||
gpu_detail: '未接入真实GPU监控',
|
||||
simulated: true,
|
||||
},
|
||||
services: [
|
||||
{
|
||||
key: 'mineru',
|
||||
name: 'MinerU',
|
||||
state: 'healthy',
|
||||
detail: '模拟',
|
||||
latency_ms: 1,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
simulated: true,
|
||||
},
|
||||
],
|
||||
knowledge_bases: [],
|
||||
health: [
|
||||
{
|
||||
key: 'mineru',
|
||||
name: 'MinerU',
|
||||
liveness: 'up',
|
||||
readiness: 'blocked',
|
||||
reason: '服务可达但容量已满(429),暂时不可接单',
|
||||
latency_ms: 30,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 2,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
],
|
||||
}
|
||||
const sources: CatalogSource[] = [
|
||||
{
|
||||
connection_id: 'ding-1',
|
||||
source_type: 'dingtalk',
|
||||
name: '公司级技术支持知识库',
|
||||
root_node_id: 'root-1',
|
||||
folder_count: 1079,
|
||||
file_count: 3444,
|
||||
observed_at: '2026-09-09T09:30:32Z',
|
||||
snapshot_only: true,
|
||||
snapshot_status: 'ready',
|
||||
last_refresh_duration_ms: 0,
|
||||
},
|
||||
]
|
||||
const connections: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'conn-ding',
|
||||
source_type: 'dingtalk',
|
||||
name: '公司级技术支持知识库',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 3444,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: '2026-09-12T10:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 'conn-man',
|
||||
source_type: 'manual',
|
||||
name: '本地手工验收',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 5,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
const settings: UISettings = {
|
||||
id: 'settings-default',
|
||||
state: 'active',
|
||||
document_refresh_seconds: 15,
|
||||
resource_refresh_seconds: 30,
|
||||
stalled_after_seconds: 1800,
|
||||
finalizing_after_seconds: 7200,
|
||||
ingestion_concurrency: 2,
|
||||
test_weknora_base_url: '',
|
||||
production_weknora_base_url: '',
|
||||
production_tenant_id: '',
|
||||
production_knowledge_base_id: '',
|
||||
updated_by: 'system:migration',
|
||||
created_at: '2026-09-10T08:00:00Z',
|
||||
activated_at: '2026-09-10T08:00:00Z',
|
||||
retired_at: null,
|
||||
error_code: '',
|
||||
}
|
||||
const authValue = (role: 'admin' | 'engineer') => ({
|
||||
identity: { id: `${role}-1`, username: role, display_name: role, role, must_change_password: false },
|
||||
ready: true,
|
||||
login: async () => null,
|
||||
logout: async () => {},
|
||||
changePassword: async () => null,
|
||||
signedOut: 0,
|
||||
notifySignedOut: () => {},
|
||||
})
|
||||
describe('SystemSettingsView',()=>{
|
||||
it('separates document-engineer settings from locked administrator and production controls',()=>{
|
||||
const html=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时" onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} />)
|
||||
for(const text of ['系统设置','数据源配置','服务配置','存储与备份','刷新策略','设置服务已启用','当前活动版本','公司级技术支持知识库','钉钉知识库','认证方式','端点与凭据','文档工程师可调整','管理员设置已锁定'])expect(html).toContain(text)
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
for(const removed of ['文件格式筛选','未勾选的一律不取件','保存保留格式','恢复继承上级规则'])expect(html).not.toContain(removed)
|
||||
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
|
||||
for(const removed of ['+ 新增钉钉知识库','新增钉钉知识库'])expect(html).not.toContain(removed)
|
||||
const servicesHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
for(const text of ['测试 WeKnora','生产 WeKnora','测试地址','生产地址','生产 ID','知识库 ID'])expect(servicesHtml).toContain(text)
|
||||
const storageHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="storage" />)
|
||||
// 存储与备份分区已换成真实功能(整库逻辑备份的定时计划),静态占位文案不再存在。
|
||||
expect(storageHtml).toContain('存储与备份')
|
||||
expect(storageHtml).toContain('正在读取备份计划…')
|
||||
expect(storageHtml).not.toContain('仅保存凭据引用,不可回读')
|
||||
const refreshHtml=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时" onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="refresh" />)
|
||||
for(const text of ['刷新与告警参数已验证并启用','停滞30分钟','finalizing 2小时','文档状态刷新间隔','15秒','解析停滞判定','30分钟','保存并应用刷新与告警参数'])expect(refreshHtml).toContain(text)
|
||||
expect(visibleSaveMessage('已保存',true)).toBeNull();expect(visibleSaveMessage('已保存',false)).toBe('已保存')
|
||||
expect(html).not.toContain('本地模拟');expect(html).not.toContain('保存模拟设置')
|
||||
for(const forbidden of ['DATABASE_URL','RELEASE_CONFIG_FILE','API Key明文','secret_ref'])expect(html).not.toContain(forbidden)
|
||||
// 两个环境卡仍由真实探测驱动(依赖矩阵搬到总览页,本页不再渲染)。
|
||||
expect(servicesHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
|
||||
expect(servicesHtml).not.toContain('PostgreSQL')
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
expect(html).toContain('下次自动刷新')
|
||||
expect(html).toContain('仅手动刷新')
|
||||
expect(html).toContain('查看修订历史')
|
||||
expect(html).toContain('保存并启用调度')
|
||||
expect(html).toContain('停用来源')
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
})
|
||||
it('lets an administrator bind the internal/external import knowledge bases from 系统设置',()=>{
|
||||
// 组件一直在(RoutingBindingsSection),但从未挂到任何页面 —— 导入目标库只能靠
|
||||
// 部署 env 钉死,换库必须重建容器。
|
||||
const view=(section:'sources'|'bindings'|'production-bindings')=>renderToStaticMarkup(<AuthContext.Provider value={authValue('admin')}><SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection={section} /></AuthContext.Provider>)
|
||||
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 的对应知识库')
|
||||
describe('SystemSettingsView service configuration', () => {
|
||||
it('lets an administrator edit exactly the four service fields in the web console', () => {
|
||||
const configured: UISettings = {
|
||||
...settings,
|
||||
test_weknora_base_url: 'https://weknora.test.example',
|
||||
production_weknora_base_url: 'https://weknora.prod.example',
|
||||
production_tenant_id: '10000',
|
||||
production_knowledge_base_id: 'kb-abc123',
|
||||
}
|
||||
const view = (role: 'admin' | 'engineer') =>
|
||||
renderToStaticMarkup(
|
||||
<AuthContext.Provider value={authValue(role)}>
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={configured}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
const adminHtml = view('admin')
|
||||
for (const text of [
|
||||
'测试地址',
|
||||
'生产地址',
|
||||
'生产 ID',
|
||||
'知识库 ID',
|
||||
'保存并启用服务配置',
|
||||
'https://weknora.test.example',
|
||||
'https://weknora.prod.example',
|
||||
'10000',
|
||||
'kb-abc123',
|
||||
'四项留空即表示未配置',
|
||||
])
|
||||
expect(adminHtml).toContain(text)
|
||||
expect(adminHtml).not.toContain('仅管理员可修改')
|
||||
// 界面只剩这四项:依赖探活矩阵与对内/对外绑定下拉不再出现在服务配置页。
|
||||
for (const removed of ['MinerU', 'Embedding', 'Redis / MQ', 'PostgreSQL', '测试知识库映射'])
|
||||
expect(adminHtml).not.toContain(removed)
|
||||
const engineerHtml = view('engineer')
|
||||
expect(engineerHtml).toContain('仅管理员可修改')
|
||||
expect(engineerHtml).not.toContain('保存并启用服务配置')
|
||||
})
|
||||
})
|
||||
it('does not show healthy simulation when the settings data failed to load',()=>{
|
||||
const html=renderToStaticMarkup(<SystemSettingsView sources={[]} connections={[]} monitor={null} settings={null} productionEnabled={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error="加载失败" saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} />)
|
||||
expect(html).toContain('加载失败');expect(html).not.toContain('模拟运行中')
|
||||
})
|
||||
it('renders the WeKnora cards and production channel from live probe and the real production gate',()=>{
|
||||
const probed:MonitorOverview={...monitor,health:[
|
||||
{key:'weknora',name:'WeKnora API',liveness:'up',readiness:'ready',reason:'',latency_ms:86,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:0,configured:true,applicable:true},
|
||||
{key:'weknora-production',name:'生产 WeKnora',liveness:'up',readiness:'ready',reason:'',latency_ms:41,observed_at:'2026-09-08T12:00:00Z',last_success_at:'2026-09-08T11:59:00Z',consecutive_failures:0,configured:true,applicable:true},
|
||||
{key:'embedding',name:'Embedding',liveness:'up',readiness:'not_applicable',reason:'未部署:本平台不使用该依赖',latency_ms:0,observed_at:'2026-09-08T12:00:00Z',last_success_at:null,consecutive_failures:0,configured:false,applicable:false}]}
|
||||
const view=(enabled:boolean,verified:boolean)=>renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={probed} settings={settings} productionEnabled={enabled} productionBackupRestoreVerified={verified} routingCapabilities={{internal_enabled:true,external_enabled:true}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
const on=view(true,true)
|
||||
expect(on).toContain('测试 WeKnora')
|
||||
expect(on).toContain('可达 · 可接单');expect(on).toContain('延迟 86ms')
|
||||
expect(on).toContain('已启用 · 可提交生产请求');expect(on).toContain('生产写入:开启');expect(on).toContain('发布目标与凭据:管理员受限配置')
|
||||
const off=view(false,false)
|
||||
expect(off).toContain('未启用');expect(off).toContain('生产写入:关闭')
|
||||
// 卡片状态由真实探测/门禁驱动,写死的“已连接 / 未连接 / 生产映射:未配置”必须消失。
|
||||
for(const removed of ['本地真实连接','生产映射:未配置'])expect(off).not.toContain(removed)
|
||||
// 生产端点可达性来自真实探活,且只说真话:探活不等于验证过接单能力。
|
||||
expect(on).toContain('端点探测:端点可达 · 未做接单验证')
|
||||
const blocked=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={true} productionBackupRestoreVerified={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
expect(blocked).toContain('已启用 · 被阻断')
|
||||
// 未配置生产端点时必须显式说「未配置」,不得靠文案含糊过去。
|
||||
expect(blocked).toContain('端点探测:暂无真实探测结果')
|
||||
const unconfigured=renderToStaticMarkup(<SystemSettingsView sources={sources} connections={connections} monitor={{...monitor,health:[{key:'weknora-production',name:'生产 WeKnora',liveness:'unknown',readiness:'not_configured',reason:'已部署但未配置探测参数',latency_ms:0,observed_at:'2026-09-08T12:00:00Z',last_success_at:null,consecutive_failures:0,configured:false,applicable:false}]}} settings={settings} productionEnabled={false} routingCapabilities={{internal_enabled:false,external_enabled:false}} loading={false} saving={false} error={null} saveMessage={null} onSave={vi.fn()} onSourcesChanged={vi.fn()} onRefresh={vi.fn()} initialSection="services" />)
|
||||
expect(unconfigured).toContain('端点探测:未配置')
|
||||
expect(unconfigured).not.toContain('端点可达')
|
||||
describe('SystemSettingsView', () => {
|
||||
it('separates document-engineer settings from locked administrator and production controls', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时"
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
for (const text of [
|
||||
'系统设置',
|
||||
'数据源配置',
|
||||
'服务配置',
|
||||
'存储与备份',
|
||||
'刷新策略',
|
||||
'设置服务已启用',
|
||||
'当前活动版本',
|
||||
'端点与凭据',
|
||||
'文档工程师可调整',
|
||||
'管理员设置已锁定',
|
||||
])
|
||||
expect(html).toContain(text)
|
||||
// 需求(2026-10-14):数据源配置默认只列 PP 资料 + 「可加入的来源」;AList 与钉钉知识库来源
|
||||
// 不删除,收进折叠开关,展开后才渲染(原来它们默认就在列表里)。
|
||||
// 折叠开关自己的文案里就含“钉钉知识库”,所以只核对来源卡片才有的标记。
|
||||
for (const folded of ['公司级技术支持知识库', '专用浏览器扫码会话', '直连 API Token'])
|
||||
expect(html).not.toContain(folded)
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(1)')
|
||||
expect(html).toContain('这 1 个已接入来源未删除,数据不变')
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
for (const removed of ['文件格式筛选', '未勾选的一律不取件', '保存保留格式', '恢复继承上级规则'])
|
||||
expect(html).not.toContain(removed)
|
||||
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
|
||||
for (const removed of ['+ 新增钉钉知识库', '新增钉钉知识库']) expect(html).not.toContain(removed)
|
||||
const servicesHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
for (const text of ['测试 WeKnora', '生产 WeKnora', '测试地址', '生产地址', '生产 ID', '知识库 ID'])
|
||||
expect(servicesHtml).toContain(text)
|
||||
const storageHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="storage"
|
||||
/>
|
||||
)
|
||||
// 存储与备份分区已换成真实功能(整库逻辑备份的定时计划),静态占位文案不再存在。
|
||||
expect(storageHtml).toContain('存储与备份')
|
||||
expect(storageHtml).toContain('正在读取备份计划…')
|
||||
expect(storageHtml).not.toContain('仅保存凭据引用,不可回读')
|
||||
const refreshHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage="刷新与告警参数已验证并启用:文档15秒、资源30秒、停滞30分钟、finalizing 2小时"
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="refresh"
|
||||
/>
|
||||
)
|
||||
for (const text of [
|
||||
'刷新与告警参数已验证并启用',
|
||||
'停滞30分钟',
|
||||
'finalizing 2小时',
|
||||
'文档状态刷新间隔',
|
||||
'15秒',
|
||||
'解析停滞判定',
|
||||
'30分钟',
|
||||
'保存并应用刷新与告警参数',
|
||||
])
|
||||
expect(refreshHtml).toContain(text)
|
||||
expect(visibleSaveMessage('已保存', true)).toBeNull()
|
||||
expect(visibleSaveMessage('已保存', false)).toBe('已保存')
|
||||
expect(html).not.toContain('本地模拟')
|
||||
expect(html).not.toContain('保存模拟设置')
|
||||
for (const forbidden of ['DATABASE_URL', 'RELEASE_CONFIG_FILE', 'API Key明文', 'secret_ref'])
|
||||
expect(html).not.toContain(forbidden)
|
||||
// 两个环境卡仍由真实探测驱动(依赖矩阵搬到总览页,本页不再渲染)。
|
||||
expect(servicesHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
|
||||
expect(servicesHtml).not.toContain('PostgreSQL')
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
expect(html).toContain('查看修订历史')
|
||||
expect(html).toContain('保存并启用')
|
||||
expect(html).toContain('停用中(不入队)')
|
||||
// 卡片级调度/停用按钮仍在,只是默认只对可见来源渲染(钉钉/AList 卡片已折起)。
|
||||
for (const foldedControl of ['下次自动刷新', '保存并启用调度', '停用来源'])
|
||||
expect(html).not.toContain(foldedControl)
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
})
|
||||
it('lets an administrator bind the internal/external import knowledge bases from 系统设置', () => {
|
||||
// 组件一直在(RoutingBindingsSection),但从未挂到任何页面 —— 导入目标库只能靠
|
||||
// 部署 env 钉死,换库必须重建容器。
|
||||
const view = (section: 'sources' | 'bindings' | 'production-bindings') =>
|
||||
renderToStaticMarkup(
|
||||
<AuthContext.Provider value={authValue('admin')}>
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection={section}
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
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(
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={[]}
|
||||
monitor={null}
|
||||
settings={null}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error="加载失败"
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
expect(html).toContain('加载失败')
|
||||
expect(html).not.toContain('模拟运行中')
|
||||
})
|
||||
it('renders the WeKnora cards and production channel from live probe and the real production gate', () => {
|
||||
const probed: MonitorOverview = {
|
||||
...monitor,
|
||||
health: [
|
||||
{
|
||||
key: 'weknora',
|
||||
name: 'WeKnora API',
|
||||
liveness: 'up',
|
||||
readiness: 'ready',
|
||||
reason: '',
|
||||
latency_ms: 86,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 0,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
{
|
||||
key: 'weknora-production',
|
||||
name: '生产 WeKnora',
|
||||
liveness: 'up',
|
||||
readiness: 'ready',
|
||||
reason: '',
|
||||
latency_ms: 41,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: '2026-09-08T11:59:00Z',
|
||||
consecutive_failures: 0,
|
||||
configured: true,
|
||||
applicable: true,
|
||||
},
|
||||
{
|
||||
key: 'embedding',
|
||||
name: 'Embedding',
|
||||
liveness: 'up',
|
||||
readiness: 'not_applicable',
|
||||
reason: '未部署:本平台不使用该依赖',
|
||||
latency_ms: 0,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: null,
|
||||
consecutive_failures: 0,
|
||||
configured: false,
|
||||
applicable: false,
|
||||
},
|
||||
],
|
||||
}
|
||||
const view = (enabled: boolean, verified: boolean) =>
|
||||
renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={probed}
|
||||
settings={settings}
|
||||
productionEnabled={enabled}
|
||||
productionBackupRestoreVerified={verified}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
const on = view(true, true)
|
||||
expect(on).toContain('测试 WeKnora')
|
||||
expect(on).toContain('可达 · 可接单')
|
||||
expect(on).toContain('延迟 86ms')
|
||||
expect(on).toContain('已启用 · 可提交生产请求')
|
||||
expect(on).toContain('生产写入:开启')
|
||||
expect(on).toContain('发布目标与凭据:管理员受限配置')
|
||||
const off = view(false, false)
|
||||
expect(off).toContain('未启用')
|
||||
expect(off).toContain('生产写入:关闭')
|
||||
// 卡片状态由真实探测/门禁驱动,写死的“已连接 / 未连接 / 生产映射:未配置”必须消失。
|
||||
for (const removed of ['本地真实连接', '生产映射:未配置']) expect(off).not.toContain(removed)
|
||||
// 生产端点可达性来自真实探活,且只说真话:探活不等于验证过接单能力。
|
||||
expect(on).toContain('端点探测:端点可达 · 未做接单验证')
|
||||
const blocked = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={true}
|
||||
productionBackupRestoreVerified={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
expect(blocked).toContain('已启用 · 被阻断')
|
||||
// 未配置生产端点时必须显式说「未配置」,不得靠文案含糊过去。
|
||||
expect(blocked).toContain('端点探测:暂无真实探测结果')
|
||||
const unconfigured = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={{
|
||||
...monitor,
|
||||
health: [
|
||||
{
|
||||
key: 'weknora-production',
|
||||
name: '生产 WeKnora',
|
||||
liveness: 'unknown',
|
||||
readiness: 'not_configured',
|
||||
reason: '已部署但未配置探测参数',
|
||||
latency_ms: 0,
|
||||
observed_at: '2026-09-08T12:00:00Z',
|
||||
last_success_at: null,
|
||||
consecutive_failures: 0,
|
||||
configured: false,
|
||||
applicable: false,
|
||||
},
|
||||
],
|
||||
}}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: false, external_enabled: false }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
initialSection="services"
|
||||
/>
|
||||
)
|
||||
expect(unconfigured).toContain('端点探测:未配置')
|
||||
expect(unconfigured).not.toContain('端点可达')
|
||||
})
|
||||
})
|
||||
describe('SystemSettingsView 数据源配置的默认清单', () => {
|
||||
const withPP: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'conn-pp',
|
||||
source_type: 'pp',
|
||||
name: 'PP资料下载中心',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 613,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'conn-alist',
|
||||
source_type: 'alist',
|
||||
name: '国内工业',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 3027,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'conn-ding2',
|
||||
source_type: 'dingtalk',
|
||||
name: 'ATOM知识库',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 109,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
const view = () =>
|
||||
renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={withPP}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={false}
|
||||
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
|
||||
loading={false}
|
||||
saving={false}
|
||||
error={null}
|
||||
saveMessage={null}
|
||||
onSave={vi.fn()}
|
||||
onSourcesChanged={vi.fn()}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
it('默认只列 PP 资料:AList 与钉钉知识库来源折起来但没删', () => {
|
||||
const html = view()
|
||||
expect(html).toContain('PP资料下载中心')
|
||||
expect(html).toContain('PP 资料下载中心')
|
||||
expect(html).not.toContain('国内工业')
|
||||
expect(html).not.toContain('ATOM知识库')
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(2)')
|
||||
// 登记路径说清楚:新来源一律走「可加入的来源」;格式筛选与旧的新增入口继续不存在。
|
||||
expect(html).toContain('可加入的来源')
|
||||
expect(html).toContain('钉盘文件已替代 AList')
|
||||
for (const removed of ['+ 新增钉钉知识库', '文件格式筛选']) expect(html).not.toContain(removed)
|
||||
})
|
||||
})
|
||||
describe('splitSourceConnections(数据源配置的默认清单规则)', () => {
|
||||
const rows: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'a',
|
||||
source_type: 'pp',
|
||||
name: 'PP资料下载中心',
|
||||
enabled: true,
|
||||
schedule_configured: true,
|
||||
health_status: 'healthy',
|
||||
item_count: 1,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
source_type: 'alist',
|
||||
name: '国内工业',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 2,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'c',
|
||||
source_type: 'dingtalk',
|
||||
name: 'ATOM知识库',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 3,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'd',
|
||||
source_type: 'manual',
|
||||
name: '本地手工验收',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 4,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
it('默认折起 AList 与钉钉知识库,展开后原样返回(顺序不变、一个不少)', () => {
|
||||
const folded = splitSourceConnections(rows, false)
|
||||
expect(folded.visible.map((item) => item.id)).toEqual(['a', 'd'])
|
||||
expect(folded.legacy.map((item) => item.id)).toEqual(['b', 'c'])
|
||||
const expanded = splitSourceConnections(rows, true)
|
||||
expect(expanded.visible.map((item) => item.id)).toEqual(['a', 'b', 'c', 'd'])
|
||||
expect(expanded.legacy.length).toBe(2)
|
||||
})
|
||||
})
|
||||
|
||||
+646
-121
@@ -12,9 +12,21 @@ import type { MonitorOverview } from './monitor'
|
||||
import { fetchReleaseCapabilities } from './reviewRelease'
|
||||
import { fetchCatalogRoutingCapabilities, fetchCatalogSources } from './sourceCatalog'
|
||||
import type { CatalogRoutingCapabilities, CatalogSource } from './sourceCatalog'
|
||||
import { activateSourceSettingsRevision, createSourceSettingsRevision, fetchSourceConnectionList, fetchSourceSettingsRevisions } from './sourceConnections'
|
||||
import {
|
||||
activateSourceSettingsRevision,
|
||||
createSourceSettingsRevision,
|
||||
fetchSourceConnectionList,
|
||||
fetchSourceSettingsRevisions,
|
||||
} from './sourceConnections'
|
||||
import type { SourceConnectionListItem, SourceSettingsRevision } from './sourceConnections'
|
||||
import { activateUISettings, createUISettingsCandidate, fetchActiveUISettings, validKnowledgeBaseID, validProductionTenantID, validServiceEndpoint } from './uiSettings'
|
||||
import {
|
||||
activateUISettings,
|
||||
createUISettingsCandidate,
|
||||
fetchActiveUISettings,
|
||||
validKnowledgeBaseID,
|
||||
validProductionTenantID,
|
||||
validServiceEndpoint,
|
||||
} from './uiSettings'
|
||||
import type { UISettings, UISettingsCandidateInput } from './uiSettings'
|
||||
import './systemSettings.css'
|
||||
|
||||
@@ -48,17 +60,37 @@ const sections: { key: SectionKey; label: string; adminOnly?: boolean }[] = [
|
||||
{ key: 'members', label: '成员与角色', adminOnly: true },
|
||||
] as { key: SectionKey; label: string; adminOnly?: boolean }[]
|
||||
|
||||
const sourceTypeLabels: Record<string, string> = { dingtalk: '钉钉知识库', pp: 'PP 资料下载中心', alist: 'AList 文件源', manual: '本地手工导入' }
|
||||
const sourceAuthLabels: Record<string, string> = { dingtalk: '专用浏览器扫码会话', pp: '公开只读访问', alist: '直连 API Token', manual: '离线导入,无在线认证' }
|
||||
const secondsLabel = (value: number) => value < 60 ? `${value}秒` : value < 3600 ? `${value / 60}分钟` : `${value / 3600}小时`
|
||||
export const visibleSaveMessage = (message: string | null, dirty: boolean) => dirty ? null : message
|
||||
const sourceTypeLabels: Record<string, string> = {
|
||||
dingtalk: '钉钉知识库',
|
||||
pp: 'PP 资料下载中心',
|
||||
alist: 'AList 文件源',
|
||||
manual: '本地手工导入',
|
||||
}
|
||||
|
||||
// 已由钉盘文件替代 / 改为按当前钉钉账号发现的来源类型:数据不删,只是在「数据源配置」默认折起来。
|
||||
export const legacySourceTypes = ['alist', 'dingtalk'] as const
|
||||
export const splitSourceConnections = (connections: SourceConnectionListItem[], showLegacy: boolean) => {
|
||||
const legacy = connections.filter((item) => (legacySourceTypes as readonly string[]).includes(item.source_type))
|
||||
const legacyIDs = new Set(legacy.map((item) => item.id))
|
||||
return { legacy, visible: showLegacy ? connections : connections.filter((item) => !legacyIDs.has(item.id)) }
|
||||
}
|
||||
const sourceAuthLabels: Record<string, string> = {
|
||||
dingtalk: '专用浏览器扫码会话',
|
||||
pp: '公开只读访问',
|
||||
alist: '直连 API Token',
|
||||
manual: '离线导入,无在线认证',
|
||||
}
|
||||
const secondsLabel = (value: number) =>
|
||||
value < 60 ? `${value}秒` : value < 3600 ? `${value / 60}分钟` : `${value / 3600}小时`
|
||||
export const visibleSaveMessage = (message: string | null, dirty: boolean) => (dirty ? null : message)
|
||||
|
||||
type ServiceHealthView = MonitorOverview['health'][number]
|
||||
type ServiceView = MonitorOverview['services'][number]
|
||||
|
||||
// 服务配置只保留四项可写值(测试地址、生产地址、生产 ID、知识库 ID),
|
||||
// 依赖与解析队列的状态仍按真实探测呈现,不写死。
|
||||
const findHealth = (monitor: MonitorOverview | null, name: string): ServiceHealthView | undefined => (monitor?.health || []).find((item) => item.name === name || item.name.startsWith(name))
|
||||
const findHealth = (monitor: MonitorOverview | null, name: string): ServiceHealthView | undefined =>
|
||||
(monitor?.health || []).find((item) => item.name === name || item.name.startsWith(name))
|
||||
export const healthStateLabel = (health: ServiceHealthView | undefined, service: ServiceView | undefined): string => {
|
||||
if (!health) {
|
||||
if (!service) return '待配置'
|
||||
@@ -71,7 +103,9 @@ export const healthStateLabel = (health: ServiceHealthView | undefined, service:
|
||||
}
|
||||
export const healthStateDetail = (health: ServiceHealthView | undefined, service: ServiceView | undefined): string => {
|
||||
if (!health) return service?.detail || '真实 Provider 未接入'
|
||||
const success = health.last_success_at ? `最近成功 ${new Date(health.last_success_at).toLocaleTimeString('zh-CN', { hour12: false })}` : ''
|
||||
const success = health.last_success_at
|
||||
? `最近成功 ${new Date(health.last_success_at).toLocaleTimeString('zh-CN', { hour12: false })}`
|
||||
: ''
|
||||
if (health.readiness === 'ready') return [`延迟 ${health.latency_ms}ms`, success].filter(Boolean).join(';')
|
||||
const failures = health.consecutive_failures ? `连续失败${health.consecutive_failures}次` : ''
|
||||
return [health.reason, success, failures].filter(Boolean).join(';')
|
||||
@@ -84,7 +118,12 @@ export const productionWeKnoraProbe = (monitor: MonitorOverview | null): string
|
||||
const health = findHealth(monitor, '生产 WeKnora')
|
||||
if (!health) return '端点探测:暂无真实探测结果'
|
||||
if (!health.configured) return '端点探测:未配置'
|
||||
const label = health.liveness === 'up' ? (health.readiness === 'ready' ? '端点可达 · 未做接单验证' : '端点可达 · 不可接单') : '端点不可达'
|
||||
const label =
|
||||
health.liveness === 'up'
|
||||
? health.readiness === 'ready'
|
||||
? '端点可达 · 未做接单验证'
|
||||
: '端点可达 · 不可接单'
|
||||
: '端点不可达'
|
||||
const detail = healthStateDetail(health, undefined)
|
||||
return `端点探测:${label}${detail ? `(${detail})` : ''}`
|
||||
}
|
||||
@@ -103,7 +142,13 @@ function formatHorizon(value: string | null): string {
|
||||
return `下次自动刷新 ${at.toLocaleString('zh-CN', { hour12: false })}`
|
||||
}
|
||||
|
||||
function SourceSettingsCard({ connection, onSourcesChanged }: { connection: SourceConnectionListItem; onSourcesChanged: () => void }) {
|
||||
function SourceSettingsCard({
|
||||
connection,
|
||||
onSourcesChanged,
|
||||
}: {
|
||||
connection: SourceConnectionListItem
|
||||
onSourcesChanged: () => void
|
||||
}) {
|
||||
const auth = useOptionalAuth()
|
||||
const isAdmin = auth?.identity?.role === 'admin'
|
||||
const [interval, setInterval] = useState<number>(() => {
|
||||
@@ -121,15 +166,23 @@ function SourceSettingsCard({ connection, onSourcesChanged }: { connection: Sour
|
||||
const scheduled = connection.source_type !== 'manual'
|
||||
|
||||
const submit = async (nextEnabled: boolean) => {
|
||||
setBusy(true); setMessage(null); setFailure(null)
|
||||
setBusy(true)
|
||||
setMessage(null)
|
||||
setFailure(null)
|
||||
try {
|
||||
const draft = {
|
||||
source_type: connection.source_type, name: connection.name, endpoint: '', credential_ref: '',
|
||||
enabled: nextEnabled, schedule: { refresh_interval_seconds: nextEnabled && interval > 0 ? interval : null },
|
||||
source_type: connection.source_type,
|
||||
name: connection.name,
|
||||
endpoint: '',
|
||||
credential_ref: '',
|
||||
enabled: nextEnabled,
|
||||
schedule: { refresh_interval_seconds: nextEnabled && interval > 0 ? interval : null },
|
||||
}
|
||||
const created = await createSourceSettingsRevision(connection.id, draft)
|
||||
const activated = await activateSourceSettingsRevision(connection.id, created.id)
|
||||
setMessage(`${connection.name}:调度设置已验证并启用${activated.operation === 'replayed' ? '(沿用上次结果)' : ''};${nextEnabled ? formatHorizon(new Date(Date.now() + interval * 1000).toISOString()) : '已停用,新的自动扫描与刷新任务不再入队,历史记录全部保留'}。`)
|
||||
setMessage(
|
||||
`${connection.name}:调度设置已验证并启用${activated.operation === 'replayed' ? '(沿用上次结果)' : ''};${nextEnabled ? formatHorizon(new Date(Date.now() + interval * 1000).toISOString()) : '已停用,新的自动扫描与刷新任务不再入队,历史记录全部保留'}。`
|
||||
)
|
||||
onSourcesChanged()
|
||||
} catch (cause) {
|
||||
setFailure(cause instanceof Error ? cause.message : '保存来源设置失败')
|
||||
@@ -142,42 +195,150 @@ function SourceSettingsCard({ connection, onSourcesChanged }: { connection: Sour
|
||||
const loadHistory = async () => {
|
||||
setShowHistory(true)
|
||||
if (history) return
|
||||
try { setHistory(await fetchSourceSettingsRevisions(connection.id)) }
|
||||
catch (cause) { setFailure(cause instanceof Error ? cause.message : '加载修订历史失败') }
|
||||
try {
|
||||
setHistory(await fetchSourceSettingsRevisions(connection.id))
|
||||
} catch (cause) {
|
||||
setFailure(cause instanceof Error ? cause.message : '加载修订历史失败')
|
||||
}
|
||||
}
|
||||
|
||||
const canApply = !busy
|
||||
|
||||
return <article className="settings-source-row">
|
||||
<div className="settings-source-name"><strong>{connection.name}</strong><span>{sourceTypeLabels[connection.source_type] ?? connection.source_type}{connection.enabled ? '' : ' · 已停用'}</span></div>
|
||||
<dl>
|
||||
<div><dt>认证方式</dt><dd>{sourceAuthLabels[connection.source_type] ?? '按连接配置'}</dd></div>
|
||||
<div><dt>端点与凭据</dt><dd>已保存,不可回读(草稿留空即沿用现值)</dd></div>
|
||||
<div><dt>当前调度</dt><dd>{connection.enabled ? formatHorizon(connection.next_refresh_at) : '停用中(不入队)'}</dd></div>
|
||||
</dl>
|
||||
<div className="source-schedule-form">
|
||||
{scheduled ? <label>自动刷新周期<select value={interval} onChange={(event) => setInterval(Number(event.target.value))}>{intervalChoices.map((choice) => <option key={choice.value} value={choice.value}>{choice.label}</option>)}</select></label>
|
||||
: <small className="manual-source-note">本地手工导入来源不支持定时刷新,只能手动触发扫描。</small>}
|
||||
{connection.enabled
|
||||
? <div className="source-schedule-actions"><button className="secondary" disabled={!canApply || (scheduled && interval === 0 && !connection.schedule_configured)} onClick={() => void submit(true)}>{busy ? '正在验证并启用…' : '保存并启用调度'}</button>
|
||||
<button className="danger" disabled={!canApply} onClick={() => setPendingDisable(true)}>停用来源</button></div>
|
||||
: <div className="source-schedule-actions"><button className="secondary" disabled={!canApply} onClick={() => void submit(true)}>保存并启用</button></div>}
|
||||
{connection.source_type === "dingtalk" && isAdmin ? <DingtalkSessionControl /> : null}
|
||||
<button className="link" onClick={() => void loadHistory()}>{showHistory ? '收起修订历史' : '查看修订历史'}</button>
|
||||
</div>
|
||||
{message ? <p className="success-message" role="status">{message}</p> : null}
|
||||
{failure ? <p className="error-message" role="alert">{failure}</p> : null}
|
||||
{showHistory && history ? <ul className="revision-list">{history.map((item) => <li key={item.id}><b>修订 {item.revision_number}</b><span>{item.state === 'active' ? '当前启用' : item.state === 'validated' ? '待启用' : item.state === 'retired' ? '已退休' : '失败'}</span><small>{item.created_by} · {new Date(item.created_at).toLocaleString('zh-CN', { hour12: false })} · {item.refresh_interval_seconds ? `每${secondsLabel(Number(item.refresh_interval_seconds))}` : '仅手动'}</small></li>)}</ul> : null}
|
||||
{showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{pendingDisable ? <div className="modal-backdrop" role="dialog" aria-modal="true"><div className="modal-card">
|
||||
<h3>停用「{connection.name}」?</h3>
|
||||
<p>停用会立即停止该来源的自动扫描与新刷新任务入队;历史快照、标注和审计全部保留,随时可以重新启用。此操作会先由后端再次校验权限。</p>
|
||||
<div className="modal-actions"><button className="danger" disabled={busy} onClick={() => void submit(false)}>{busy ? '正在停用…' : '确认停用'}</button><button className="secondary" disabled={busy} onClick={() => setPendingDisable(false)}>取消</button></div>
|
||||
</div></div> : null}
|
||||
</article>
|
||||
return (
|
||||
<article className="settings-source-row">
|
||||
<div className="settings-source-name">
|
||||
<strong>{connection.name}</strong>
|
||||
<span>
|
||||
{sourceTypeLabels[connection.source_type] ?? connection.source_type}
|
||||
{connection.enabled ? '' : ' · 已停用'}
|
||||
</span>
|
||||
</div>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>认证方式</dt>
|
||||
<dd>{sourceAuthLabels[connection.source_type] ?? '按连接配置'}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>端点与凭据</dt>
|
||||
<dd>已保存,不可回读(草稿留空即沿用现值)</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>当前调度</dt>
|
||||
<dd>{connection.enabled ? formatHorizon(connection.next_refresh_at) : '停用中(不入队)'}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div className="source-schedule-form">
|
||||
{scheduled ? (
|
||||
<label>
|
||||
自动刷新周期
|
||||
<select value={interval} onChange={(event) => setInterval(Number(event.target.value))}>
|
||||
{intervalChoices.map((choice) => (
|
||||
<option key={choice.value} value={choice.value}>
|
||||
{choice.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
) : (
|
||||
<small className="manual-source-note">本地手工导入来源不支持定时刷新,只能手动触发扫描。</small>
|
||||
)}
|
||||
{connection.enabled ? (
|
||||
<div className="source-schedule-actions">
|
||||
<button
|
||||
className="secondary"
|
||||
disabled={!canApply || (scheduled && interval === 0 && !connection.schedule_configured)}
|
||||
onClick={() => void submit(true)}
|
||||
>
|
||||
{busy ? '正在验证并启用…' : '保存并启用调度'}
|
||||
</button>
|
||||
<button className="danger" disabled={!canApply} onClick={() => setPendingDisable(true)}>
|
||||
停用来源
|
||||
</button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="source-schedule-actions">
|
||||
<button className="secondary" disabled={!canApply} onClick={() => void submit(true)}>
|
||||
保存并启用
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{connection.source_type === 'dingtalk' && isAdmin ? <DingtalkSessionControl /> : null}
|
||||
<button className="link" onClick={() => void loadHistory()}>
|
||||
{showHistory ? '收起修订历史' : '查看修订历史'}
|
||||
</button>
|
||||
</div>
|
||||
{message ? (
|
||||
<p className="success-message" role="status">
|
||||
{message}
|
||||
</p>
|
||||
) : null}
|
||||
{failure ? (
|
||||
<p className="error-message" role="alert">
|
||||
{failure}
|
||||
</p>
|
||||
) : null}
|
||||
{showHistory && history ? (
|
||||
<ul className="revision-list">
|
||||
{history.map((item) => (
|
||||
<li key={item.id}>
|
||||
<b>修订 {item.revision_number}</b>
|
||||
<span>
|
||||
{item.state === 'active'
|
||||
? '当前启用'
|
||||
: item.state === 'validated'
|
||||
? '待启用'
|
||||
: item.state === 'retired'
|
||||
? '已退休'
|
||||
: '失败'}
|
||||
</span>
|
||||
<small>
|
||||
{item.created_by} · {new Date(item.created_at).toLocaleString('zh-CN', { hour12: false })} ·{' '}
|
||||
{item.refresh_interval_seconds ? `每${secondsLabel(Number(item.refresh_interval_seconds))}` : '仅手动'}
|
||||
</small>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
{showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{pendingDisable ? (
|
||||
<div className="modal-backdrop" role="dialog" aria-modal="true">
|
||||
<div className="modal-card">
|
||||
<h3>停用「{connection.name}」?</h3>
|
||||
<p>
|
||||
停用会立即停止该来源的自动扫描与新刷新任务入队;历史快照、标注和审计全部保留,随时可以重新启用。此操作会先由后端再次校验权限。
|
||||
</p>
|
||||
<div className="modal-actions">
|
||||
<button className="danger" disabled={busy} onClick={() => void submit(false)}>
|
||||
{busy ? '正在停用…' : '确认停用'}
|
||||
</button>
|
||||
<button className="secondary" disabled={busy} onClick={() => setPendingDisable(false)}>
|
||||
取消
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
export function SystemSettingsView({ sources, connections, monitor, settings, productionEnabled, productionBackupRestoreVerified = false, routingCapabilities, loading, saving, error, saveMessage, onSave, onSourcesChanged, onRefresh, initialSection = 'sources' }: Props) {
|
||||
export function SystemSettingsView({
|
||||
sources,
|
||||
connections,
|
||||
monitor,
|
||||
settings,
|
||||
productionEnabled,
|
||||
productionBackupRestoreVerified = false,
|
||||
routingCapabilities,
|
||||
loading,
|
||||
saving,
|
||||
error,
|
||||
saveMessage,
|
||||
onSave,
|
||||
onSourcesChanged,
|
||||
onRefresh,
|
||||
initialSection = 'sources',
|
||||
}: Props) {
|
||||
const auth = useOptionalAuth()
|
||||
const identity = auth?.identity ?? null
|
||||
const [section, setSection] = useState<SectionKey>(initialSection)
|
||||
@@ -189,9 +350,19 @@ export function SystemSettingsView({ sources, connections, monitor, settings, pr
|
||||
const [endpoint, setEndpoint] = useState<string>(settings?.production_weknora_base_url ?? '')
|
||||
const [testEndpoint, setTestEndpoint] = useState<string>(settings?.test_weknora_base_url ?? '')
|
||||
const [productionTenantID, setProductionTenantID] = useState<string>(settings?.production_tenant_id ?? '')
|
||||
const [productionKnowledgeBaseID, setProductionKnowledgeBaseID] = useState<string>(settings?.production_knowledge_base_id ?? '')
|
||||
const [productionKnowledgeBaseID, setProductionKnowledgeBaseID] = useState<string>(
|
||||
settings?.production_knowledge_base_id ?? ''
|
||||
)
|
||||
const [dirty, setDirty] = useState(false)
|
||||
|
||||
// 「数据源配置」默认只列 PP 资料:AList 已被钉盘文件替代、钉钉知识库一律走当前账号发现
|
||||
//(见下方「可加入的来源」)。这 9 个已接入来源**不删除**,收进折叠开关里,随时可展开管理。
|
||||
const [showLegacySources, setShowLegacySources] = useState(false)
|
||||
const { legacy: legacyConnections, visible: visibleConnections } = splitSourceConnections(
|
||||
connections,
|
||||
showLegacySources
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!settings) return
|
||||
setDocumentRefresh(settings.document_refresh_seconds)
|
||||
@@ -212,76 +383,375 @@ export function SystemSettingsView({ sources, connections, monitor, settings, pr
|
||||
const testEndpointValid = validServiceEndpoint(testEndpoint)
|
||||
const productionTenantIDValid = validProductionTenantID(productionTenantID)
|
||||
const productionKnowledgeBaseIDValid = validKnowledgeBaseID(productionKnowledgeBaseID)
|
||||
const serviceSettingsValid = endpointValid && testEndpointValid && productionTenantIDValid && productionKnowledgeBaseIDValid
|
||||
const serviceSettingsDirty = Boolean(settings && (
|
||||
testEndpoint.trim() !== settings.test_weknora_base_url ||
|
||||
endpoint.trim() !== settings.production_weknora_base_url ||
|
||||
productionTenantID.trim() !== settings.production_tenant_id ||
|
||||
productionKnowledgeBaseID.trim() !== settings.production_knowledge_base_id))
|
||||
const serviceSettingsValid =
|
||||
endpointValid && testEndpointValid && productionTenantIDValid && productionKnowledgeBaseIDValid
|
||||
const serviceSettingsDirty = Boolean(
|
||||
settings &&
|
||||
(testEndpoint.trim() !== settings.test_weknora_base_url ||
|
||||
endpoint.trim() !== settings.production_weknora_base_url ||
|
||||
productionTenantID.trim() !== settings.production_tenant_id ||
|
||||
productionKnowledgeBaseID.trim() !== settings.production_knowledge_base_id)
|
||||
)
|
||||
const candidateInput = (overrides: Partial<UISettingsCandidateInput> = {}): UISettingsCandidateInput => ({
|
||||
document_refresh_seconds: documentRefresh, resource_refresh_seconds: resourceRefresh,
|
||||
stalled_after_seconds: stalled, finalizing_after_seconds: finalizing, ingestion_concurrency: concurrency,
|
||||
test_weknora_base_url: testEndpoint.trim(), production_weknora_base_url: endpoint.trim(),
|
||||
production_tenant_id: productionTenantID.trim(), production_knowledge_base_id: productionKnowledgeBaseID.trim(), ...overrides,
|
||||
document_refresh_seconds: documentRefresh,
|
||||
resource_refresh_seconds: resourceRefresh,
|
||||
stalled_after_seconds: stalled,
|
||||
finalizing_after_seconds: finalizing,
|
||||
ingestion_concurrency: concurrency,
|
||||
test_weknora_base_url: testEndpoint.trim(),
|
||||
production_weknora_base_url: endpoint.trim(),
|
||||
production_tenant_id: productionTenantID.trim(),
|
||||
production_knowledge_base_id: productionKnowledgeBaseID.trim(),
|
||||
...overrides,
|
||||
})
|
||||
const saveEndpoint = () => { setDirty(false); onSave(candidateInput()) }
|
||||
return <main className="page-shell system-settings">
|
||||
<header className="hero compact"><div><h1>系统设置</h1><p className="subtitle">查看内容源、服务与备份状态;来源调度与刷新参数采用版本化保存。</p></div><button onClick={onRefresh} disabled={loading}>{loading ? '刷新中…' : '刷新状态'}</button></header>
|
||||
{error ? <div className="error-banner" role="alert">{error}</div> : null}
|
||||
{monitor && settings ? <div className="settings-layout">
|
||||
<nav className="settings-nav" aria-label="系统设置分区">{sections.filter((item) => !item.adminOnly || identity?.role === 'admin').map((item) => <button key={item.key} className={section === item.key ? 'active' : ''} onClick={() => setSection(item.key)}>{item.label}</button>)}</nav>
|
||||
<div className="settings-content">
|
||||
<div className="settings-role-strip"><span className="engineer-role">文档工程师可调整:来源调度周期、刷新间隔、停滞判断</span><span className="admin-role">管理员设置已锁定:端点、凭据、映射、生产开关</span></div>
|
||||
<div className="simulation-banner server-settings-banner"><strong>设置服务已启用</strong><span>当前活动版本 · 启用人 {settings.updated_by} · 启用时间 {settings.activated_at ? new Date(settings.activated_at).toLocaleString('zh-CN') : '待激活'};新设置先验证,再原子切换。</span></div>
|
||||
{section === 'sources' ? <section className="settings-panel wide source-settings-panel" id="settings-sources">
|
||||
<div className="settings-section-heading"><div><h2>数据源配置</h2><p>从下方「可加入的来源」勾选即可登记新来源;逐来源设置自动刷新周期或保持仅手动,保存会先生成修订、验证后原子启用。</p></div></div>
|
||||
{identity?.role === 'admin' ? <DingtalkSourceDiscovery registeredNames={connections.map((item) => item.name)} onRegistered={onSourcesChanged} /> : null}
|
||||
{connections.length ? <div className="settings-source-list">
|
||||
{connections.map((connection) => <SourceSettingsCard key={connection.id} connection={connection} onSourcesChanged={onSourcesChanged}/>)}
|
||||
{sources.length ? null : <small className="empty-inline">尚无快照数据;快照将在来源首次刷新完成后出现。</small>}
|
||||
</div> : <div className="empty-state">尚无可显示的来源连接。</div>}
|
||||
</section> : null}
|
||||
{section === 'services' ? <section className="settings-panel wide" id="settings-services">
|
||||
<div className="settings-section-heading"><div><h2>服务配置</h2><p>只配四项:测试地址、生产地址、生产 ID、知识库 ID。保存会先生成修订、验证后原子启用,旧版本保留用于审计;凭据只写不读。</p></div></div>
|
||||
<div className="environment-cards"><article><b>测试 WeKnora</b><span>{healthStateLabel(findHealth(monitor, 'WeKnora API'), undefined)}</span><small>{`${healthStateDetail(findHealth(monitor, 'WeKnora API'), undefined) || '端点探测:未配置'};解析队列 对内 ${routingCapabilities.internal_enabled ? '已配置' : '未配置'} · 对外 ${routingCapabilities.external_enabled ? '已配置' : '未配置'}`}</small></article><article className="production"><b>生产 WeKnora</b><span>{!productionEnabled ? '未启用' : productionBackupRestoreVerified ? '已启用 · 可提交生产请求' : '已启用 · 被阻断'}</span><small>{`${productionWeKnoraProbe(monitor)};生产写入:${productionEnabled ? '开启' : '关闭'};发布目标与凭据:管理员受限配置,本页不可回读`}</small></article></div>
|
||||
<div className="safe-setting-grid production-endpoint-form">
|
||||
{isAdmin ? <>
|
||||
<label>测试地址<input value={testEndpoint} onChange={(event) => { setTestEndpoint(event.target.value); setDirty(true) }} placeholder="https://weknora.test.example" aria-invalid={!testEndpointValid} /></label>
|
||||
<label>生产地址<input value={endpoint} onChange={(event) => { setEndpoint(event.target.value); setDirty(true) }} placeholder="https://weknora.prod.example" aria-invalid={!endpointValid} /></label>
|
||||
<label>生产 ID<input value={productionTenantID} onChange={(event) => { setProductionTenantID(event.target.value); setDirty(true) }} placeholder="10000" aria-invalid={!productionTenantIDValid} /></label>
|
||||
<label>知识库 ID<input value={productionKnowledgeBaseID} onChange={(event) => { setProductionKnowledgeBaseID(event.target.value); setDirty(true) }} placeholder="生产知识库 ID" aria-invalid={!productionKnowledgeBaseIDValid} /></label>
|
||||
</> : <>
|
||||
<label>测试地址<input value={settings.test_weknora_base_url || '未配置'} readOnly disabled /></label>
|
||||
<label>生产地址<input value={settings.production_weknora_base_url || '未配置'} readOnly disabled /></label>
|
||||
<label>生产 ID<input value={settings.production_tenant_id || '未配置'} readOnly disabled /></label>
|
||||
<label>知识库 ID<input value={settings.production_knowledge_base_id || '未配置'} readOnly disabled /></label>
|
||||
</>}
|
||||
const saveEndpoint = () => {
|
||||
setDirty(false)
|
||||
onSave(candidateInput())
|
||||
}
|
||||
return (
|
||||
<main className="page-shell system-settings">
|
||||
<header className="hero compact">
|
||||
<div>
|
||||
<h1>系统设置</h1>
|
||||
<p className="subtitle">查看内容源、服务与备份状态;来源调度与刷新参数采用版本化保存。</p>
|
||||
</div>
|
||||
<button onClick={onRefresh} disabled={loading}>
|
||||
{loading ? '刷新中…' : '刷新状态'}
|
||||
</button>
|
||||
</header>
|
||||
{error ? (
|
||||
<div className="error-banner" role="alert">
|
||||
{error}
|
||||
</div>
|
||||
) : null}
|
||||
{monitor && settings ? (
|
||||
<div className="settings-layout">
|
||||
<nav className="settings-nav" aria-label="系统设置分区">
|
||||
{sections
|
||||
.filter((item) => !item.adminOnly || identity?.role === 'admin')
|
||||
.map((item) => (
|
||||
<button
|
||||
key={item.key}
|
||||
className={section === item.key ? 'active' : ''}
|
||||
onClick={() => setSection(item.key)}
|
||||
>
|
||||
{item.label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<div className="settings-content">
|
||||
<div className="settings-role-strip">
|
||||
<span className="engineer-role">文档工程师可调整:来源调度周期、刷新间隔、停滞判断</span>
|
||||
<span className="admin-role">管理员设置已锁定:端点、凭据、映射、生产开关</span>
|
||||
</div>
|
||||
<div className="simulation-banner server-settings-banner">
|
||||
<strong>设置服务已启用</strong>
|
||||
<span>
|
||||
当前活动版本 · 启用人 {settings.updated_by} · 启用时间{' '}
|
||||
{settings.activated_at ? new Date(settings.activated_at).toLocaleString('zh-CN') : '待激活'}
|
||||
;新设置先验证,再原子切换。
|
||||
</span>
|
||||
</div>
|
||||
{section === 'sources' ? (
|
||||
<section className="settings-panel wide source-settings-panel" id="settings-sources">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>数据源配置</h2>
|
||||
<p>
|
||||
新来源只从下方「可加入的来源」勾选登记(按当前钉钉账号列出可访问的知识库与钉盘空间,钉盘文件已替代
|
||||
AList);本页保留 PP 资料。逐来源设置自动刷新周期或保持仅手动,保存会先生成修订、验证后原子启用。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{identity?.role === 'admin' ? (
|
||||
<DingtalkSourceDiscovery
|
||||
registeredNames={connections.map((item) => item.name)}
|
||||
onRegistered={onSourcesChanged}
|
||||
/>
|
||||
) : null}
|
||||
{legacyConnections.length ? (
|
||||
<div className="settings-legacy-toggle">
|
||||
<button type="button" className="secondary" onClick={() => setShowLegacySources((value) => !value)}>
|
||||
{showLegacySources
|
||||
? `收起 AList/钉钉知识库来源(${legacyConnections.length})`
|
||||
: `显示 AList/钉钉知识库来源(${legacyConnections.length})`}
|
||||
</button>
|
||||
<small>
|
||||
{showLegacySources
|
||||
? '这些来源已在两处保留:本列表可改刷新周期与启停,「来源与目录」里照旧浏览它们的内容。'
|
||||
: `AList 来源已由钉盘文件替代,钉钉知识库来源改为按当前账号发现;这 ${legacyConnections.length} 个已接入来源未删除,数据不变。`}
|
||||
</small>
|
||||
</div>
|
||||
) : null}
|
||||
{visibleConnections.length ? (
|
||||
<div className="settings-source-list">
|
||||
{visibleConnections.map((connection) => (
|
||||
<SourceSettingsCard
|
||||
key={connection.id}
|
||||
connection={connection}
|
||||
onSourcesChanged={onSourcesChanged}
|
||||
/>
|
||||
))}
|
||||
{sources.length ? null : (
|
||||
<small className="empty-inline">尚无快照数据;快照将在来源首次刷新完成后出现。</small>
|
||||
)}
|
||||
</div>
|
||||
) : legacyConnections.length ? (
|
||||
<div className="empty-state">
|
||||
本页只列 PP 资料;AList/钉钉知识库来源已收在上方开关里(共 {legacyConnections.length}{' '}
|
||||
个,未删除)。
|
||||
</div>
|
||||
) : (
|
||||
<div className="empty-state">尚无可显示的来源连接。</div>
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
{section === 'services' ? (
|
||||
<section className="settings-panel wide" id="settings-services">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>服务配置</h2>
|
||||
<p>
|
||||
只配四项:测试地址、生产地址、生产 ID、知识库
|
||||
ID。保存会先生成修订、验证后原子启用,旧版本保留用于审计;凭据只写不读。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="environment-cards">
|
||||
<article>
|
||||
<b>测试 WeKnora</b>
|
||||
<span>{healthStateLabel(findHealth(monitor, 'WeKnora API'), undefined)}</span>
|
||||
<small>{`${healthStateDetail(findHealth(monitor, 'WeKnora API'), undefined) || '端点探测:未配置'};解析队列 对内 ${routingCapabilities.internal_enabled ? '已配置' : '未配置'} · 对外 ${routingCapabilities.external_enabled ? '已配置' : '未配置'}`}</small>
|
||||
</article>
|
||||
<article className="production">
|
||||
<b>生产 WeKnora</b>
|
||||
<span>
|
||||
{!productionEnabled
|
||||
? '未启用'
|
||||
: productionBackupRestoreVerified
|
||||
? '已启用 · 可提交生产请求'
|
||||
: '已启用 · 被阻断'}
|
||||
</span>
|
||||
<small>{`${productionWeKnoraProbe(monitor)};生产写入:${productionEnabled ? '开启' : '关闭'};发布目标与凭据:管理员受限配置,本页不可回读`}</small>
|
||||
</article>
|
||||
</div>
|
||||
<div className="safe-setting-grid production-endpoint-form">
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<label>
|
||||
测试地址
|
||||
<input
|
||||
value={testEndpoint}
|
||||
onChange={(event) => {
|
||||
setTestEndpoint(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="https://weknora.test.example"
|
||||
aria-invalid={!testEndpointValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
生产地址
|
||||
<input
|
||||
value={endpoint}
|
||||
onChange={(event) => {
|
||||
setEndpoint(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="https://weknora.prod.example"
|
||||
aria-invalid={!endpointValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
生产 ID
|
||||
<input
|
||||
value={productionTenantID}
|
||||
onChange={(event) => {
|
||||
setProductionTenantID(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="10000"
|
||||
aria-invalid={!productionTenantIDValid}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
知识库 ID
|
||||
<input
|
||||
value={productionKnowledgeBaseID}
|
||||
onChange={(event) => {
|
||||
setProductionKnowledgeBaseID(event.target.value)
|
||||
setDirty(true)
|
||||
}}
|
||||
placeholder="生产知识库 ID"
|
||||
aria-invalid={!productionKnowledgeBaseIDValid}
|
||||
/>
|
||||
</label>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<label>
|
||||
测试地址
|
||||
<input value={settings.test_weknora_base_url || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
生产地址
|
||||
<input value={settings.production_weknora_base_url || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
生产 ID
|
||||
<input value={settings.production_tenant_id || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
<label>
|
||||
知识库 ID
|
||||
<input value={settings.production_knowledge_base_id || '未配置'} readOnly disabled />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<button
|
||||
onClick={saveEndpoint}
|
||||
disabled={!canSave || !serviceSettingsValid || !serviceSettingsDirty}
|
||||
>
|
||||
{saving ? '正在验证并启用…' : '保存并启用服务配置'}
|
||||
</button>
|
||||
<small>
|
||||
四项留空即表示未配置。地址只接受 http(s) 源地址(不能带用户名密码、查询串或 #
|
||||
片段,凭据一律走文件引用);生产 ID 是发布契约里的租户 ID,十进制数字;知识库 ID
|
||||
是生产知识库标识,粘贴 URL 不会通过。保存写入服务器活动版本(版本化 + 审计 +
|
||||
原子切换);后端同时对测试地址/生产地址做真实探活,并用生产地址真查这两个 ID(WeKnora
|
||||
列库接口):端点回答"没有这个知识库"或租户不符会拒绝保存,端点抖动、鉴权失败或未配置生产凭据只警告不拦,核验原话与知识库名在保存后显示。
|
||||
</small>
|
||||
{serviceSettingsValid ? null : (
|
||||
<p className="error-message" role="alert">
|
||||
格式不合法:地址需 http:// 或 https:// 开头的纯地址,不能带用户名密码、? 查询串或 # 片段;生产
|
||||
ID 需为十进制数字;知识库 ID 不能含空格、/、?、# 或 \。
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<small>
|
||||
服务配置仅管理员可修改;当前值:测试地址 {settings.test_weknora_base_url || '未配置'} · 生产地址{' '}
|
||||
{settings.production_weknora_base_url || '未配置'} · 生产 ID{' '}
|
||||
{settings.production_tenant_id || '未配置'} · 知识库 ID{' '}
|
||||
{settings.production_knowledge_base_id || '未配置'}。
|
||||
</small>
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
{section === 'bindings' ? <RoutingBindingsSection /> : null}
|
||||
{section === 'production-bindings' ? <ProductionBindingsSection /> : null}
|
||||
{section === 'storage' ? <BackupScheduleSection /> : null}
|
||||
{section === 'members' && identity?.role === 'admin' ? <MembersSection /> : null}
|
||||
{section === 'refresh' ? (
|
||||
<section className="settings-panel wide" id="settings-refresh">
|
||||
<div className="settings-section-heading">
|
||||
<div>
|
||||
<h2>刷新策略</h2>
|
||||
<p>这些值保存在服务器活动版本中;保存不会修改端点、凭据或生产开关。</p>
|
||||
</div>
|
||||
<span className="safe-badge">当前活动版本</span>
|
||||
</div>
|
||||
<div className="safe-setting-grid">
|
||||
<label>
|
||||
文档状态刷新间隔
|
||||
<select
|
||||
value={documentRefresh}
|
||||
onChange={(event) => {
|
||||
setDocumentRefresh(Number(event.target.value) as 15 | 30 | 60)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={15}>15秒</option>
|
||||
<option value={30}>30秒</option>
|
||||
<option value={60}>1分钟</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
资源刷新间隔
|
||||
<select
|
||||
value={resourceRefresh}
|
||||
onChange={(event) => {
|
||||
setResourceRefresh(Number(event.target.value) as 30 | 60)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={30}>30秒</option>
|
||||
<option value={60}>1分钟</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
解析停滞判定
|
||||
<select
|
||||
value={stalled}
|
||||
onChange={(event) => {
|
||||
setStalled(Number(event.target.value) as 1800 | 3600)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={1800}>30分钟</option>
|
||||
<option value={3600}>1小时</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
finalizing 告警
|
||||
<select
|
||||
value={finalizing}
|
||||
onChange={(event) => {
|
||||
setFinalizing(Number(event.target.value) as 7200 | 14400)
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={7200}>2小时</option>
|
||||
<option value={14400}>4小时</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
入库并发上限
|
||||
<select
|
||||
value={concurrency}
|
||||
onChange={(event) => {
|
||||
setConcurrency(Number(event.target.value))
|
||||
setDirty(true)
|
||||
}}
|
||||
>
|
||||
<option value={1}>1(谨慎,MinerU 并发 1)</option>
|
||||
<option value={2}>2</option>
|
||||
<option value={3}>3</option>
|
||||
<option value={4}>4</option>
|
||||
<option value={6}>6</option>
|
||||
<option value={8}>8</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
setDirty(false)
|
||||
onSave(candidateInput())
|
||||
}}
|
||||
disabled={!canSave}
|
||||
>
|
||||
{saving ? '正在验证并应用…' : '保存并应用刷新与告警参数'}
|
||||
</button>
|
||||
{visibleSaveMessage(saveMessage, dirty) ? (
|
||||
<p className="success-message" role="status">
|
||||
{saveMessage}
|
||||
</p>
|
||||
) : null}
|
||||
<small>
|
||||
当前:文档 {secondsLabel(settings.document_refresh_seconds)}、资源{' '}
|
||||
{secondsLabel(settings.resource_refresh_seconds)}、停滞 {secondsLabel(settings.stalled_after_seconds)}
|
||||
、finalizing {secondsLabel(settings.finalizing_after_seconds)}、入库并发{' '}
|
||||
{settings.ingestion_concurrency}。
|
||||
</small>
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
{isAdmin ? <><button onClick={saveEndpoint} disabled={!canSave || !serviceSettingsValid || !serviceSettingsDirty}>{saving ? '正在验证并启用…' : '保存并启用服务配置'}</button>
|
||||
<small>四项留空即表示未配置。地址只接受 http(s) 源地址(不能带用户名密码、查询串或 # 片段,凭据一律走文件引用);生产 ID 是发布契约里的租户 ID,十进制数字;知识库 ID 是生产知识库标识,粘贴 URL 不会通过。保存写入服务器活动版本(版本化 + 审计 + 原子切换);后端同时对测试地址/生产地址做真实探活,并用生产地址真查这两个 ID(WeKnora 列库接口):端点回答"没有这个知识库"或租户不符会拒绝保存,端点抖动、鉴权失败或未配置生产凭据只警告不拦,核验原话与知识库名在保存后显示。</small>
|
||||
{serviceSettingsValid ? null : <p className="error-message" role="alert">格式不合法:地址需 http:// 或 https:// 开头的纯地址,不能带用户名密码、? 查询串或 # 片段;生产 ID 需为十进制数字;知识库 ID 不能含空格、/、?、# 或 \。</p>}</>
|
||||
: <small>服务配置仅管理员可修改;当前值:测试地址 {settings.test_weknora_base_url || '未配置'} · 生产地址 {settings.production_weknora_base_url || '未配置'} · 生产 ID {settings.production_tenant_id || '未配置'} · 知识库 ID {settings.production_knowledge_base_id || '未配置'}。</small>}
|
||||
</section> : null}
|
||||
{section === 'bindings' ? <RoutingBindingsSection /> : null}
|
||||
{section === 'production-bindings' ? <ProductionBindingsSection /> : null}
|
||||
{section === 'storage' ? <BackupScheduleSection /> : null}
|
||||
{section === 'members' && identity?.role === 'admin' ? <MembersSection /> : null}
|
||||
{section === 'refresh' ? <section className="settings-panel wide" id="settings-refresh">
|
||||
<div className="settings-section-heading"><div><h2>刷新策略</h2><p>这些值保存在服务器活动版本中;保存不会修改端点、凭据或生产开关。</p></div><span className="safe-badge">当前活动版本</span></div>
|
||||
<div className="safe-setting-grid">
|
||||
<label>文档状态刷新间隔<select value={documentRefresh} onChange={(event) => { setDocumentRefresh(Number(event.target.value) as 15 | 30 | 60); setDirty(true) }}><option value={15}>15秒</option><option value={30}>30秒</option><option value={60}>1分钟</option></select></label>
|
||||
<label>资源刷新间隔<select value={resourceRefresh} onChange={(event) => { setResourceRefresh(Number(event.target.value) as 30 | 60); setDirty(true) }}><option value={30}>30秒</option><option value={60}>1分钟</option></select></label>
|
||||
<label>解析停滞判定<select value={stalled} onChange={(event) => { setStalled(Number(event.target.value) as 1800 | 3600); setDirty(true) }}><option value={1800}>30分钟</option><option value={3600}>1小时</option></select></label>
|
||||
<label>finalizing 告警<select value={finalizing} onChange={(event) => { setFinalizing(Number(event.target.value) as 7200 | 14400); setDirty(true) }}><option value={7200}>2小时</option><option value={14400}>4小时</option></select></label>
|
||||
<label>入库并发上限<select value={concurrency} onChange={(event) => { setConcurrency(Number(event.target.value)); setDirty(true) }}><option value={1}>1(谨慎,MinerU 并发 1)</option><option value={2}>2</option><option value={3}>3</option><option value={4}>4</option><option value={6}>6</option><option value={8}>8</option></select></label>
|
||||
</div>
|
||||
<button onClick={() => { setDirty(false); onSave(candidateInput()) }} disabled={!canSave}>{saving ? '正在验证并应用…' : '保存并应用刷新与告警参数'}</button>
|
||||
{visibleSaveMessage(saveMessage, dirty) ? <p className="success-message" role="status">{saveMessage}</p> : null}
|
||||
<small>当前:文档 {secondsLabel(settings.document_refresh_seconds)}、资源 {secondsLabel(settings.resource_refresh_seconds)}、停滞 {secondsLabel(settings.stalled_after_seconds)}、finalizing {secondsLabel(settings.finalizing_after_seconds)}、入库并发 {settings.ingestion_concurrency}。</small>
|
||||
</section> : null}
|
||||
</div>
|
||||
</div> : null}
|
||||
</main>
|
||||
</div>
|
||||
) : null}
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
export function SystemSettings() {
|
||||
@@ -291,7 +761,10 @@ export function SystemSettings() {
|
||||
const [settings, setSettings] = useState<UISettings | null>(null)
|
||||
const [productionEnabled, setProductionEnabled] = useState(false)
|
||||
const [productionBackupRestoreVerified, setProductionBackupRestoreVerified] = useState(false)
|
||||
const [routingCapabilities, setRoutingCapabilities] = useState<CatalogRoutingCapabilities>({ internal_enabled: false, external_enabled: false })
|
||||
const [routingCapabilities, setRoutingCapabilities] = useState<CatalogRoutingCapabilities>({
|
||||
internal_enabled: false,
|
||||
external_enabled: false,
|
||||
})
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
@@ -299,24 +772,76 @@ export function SystemSettings() {
|
||||
const [revision, setRevision] = useState(0)
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController(); setLoading(true)
|
||||
void Promise.all([fetchCatalogSources(controller.signal), fetchSourceConnectionList(controller.signal), fetchMonitorOverview(controller.signal), fetchReleaseCapabilities(controller.signal), fetchCatalogRoutingCapabilities(controller.signal), fetchActiveUISettings(controller.signal)]).then(([nextSources, nextConnections, overview, capabilities, routing, active]) => { if (!controller.signal.aborted) { setSources(nextSources); setConnections(nextConnections); setMonitor(overview); setProductionEnabled(capabilities.production_release_requests_enabled); setProductionBackupRestoreVerified(capabilities.production_backup_restore_verified); setRoutingCapabilities(routing); setSettings(active); setError(null) } }).catch((cause) => { if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : '加载系统设置失败') }).finally(() => { if (!controller.signal.aborted) setLoading(false) })
|
||||
const controller = new AbortController()
|
||||
setLoading(true)
|
||||
void Promise.all([
|
||||
fetchCatalogSources(controller.signal),
|
||||
fetchSourceConnectionList(controller.signal),
|
||||
fetchMonitorOverview(controller.signal),
|
||||
fetchReleaseCapabilities(controller.signal),
|
||||
fetchCatalogRoutingCapabilities(controller.signal),
|
||||
fetchActiveUISettings(controller.signal),
|
||||
])
|
||||
.then(([nextSources, nextConnections, overview, capabilities, routing, active]) => {
|
||||
if (!controller.signal.aborted) {
|
||||
setSources(nextSources)
|
||||
setConnections(nextConnections)
|
||||
setMonitor(overview)
|
||||
setProductionEnabled(capabilities.production_release_requests_enabled)
|
||||
setProductionBackupRestoreVerified(capabilities.production_backup_restore_verified)
|
||||
setRoutingCapabilities(routing)
|
||||
setSettings(active)
|
||||
setError(null)
|
||||
}
|
||||
})
|
||||
.catch((cause) => {
|
||||
if (!controller.signal.aborted) setError(cause instanceof Error ? cause.message : '加载系统设置失败')
|
||||
})
|
||||
.finally(() => {
|
||||
if (!controller.signal.aborted) setLoading(false)
|
||||
})
|
||||
return () => controller.abort()
|
||||
}, [revision])
|
||||
|
||||
const save = async (input: UISettingsCandidateInput) => {
|
||||
setSaving(true); setSaveMessage(null); setError(null)
|
||||
setSaving(true)
|
||||
setSaveMessage(null)
|
||||
setError(null)
|
||||
try {
|
||||
const candidate = await createUISettingsCandidate(input)
|
||||
const activated = await activateUISettings(candidate.settings.id)
|
||||
const active = activated.settings
|
||||
const verification = activated.verification ?? candidate.verification
|
||||
setSettings(active)
|
||||
setSaveMessage(`设置已验证并启用:文档${secondsLabel(active.document_refresh_seconds)}、资源${secondsLabel(active.resource_refresh_seconds)}、停滞${secondsLabel(active.stalled_after_seconds)}、finalizing ${secondsLabel(active.finalizing_after_seconds)}、入库并发 ${active.ingestion_concurrency}、测试地址 ${active.test_weknora_base_url || '未配置'}、生产地址 ${active.production_weknora_base_url || '未配置'}、生产 ID ${active.production_tenant_id || '未配置'}、知识库 ID ${active.production_knowledge_base_id || '未配置'};旧版本已保留用于审计。${verification ? `核验:${verification.message}` : ''}`)
|
||||
setSaveMessage(
|
||||
`设置已验证并启用:文档${secondsLabel(active.document_refresh_seconds)}、资源${secondsLabel(active.resource_refresh_seconds)}、停滞${secondsLabel(active.stalled_after_seconds)}、finalizing ${secondsLabel(active.finalizing_after_seconds)}、入库并发 ${active.ingestion_concurrency}、测试地址 ${active.test_weknora_base_url || '未配置'}、生产地址 ${active.production_weknora_base_url || '未配置'}、生产 ID ${active.production_tenant_id || '未配置'}、知识库 ID ${active.production_knowledge_base_id || '未配置'};旧版本已保留用于审计。${verification ? `核验:${verification.message}` : ''}`
|
||||
)
|
||||
} catch (cause) {
|
||||
setError(cause instanceof Error ? cause.message : '保存系统设置失败')
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
catch (cause) { setError(cause instanceof Error ? cause.message : '保存系统设置失败') }
|
||||
finally { setSaving(false) }
|
||||
}
|
||||
const reloadSources = useCallback(() => { setSaveMessage(null); setRevision((value) => value + 1) }, [])
|
||||
return <SystemSettingsView sources={sources} connections={connections} monitor={monitor} settings={settings} productionEnabled={productionEnabled} productionBackupRestoreVerified={productionBackupRestoreVerified} routingCapabilities={routingCapabilities} loading={loading} saving={saving} error={error} saveMessage={saveMessage} onSave={(input) => void save(input)} onSourcesChanged={reloadSources} onRefresh={reloadSources}/>
|
||||
const reloadSources = useCallback(() => {
|
||||
setSaveMessage(null)
|
||||
setRevision((value) => value + 1)
|
||||
}, [])
|
||||
return (
|
||||
<SystemSettingsView
|
||||
sources={sources}
|
||||
connections={connections}
|
||||
monitor={monitor}
|
||||
settings={settings}
|
||||
productionEnabled={productionEnabled}
|
||||
productionBackupRestoreVerified={productionBackupRestoreVerified}
|
||||
routingCapabilities={routingCapabilities}
|
||||
loading={loading}
|
||||
saving={saving}
|
||||
error={error}
|
||||
saveMessage={saveMessage}
|
||||
onSave={(input) => void save(input)}
|
||||
onSourcesChanged={reloadSources}
|
||||
onRefresh={reloadSources}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
+841
-62
@@ -1,64 +1,843 @@
|
||||
.system-settings{max-width:1500px}.settings-role-strip{display:flex;gap:10px;margin-bottom:12px}.settings-role-strip span{border-radius:8px;padding:8px 11px;font-size:10px}.engineer-role{background:var(--c-run-bg);color:var(--c-run)}.admin-role{background:var(--bg-soft);color:var(--ink-mute)}.settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.settings-panel{min-width:0;border:1px solid var(--border-base);border-radius:12px;padding:15px;background:var(--bg-panel)}.settings-panel.wide{grid-column:1/-1}.settings-panel h2{margin:0 0 12px;color:var(--ink-base);font-size:14px}.settings-panel dl{display:grid;grid-template-columns:1fr auto;gap:8px;margin:0;color:var(--ink-mute);font-size:10px}.settings-panel dd{margin:0;color:var(--ink-base);font-weight:700}.settings-panel dd.ok{color:var(--c-done)}.settings-panel dd.off,.settings-panel .production span{color:var(--c-fail)}.environment-cards{display:grid;grid-template-columns:1fr 1fr;gap:10px}.environment-cards article{display:grid;grid-template-columns:1fr auto;gap:6px;border:1px solid var(--border-base);border-radius:9px;padding:11px;background:var(--bg-soft)}.environment-cards b{color:var(--ink-base);font-size:11px}.environment-cards span{color:var(--c-done);font-size:10px}.environment-cards small{grid-column:1/-1;color:var(--ink-mute);font-size:9px}.environment-cards button{grid-column:2;padding:5px 7px}.mapping-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}.mapping-row>*{border-radius:6px;padding:6px 8px;background:var(--border-soft);color:var(--ink-mute);font-size:9px}.dependency-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px}.dependency-grid article{display:grid;gap:4px;border-radius:8px;padding:9px;background:var(--bg-soft)}.dependency-grid span{color:var(--ink-mute);font-size:9px}.dependency-grid b{color:var(--ink-base);font-size:10px}.dependency-grid small{color:var(--ink-mute);font-size:8px;line-height:1.5}.target-list{display:grid;gap:7px;margin:0;padding:0;list-style:none}.target-list li{display:flex;justify-content:space-between;gap:10px;color:var(--ink-mute);font-size:10px}.target-list b{color:var(--c-fail)}.settings-panel>button{margin-top:12px;padding:7px 10px}.settings-panel>small{display:block;margin-top:7px;color:var(--ink-mute);font-size:8px}.safe-setting-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.safe-setting-grid label{display:grid;gap:6px;color:var(--ink-mute);font-size:10px}.safe-setting-grid select{border:1px solid var(--border-strong);border-radius:7px;padding:8px;background:var(--bg-panel);color:var(--ink-base)}.locked-gates{display:flex;flex-wrap:wrap;gap:7px;margin-top:11px}.locked-gates span{border-radius:6px;padding:6px 8px;background:var(--c-fail-bg);color:var(--c-fail);font-size:9px}@media(max-width:900px){.dependency-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.safe-setting-grid{grid-template-columns:1fr 1fr}}@media(max-width:650px){.settings-grid,.environment-cards{grid-template-columns:1fr}.settings-panel.wide{grid-column:auto}.dependency-grid,.safe-setting-grid{grid-template-columns:1fr}.settings-role-strip{flex-direction:column}}
|
||||
.settings-section-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:14px}.settings-section-heading h2{margin-bottom:4px}.settings-section-heading p{margin:0;color:var(--ink-mute);font-size:10px}.settings-section-heading button{padding:7px 10px;box-shadow:none}.settings-source-list{display:grid;gap:9px}.settings-source-row{display:grid;grid-template-columns:minmax(170px,.8fr) minmax(420px,2fr) minmax(130px,.55fr) auto;align-items:center;gap:14px;border:1px solid var(--border-base);border-radius:10px;padding:12px;background:var(--bg-page)}.settings-source-name{display:grid;gap:4px}.settings-source-name strong{color:var(--ink-base);font-size:12px}.settings-source-name span{color:var(--ink-mute);font-size:9px}.settings-source-row dl{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.settings-source-row dl div{display:grid;gap:3px}.settings-source-row dt{color:var(--ink-mute);font-size:8px}.settings-source-row dd{overflow-wrap:anywhere;color:var(--ink-base);font-size:9px;font-weight:650}.settings-source-row label{display:grid;gap:5px;color:var(--ink-mute);font-size:9px}.settings-source-row select{border:1px solid #c9d9e4;border-radius:7px;padding:7px;background:var(--bg-panel);color:var(--ink-base)}.settings-source-row>button{padding:7px 9px;box-shadow:none}.dependency-grid{margin-top:12px}.storage-settings-grid{display:grid;grid-template-columns:1fr 1fr minmax(220px,.8fr);gap:14px}.storage-settings-grid>dl,.storage-settings-grid>.target-list{border:1px solid var(--border-base);border-radius:9px;padding:12px;background:var(--bg-soft)}@media(max-width:1100px){.settings-source-row{grid-template-columns:1fr 1fr}.settings-source-row dl{grid-column:1/-1}.storage-settings-grid{grid-template-columns:1fr 1fr}.storage-settings-grid>.target-list{grid-column:1/-1}}@media(max-width:700px){.settings-section-heading{flex-direction:column}.settings-source-row,.settings-source-row dl,.storage-settings-grid{grid-template-columns:1fr}.settings-source-row dl{grid-column:auto}.storage-settings-grid>.target-list{grid-column:auto}}.settings-layout{display:grid;grid-template-columns:200px minmax(0,1fr);gap:18px;align-items:start}
|
||||
.settings-nav{display:flex;flex-direction:column;gap:6px;position:sticky;top:16px}
|
||||
.settings-nav button{border:1px solid transparent;background:transparent;text-align:left;padding:9px 12px;border-radius:8px;font:inherit;cursor:pointer;color:var(--ink-base)}
|
||||
.settings-nav button:hover{background:var(--border-soft)}
|
||||
.settings-nav button.active{background:var(--c-run);color:var(--bg-panel);font-weight:600}
|
||||
.settings-content{display:flex;flex-direction:column;gap:14px;min-width:0}
|
||||
.source-schedule-form{display:flex;flex-wrap:wrap;gap:10px;align-items:end;padding-top:6px}
|
||||
.source-schedule-form label{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--ink-base)}
|
||||
.source-schedule-form select,.source-schedule-form input{padding:6px 8px;border:1px solid var(--border-strong);border-radius:6px;font:inherit;background:var(--bg-panel)}
|
||||
.source-schedule-actions{display:flex;gap:8px;align-items:end}
|
||||
button.danger{background:var(--c-fail);color:var(--bg-panel);border:none;padding:8px 14px;border-radius:8px;font:inherit;cursor:pointer}
|
||||
button.danger:hover{background:var(--c-fail)}
|
||||
button.danger:disabled{background:var(--c-fail-border);cursor:not-allowed}
|
||||
button.link{background:none;border:none;color:var(--c-run);cursor:pointer;text-decoration:underline;font:inherit;padding:4px}
|
||||
.manual-source-note{color:var(--ink-mute);font-size:13px}
|
||||
.error-message{color:var(--c-fail);font-size:13px;margin:4px 0}
|
||||
.revision-list{list-style:none;margin:8px 0 0;padding:8px 10px;background:var(--bg-soft);border-radius:8px;display:flex;flex-direction:column;gap:6px;font-size:13px}
|
||||
.revision-list li{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
|
||||
.revision-list span{color:var(--c-run);font-weight:600}
|
||||
.revision-list small{color:var(--ink-mute)}
|
||||
.empty-inline{color:var(--ink-mute);font-size:13px}
|
||||
.modal-backdrop{position:fixed;inset:0;background:rgba(10,25,40,.45);display:flex;align-items:center;justify-content:center;z-index:50;padding:16px}
|
||||
.modal-card{background:var(--bg-panel);border-radius:12px;padding:20px;max-width:420px;box-shadow:0 18px 48px rgba(9,28,46,.35)}
|
||||
.modal-card h3{margin:0 0 8px}
|
||||
.modal-card p{color:var(--ink-base);font-size:14px;line-height:1.6}
|
||||
.modal-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:14px}
|
||||
@media (max-width:900px){.settings-layout{grid-template-columns:1fr}.settings-nav{position:static;flex-direction:row;flex-wrap:wrap}}
|
||||
.kb-binding-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px 0}.kb-binding-side{display:grid;gap:4px;border:1px solid var(--border-base);border-radius:9px;padding:11px;background:var(--bg-soft)}.kb-binding-side.bound{border-color:var(--c-done)}.kb-binding-side.warn{border-color:var(--c-fail)}.kb-binding-side b{color:var(--ink-base);font-size:11px}.kb-binding-side span{color:var(--c-done);font-size:11px;word-break:break-all}.kb-binding-side.warn span{color:var(--c-fail)}.kb-binding-side small{color:var(--ink-mute);font-size:9px}.kb-binding-editor{display:grid;gap:10px;border-top:1px dashed var(--border-base);margin-top:8px;padding-top:12px}.kb-binding-editor label{display:grid;gap:6px;color:var(--ink-mute);font-size:10px}.kb-binding-editor select,.kb-binding-editor input{border:1px solid var(--border-strong);border-radius:7px;padding:8px;background:var(--bg-panel);color:var(--ink-base)}.kb-binding-editor button{justify-self:start;padding:7px 10px}@media(max-width:650px){.kb-binding-grid{grid-template-columns:1fr}}.hint{color:var(--ink-mute);font-size:10px;margin:4px 0}
|
||||
.dingtalk-session-control{display:flex;flex-direction:column;gap:4px;align-self:end}
|
||||
.dingtalk-qr-card{max-width:440px;text-align:center}
|
||||
.dingtalk-qr-hint{color:var(--ink-mute);font-size:13px;min-height:20px}
|
||||
.dingtalk-qr-image{display:block;margin:12px auto;width:320px;height:320px;image-rendering:pixelated;border:12px solid #fff;border-radius:4px;background:#fff;box-sizing:content-box}
|
||||
.dingtalk-qr-loading{display:grid;place-items:center;margin:12px auto;width:320px;height:320px;max-width:80vw;max-height:80vw;border:12px solid #fff;border-radius:4px;background:#fff;box-sizing:content-box}
|
||||
.dingtalk-qr-loading span{width:42px;height:42px;border:4px solid #dbe4ee;border-top-color:var(--brand);border-radius:50%;animation:dingtalk-qr-spin .8s linear infinite}
|
||||
@keyframes dingtalk-qr-spin{to{transform:rotate(360deg)}}
|
||||
.dingtalk-qr-card .modal-actions{justify-content:center}
|
||||
.filename-filter-editor{flex-basis:100%;margin-top:10px;padding:12px;border:1px solid var(--border-base);border-radius:10px;background:var(--bg-soft)}
|
||||
.filename-filter-heading{display:flex;justify-content:space-between;gap:10px;margin-bottom:7px}.filename-filter-heading div{display:grid;gap:3px}.filename-filter-heading small{color:var(--ink-mute)}
|
||||
.filename-filter-inherited,.filename-filter-direct{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:6px 0}.filename-filter-inherited span,.filename-filter-direct span{font-size:10px;color:var(--ink-mute)}
|
||||
.filename-filter-editor code{padding:2px 7px;border-radius:999px;background:#eaf2ff;color:#2456a6;font-family:inherit;font-size:11px}
|
||||
.filename-filter-form{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:9px 0}.filename-filter-form input{min-width:220px;flex:1;padding:7px 9px;border:1px solid var(--border-strong);border-radius:7px;background:var(--bg-panel)}
|
||||
.filename-filter-modes{display:flex;gap:12px;align-self:center;font-size:11px;color:var(--ink-base)}.filename-filter-modes label{display:flex;gap:4px;align-items:center;cursor:pointer}
|
||||
.filename-filter-groups{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px 14px;margin:8px 0}.filename-filter-group{display:grid;gap:4px}.filename-filter-group>span{color:var(--ink-mute);font-size:9px}
|
||||
.filename-filter-group>div{display:flex;flex-wrap:wrap;gap:4px}.filename-filter-group button{border:1px solid var(--border-base);background:var(--bg-panel);color:var(--ink-base);border-radius:999px;padding:2px 8px;font-size:10px;font-family:inherit;cursor:pointer}
|
||||
.filename-filter-group button.picked{background:var(--c-run);border-color:var(--c-run);color:var(--bg-panel);font-weight:650}.filename-filter-group button.blocked{color:var(--c-fail)}
|
||||
@media(max-width:900px){.filename-filter-groups{grid-template-columns:1fr 1fr}}
|
||||
.system-settings {
|
||||
max-width: 1500px;
|
||||
}
|
||||
.settings-role-strip {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.settings-role-strip span {
|
||||
border-radius: 8px;
|
||||
padding: 8px 11px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.engineer-role {
|
||||
background: var(--c-run-bg);
|
||||
color: var(--c-run);
|
||||
}
|
||||
.admin-role {
|
||||
background: var(--bg-soft);
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.settings-panel {
|
||||
min-width: 0;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 12px;
|
||||
padding: 15px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.settings-panel.wide {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.settings-panel h2 {
|
||||
margin: 0 0 12px;
|
||||
color: var(--ink-base);
|
||||
font-size: 14px;
|
||||
}
|
||||
.settings-panel dl {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.settings-panel dd {
|
||||
margin: 0;
|
||||
color: var(--ink-base);
|
||||
font-weight: 700;
|
||||
}
|
||||
.settings-panel dd.ok {
|
||||
color: var(--c-done);
|
||||
}
|
||||
.settings-panel dd.off,
|
||||
.settings-panel .production span {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.environment-cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
.environment-cards article {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 6px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.environment-cards b {
|
||||
color: var(--ink-base);
|
||||
font-size: 11px;
|
||||
}
|
||||
.environment-cards span {
|
||||
color: var(--c-done);
|
||||
font-size: 10px;
|
||||
}
|
||||
.environment-cards small {
|
||||
grid-column: 1/-1;
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.environment-cards button {
|
||||
grid-column: 2;
|
||||
padding: 5px 7px;
|
||||
}
|
||||
.mapping-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.mapping-row > * {
|
||||
border-radius: 6px;
|
||||
padding: 6px 8px;
|
||||
background: var(--border-soft);
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.dependency-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.dependency-grid article {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
border-radius: 8px;
|
||||
padding: 9px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.dependency-grid span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.dependency-grid b {
|
||||
color: var(--ink-base);
|
||||
font-size: 10px;
|
||||
}
|
||||
.dependency-grid small {
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.target-list {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.target-list li {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.target-list b {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.settings-panel > button {
|
||||
margin-top: 12px;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
.settings-panel > small {
|
||||
display: block;
|
||||
margin-top: 7px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
}
|
||||
.safe-setting-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.safe-setting-grid label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.safe-setting-grid select {
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
padding: 8px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.locked-gates {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 7px;
|
||||
margin-top: 11px;
|
||||
}
|
||||
.locked-gates span {
|
||||
border-radius: 6px;
|
||||
padding: 6px 8px;
|
||||
background: var(--c-fail-bg);
|
||||
color: var(--c-fail);
|
||||
font-size: 9px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.dependency-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
.safe-setting-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 650px) {
|
||||
.settings-grid,
|
||||
.environment-cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-panel.wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
.dependency-grid,
|
||||
.safe-setting-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-role-strip {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
.settings-section-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.settings-section-heading h2 {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.settings-section-heading p {
|
||||
margin: 0;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.settings-section-heading button {
|
||||
padding: 7px 10px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.settings-source-list {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
}
|
||||
.settings-source-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(170px, 0.8fr) minmax(420px, 2fr) minmax(130px, 0.55fr) auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
background: var(--bg-page);
|
||||
}
|
||||
.settings-source-name {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.settings-source-name strong {
|
||||
color: var(--ink-base);
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-source-name span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
.settings-source-row dl div {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
.settings-source-row dt {
|
||||
color: var(--ink-mute);
|
||||
font-size: 8px;
|
||||
}
|
||||
.settings-source-row dd {
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--ink-base);
|
||||
font-size: 9px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.settings-source-row label {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.settings-source-row select {
|
||||
border: 1px solid #c9d9e4;
|
||||
border-radius: 7px;
|
||||
padding: 7px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.settings-source-row > button {
|
||||
padding: 7px 9px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.dependency-grid {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.storage-settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr minmax(220px, 0.8fr);
|
||||
gap: 14px;
|
||||
}
|
||||
.storage-settings-grid > dl,
|
||||
.storage-settings-grid > .target-list {
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 12px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.settings-source-row {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.storage-settings-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.storage-settings-grid > .target-list {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
.settings-section-heading {
|
||||
flex-direction: column;
|
||||
}
|
||||
.settings-source-row,
|
||||
.settings-source-row dl,
|
||||
.storage-settings-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
grid-column: auto;
|
||||
}
|
||||
.storage-settings-grid > .target-list {
|
||||
grid-column: auto;
|
||||
}
|
||||
}
|
||||
.settings-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 200px minmax(0, 1fr);
|
||||
gap: 18px;
|
||||
align-items: start;
|
||||
}
|
||||
.settings-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
position: sticky;
|
||||
top: 16px;
|
||||
}
|
||||
.settings-nav button {
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
padding: 9px 12px;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.settings-nav button:hover {
|
||||
background: var(--border-soft);
|
||||
}
|
||||
.settings-nav button.active {
|
||||
background: var(--c-run);
|
||||
color: var(--bg-panel);
|
||||
font-weight: 600;
|
||||
}
|
||||
.settings-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
.source-schedule-form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
padding-top: 6px;
|
||||
}
|
||||
.source-schedule-form label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.source-schedule-form select,
|
||||
.source-schedule-form input {
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
font: inherit;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.source-schedule-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: end;
|
||||
}
|
||||
button.danger {
|
||||
background: var(--c-fail);
|
||||
color: var(--bg-panel);
|
||||
border: none;
|
||||
padding: 8px 14px;
|
||||
border-radius: 8px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
button.danger:hover {
|
||||
background: var(--c-fail);
|
||||
}
|
||||
button.danger:disabled {
|
||||
background: var(--c-fail-border);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
button.link {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--c-run);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
font: inherit;
|
||||
padding: 4px;
|
||||
}
|
||||
.manual-source-note {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
}
|
||||
.error-message {
|
||||
color: var(--c-fail);
|
||||
font-size: 13px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.revision-list {
|
||||
list-style: none;
|
||||
margin: 8px 0 0;
|
||||
padding: 8px 10px;
|
||||
background: var(--bg-soft);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.revision-list li {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.revision-list span {
|
||||
color: var(--c-run);
|
||||
font-weight: 600;
|
||||
}
|
||||
.revision-list small {
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.empty-inline {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
}
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(10, 25, 40, 0.45);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 50;
|
||||
padding: 16px;
|
||||
}
|
||||
.modal-card {
|
||||
background: var(--bg-panel);
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
max-width: 420px;
|
||||
box-shadow: 0 18px 48px rgba(9, 28, 46, 0.35);
|
||||
}
|
||||
.modal-card h3 {
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.modal-card p {
|
||||
color: var(--ink-base);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 14px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.settings-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.settings-nav {
|
||||
position: static;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
.kb-binding-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
.kb-binding-side {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.kb-binding-side.bound {
|
||||
border-color: var(--c-done);
|
||||
}
|
||||
.kb-binding-side.warn {
|
||||
border-color: var(--c-fail);
|
||||
}
|
||||
.kb-binding-side b {
|
||||
color: var(--ink-base);
|
||||
font-size: 11px;
|
||||
}
|
||||
.kb-binding-side span {
|
||||
color: var(--c-done);
|
||||
font-size: 11px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.kb-binding-side.warn span {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
.kb-binding-side small {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.kb-binding-editor {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
border-top: 1px dashed var(--border-base);
|
||||
margin-top: 8px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
.kb-binding-editor label {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
}
|
||||
.kb-binding-editor select,
|
||||
.kb-binding-editor input {
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
padding: 8px;
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.kb-binding-editor button {
|
||||
justify-self: start;
|
||||
padding: 7px 10px;
|
||||
}
|
||||
@media (max-width: 650px) {
|
||||
.kb-binding-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
.hint {
|
||||
color: var(--ink-mute);
|
||||
font-size: 10px;
|
||||
margin: 4px 0;
|
||||
}
|
||||
.dingtalk-session-control {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
align-self: end;
|
||||
}
|
||||
.dingtalk-qr-card {
|
||||
max-width: 440px;
|
||||
text-align: center;
|
||||
}
|
||||
.dingtalk-qr-hint {
|
||||
color: var(--ink-mute);
|
||||
font-size: 13px;
|
||||
min-height: 20px;
|
||||
}
|
||||
.dingtalk-qr-image {
|
||||
display: block;
|
||||
margin: 12px auto;
|
||||
width: 320px;
|
||||
height: 320px;
|
||||
image-rendering: pixelated;
|
||||
border: 12px solid #fff;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.dingtalk-qr-loading {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin: 12px auto;
|
||||
width: 320px;
|
||||
height: 320px;
|
||||
max-width: 80vw;
|
||||
max-height: 80vw;
|
||||
border: 12px solid #fff;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.dingtalk-qr-loading span {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border: 4px solid #dbe4ee;
|
||||
border-top-color: var(--brand);
|
||||
border-radius: 50%;
|
||||
animation: dingtalk-qr-spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes dingtalk-qr-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
.dingtalk-qr-card .modal-actions {
|
||||
justify-content: center;
|
||||
}
|
||||
.filename-filter-editor {
|
||||
flex-basis: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-soft);
|
||||
}
|
||||
.filename-filter-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
.filename-filter-heading div {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
.filename-filter-heading small {
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.filename-filter-inherited,
|
||||
.filename-filter-direct {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin: 6px 0;
|
||||
}
|
||||
.filename-filter-inherited span,
|
||||
.filename-filter-direct span {
|
||||
font-size: 10px;
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.filename-filter-editor code {
|
||||
padding: 2px 7px;
|
||||
border-radius: 999px;
|
||||
background: #eaf2ff;
|
||||
color: #2456a6;
|
||||
font-family: inherit;
|
||||
font-size: 11px;
|
||||
}
|
||||
.filename-filter-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin: 9px 0;
|
||||
}
|
||||
.filename-filter-form input {
|
||||
min-width: 220px;
|
||||
flex: 1;
|
||||
padding: 7px 9px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.filename-filter-modes {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-self: center;
|
||||
font-size: 11px;
|
||||
color: var(--ink-base);
|
||||
}
|
||||
.filename-filter-modes label {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.filename-filter-groups {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 6px 14px;
|
||||
margin: 8px 0;
|
||||
}
|
||||
.filename-filter-group {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.filename-filter-group > span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
}
|
||||
.filename-filter-group > div {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
.filename-filter-group button {
|
||||
border: 1px solid var(--border-base);
|
||||
background: var(--bg-panel);
|
||||
color: var(--ink-base);
|
||||
border-radius: 999px;
|
||||
padding: 2px 8px;
|
||||
font-size: 10px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.filename-filter-group button.picked {
|
||||
background: var(--c-run);
|
||||
border-color: var(--c-run);
|
||||
color: var(--bg-panel);
|
||||
font-weight: 650;
|
||||
}
|
||||
.filename-filter-group button.blocked {
|
||||
color: var(--c-fail);
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.filename-filter-groups {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
/* 数据源发现(系统设置 → 数据源配置):列出可勾选为来源的钉钉知识库与钉盘空间。 */
|
||||
.dingtalk-discovery { display: flex; flex-direction: column; gap: 10px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--border, #e3e8ec); border-radius: 10px; background: var(--card, #fff); }
|
||||
.dingtalk-discovery-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
||||
.dingtalk-discovery-heading strong { display: block; font-size: 14px; }
|
||||
.dingtalk-discovery-heading small { display: block; color: var(--muted-foreground, #5b6773); font-size: 12px; }
|
||||
.dingtalk-discovery-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
||||
.discovery-group h4 { margin: 0 0 6px; font-size: 13px; }
|
||||
.discovery-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
|
||||
.discovery-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 6px; }
|
||||
.discovery-row:hover { background: var(--accent, #f2f5f8); }
|
||||
.discovery-row label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
||||
.discovery-row.registered label { cursor: default; color: var(--muted-foreground, #5b6773); }
|
||||
.discovery-row strong { font-size: 13px; font-weight: 500; }
|
||||
.discovery-row small { display: block; font-size: 11px; color: var(--muted-foreground, #5b6773); }
|
||||
.dingtalk-discovery-actions { display: flex; align-items: center; gap: 10px; }
|
||||
.dingtalk-discovery-actions small { color: var(--muted-foreground, #5b6773); font-size: 12px; }
|
||||
.dingtalk-discovery {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
margin-bottom: 14px;
|
||||
border: 1px solid var(--border, #e3e8ec);
|
||||
border-radius: 10px;
|
||||
background: var(--card, #fff);
|
||||
}
|
||||
.dingtalk-discovery-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.dingtalk-discovery-heading strong {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dingtalk-discovery-heading small {
|
||||
display: block;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
font-size: 12px;
|
||||
}
|
||||
.dingtalk-discovery-groups {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
.discovery-group h4 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.discovery-group ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
max-height: 220px;
|
||||
overflow: auto;
|
||||
}
|
||||
.discovery-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.discovery-row:hover {
|
||||
background: var(--accent, #f2f5f8);
|
||||
}
|
||||
.discovery-row label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.discovery-row.registered label {
|
||||
cursor: default;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
}
|
||||
.discovery-row strong {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.discovery-row small {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
}
|
||||
.dingtalk-discovery-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.dingtalk-discovery-actions small {
|
||||
color: var(--muted-foreground, #5b6773);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 折叠的 AList/钉钉知识库来源开关:默认收起,只露一行说明,不抢 PP 资料的视线。 */
|
||||
.settings-legacy-toggle {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 0.75rem;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
.settings-legacy-toggle small {
|
||||
color: #5a6572;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user