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 { dialog, ipcMain } from "electron";
import os from "os"; import os from "os";
import { findDcmFiles, processFilesInBatches, structureMetadata } from "./core/dicom"; import {
findDcmFiles,
processFilesInBatches,
structureMetadata,
} from "./core/dicom";
import { EVENT_PARSE_DICOM } from "./ipcEvent"; 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) => { ipcMain.on(EVENT_PARSE_DICOM, async (event, file: string) => {
const dirDialog = await dialog.showOpenDialog(mainWindow, { const dirDialog = await dialog.showOpenDialog(mainWindow, {
properties: ["openDirectory"], properties: ["openDirectory"],

View File

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

View File

@ -12,6 +12,7 @@
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.4.0", "@ant-design/icons": "^5.4.0",
"@google-cloud/spanner": "^7.12.0",
"@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-label": "^2.1.0", "@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-menubar": "^1.1.1", "@radix-ui/react-menubar": "^1.1.1",
@ -26,6 +27,7 @@
"cmdk": "^1.0.0", "cmdk": "^1.0.0",
"custom-electron-titlebar": "^4.2.8", "custom-electron-titlebar": "^4.2.8",
"date-fns": "^3.6.0", "date-fns": "^3.6.0",
"dexie": "^4.0.8",
"dicom-parser": "1.8.21", "dicom-parser": "1.8.21",
"dockview": "^1.15.2", "dockview": "^1.15.2",
"flexlayout-react": "^0.7.15", "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 { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge" import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) { 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 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 ( return (
<div className="p-2"> <div className="p-2">
<div className="grid w-full max-w-sm items-center gap-1.5"> <div className="grid w-full max-w-sm items-center gap-1.5">123</div>
<Button onClick={handleOpenDialog}>dicom</Button>
</div>
<div>{JSON.stringify(uploadDicomInfo)}</div>
</div> </div>
); );
}; };

View File

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

View File

@ -13,17 +13,34 @@ import {
MenubarSubTrigger, MenubarSubTrigger,
MenubarTrigger, MenubarTrigger,
} from "@/components/ui/menubar"; } from "@/components/ui/menubar";
import { EVENT_PARSE_DICOM } from "../../electron/ipcEvent";
import { useEffect } from "react";
export const MenuBar = () => { 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 ( return (
<Menubar <Menubar
style={{ background: "transparent", border: 0, boxShadow: "none" }} style={{ background: "transparent", border: 0, boxShadow: "none" }}
> >
<MenubarMenu> <MenubarMenu>
<MenubarTrigger>File</MenubarTrigger> <MenubarTrigger></MenubarTrigger>
<MenubarContent> <MenubarContent>
<MenubarItem> <MenubarItem onSelect={handleImportDicom}>
New Tab <MenubarShortcut>T</MenubarShortcut> Dicom<MenubarShortcut>T</MenubarShortcut>
</MenubarItem> </MenubarItem>
<MenubarItem> <MenubarItem>
New Window <MenubarShortcut>N</MenubarShortcut> New Window <MenubarShortcut>N</MenubarShortcut>

View File

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