refactor: remove document download functionality and related translations

This commit is contained in:
twwu 2025-08-22 18:16:50 +08:00 committed by -LAN-
parent 9704319e10
commit 337ad75114
No known key found for this signature in database
GPG Key ID: 6BA0D108DED011FF
3 changed files with 3 additions and 49 deletions

View File

@ -7,7 +7,6 @@ import { pick, uniq } from 'lodash-es'
import {
RiArchive2Line,
RiDeleteBinLine,
RiDownloadLine,
RiEditLine,
RiEqualizer2Line,
RiLoopLeftLine,
@ -35,7 +34,6 @@ import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator
import Indicator from '@/app/components/header/indicator'
import { asyncRunSafe } from '@/utils'
import { formatNumber } from '@/utils/format'
import { useDocumentDownload } from '@/service/knowledge/use-document'
import NotionIcon from '@/app/components/base/notion-icon'
import ProgressBar from '@/app/components/base/progress-bar'
import { ChunkingMode, DataSourceType, DocumentActionType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets'
@ -189,7 +187,6 @@ export const OperationAction: FC<{
scene?: 'list' | 'detail'
className?: string
}> = ({ embeddingAvailable, datasetId, detail, onUpdate, scene = 'list', className = '' }) => {
const downloadDocument = useDocumentDownload()
const { id, enabled = false, archived = false, data_source_type, display_status } = detail || {}
const [showModal, setShowModal] = useState(false)
const [deleting, setDeleting] = useState(false)
@ -298,31 +295,6 @@ export const OperationAction: FC<{
)}
{embeddingAvailable && (
<>
<Tooltip
popupContent={t('datasetDocuments.list.action.download')}
popupClassName='text-text-secondary system-xs-medium'
>
<button
className={cn('mr-2 cursor-pointer rounded-lg',
!isListScene
? 'shadow-shadow-3 border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg p-2 shadow-xs backdrop-blur-[5px] hover:border-components-button-secondary-border-hover hover:bg-components-button-secondary-bg-hover'
: 'p-0.5 hover:bg-state-base-hover')}
onClick={() => {
downloadDocument.mutateAsync({
datasetId,
documentId: detail.id,
}).then((response) => {
if (response.download_url)
window.location.href = response.download_url
}).catch((error) => {
console.error(error)
notify({ type: 'error', message: t('common.actionMsg.downloadFailed') })
})
}}
>
<RiDownloadLine className='h-4 w-4 text-components-button-secondary-text' />
</button>
</Tooltip>
<Tooltip
popupContent={t('datasetDocuments.list.action.settings')}
popupClassName='text-text-secondary system-xs-medium'
@ -526,7 +498,7 @@ const DocumentList: FC<IDocumentListProps> = ({
const result = aValue.localeCompare(bValue)
return sortOrder === 'asc' ? result : -result
}
else {
else {
const result = aValue - bValue
return sortOrder === 'asc' ? result : -result
}
@ -539,7 +511,7 @@ const DocumentList: FC<IDocumentListProps> = ({
if (sortField === field) {
setSortOrder(sortOrder === 'asc' ? 'desc' : 'asc')
}
else {
else {
setSortField(field)
setSortOrder('desc')
}

View File

@ -32,7 +32,6 @@ const translation = {
sync: 'Sync',
pause: 'Pause',
resume: 'Resume',
download: 'Download File',
},
index: {
enable: 'Enable',

View File

@ -8,9 +8,7 @@ import type { MetadataType, SortType } from '../datasets'
import { pauseDocIndexing, resumeDocIndexing } from '../datasets'
import type { DocumentDetailResponse, DocumentListResponse, UpdateDocumentBatchParams } from '@/models/datasets'
import { DocumentActionType } from '@/models/datasets'
import type { CommonResponse, FileDownloadResponse } from '@/models/common'
// Download document with authentication (sends Authorization header)
import Toast from '@/app/components/base/toast'
import type { CommonResponse } from '@/models/common'
const NAME_SPACE = 'knowledge/document'
@ -97,21 +95,6 @@ export const useSyncDocument = () => {
})
}
// Download document with authentication (sends Authorization header)
export const useDocumentDownload = () => {
return useMutation({
mutationFn: async ({ datasetId, documentId }: { datasetId: string; documentId: string }) => {
// The get helper automatically adds the Authorization header from localStorage
return get<FileDownloadResponse>(`/datasets/${datasetId}/documents/${documentId}/upload-file`)
},
onError: (error: any) => {
// Show a toast notification if download fails
const message = error?.message || 'Download failed.'
Toast.notify({ type: 'error', message })
},
})
}
export const useSyncWebsite = () => {
return useMutation({
mutationFn: ({ datasetId, documentId }: UpdateDocumentBatchParams) => {