feat: Enhance file upload functionality with progress tracking

- Updated the `uploadKnowledgeFile` function to accept an optional progress callback, enabling real-time upload progress tracking.
- Refactored the document upload handling in the menu component to support multiple file uploads with individual progress events.
- Removed deprecated document processing state management from the KnowledgeBase view, streamlining the upload process.
- Improved user feedback during file uploads by dispatching events for upload start, progress, and completion.
This commit is contained in:
wizardchen
2025-11-24 00:21:42 +08:00
parent 057cfd9eb0
commit 4a2be2b878
12 changed files with 790 additions and 532 deletions
+19
View File
@@ -171,3 +171,22 @@ func (r *chunkRepository) CountChunksByKnowledgeBaseID(ctx context.Context, tena
Count(&count).Error
return count, err
}
func (r *chunkRepository) DeleteChunksByChunkIndexRange(ctx context.Context, tenantID uint, knowledgeID string, startChunkIndex int, endChunkIndex int) ([]*types.Chunk, error) {
var chunks []*types.Chunk
// 先查询要删除的chunks
if err := r.db.WithContext(ctx).
Where("tenant_id = ? AND knowledge_id = ? AND chunk_index >= ? AND chunk_index <= ? AND deleted_at IS NULL", tenantID, knowledgeID, startChunkIndex, endChunkIndex).
Find(&chunks).Error; err != nil {
return nil, err
}
// 然后删除它们
if len(chunks) > 0 {
if err := r.db.WithContext(ctx).
Where("tenant_id = ? AND knowledge_id = ? AND chunk_index >= ? AND chunk_index <= ? AND deleted_at IS NULL", tenantID, knowledgeID, startChunkIndex, endChunkIndex).
Delete(&types.Chunk{}).Error; err != nil {
return nil, err
}
}
return chunks, nil
}