cvpilot-tool/apps/desktop/electron/core/pacs.ts
2024-09-10 22:03:12 +08:00

26 lines
916 B
TypeScript

import { spawn } from "node:child_process";
import { existsSync } from "node:fs";
import log from 'electron-log'
import path from "node:path";
export const getPacsPath = (platform: "macos" | "windows", isDevelopment: boolean): string => {
const orthancExecFile = {
macos: "orthanc-mac-24.8.1/Orthanc",
windows: "orthanc-win64-1.12.4/Orthanc.exe"
}
const basePath = isDevelopment
? path.join(process.env.VITE_PUBLIC, "../extraResources")
: path.join(process.resourcesPath, 'lib');
return path.join(basePath, orthancExecFile[platform])
}
export const runOrthancServer = (pacsPath: string) => {
if (existsSync(pacsPath)) {
const child_process = spawn(pacsPath)
child_process.stdout.on('data', data => log.info(data))
// child_process.stderr.on('data', data => log.error(data))
} else {
console.error('pacsPath is a not exist')
log.error('pacsPath is a not exist')
}
}