Fix: Standardize Electron bridge and implement robust caching
- Refactored all IPC methods and parameters to snake_case for consistency with SvelteKit. - Implemented exhaustive background caching engine with download locking. - Reverted to legacy-proven flat hash storage pattern (hash.file). - Added axios for reliable stream-based binary downloads. - Updated preload and main handlers to support recursive room data fetching.
This commit is contained in:
38
src/main/shell_handlers.ts
Normal file
38
src/main/shell_handlers.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ipcMain, shell } from 'electron';
|
||||
import { exec } from 'child_process';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export function registerShellHandlers() {
|
||||
// Open a local directory in the OS File Manager
|
||||
ipcMain.handle('native:open-folder', async (event, folderPath: string) => {
|
||||
console.log(`Native: Opening folder ${folderPath}`);
|
||||
const error = await shell.openPath(folderPath);
|
||||
return { success: !error, error };
|
||||
});
|
||||
|
||||
// Run a generic shell command (Whitelisted logic can be added here)
|
||||
ipcMain.handle('native:run-cmd', async (event, command: string) => {
|
||||
console.log(`Native: Running command: ${command}`);
|
||||
return new Promise((resolve) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
resolve({
|
||||
success: !error,
|
||||
stdout,
|
||||
stderr,
|
||||
error: error ? error.message : null
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Specific handler for launching a presentation file
|
||||
ipcMain.handle('native:launch-file', async (event, filePath: string) => {
|
||||
console.log(`Native: Launching file: ${filePath}`);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return { success: false, error: 'File not found' };
|
||||
}
|
||||
const error = await shell.openPath(filePath);
|
||||
return { success: !error, error };
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user