24 lines
1.2 KiB
JavaScript
24 lines
1.2 KiB
JavaScript
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
contextBridge.exposeInMainWorld('api', {
|
|
openFile: async () => ipcRenderer.invoke('file:open'),
|
|
saveAs: async (payload) => ipcRenderer.invoke('file:saveAs', payload),
|
|
saveToPath: async (payload) => ipcRenderer.invoke('file:saveToPath', payload),
|
|
revealInFolder: async (filePath) => ipcRenderer.invoke('os:revealInFolder', filePath),
|
|
getConfig: async (key) => ipcRenderer.invoke('config:get', key),
|
|
setConfig: async (key, value) => ipcRenderer.invoke('config:set', key, value),
|
|
getAllConfig: async () => ipcRenderer.invoke('config:getAll'),
|
|
setAllConfig: async (config) => ipcRenderer.invoke('config:setAll', config),
|
|
closeSettings: async () => ipcRenderer.invoke('settings:close'),
|
|
localKnock: async (payload) => ipcRenderer.invoke('knock:local', payload),
|
|
getNetworkInterfaces: async () => ipcRenderer.invoke('network:interfaces'),
|
|
testConnection: async (payload) => ipcRenderer.invoke('network:test-connection', payload)
|
|
});
|
|
|
|
// Пробрасываем конфигурацию в рендерер (безопасно)
|
|
contextBridge.exposeInMainWorld('config', {
|
|
apiBase: process.env.KNOCKER_DESKTOP_API_BASE || 'http://localhost:8080/api/v1'
|
|
});
|
|
|
|
|