fix: 添加多个目录到知识库多个进度之间展示混淆
This commit is contained in:
parent
b3629e83f2
commit
3015e90925
@ -87,7 +87,10 @@ class KnowledgeService {
|
|||||||
|
|
||||||
const sendDirectoryProcessingPercent = (totalFiles: number, processedFiles: number) => {
|
const sendDirectoryProcessingPercent = (totalFiles: number, processedFiles: number) => {
|
||||||
const mainWindow = windowService.getMainWindow()
|
const mainWindow = windowService.getMainWindow()
|
||||||
mainWindow?.webContents.send(base.id, (processedFiles / totalFiles) * 100)
|
mainWindow?.webContents.send('directory-processing-percent', {
|
||||||
|
itemId: item.id,
|
||||||
|
percent: (processedFiles / totalFiles) * 100
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.type === 'directory') {
|
if (item.type === 'directory') {
|
||||||
|
|||||||
@ -207,9 +207,14 @@ export const useKnowledge = (baseId: string) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanup = window.electron.ipcRenderer.on(itemId, (_, progressingPercent: number) => {
|
const cleanup = window.electron.ipcRenderer.on(
|
||||||
setPercent(progressingPercent)
|
'directory-processing-percent',
|
||||||
})
|
(_, { itemId: id, percent }: { itemId: string; percent: number }) => {
|
||||||
|
if (itemId === id) {
|
||||||
|
setPercent(percent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|||||||
@ -65,7 +65,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const progressingPercent = getDirectoryProcessingPercent(base?.id)
|
const getProgressingPercentForItem = (itemId: string) => getDirectoryProcessingPercent(itemId)
|
||||||
|
|
||||||
const handleAddFile = () => {
|
const handleAddFile = () => {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
@ -278,7 +278,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
sourceId={item.id}
|
sourceId={item.id}
|
||||||
base={base}
|
base={base}
|
||||||
getProcessingStatus={getProcessingStatus}
|
getProcessingStatus={getProcessingStatus}
|
||||||
progressingPercent={progressingPercent}
|
getProcessingPercent={getProgressingPercentForItem}
|
||||||
type="directory"
|
type="directory"
|
||||||
/>
|
/>
|
||||||
</StatusIconWrapper>
|
</StatusIconWrapper>
|
||||||
|
|||||||
@ -9,13 +9,14 @@ interface StatusIconProps {
|
|||||||
sourceId: string
|
sourceId: string
|
||||||
base: KnowledgeBase
|
base: KnowledgeBase
|
||||||
getProcessingStatus: (sourceId: string) => ProcessingStatus | undefined
|
getProcessingStatus: (sourceId: string) => ProcessingStatus | undefined
|
||||||
progressingPercent?: number
|
getProcessingPercent?: (sourceId: string) => number | undefined
|
||||||
type: string
|
type: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatusIcon: FC<StatusIconProps> = ({ sourceId, base, getProcessingStatus, progressingPercent, type }) => {
|
const StatusIcon: FC<StatusIconProps> = ({ sourceId, base, getProcessingStatus, getProcessingPercent, type }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const status = getProcessingStatus(sourceId)
|
const status = getProcessingStatus(sourceId)
|
||||||
|
const percent = getProcessingPercent?.(sourceId)
|
||||||
const item = base.items.find((item) => item.id === sourceId)
|
const item = base.items.find((item) => item.id === sourceId)
|
||||||
const errorText = item?.processingError
|
const errorText = item?.processingError
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ const StatusIcon: FC<StatusIconProps> = ({ sourceId, base, getProcessingStatus,
|
|||||||
|
|
||||||
case 'processing': {
|
case 'processing': {
|
||||||
return type === 'directory' ? (
|
return type === 'directory' ? (
|
||||||
<Progress type="circle" size={14} percent={Number(progressingPercent?.toFixed(0))} />
|
<Progress type="circle" size={14} percent={Number(percent?.toFixed(0))} />
|
||||||
) : (
|
) : (
|
||||||
<Tooltip title={t('knowledge.status_processing')} placement="left">
|
<Tooltip title={t('knowledge.status_processing')} placement="left">
|
||||||
<StatusDot $status="processing" />
|
<StatusDot $status="processing" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user