hamster-desktop/electron/ipcMainHandlers.ts

22 lines
665 B
TypeScript
Raw Normal View History

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;