Fix simple issue
This commit is contained in:
@@ -39,6 +39,7 @@ function createWindow(): void {
|
||||
},
|
||||
});
|
||||
void mainWindow.loadFile(path.join(__dirname, 'index.html'));
|
||||
mainWindow.webContents.openDevTools();
|
||||
mainWindow.on('close', (e: Electron.Event) => {
|
||||
if (!isQuitting) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1,58 +1,3 @@
|
||||
interface DeviceEntry {
|
||||
vendorId: number;
|
||||
productId: number;
|
||||
displayName: string;
|
||||
manufacturer: string;
|
||||
product: string;
|
||||
serialNumber: string;
|
||||
}
|
||||
|
||||
interface CpuTempResult {
|
||||
main: number;
|
||||
cores: number[];
|
||||
max: number;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface RamResult {
|
||||
total: number;
|
||||
free: number;
|
||||
used: number;
|
||||
usedPercent: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface GpuController {
|
||||
vendor: string;
|
||||
model: string;
|
||||
temperatureGpu: number | null;
|
||||
memoryUsed: number | null;
|
||||
memoryTotal: number | null;
|
||||
}
|
||||
|
||||
interface ElectronAPI {
|
||||
systemCpuTemp: () => Promise<CpuTempResult>;
|
||||
systemRam: () => Promise<RamResult>;
|
||||
systemGpu: () => Promise<GpuController[] | { error: string }>;
|
||||
usbListDevices: () => Promise<DeviceEntry[] | { error: string }>;
|
||||
usbConnect: (vendorId: number, productId: number) => Promise<{ success: boolean } | { error: string }>;
|
||||
prefsGet: (key?: string) => Promise<unknown>;
|
||||
prefsSet: (key: string, value: unknown) => Promise<unknown>;
|
||||
prefsDelete: (key: string) => Promise<unknown>;
|
||||
dialogOpenFile: (options?: unknown) => Promise<{ canceled: boolean; filePaths: string[] }>;
|
||||
dialogSaveFile: (options?: unknown) => Promise<{ canceled: boolean; filePath: string }>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI: ElectronAPI;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
const api: ElectronAPI = window.electronAPI;
|
||||
|
||||
function isError<T>(result: T | { error: string }): result is { error: string } {
|
||||
return result !== null && typeof result === 'object' && 'error' in result;
|
||||
}
|
||||
@@ -61,6 +6,8 @@ function formatError(result: { error: string }): string {
|
||||
return `Error: ${result.error}`;
|
||||
}
|
||||
|
||||
const api: ElectronAPI = window.electronAPI;
|
||||
|
||||
// --- System Info ---
|
||||
async function refreshSystemInfo(): Promise<void> {
|
||||
const [cpuTemp, ram, gpu] = await Promise.all([
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true
|
||||
},
|
||||
"include": ["src/**/*.ts"]
|
||||
"include": ["src"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user