config system + move api to frontend
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
const api = {
|
||||
getConfig: () => ipcRenderer.invoke("getConfig"),
|
||||
setConfig: (config) => ipcRenderer.invoke("setConfig", config),
|
||||
listPlugins: () => ipcRenderer.invoke("listPlugins"),
|
||||
setActivePlugin: (pluginId) => ipcRenderer.invoke("setActivePlugin", pluginId),
|
||||
openNoteWindow: (noteId) => {
|
||||
ipcRenderer.send("open-note-window", noteId);
|
||||
},
|
||||
@@ -11,18 +15,22 @@ const api = {
|
||||
},
|
||||
onNoteDeleted: (callback) => {
|
||||
ipcRenderer.on("note-deleted", (_, data) => callback(data));
|
||||
},
|
||||
notifyNoteChanged: (event, data) => {
|
||||
ipcRenderer.send("note-changed", event, data);
|
||||
}
|
||||
};
|
||||
const notesAPI = {
|
||||
call: (method, ...args) => ipcRenderer.invoke("notesAPI:call", method, args)
|
||||
const adapter = {
|
||||
call: (method, ...args) => ipcRenderer.invoke("adapter:call", method, args)
|
||||
};
|
||||
if (process.contextIsolated) {
|
||||
try {
|
||||
contextBridge.exposeInMainWorld("api", api);
|
||||
contextBridge.exposeInMainWorld("notesAPI", notesAPI);
|
||||
contextBridge.exposeInMainWorld("adapter", adapter);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
window.api = api;
|
||||
window.adapter = adapter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user