diff --git a/frontend/electron.js b/frontend/electron.js index f77c2a1..c2f903c 100644 --- a/frontend/electron.js +++ b/frontend/electron.js @@ -17,12 +17,14 @@ function createWindow() { height: 600, webPreferences: { nodeIntegration: true, - contextIsolation: true, + contextIsolation: false, + preload: __dirname + '/preload.js' }, }); // Load the production build of the React application mainWindow.loadFile(path.join(__dirname, 'build', 'index.html')); + global.executeBackendScriptSync = (fileName) => { try { const scriptPath = path.join(__dirname, '../backend/build/determine_file_type'); diff --git a/frontend/preload.js b/frontend/preload.js new file mode 100644 index 0000000..a25389c --- /dev/null +++ b/frontend/preload.js @@ -0,0 +1,2 @@ +window.require = require; + diff --git a/frontend/src/components/FileUploader.tsx b/frontend/src/components/FileUploader.tsx index d0995e6..a881e37 100644 --- a/frontend/src/components/FileUploader.tsx +++ b/frontend/src/components/FileUploader.tsx @@ -1,5 +1,7 @@ import React, { ChangeEvent, useState } from 'react'; +const { ipcRenderer } = window.require('electron'); + const FileUploader: React.FC = () => { const [selectedFile, setSelectedFile] = useState(null); @@ -9,7 +11,6 @@ const FileUploader: React.FC = () => { if (files && files[0]) { setSelectedFile(files[0]); console.log('Selected file:', files[0].name); - const { ipcRenderer } = window.require('electron'); ipcRenderer.send('file-upload', JSON.stringify(files[0].name)); }