2021-12-11 14:12:42 +08:00
|
|
|
/**
|
2022-02-07 02:08:30 +08:00
|
|
|
* Example of 'electron-store' usage.
|
2021-12-11 14:12:42 +08:00
|
|
|
*/
|
|
|
|
import { ipcMain } from 'electron'
|
|
|
|
import Store from 'electron-store'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expose 'electron-store' to Renderer-process through 'ipcMain.handle'
|
|
|
|
*/
|
2022-02-07 02:08:30 +08:00
|
|
|
const store = new Store()
|
|
|
|
ipcMain.handle(
|
|
|
|
'electron-store',
|
2022-03-25 00:44:11 +08:00
|
|
|
async (_event, methodSign: string, ...args: any[]) => {
|
2022-02-07 02:08:30 +08:00
|
|
|
if (typeof (store as any)[methodSign] === 'function') {
|
|
|
|
return (store as any)[methodSign](...args)
|
|
|
|
}
|
|
|
|
return (store as any)[methodSign]
|
|
|
|
}
|
|
|
|
)
|