2024-08-05 16:50:11 +08:00
|
|
|
import path from "path";
|
|
|
|
import { ipcMain } from "electron";
|
2024-08-06 09:44:11 +08:00
|
|
|
import os from "os";
|
|
|
|
import { findDcmFiles, processFilesInBatches } from "./core/dicom";
|
2024-08-05 16:50:11 +08:00
|
|
|
|
2024-08-06 16:59:49 +08:00
|
|
|
/**
|
|
|
|
* 渲染进程和主进程的事件调度
|
|
|
|
*/
|
2024-08-05 16:50:11 +08:00
|
|
|
const registerIpcMainHandlers = () => {
|
|
|
|
ipcMain.on("parseDicom", async (event, file: string) => {
|
|
|
|
const rootFolder = path.dirname(file);
|
2024-08-06 09:44:11 +08:00
|
|
|
const filePaths = await findDcmFiles(rootFolder);
|
|
|
|
const batchSize = os.cpus().length * 1 || 10;
|
|
|
|
console.time("分批处理");
|
|
|
|
const result = await processFilesInBatches(filePaths, batchSize);
|
2024-08-06 16:59:49 +08:00
|
|
|
console.log(result);
|
2024-08-06 09:44:11 +08:00
|
|
|
console.timeEnd("分批处理");
|
2024-08-05 16:50:11 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default registerIpcMainHandlers;
|