Skip to content

Commit

Permalink
preload file
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleli04 committed Feb 22, 2024
1 parent 050298c commit e8d4f73
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion frontend/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions frontend/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
window.require = require;

3 changes: 2 additions & 1 deletion frontend/src/components/FileUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

import React, { ChangeEvent, useState } from 'react';
const { ipcRenderer } = window.require('electron');


const FileUploader: React.FC = () => {
const [selectedFile, setSelectedFile] = useState<File | null>(null);
Expand All @@ -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));

}
Expand Down

0 comments on commit e8d4f73

Please sign in to comment.