mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-07 12:28:57 -05:00
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
const { ipcRenderer, contextBridge } = require('electron');
|
|
|
|
const { version: VERSION, isDev: IS_DEV } =
|
|
ipcRenderer.sendSync('get-bootstrap-data');
|
|
|
|
contextBridge.exposeInMainWorld('Actual', {
|
|
IS_DEV,
|
|
ACTUAL_VERSION: VERSION,
|
|
logToTerminal: (...args) => {
|
|
require('console').log(...args);
|
|
},
|
|
|
|
ipcConnect: func => {
|
|
func({
|
|
on(name, handler) {
|
|
return ipcRenderer.on(name, (_event, value) => handler(value));
|
|
},
|
|
emit(name, data) {
|
|
return ipcRenderer.send('message', { name, args: data });
|
|
},
|
|
});
|
|
},
|
|
|
|
relaunch: () => {
|
|
ipcRenderer.invoke('relaunch');
|
|
},
|
|
|
|
openFileDialog: opts => {
|
|
return ipcRenderer.invoke('open-file-dialog', opts);
|
|
},
|
|
|
|
saveFile: async (contents, filename, dialogTitle) => {
|
|
await ipcRenderer.invoke('save-file-dialog', {
|
|
title: dialogTitle,
|
|
defaultPath: filename,
|
|
fileContents: contents,
|
|
});
|
|
},
|
|
|
|
openURLInBrowser: url => {
|
|
ipcRenderer.invoke('open-external-url', url);
|
|
},
|
|
|
|
onEventFromMain: (type, handler) => {
|
|
ipcRenderer.on(type, handler);
|
|
},
|
|
|
|
updateAppMenu: budgetId => {
|
|
ipcRenderer.send('update-menu', budgetId);
|
|
},
|
|
|
|
getServerSocket: () => {
|
|
return null;
|
|
},
|
|
|
|
setTheme: theme => {
|
|
ipcRenderer.send('set-theme', theme);
|
|
},
|
|
});
|