diff --git a/apps/desktop/electron/ipcEvent/dicom/handler.ts b/apps/desktop/electron/ipcEvent/dicom/handler.ts index 36529f0..84decd1 100644 --- a/apps/desktop/electron/ipcEvent/dicom/handler.ts +++ b/apps/desktop/electron/ipcEvent/dicom/handler.ts @@ -8,11 +8,12 @@ export const registerDicomHandler = () => { const dia = await dialog.showOpenDialog({ properties: ["openDirectory"] }); if (dia.canceled) return null; const dcmPaths = await filterDicoms(dia.filePaths[0]); - uploadFilesInBatches({ + await uploadFilesInBatches({ filePaths: dcmPaths, batchSize: 6, feedback: (d) => event.reply("dicom:upload:detail", d), }); + event.reply("dicom:upload:finished"); // 重新刷新病人列表 }); ipcMain.handle("dicom:select", async () => { diff --git a/apps/desktop/src/pages/Datasource/index.tsx b/apps/desktop/src/pages/Datasource/index.tsx index 85351f5..62aba4a 100644 --- a/apps/desktop/src/pages/Datasource/index.tsx +++ b/apps/desktop/src/pages/Datasource/index.tsx @@ -23,7 +23,7 @@ export const Datasource = () => { const [selectedStudyId, setSelectedStudyId] = useState(null); const navigate = useNavigate(); - useEffect(() => { + const fetchPatients = () => { window.ipcRenderer .invoke("dicom:select") .then((patients: PatientInfo[]) => { @@ -31,6 +31,17 @@ export const Datasource = () => { rawPatientsRef.current = patients; setPatients(patients); }); + }; + + useEffect(() => { + fetchPatients(); + }, []); + + useEffect(() => { + window.ipcRenderer.on("dicom:upload:finished", fetchPatients); + return () => { + window.ipcRenderer.off("dicom:upload:finished", fetchPatients); + }; }, []); const handlePatientSearch = (filterValue: string) => {