feat(llm): 处理完成的消息自动软删除并隐藏删除按钮
- MarkAsProcessed 在写入 reply/processed_at 的同时设置 deleted_at, 避免 /admin/llm 队列页堆积已处理消息(仍可勾选"包含已删除"查看) - 前端列表中已删除的消息行隐藏删除按钮,改为显示灰色"已删除"标签 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -92,13 +92,15 @@ func (q *DBMessageQueue) MarkAsProcessing(id uint64) error {
|
|||||||
return q.db.Model(&llmMessageQueueRecord{}).Where("id = ?", id).Update("status", statusProcessing).Error
|
return q.db.Model(&llmMessageQueueRecord{}).Where("id = ?", id).Update("status", statusProcessing).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkAsProcessed marks a message as successfully processed
|
// MarkAsProcessed marks a message as successfully processed and soft-deletes it
|
||||||
|
// 处理完成的消息直接软删除,避免队列页堆积;保留 reply/processed_at 便于查询历史
|
||||||
func (q *DBMessageQueue) MarkAsProcessed(id uint64, reply string) error {
|
func (q *DBMessageQueue) MarkAsProcessed(id uint64, reply string) error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
return q.db.Model(&llmMessageQueueRecord{}).Where("id = ?", id).Updates(map[string]any{
|
return q.db.Model(&llmMessageQueueRecord{}).Where("id = ?", id).Updates(map[string]any{
|
||||||
"status": statusProcessed,
|
"status": statusProcessed,
|
||||||
"reply": reply,
|
"reply": reply,
|
||||||
"processed_at": &now,
|
"processed_at": &now,
|
||||||
|
"deleted_at": &now,
|
||||||
}).Error
|
}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,9 +298,14 @@ onMounted(() => {
|
|||||||
<td>{{ formatTime(msg.received_at) }}</td>
|
<td>{{ formatTime(msg.received_at) }}</td>
|
||||||
<td>{{ formatTime(msg.processed_at) }}</td>
|
<td>{{ formatTime(msg.processed_at) }}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="admin-button admin-button-small admin-button-danger" @click="handleDeleteMessage(msg.id)">
|
<button
|
||||||
|
v-if="!msg.deleted_at"
|
||||||
|
class="admin-button admin-button-small admin-button-danger"
|
||||||
|
@click="handleDeleteMessage(msg.id)"
|
||||||
|
>
|
||||||
删除
|
删除
|
||||||
</button>
|
</button>
|
||||||
|
<span v-else class="muted-tag">已删除</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="messages.length === 0">
|
<tr v-if="messages.length === 0">
|
||||||
@@ -678,6 +683,15 @@ onMounted(() => {
|
|||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.muted-tag {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.25rem 0.6rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #94a3b8;
|
||||||
|
background: #f1f5f9;
|
||||||
|
}
|
||||||
|
|
||||||
.status-badge[style*='#fff3cd'] {
|
.status-badge[style*='#fff3cd'] {
|
||||||
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
|
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
|
||||||
color: #92400e;
|
color: #92400e;
|
||||||
|
|||||||
Reference in New Issue
Block a user