mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
Replace the Tauri/sidecar architecture with an Electron main process. Adds an electron/ directory (main, preload, handlers, core integrations for @xmcl/*), electron-builder.yml, TypeScript electron config and declarations, and updated IPC utilities (ipc.ts) so frontend uses ipcRenderer/ipcMain. Removes Tauri sidecar and src-tauri artifacts, deletes sidecar sources and keys, updates .gitignore, VSCode recommendations, package scripts and icons, and updates documentation (README, AGENTS, DEV) and frontend stores/apis to reflect the Electron-based architecture and config/auth persistence changes.
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import electron from 'electron';
|
|
import { execSync } from 'child_process';
|
|
import * as os from 'os';
|
|
|
|
const { ipcMain, app } = electron;
|
|
|
|
function getBiosId(): string {
|
|
if (process.platform !== 'win32') return 'N/A (non-Windows)';
|
|
try {
|
|
const output = execSync('powershell -NoProfile -Command "(Get-CimInstance Win32_BIOS).SerialNumber"', {
|
|
encoding: 'utf-8',
|
|
timeout: 5000,
|
|
});
|
|
return output.trim() || 'Unknown';
|
|
} catch {
|
|
return 'Unknown';
|
|
}
|
|
}
|
|
|
|
function getOsVersion(): string {
|
|
if (process.platform !== 'win32') return 'N/A (non-Windows)';
|
|
try {
|
|
const output = execSync('powershell -NoProfile -Command "[System.Environment]::OSVersion.VersionString"', {
|
|
encoding: 'utf-8',
|
|
timeout: 5000,
|
|
});
|
|
return output.trim() || 'Unknown';
|
|
} catch {
|
|
return 'Unknown';
|
|
}
|
|
}
|
|
|
|
function getOsName(): string {
|
|
if (process.platform !== 'win32') return 'N/A (non-Windows)';
|
|
try {
|
|
const output = execSync('powershell -NoProfile -Command "(Get-CimInstance Win32_OperatingSystem).Caption"', {
|
|
encoding: 'utf-8',
|
|
timeout: 5000,
|
|
});
|
|
return output.trim() || 'Unknown';
|
|
} catch {
|
|
return 'Unknown';
|
|
}
|
|
}
|
|
|
|
export function registerSystemHandlers() {
|
|
ipcMain.handle('system:info', () => {
|
|
try {
|
|
return {
|
|
success: true,
|
|
data: {
|
|
app_version: app.getVersion(),
|
|
bios_id: getBiosId(),
|
|
os_version: getOsVersion(),
|
|
os_name: getOsName(),
|
|
},
|
|
error: null,
|
|
};
|
|
} catch (e: unknown) {
|
|
return { success: false, data: null, error: String(e) };
|
|
}
|
|
});
|
|
}
|