diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index b252c39..9abeb02 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)
project(Tubender)
set(CMAKE_CXX_STANDARD 14)
diff --git a/frontend/electron.js b/frontend/electron.js
index 5a26f02..420530f 100644
--- a/frontend/electron.js
+++ b/frontend/electron.js
@@ -1,6 +1,9 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
-const isDev = require('electron-is-dev');
+const express = require('express');
+
+// Implement NSApplicationDelegate.applicationSupportsSecureRestorableState
+app.applicationSupportsSecureRestorableState = () => true;
let mainWindow;
@@ -9,22 +12,34 @@ function createWindow() {
width: 800,
height: 600,
webPreferences: {
- nodeIntegration: false, // nodeIntegration is set to false
- contextIsolation: true, // enable context isolation
- preload: path.join(__dirname, 'preload.js'), // specify preload script
+ nodeIntegration: false,
+ contextIsolation: true,
},
});
- const startURL = isDev
- ? 'http://localhost:3000'
- : `file://${path.join(__dirname, '../build/index.html')}`;
-
- mainWindow.loadURL(startURL);
+ // Load the production build of the React application
+ mainWindow.loadFile(path.join(__dirname, 'build', 'index.html'));
mainWindow.on('closed', () => (mainWindow = null));
}
-app.on('ready', createWindow);
+app.on('ready', () => {
+ createWindow();
+
+ // Create an express server to serve static files
+ const expressApp = express();
+ const staticPath = path.join(__dirname, 'build', 'static');
+ expressApp.use(express.static(staticPath));
+
+ // Error handling
+ expressApp.on('error', (err) => {
+ console.error('Express server error:', err);
+ });
+
+ expressApp.listen(3000, () => {
+ console.log('Static server running on port 3000');
+ });
+});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
@@ -36,4 +51,4 @@ app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
-});
\ No newline at end of file
+});
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 9d61c6e..0bb5889 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -22,7 +22,7 @@
"@types/electron": "^1.6.10",
"@types/react": "^18.2.53",
"@types/react-dom": "^18.2.18",
- "electron": "^28.1.1",
+ "electron": "^28.2.3",
"electron-builder": "^24.9.1",
"electron-is-dev": "^2.0.0",
"tailwindcss": "^3.4.1",
@@ -8230,9 +8230,9 @@
}
},
"node_modules/electron": {
- "version": "28.1.1",
- "resolved": "https://registry.npmjs.org/electron/-/electron-28.1.1.tgz",
- "integrity": "sha512-HJSbGHpRl46jWCp5G4OH57KSm2F5u15tB10ixD8iFiz9dhwojqlSQTRAcjSwvga+Vqs1jv7iqwQRrolXP4DgOA==",
+ "version": "28.2.3",
+ "resolved": "https://registry.npmjs.org/electron/-/electron-28.2.3.tgz",
+ "integrity": "sha512-he9nGphZo03ejDjYBXpmFVw0KBKogXvR2tYxE4dyYvnfw42uaFIBFrwGeenvqoEOfheJfcI0u4rFG6h3QxDwnA==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
diff --git a/frontend/package.json b/frontend/package.json
index 9142521..b929294 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -51,7 +51,7 @@
"@types/electron": "^1.6.10",
"@types/react": "^18.2.53",
"@types/react-dom": "^18.2.18",
- "electron": "^28.1.1",
+ "electron": "^28.2.3",
"electron-builder": "^24.9.1",
"electron-is-dev": "^2.0.0",
"tailwindcss": "^3.4.1",
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index ff52163..7f1b967 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,6 +1,7 @@
import React from 'react';
-import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
+import { Route } from "react-router-dom";
import HomePage from './pages/HomePage';
+import RoutingComponent from './components/RoutingComponent';
import AboutPage from './pages/AboutPage';
import MainPage from './pages/MainPage';
import PersuasivePage from './pages/PersuasivePage';
@@ -9,17 +10,14 @@ import ReviewsPage from './pages/ReviewsPage';
function App() {
return (
-
-
+
} />
} />
} />
} />
} />
} />
-
-
-
+
);
}
diff --git a/frontend/src/components/RoutingComponent.tsx b/frontend/src/components/RoutingComponent.tsx
new file mode 100644
index 0000000..cbdb214
--- /dev/null
+++ b/frontend/src/components/RoutingComponent.tsx
@@ -0,0 +1,30 @@
+import React, { ReactNode } from 'react';
+import { BrowserRouter as BrowserRouterImpl, HashRouter as HashRouterImpl, Routes } from 'react-router-dom';
+
+interface RoutingComponentProps {
+ children: ReactNode;
+}
+
+const RoutingComponent: React.FC = ({ children }) => {
+ if (isElectron()) {
+ return (
+
+ {children}
+
+ );
+ } else {
+ return (
+
+ {children}
+
+ );
+ }
+}
+
+function isElectron() {
+ // Check if running in Electron environment
+ const isElectron = navigator.userAgent.toLowerCase().indexOf(' electron/') > -1;
+ return isElectron;
+}
+
+export default RoutingComponent;