|
|
|
@ -18,6 +18,7 @@ interface AgentDocumentItem { |
|
|
|
type: 'memory' | 'document' |
|
|
|
summary: string | null |
|
|
|
tags: string[] |
|
|
|
disabled: boolean |
|
|
|
createdAt: string |
|
|
|
updatedAt: string |
|
|
|
} |
|
|
|
@ -38,6 +39,7 @@ interface DocDetail { |
|
|
|
summary: string | null |
|
|
|
tags: string[] |
|
|
|
agentId: number | null |
|
|
|
disabled: boolean |
|
|
|
createdAt: string |
|
|
|
updatedAt: string |
|
|
|
} |
|
|
|
@ -57,6 +59,25 @@ const searchQuery = ref('') |
|
|
|
const scope = ref<'agent' | 'all'>('agent') |
|
|
|
const agents = ref<AgentItem[]>([]) |
|
|
|
const scopeSaving = ref(false) |
|
|
|
const toggling = ref(false) |
|
|
|
|
|
|
|
async function toggleDisabled() { |
|
|
|
if (!selectedDoc.value) return |
|
|
|
toggling.value = true |
|
|
|
try { |
|
|
|
await request(`/api/agent-documents/${selectedDoc.value.id}`, { |
|
|
|
method: 'PATCH', |
|
|
|
body: { disabled: !selectedDoc.value.disabled }, |
|
|
|
}) |
|
|
|
$toast.success(selectedDoc.value.disabled ? '已启用' : '已禁用') |
|
|
|
await openDetail(selectedDoc.value.id) |
|
|
|
await fetchDocuments() |
|
|
|
} catch (e: any) { |
|
|
|
$toast.error(e?.data?.message || e?.message || '操作失败') |
|
|
|
} finally { |
|
|
|
toggling.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function fetchAgents() { |
|
|
|
try { |
|
|
|
@ -267,6 +288,7 @@ watch(() => props.show, (val) => { |
|
|
|
<span class="type-badge" :class="item.type"> |
|
|
|
{{ item.type === 'document' ? '文档' : '记忆' }} |
|
|
|
</span> |
|
|
|
<span v-if="item.type === 'memory' && item.disabled" class="disabled-badge">已禁用</span> |
|
|
|
<span class="card-date">{{ new Date(item.updatedAt).toLocaleDateString('zh-CN') }}</span> |
|
|
|
<button |
|
|
|
class="card-delete-btn" |
|
|
|
@ -298,6 +320,14 @@ watch(() => props.show, (val) => { |
|
|
|
<Icon name="lucide:trash-2" /> |
|
|
|
<span>{{ deleting ? '删除中…' : '删除' }}</span> |
|
|
|
</button> |
|
|
|
<button |
|
|
|
v-if="selectedDoc.type === 'memory'" |
|
|
|
class="toggle-btn" |
|
|
|
:disabled="toggling" |
|
|
|
@click="toggleDisabled" |
|
|
|
> |
|
|
|
{{ toggling ? '处理中…' : (selectedDoc.disabled ? '启用' : '禁用') }} |
|
|
|
</button> |
|
|
|
<button class="close-btn" @click="emit('close')"> |
|
|
|
<Icon name="lucide:x" /> |
|
|
|
</button> |
|
|
|
@ -310,6 +340,7 @@ watch(() => props.show, (val) => { |
|
|
|
<span class="type-badge" :class="selectedDoc.type"> |
|
|
|
{{ selectedDoc.type === 'document' ? '文档' : '记忆' }} |
|
|
|
</span> |
|
|
|
<span v-if="selectedDoc.type === 'memory' && selectedDoc.disabled" class="disabled-badge">已禁用</span> |
|
|
|
<span class="detail-date"> |
|
|
|
{{ new Date(selectedDoc.updatedAt).toLocaleString('zh-CN') }} |
|
|
|
</span> |
|
|
|
@ -629,6 +660,39 @@ watch(() => props.show, (val) => { |
|
|
|
color: #1a5276; |
|
|
|
} |
|
|
|
|
|
|
|
.disabled-badge { |
|
|
|
font-size: 10px; |
|
|
|
padding: 2px 6px; |
|
|
|
border-radius: 4px; |
|
|
|
font-weight: 500; |
|
|
|
background: #fde8e8; |
|
|
|
color: #c0392b; |
|
|
|
} |
|
|
|
|
|
|
|
.toggle-btn { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
gap: 4px; |
|
|
|
padding: 6px 10px; |
|
|
|
border: none; |
|
|
|
background: none; |
|
|
|
border-radius: 8px; |
|
|
|
cursor: pointer; |
|
|
|
color: var(--color-muted, #6c6a64); |
|
|
|
font-size: 13px; |
|
|
|
transition: all 0.15s; |
|
|
|
} |
|
|
|
|
|
|
|
.toggle-btn:hover:not(:disabled) { |
|
|
|
background: var(--color-surface-soft, #efe9de); |
|
|
|
color: var(--color-ink, #141413); |
|
|
|
} |
|
|
|
|
|
|
|
.toggle-btn:disabled { |
|
|
|
opacity: 0.5; |
|
|
|
cursor: not-allowed; |
|
|
|
} |
|
|
|
|
|
|
|
.card-date { |
|
|
|
font-size: 11px; |
|
|
|
color: var(--color-muted, #b8b2a6); |
|
|
|
|