forked from lynx-family/lynx-devtool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
45 lines (42 loc) · 1.37 KB
/
Copy pathpreload.js
File metadata and controls
45 lines (42 loc) · 1.37 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
const { ipcRenderer } = require('electron');
const fs = require('fs');
const path = require('path');
window.React = require('react');
window.ReactDOM = require('react-dom');
// Expose IPC communication interface
window.ldtElectronAPI = {
send: (name, params) => ipcRenderer.send(name, params),
invoke: (name, params) => ipcRenderer.invoke(name, params),
on: (key, listener) => ipcRenderer.on(key, listener),
once: (key, listener) => ipcRenderer.once(key, listener),
off: (key, listener) => ipcRenderer.off(key, listener),
ipcRenderer: {
send: (channel, ...args) => ipcRenderer.send(channel, ...args),
sendSync: (channel, ...args) => ipcRenderer.sendSync(channel, ...args),
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
on: (channel, func) => {
ipcRenderer.on(channel, func);
},
off: (channel, func) => {
ipcRenderer.off(channel, func);
},
once: (channel, func) => {
ipcRenderer.once(channel, (event, ...args) => func(...args));
},
removeAllListeners: (channel) => {
ipcRenderer.removeAllListeners(channel);
}
}
};
// Expose necessary process information
window.process = {
platform: process.platform,
env: {
NODE_ENV: process.env.NODE_ENV,
// Add other required environment variables
},
versions: {
node: process.versions.node,
electron: process.versions.electron
}
};