Clean up backend files

This commit is contained in:
LukeGus
2025-09-12 00:34:53 -05:00
parent 01da97e86d
commit 4fdda82a30
17 changed files with 648 additions and 433 deletions

View File

@@ -1,38 +1,27 @@
const { contextBridge, ipcRenderer } = require('electron');
const {contextBridge, ipcRenderer} = require('electron');
console.log('Preload script loaded');
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld('electronAPI', {
// App info
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
getPlatform: () => ipcRenderer.invoke('get-platform'),
// Server configuration
getServerConfig: () => ipcRenderer.invoke('get-server-config'),
saveServerConfig: (config) => ipcRenderer.invoke('save-server-config', config),
testServerConnection: (serverUrl) => ipcRenderer.invoke('test-server-connection', serverUrl),
// File dialogs
showSaveDialog: (options) => ipcRenderer.invoke('show-save-dialog', options),
showOpenDialog: (options) => ipcRenderer.invoke('show-open-dialog', options),
// Update events
onUpdateAvailable: (callback) => ipcRenderer.on('update-available', callback),
onUpdateDownloaded: (callback) => ipcRenderer.on('update-downloaded', callback),
// Utility
removeAllListeners: (channel) => ipcRenderer.removeAllListeners(channel),
isElectron: true,
isDev: process.env.NODE_ENV === 'development',
// Generic invoke method
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
});
// Also set the legacy IS_ELECTRON flag for backward compatibility
window.IS_ELECTRON = true;
console.log('electronAPI exposed to window');