adding in global store access but not done
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { contextBridge, ipcRenderer } from "electron";
|
import { contextBridge, ipcRenderer } from "electron";
|
||||||
|
|
||||||
import Channels from "./constants";
|
import Channels from "./constants";
|
||||||
|
import { STORE_ITEMS } from "./store";
|
||||||
|
|
||||||
const electronAPI = {
|
const electronAPI = {
|
||||||
auth: {
|
auth: {
|
||||||
@@ -11,8 +12,15 @@ const electronAPI = {
|
|||||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
batteryApi: {},
|
store: {
|
||||||
fileApi: {},
|
get(val: STORE_ITEMS) {
|
||||||
|
return ipcRenderer.sendSync("electron-store-get", val);
|
||||||
|
},
|
||||||
|
set(property: STORE_ITEMS, val: any) {
|
||||||
|
ipcRenderer.send("electron-store-set", property, val);
|
||||||
|
},
|
||||||
|
// Other method you want to add like has(), reset(), etc.
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("electronAPI", electronAPI);
|
contextBridge.exposeInMainWorld("electronAPI", electronAPI);
|
||||||
|
|||||||
@@ -49,6 +49,14 @@ app
|
|||||||
console.log("initiating log in");
|
console.log("initiating log in");
|
||||||
await handleLogin();
|
await handleLogin();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// IPC listener
|
||||||
|
ipcMain.on("electron-store-get", async (event, val) => {
|
||||||
|
event.returnValue = store.get(val);
|
||||||
|
});
|
||||||
|
ipcMain.on("electron-store-set", async (event, key, val) => {
|
||||||
|
store.set(key, val);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
|||||||
Reference in New Issue
Block a user