feat: add real-time files watch for LibraryView

Implement comprehensive monitoring system:
- Watch for new registered files (5s interval)
- Detect file status changes (registered → processing → completed)
- Monitor file additions/removals

Functions added:
- startFilesWatch(): Poll get_files API every 5s
- stopFilesWatch(): Clean up interval

LibraryView integration:
- Enable on mount
- Disable on unmount

Enables cross-machine monitoring: one operates, another watches changes
This commit is contained in:
2026-07-24 21:49:06 +08:00
parent 1fd6312f7e
commit 55d0216083
2 changed files with 48 additions and 3 deletions

View File

@@ -571,7 +571,7 @@
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
import { apiCall } from '@/api'
import { useI18n } from 'vue-i18n'
import { ensureFiles, filesCache, filesLoaded, thumbnailsCache, loadThumbnail, loadUnregisteredThumbnail, invalidateFiles, processorCountsCache, loadProcessorCounts, getProcessorCounts, ProcessorOutputInfo, pollProgress, stopPolling, getProgress, refreshFileStatus, refreshAllFilesStatus, fileProgressCache, pollingProgressSet, getFileProcessingStatus, ProcessingStatus, ProcessingLevel, loadPipelineStats, getPipelineStats, PipelineStats, loadFileStats, getFileStats, FileStats, pollPipelineProgress, startStatsAutoRefresh, stopStatsAutoRefresh, startProcessingFilesPolling, stopProcessingFilesPolling, JsonProcessorInfo, pipelineStatsCache, clearFileStatusCache } from '@/store'
import { ensureFiles, filesCache, filesLoaded, thumbnailsCache, loadThumbnail, loadUnregisteredThumbnail, invalidateFiles, processorCountsCache, loadProcessorCounts, getProcessorCounts, ProcessorOutputInfo, pollProgress, stopPolling, getProgress, refreshFileStatus, refreshAllFilesStatus, fileProgressCache, pollingProgressSet, getFileProcessingStatus, ProcessingStatus, ProcessingLevel, loadPipelineStats, getPipelineStats, PipelineStats, loadFileStats, getFileStats, FileStats, pollPipelineProgress, startStatsAutoRefresh, stopStatsAutoRefresh, startProcessingFilesPolling, stopProcessingFilesPolling, startFilesWatch, stopFilesWatch, JsonProcessorInfo, pipelineStatsCache, clearFileStatusCache } from '@/store'
import { isDark, toggleDark } from '@/composables/useTheme'
import { getAsrStatus } from '@/utils/asrStatus'
import { useAdvancedMode } from '@/stores/advancedMode'
@@ -753,8 +753,8 @@ const pendingCount = computed(() => files.value.filter((f: any) => f.isRegistere
const processingCount = computed(() => files.value.filter((f: any) => f.status === 'processing').length)
const completedCount = computed(() => files.value.filter((f: any) => f.status === 'completed').length)
onMounted(() => { loadFiles(); document.addEventListener('click', docClickClose); startStatsAutoRefresh(); startProcessingFilesPolling() })
onUnmounted(() => { document.removeEventListener('click', docClickClose); stopStatsAutoRefresh(); stopProcessingFilesPolling() })
onMounted(() => { loadFiles(); document.addEventListener('click', docClickClose); startStatsAutoRefresh(); startProcessingFilesPolling(); startFilesWatch() })
onUnmounted(() => { document.removeEventListener('click', docClickClose); stopStatsAutoRefresh(); stopProcessingFilesPolling(); stopFilesWatch() })
function docClickClose(e: MouseEvent) {
if (e.target instanceof Element && e.target.closest('.ms-ctx-menu')) return