feat: some feat not important

This commit is contained in:
mozzie 2024-08-07 13:46:02 +08:00
parent d69de380f7
commit f65fed3bd3
11 changed files with 1146 additions and 497 deletions

View File

@ -1,13 +1,18 @@
import path from "path";
import { dialog, ipcMain } from "electron";
import os from "os";
import { findDcmFiles, processFilesInBatches, structureMetadata } from "./core/dicom";
import {
findDcmFiles,
processFilesInBatches,
structureMetadata,
} from "./core/dicom";
import { EVENT_PARSE_DICOM } from "./ipcEvent";
/**
*
*/
const registerIpcMainHandlers = (mainWindow) => {
const registerIpcMainHandlers = (mainWindow: Electron.BrowserWindow | null) => {
if (!mainWindow) return;
ipcMain.on(EVENT_PARSE_DICOM, async (event, file: string) => {
const dirDialog = await dialog.showOpenDialog(mainWindow, {
properties: ["openDirectory"],

View File

@ -9,8 +9,6 @@ import {
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { readdirSync } from "node:fs";
import dicomParser from "dicom-parser";
import registerIpcMainHandlers from "./ipcMainHandlers";
const require = createRequire(import.meta.url);
@ -130,4 +128,4 @@ app.whenReady().then(() => {
// 注销全局快捷键,当应用退出时
app.on("will-quit", () => {
globalShortcut.unregisterAll();
});
});

View File

@ -12,6 +12,7 @@
},
"dependencies": {
"@ant-design/icons": "^5.4.0",
"@google-cloud/spanner": "^7.12.0",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-menubar": "^1.1.1",
@ -26,6 +27,7 @@
"cmdk": "^1.0.0",
"custom-electron-titlebar": "^4.2.8",
"date-fns": "^3.6.0",
"dexie": "^4.0.8",
"dicom-parser": "1.8.21",
"dockview": "^1.15.2",
"flexlayout-react": "^0.7.15",

File diff suppressed because it is too large Load Diff

30
src/lib/db/database.ts Normal file
View File

@ -0,0 +1,30 @@
// database.ts
import Dexie from "dexie";
import { IFriend } from "./models/User";
class Database extends Dexie {
public friends: Dexie.Table<IFriend, number>; // `number` 是主键的类型
constructor() {
super("Database");
this.version(1).stores({
friends: "++id, name, age",
});
this.friends = this.table("friends");
}
async addFriend(friend: IFriend): Promise<number> {
return await this.friends.add(friend);
}
async getAllFriends(): Promise<IFriend[]> {
return await this.friends.toArray();
}
async getFriendsYoungerThan(ageLimit: number): Promise<IFriend[]> {
return await this.friends.where("age").below(ageLimit).toArray();
}
}
const db = new Database();
export default db;

View File

@ -0,0 +1,5 @@
export interface IFriend {
id?: number; // 可选,自增主键
name: string;
age: number;
}

View File

@ -1,6 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
return twMerge(clsx(inputs));
}

View File

@ -1,32 +1,7 @@
import { Button } from "@/components/ui/button";
import { EVENT_PARSE_DICOM } from "../../../electron/ipcEvent";
import { useEffect, useState } from "react";
const Aorta = () => {
const [uploadDicomInfo, setUploadDicomInfo] = useState([]);
useEffect(() => {
window.ipcRenderer.on(EVENT_PARSE_DICOM + ":RES", (event, data) => {
console.log(data);
if (data.error) return;
setUploadDicomInfo(data);
});
return () => {
window.ipcRenderer.off(EVENT_PARSE_DICOM + ":RES", () => {});
};
}, []);
const handleOpenDialog = () => {
window.ipcRenderer.send(EVENT_PARSE_DICOM);
};
return (
<div className="p-2">
<div className="grid w-full max-w-sm items-center gap-1.5">
<Button onClick={handleOpenDialog}>dicom</Button>
</div>
<div>{JSON.stringify(uploadDicomInfo)}</div>
<div className="grid w-full max-w-sm items-center gap-1.5">123</div>
</div>
);
};

View File

@ -1,5 +1,6 @@
import { Outlet, Link } from "react-router-dom";
import { GoFileDirectory } from "react-icons/go";
import { BsDatabaseFill } from "react-icons/bs";
import { MenuBar } from "./MenuBar";
const LayoutMain = () => {
@ -22,8 +23,9 @@ const LayoutMain = () => {
<div className="workspace w-[48px] h-full border-r">
<ul className="flex flex-col items-center pt-2 gap-2">
<li className="w-[22px] h-[22px] flex flex-col items-center justify-center">
<Link to="/">1</Link>
<GoFileDirectory />
<Link to="/">
<BsDatabaseFill />
</Link>
</li>
<li>
<Link to="/dockerview">2</Link>

View File

@ -13,17 +13,34 @@ import {
MenubarSubTrigger,
MenubarTrigger,
} from "@/components/ui/menubar";
import { EVENT_PARSE_DICOM } from "../../electron/ipcEvent";
import { useEffect } from "react";
export const MenuBar = () => {
useEffect(() => {
window.ipcRenderer.on(EVENT_PARSE_DICOM + ":RES", (event, data) => {
console.log(data);
if (data.error) return;
});
return () => {
window.ipcRenderer.off(EVENT_PARSE_DICOM + ":RES", () => {});
};
}, []);
const handleImportDicom = () => {
window.ipcRenderer.send(EVENT_PARSE_DICOM);
};
return (
<Menubar
style={{ background: "transparent", border: 0, boxShadow: "none" }}
>
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarTrigger></MenubarTrigger>
<MenubarContent>
<MenubarItem>
New Tab <MenubarShortcut>T</MenubarShortcut>
<MenubarItem onSelect={handleImportDicom}>
Dicom<MenubarShortcut>T</MenubarShortcut>
</MenubarItem>
<MenubarItem>
New Window <MenubarShortcut>N</MenubarShortcut>

View File

@ -20,6 +20,8 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {