-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
46 lines (39 loc) · 1.21 KB
/
preload.js
File metadata and controls
46 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Electron Preload Script
* * Exposes secure Electron APIs to the renderer process
* Provides folder selection dialog functionality
*/
const { contextBridge, ipcRenderer } = require("electron");
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld("electron", {
/**
* Open folder selection dialog
* @returns {Promise<{canceled: boolean, filePaths: string[]}>}
*/
selectFolder: () => ipcRenderer.invoke("dialog:openFolder"),
/**
* Get app version
* @returns {Promise<string>}
*/
getAppVersion: () => ipcRenderer.invoke("app:getVersion"),
/**
* Listen for "User Guide" menu click
* Returns a cleanup function to remove the listener
*/
onOpenHelp: (callback) => {
const subscription = (event, ...args) => callback(...args);
ipcRenderer.on("menu:open-help", subscription);
return () => ipcRenderer.removeListener("menu:open-help", subscription);
},
/**
* Platform information
*/
platform: process.platform,
/**
* Check if running in Electron
*/
isElectron: true,
});
// Log preload script loaded
console.log("✅ Preload script loaded successfully");