mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-20 19:37:45 +00:00
68 lines
2.2 KiB
JavaScript
68 lines
2.2 KiB
JavaScript
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', {
|
|
handleFileOpen: (key) => ipcRenderer.invoke('handleFileOpen', key)
|
|
})
|
|
|
|
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('needsSubscriptionAPI', {
|
|
onNeedsSubscription: (callback) => ipcRenderer.on('needsSubscription', 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', {
|
|
syncData: (regenerate) => ipcRenderer.invoke('syncData', regenerate),
|
|
deleteAllFiles: () => ipcRenderer.invoke('deleteAllFiles')
|
|
})
|
|
|
|
contextBridge.exposeInMainWorld('tokenAPI', {
|
|
setToken: (token) => ipcRenderer.invoke('setToken', token),
|
|
getToken: () => ipcRenderer.invoke('getToken')
|
|
})
|
|
|
|
contextBridge.exposeInMainWorld('appInfoAPI', {
|
|
getInfo: (callback) => ipcRenderer.on('appInfo', callback)
|
|
})
|
|
|
|
contextBridge.exposeInMainWorld('navigateAPI', {
|
|
navigateToSettings: () => ipcRenderer.send('navigate', 'config.html'),
|
|
navigateToWebSettings: () => ipcRenderer.send('navigateToWebApp', 'config'),
|
|
})
|