hamster-desktop/electron/ipcMainHandlers.ts

19 lines
590 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
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);
console.timeEnd("分批处理");
2024-08-05 16:50:11 +08:00
});
};
export default registerIpcMainHandlers;