2023-09-06 19:04:18 +00:00
|
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
|
|
const replaceText = (selector, text) => {
|
|
|
|
const element = document.getElementById(selector)
|
|
|
|
if (element) element.innerText = text
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const dependency of ['chrome', 'node', 'electron']) {
|
|
|
|
replaceText(`${dependency}-version`, process.versions[dependency])
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const { contextBridge, ipcRenderer } = require('electron');
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('electronAPI', {
|
|
|
|
setTitle: (title) => ipcRenderer.send('set-title', title)
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('storeValueAPI', {
|
2023-10-03 18:43:19 +00:00
|
|
|
handleFileOpen: (key) => ipcRenderer.invoke('handleFileOpen', key)
|
2023-09-06 19:04:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('getFilesAPI', {
|
|
|
|
getFiles: () => ipcRenderer.invoke('getFiles')
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('getFoldersAPI', {
|
|
|
|
getFolders: () => ipcRenderer.invoke('getFolders')
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('updateStateAPI', {
|
|
|
|
onUpdateState: (callback) => ipcRenderer.on('update-state', callback)
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('removeFileAPI', {
|
|
|
|
removeFile: (filePath) => ipcRenderer.invoke('removeFile', filePath)
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('removeFolderAPI', {
|
|
|
|
removeFolder: (folderPath) => ipcRenderer.invoke('removeFolder', folderPath)
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('hostURLAPI', {
|
|
|
|
setURL: (url) => ipcRenderer.invoke('setURL', url),
|
|
|
|
getURL: () => ipcRenderer.invoke('getURL')
|
|
|
|
})
|
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('syncDataAPI', {
|
2023-11-07 11:37:16 +00:00
|
|
|
syncData: (regenerate) => ipcRenderer.invoke('syncData', regenerate),
|
|
|
|
deleteAllFiles: () => ipcRenderer.invoke('deleteAllFiles')
|
2023-09-06 19:04:18 +00:00
|
|
|
})
|
2023-10-26 19:33:03 +00:00
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('tokenAPI', {
|
|
|
|
setToken: (token) => ipcRenderer.invoke('setToken', token),
|
|
|
|
getToken: () => ipcRenderer.invoke('getToken')
|
|
|
|
})
|
2023-11-04 03:56:27 +00:00
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('appInfoAPI', {
|
|
|
|
getInfo: (callback) => ipcRenderer.on('appInfo', callback)
|
|
|
|
})
|
2023-11-16 06:33:50 +00:00
|
|
|
|
|
|
|
contextBridge.exposeInMainWorld('navigateAPI', {
|
|
|
|
navigateToSettings: () => ipcRenderer.send('navigate', 'config.html'),
|
|
|
|
navigateToWebSettings: () => ipcRenderer.send('navigateToWebApp', 'config'),
|
|
|
|
})
|