-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
34 lines (29 loc) · 1.04 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { app, BrowserWindow, ipcMain } = require('electron');
const fs = require('fs');
const path = require('path');
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 950,
height: 1000,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, // Allow access to Node.js APIs in renderer
},
icon: path.join(__dirname, 'assets/icons/nutrient.ico')
});
mainWindow.loadFile('index.html');
// Load the nutrition.xml file when the window is ready
mainWindow.webContents.on('did-finish-load', () => {
const nutritionFilePath = path.join(__dirname, 'assets/nutrition.xml');
fs.readFile(nutritionFilePath, 'utf8', (err, data) => {
if (err) {
console.error("Error reading nutrition.xml file", err);
return;
}
// Send the XML data to renderer process
mainWindow.webContents.send('nutrition-data', data);
});
});
}
app.on('ready', createWindow);