feat: 这个commit有build阶段的bug,下一个commit解决

This commit is contained in:
mozzie 2024-09-29 17:01:21 +08:00
parent 1add66a3ab
commit 832e104be6
23 changed files with 49 additions and 54 deletions

View File

@ -6,13 +6,21 @@ import axios from "axios";
export const ALGServerRoot = "http://127.0.0.1:5000/root";
export const getEntryPath = () => {
// 区分操作系统
return path.join(process.env.VITE_PUBLIC!, "main.exe");
export const getAlgPath = (
platform: "macos" | "windows",
isDevelopment: boolean
): string => {
const algExecFile = {
macos: "",
windows: "main.exe",
};
const basePath = isDevelopment
? path.join(process.env.VITE_PUBLIC)
: path.join(process.resourcesPath, "lib", "alg");
return path.join(basePath, algExecFile[platform]);
};
export const startALGServer = () => {
const entryPath = getEntryPath();
export const startALGServer = (entryPath: string) => {
const child_process = spawn(entryPath);
child_process.on("message", (data) => console.log(data));
child_process.stdout.on("data", (data) => log.info(data.toString()));

View File

@ -1,7 +1,6 @@
import path from "node:path";
import { JSONFilePreset } from "lowdb/node";
import { app } from "electron";
import { Low } from "node_modules/lowdb/lib/core/Low";
import { StructuredMetadata } from "./dicom";
import { merge } from "lodash";
@ -40,7 +39,7 @@ const defaultTable: DbTable = {
},
};
export let db: Low<DbTable>;
export let db: any;
export const createDatabase = async (config: ICreateDatabase) => {
const { name } = config;

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { downloadSeriesDicomFiles, getTotalScanLength } from "../../core/pacs";
import { executeInferTask } from "../../core/alg";
import { InferDeviceEnum, InferStructuralEnum } from "../../core/alg.type";

View File

@ -2,7 +2,6 @@ import { ipcMain } from "electron";
import { registerDicomHandler } from "./dicom/handler";
import { registerCommonHandler } from "./common";
import { registerAlgHandler } from "./alg";
import { registerOllama } from "./llm";
export const registerIpcMainHandlers = (mainWindow: Electron.BrowserWindow) => {
ipcMain.removeAllListeners();
@ -15,5 +14,4 @@ export const registerIpcMainHandlers = (mainWindow: Electron.BrowserWindow) => {
registerCommonHandler();
registerDicomHandler();
registerAlgHandler();
registerOllama();
};

View File

@ -1,10 +0,0 @@
import { ipcMain } from "electron";
// import { ollama, run } from "../../core/ollama";
export const registerOllama = async () => {
// const list = await ollama.list();
// console.log(list);
// ipcMain.handle("chat", async (_event, input: string) => {
// const answer = await run("qwen2.5:3B", input);
// return answer;
// });
};

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { app, dialog, ipcMain, shell } from "electron";
import os from "os";
import {

View File

@ -13,7 +13,7 @@ import { createDatabase } from "./core/db";
import { getMachineId } from "./core/auth";
import { getPacsPath, runOrthancServer } from "./core/pacs";
import { registerIpcMainHandlers } from "./ipcEvent";
import { startALGServer } from "./core/alg";
import { getAlgPath, startALGServer } from "./core/alg";
// const require = createRequire(import.meta.url);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@ -74,7 +74,7 @@ function createWindow() {
win.loadURL(VITE_DEV_SERVER_URL);
registerIpcMainHandlers(win);
runOrthancServer(getPacsPath(platform, true));
if (platform !== "macos") startALGServer();
startALGServer(getAlgPath(platform, true));
} else {
// if (platform !== "macos") {
// python_process = spawn(path.join(process.env.VITE_PUBLIC!, "main.exe"));
@ -83,7 +83,7 @@ function createWindow() {
win.loadFile(path.join(RENDERER_DIST, "index.html")).then(() => {
registerIpcMainHandlers(win!);
runOrthancServer(getPacsPath(platform, false));
startALGServer(getAlgPath(platform, false))
// windows右键打开的目录路径
if (process.argv.length >= 2) {
const folderPath = process.argv[2];

Binary file not shown.

View File

@ -1,11 +1,5 @@
import { MenuItem } from "./type";
import {
BrainCircuit,
Package,
HardDrive,
Wrench,
Rotate3DIcon,
} from "lucide-react";
import { BrainCircuit, Package, HardDrive, Wrench } from "lucide-react";
export const menuItems: MenuItem[] = [
{ to: "/", name: "自动分析", icon: <BrainCircuit /> },

View File

@ -2,15 +2,12 @@ import { Button } from "@/components/ui/button";
import { motion } from "framer-motion";
import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import { SparkleIcon, Trash2 } from "lucide-react";
import { SparkleIcon } from "lucide-react";
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable";
import { Card } from "@/components/ui/card";
import { Series } from "../Datasource/SeriesTable";
import { ScrollArea } from "@/components/ui/scroll-area";
import { LLM } from "./llm";
@ -33,7 +30,7 @@ const Boot = () => {
};
useEffect(() => {
const receiveInfer = (_event: any, data: string) => {
const receiveInfer = (_event: unknown, data: string) => {
setMessageText(data);
};
window.ipcRenderer.on("infer:progress", receiveInfer);

View File

@ -1,12 +1,8 @@
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { useEffect, useState } from "react";
import { useState } from "react";
interface LLmProps {
children?: JSX.Element;
}
export const LLM = (props: LLmProps) => {
export const LLM = () => {
const [inputValue, setInputValue] = useState("");
const [data, setData] = useState<string>();

View File

@ -1,4 +1,4 @@
import { TrackballControls } from "three/examples/jsm/controls/TrackballControls";
import { TrackballControls } from "three/addons/controls/TrackballControls.js";
import { useCallback, useEffect, useRef } from "react";
import * as THREE from "three";
import useMultiResizeObserver from "../useMultiResizeObserver";
@ -9,7 +9,7 @@ import { valveMapping } from "./aorta.config";
interface AortaViewerProps {
SeriesInstanceUID: string;
stlFiles: { fileName: string; data: ArrayBuffer }[];
measurement: Record<string, unknown>;
measurement: Record<string, any>;
}
export const AortaViewer = (props: AortaViewerProps) => {
@ -61,12 +61,12 @@ export const AortaViewer = (props: AortaViewerProps) => {
}, [stlFiles]);
const initMeasurement = useCallback(() => {
console.log(measurement)
console.log(measurement);
for (const prop in measurement) {
if (prop in valveMapping) {
const pointArray = measurement[prop].less_points;
const curve = new THREE.CatmullRomCurve3(
pointArray.map((p) => new THREE.Vector3(p[0], p[1], p[2]))
pointArray.map((p: any) => new THREE.Vector3(p[0], p[1], p[2]))
);
curve.curveType = "centripetal"; // 曲线类型
curve.closed = true; // 曲线是否闭合

View File

@ -1,4 +1,4 @@
import { TrackballControls } from "three/examples/jsm/controls/TrackballControls";
import { TrackballControls } from "three/examples/jsm/controls/TrackballControls.js";
import { useCallback, useEffect, useRef } from "react";
import * as THREE from "three";
import useMultiResizeObserver from "../useMultiResizeObserver";

View File

@ -95,7 +95,7 @@ export const Segments = [
/**
*
*/
export const valveMapping = {
export const valveMapping: Record<string, any> = {
annulus_plane: {
color: [143 / 255, 6 / 255, 3 / 255],
name: "瓣环平面",

View File

@ -6,9 +6,7 @@ import { PeripheralViewer } from "./PeripheralViewer";
import { SparkleIcon } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
interface Model3DViewerProps {}
export const Model3DViewer = (props: Model3DViewerProps) => {
export const Model3DViewer = () => {
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const SeriesInstanceUID = queryParams.get("SeriesInstanceUID");

View File

@ -1,4 +1,4 @@
import { STLLoader } from "three/examples/jsm/loaders/STLLoader";
import { STLLoader } from "three/examples/jsm/loaders/STLLoader.js";
import { SegmentsPeripheral } from "./peri.config";
import { InferStructuralEnum } from "./type";
import { Segments } from "./aorta.config";
@ -29,7 +29,7 @@ const loadSTLFile = (
url,
(geometry: THREE.BufferGeometry) => resolve({ geometry, fileName }),
undefined,
(error) => {
(error: any) => {
console.error(`Error loading STL file ${fileName}:`, error);
reject(error);
}

View File

@ -1,4 +1,5 @@
import { metaData } from "@cornerstonejs/core";
// @ts-ignore
import cornerstoneDICOMImageLoader from "@cornerstonejs/dicom-image-loader";
/**

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { api } from "dicomweb-client";
import dcmjs from "dcmjs";
import { utilities } from "@cornerstonejs/core";
@ -22,7 +23,7 @@ interface CreateImageIdsAndCacheMetaDataOptions {
SOPInstanceUID?: string | null;
wadoRsRoot: string;
client?: api.DICOMwebClient | null;
convertMultiframe?: boolean,
convertMultiframe?: boolean;
}
/**
@ -83,7 +84,8 @@ export const createImageIdsAndCacheMetaData = async (
if (instanceMetaData) {
const metadata =
DicomMetaDictionary.naturalizeDataset(instanceMetaData);
const pixelSpacing = getPixelSpacingInformation(metadata) as Number[];
const pixelSpacing = getPixelSpacingInformation(metadata);
if (pixelSpacing) {
calibratedPixelSpacingMetadataProvider.add(imageId, {

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { metaData } from "@cornerstonejs/core";
import type { InstanceMetadata } from "@cornerstonejs/calculate-suv";

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import dicomParser from "dicom-parser";
import * as cornerstone from "@cornerstonejs/core";
import cornerstoneDICOMImageLoader from "@cornerstonejs/dicom-image-loader";
@ -22,7 +23,7 @@ export const initCornerstoneDICOMImageLoader = () => {
cornerstoneDICOMImageLoader.external.cornerstone = cornerstone;
cornerstoneDICOMImageLoader.external.dicomParser = dicomParser;
cornerstoneDICOMImageLoader.configure({
useWebWorkers: true,
useWebWorkers: false,
decodeConfig: {
convertFloatPixelDataToInt: false,
// use16BitDataType: false,

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { volumeLoader } from "@cornerstonejs/core";
import {
cornerstoneStreamingImageVolumeLoader,

View File

@ -1,3 +1,4 @@
// @ts-nocheck
import { utilities as csUtils } from "@cornerstonejs/core";
const scalingPerImageId = {};

View File

@ -29,11 +29,17 @@ export default defineConfig({
: {},
}),
],
assetsInclude: ["**/*.wasm"],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
rollupOptions: {
external: ["zlib"],
},
},
server: {
cors: true,
headers: {