This commit is contained in:
@@ -198,9 +198,8 @@ describe('SystemSettingsView', () => {
|
||||
// 需求(2026-10-14 收敛):数据源配置只剩两个入口 —— dws 导入(按当前钉钉账号发现)
|
||||
// 与 PP 导入;AList/静态钉钉知识库等来源类型不再出现在这里(也没有折叠开关兜着)。
|
||||
expect(html).toContain('公司级技术支持知识库')
|
||||
expect(html).toContain('dws 共享授权')
|
||||
for (const hidden of ['专用浏览器扫码会话', '显示 AList/钉钉知识库来源'])
|
||||
expect(html).not.toContain(hidden)
|
||||
expect(html).not.toContain('dws 共享授权')
|
||||
for (const hidden of ['专用浏览器扫码会话', '显示 AList/钉钉知识库来源']) expect(html).not.toContain(hidden)
|
||||
// 统一入口后不再按类型分标题:PP 与钉钉共用同一张清单与同一个添加向导。
|
||||
expect(html).not.toContain('PP 导入')
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
@@ -291,9 +290,10 @@ describe('SystemSettingsView', () => {
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
for (const kept of ['查看修订历史', '保存并启用调度', '停用来源', '下次自动刷新']) expect(html).toContain(kept)
|
||||
for (const kept of ['更多', '下次自动刷新']) expect(html).toContain(kept)
|
||||
for (const hidden of ['查看修订历史', '保存并启用调度', '停用来源']) expect(html).not.toContain(hidden)
|
||||
expect(html).not.toContain('本页只列 PP 来源')
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
expect(html).not.toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
@@ -561,9 +561,11 @@ describe('SystemSettingsView 数据源配置的默认清单', () => {
|
||||
expect(html).toContain('+ 添加数据源')
|
||||
expect(html).not.toContain('PP 导入')
|
||||
expect(html).not.toContain('去掉来源')
|
||||
expect(html).toContain('端点与凭据')
|
||||
// PP 来源的卡片操作照旧:改刷新周期、启停、看修订历史。
|
||||
for (const kept of ['查看修订历史', '保存并启用调度', '停用来源', '自动刷新周期']) expect(html).toContain(kept)
|
||||
for (const removed of ['端点与凭据', '认证方式', '查看修订历史', '保存并启用调度', '停用来源', '自动刷新周期'])
|
||||
expect(html).not.toContain(removed)
|
||||
expect(html).toContain('更多')
|
||||
expect(html).toContain('aria-expanded="false"')
|
||||
expect(html).toContain('已启用')
|
||||
for (const removed of ['+ 新增钉钉知识库', '文件格式筛选']) expect(html).not.toContain(removed)
|
||||
// 文档工程师看不到添加向导与「去掉来源」:两者都是管理员动作。
|
||||
const engineer = view('engineer')
|
||||
|
||||
+62
-64
@@ -76,12 +76,6 @@ const sourceTypeLabels: Record<string, string> = {
|
||||
export const ppSourceConnections = (connections: SourceConnectionListItem[]) =>
|
||||
connections.filter((item) => item.source_type === 'pp')
|
||||
|
||||
const sourceAuthLabels: Record<string, string> = {
|
||||
dingtalk: 'dws 共享授权',
|
||||
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)
|
||||
@@ -165,6 +159,7 @@ function SourceSettingsCard({
|
||||
const [showHistory, setShowHistory] = useState(false)
|
||||
const [history, setHistory] = useState<SourceSettingsRevision[] | null>(null)
|
||||
const [pendingDisable, setPendingDisable] = useState(false)
|
||||
const [showOptions, setShowOptions] = useState(false)
|
||||
const scheduled = connection.source_type !== 'manual'
|
||||
|
||||
const submit = async (nextEnabled: boolean) => {
|
||||
@@ -195,6 +190,10 @@ function SourceSettingsCard({
|
||||
}
|
||||
|
||||
const loadHistory = async () => {
|
||||
if (showHistory) {
|
||||
setShowHistory(false)
|
||||
return
|
||||
}
|
||||
setShowHistory(true)
|
||||
if (history) return
|
||||
try {
|
||||
@@ -210,67 +209,66 @@ function SourceSettingsCard({
|
||||
<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>{sourceTypeLabels[connection.source_type] ?? connection.source_type}</span>
|
||||
</div>
|
||||
<div className="settings-source-status">
|
||||
<span className={connection.enabled ? 'source-enabled' : 'source-disabled'}>
|
||||
{connection.enabled ? '已启用' : '已停用'}
|
||||
</span>
|
||||
<small>{connection.enabled ? formatHorizon(connection.next_refresh_at) : '自动刷新已暂停'}</small>
|
||||
</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
|
||||
className="secondary source-more"
|
||||
aria-expanded={showOptions}
|
||||
aria-controls={`source-options-${connection.id}`}
|
||||
onClick={() => setShowOptions(!showOptions)}
|
||||
>
|
||||
{showOptions ? '收起' : '更多'}
|
||||
</button>
|
||||
{showOptions ? (
|
||||
<div className="source-schedule-form" id={`source-options-${connection.id}`}>
|
||||
{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}
|
||||
<div className="source-schedule-links">
|
||||
<button className="link" onClick={() => void loadHistory()}>
|
||||
{showHistory ? '收起修订历史' : '查看修订历史'}
|
||||
</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}
|
||||
<div className="source-schedule-links">
|
||||
<button className="link" onClick={() => void loadHistory()}>
|
||||
{showHistory ? '收起修订历史' : '查看修订历史'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{message ? (
|
||||
<p className="success-message" role="status">
|
||||
{message}
|
||||
@@ -281,7 +279,7 @@ function SourceSettingsCard({
|
||||
{failure}
|
||||
</p>
|
||||
) : null}
|
||||
{showHistory && history ? (
|
||||
{showOptions && showHistory && history ? (
|
||||
<ul className="revision-list">
|
||||
{history.map((item) => (
|
||||
<li key={item.id}>
|
||||
@@ -303,7 +301,7 @@ function SourceSettingsCard({
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
{showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{showOptions && showHistory && !history ? <small>正在加载修订历史…</small> : null}
|
||||
{pendingDisable ? (
|
||||
<div className="modal-backdrop" role="dialog" aria-modal="true">
|
||||
<div className="modal-card">
|
||||
|
||||
@@ -235,13 +235,13 @@
|
||||
}
|
||||
.settings-source-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(170px, 0.8fr) minmax(420px, 2fr) minmax(130px, 0.55fr) auto;
|
||||
grid-template-columns: minmax(180px, 1fr) minmax(180px, 0.8fr) auto;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
border: 1px solid var(--border-base);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
background: var(--bg-page);
|
||||
padding: 18px 20px;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
.settings-source-name {
|
||||
display: grid;
|
||||
@@ -249,11 +249,11 @@
|
||||
}
|
||||
.settings-source-name strong {
|
||||
color: var(--ink-base);
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.settings-source-name span {
|
||||
color: var(--ink-mute);
|
||||
font-size: 9px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
display: grid;
|
||||
@@ -291,6 +291,39 @@
|
||||
padding: 7px 9px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.settings-source-status {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-source-status small {
|
||||
color: var(--ink-mute);
|
||||
font-size: 11px;
|
||||
}
|
||||
.source-enabled {
|
||||
color: #18704b;
|
||||
}
|
||||
.source-disabled {
|
||||
color: var(--ink-mute);
|
||||
}
|
||||
.settings-source-row .source-schedule-form {
|
||||
grid-column: 1 / -1;
|
||||
border-top: 1px solid var(--border-base);
|
||||
padding-top: 16px;
|
||||
}
|
||||
.settings-source-row > .success-message,
|
||||
.settings-source-row > .error-message,
|
||||
.settings-source-row > .revision-list {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.settings-source-row .source-more {
|
||||
font-size: 12px;
|
||||
min-width: 64px;
|
||||
}
|
||||
.settings-source-row .source-more:focus-visible {
|
||||
outline: 2px solid #2978bd;
|
||||
outline-offset: 3px;
|
||||
}
|
||||
.dependency-grid {
|
||||
margin-top: 12px;
|
||||
}
|
||||
@@ -308,7 +341,15 @@
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.settings-source-row {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
}
|
||||
.settings-source-status {
|
||||
grid-column: 1;
|
||||
grid-row: 2;
|
||||
}
|
||||
.settings-source-row .source-more {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
.settings-source-row dl {
|
||||
grid-column: 1/-1;
|
||||
|
||||
Reference in New Issue
Block a user