代码提交
This commit is contained in:
15
electron/preload.js
Normal file
15
electron/preload.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const { contextBridge, ipcRenderer } = require("electron");
|
||||
|
||||
contextBridge.exposeInMainWorld("electronAPI", {
|
||||
getConfig: () => ipcRenderer.invoke("getConfig"),
|
||||
saveConfig: (config) => ipcRenderer.invoke("saveConfig", config),
|
||||
selectDirectory: (defaultPath) => ipcRenderer.invoke("selectDirectory", defaultPath),
|
||||
selectReferenceFiles: () => ipcRenderer.invoke("selectReferenceFiles"),
|
||||
getImageDataUrl: (filePath) => ipcRenderer.invoke("getImageDataUrl", filePath),
|
||||
startGeneration: (options) => ipcRenderer.invoke("startGeneration", options),
|
||||
onGenerationProgress: (cb) => {
|
||||
const handler = (_e, data) => cb(data);
|
||||
ipcRenderer.on("generationProgress", handler);
|
||||
return () => ipcRenderer.removeListener("generationProgress", handler);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user