Skip to content

Commit 4c3cf62

Browse files
latest pushes
1 parent 3d00cc5 commit 4c3cf62

File tree

2 files changed

+24
-101
lines changed

2 files changed

+24
-101
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,5 @@
1111
* Ronaldson Bellande
1212

1313

14-
# USE CASE
15-
--------------------------------------------------------------------------------------------------------
16-
* The Organization Website Application is accessible for complimentary download and installation. It is imperative to note that the source code responsible for creating this application is governed by a specific license agreement. This license restricts the utilization of the code for any purposes other than those explicitly permitted, necessitating prior authorization for any deviation from its prescribed usage. Consequently, users are encouraged to respect and adhere to the terms and conditions outlined in the license agreement to ensure compliance with the software's legal framework
17-
--------------------------------------------------------------------------------------------------------
18-
1914
## License
2015
This package is distributed under the [GPL-3.0 license](https://www.gnu.org/licenses/gpl-3.0.en.html), see [LICENSE](https://github.com/https://github.com/Robotics-Sensors/organization-robotics-sensors-website-application/blob/main/LICENSE) and [NOTICE](https://github.com/https://github.com/Robotics-Sensors/organization-robotics-sensors-website-application/blob/main/LICENSE) for more information.

scripts/index.js

Lines changed: 24 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,47 @@
1-
const { app, globalShortcut, BrowserWindow, session } = require('electron');
2-
const path = require('path');
3-
const { switchFullscreenState } = require('./windowManager.js');
1+
const { app, BrowserWindow } = require('electron');
42

5-
var homePage = 'https://robotics-sensors.github.io';
6-
var userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3';
3+
// Application configuration
4+
const appConfig = {
5+
homePageURL: 'https://robotics-sensors.github.io',
6+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.3',
7+
};
78

8-
console.log('Using user agent: ' + userAgent);
9-
console.log('Process arguments: ' + process.argv);
9+
console.log(`Using user agent: ${appConfig.userAgent}`);
10+
console.log(`Process arguments: ${process.argv}`);
1011

12+
// Configure Electron command line switches
1113
app.commandLine.appendSwitch('enable-features', 'VaapiVideoDecoder,WaylandWindowDecorations,RawDraw');
12-
13-
app.commandLine.appendSwitch(
14-
'disable-features',
15-
'UseChromeOSDirectVideoDecoder'
16-
);
14+
app.commandLine.appendSwitch('disable-features', 'UseChromeOSDirectVideoDecoder');
1715
app.commandLine.appendSwitch('enable-accelerated-mjpeg-decode');
18-
app.commandLine.appendSwitch('enable-accelerated-video');
19-
app.commandLine.appendSwitch('ignore-gpu-blocklist');
20-
app.commandLine.appendSwitch('enable-native-gpu-memory-buffers');
21-
app.commandLine.appendSwitch('enable-gpu-rasterization');
22-
app.commandLine.appendSwitch('enable-zero-copy');
23-
app.commandLine.appendSwitch('enable-gpu-memory-buffer-video-frames');
24-
app.commandLine.appendSwitch('use-gl');
2516

26-
async function createWindow() {
17+
// Create the main application window
18+
async function createMainWindow() {
2719
const mainWindow = new BrowserWindow({
2820
fullscreenable: true,
2921
webPreferences: {
30-
preload: path.join(__dirname, 'preload.js'),
3122
contextIsolation: false,
32-
userAgent: userAgent,
23+
userAgent: appConfig.userAgent,
3324
},
3425
});
3526

36-
if (process.argv.includes('--direct-start')) {
37-
mainWindow.loadURL(homePage);
38-
} else {
39-
mainWindow.loadURL(homePage);
40-
}
41-
27+
await mainWindow.loadURL(appConfig.homePageURL);
28+
return mainWindow;
4229
}
4330

31+
// Initialize the application
4432
app.whenReady().then(async () => {
45-
createWindow();
33+
await createMainWindow();
4634

47-
app.on('activate', async function() {
35+
app.on('activate', async () => {
4836
if (BrowserWindow.getAllWindows().length === 0) {
49-
createWindow();
37+
await createMainWindow();
5038
}
5139
});
5240

53-
const { globalShortcut, BrowserWindow } = require('electron');
54-
55-
// Register global shortcuts
56-
const window = BrowserWindow.getAllWindows()[0];
57-
globalShortcut.register('Super+F', async () => {
58-
switchFullscreenState(window);
59-
});
60-
61-
globalShortcut.register('F11', async () => {
62-
switchFullscreenState(window);
63-
});
64-
65-
globalShortcut.register('Alt+F4', async () => {
66-
app.quit();
67-
});
68-
69-
globalShortcut.register('Alt+Home', async () => {
70-
window.loadURL(homePage);
71-
});
72-
73-
globalShortcut.register('F4', async () => {
74-
app.quit();
75-
});
76-
77-
globalShortcut.register('Control+Shift+I', () => {
78-
window.webContents.toggleDevTools();
79-
});
80-
81-
globalShortcut.register('Esc', async () => {
82-
// Handle 'Esc' key press event
83-
window.webContents.sendInputEvent({
84-
type: 'keyDown',
85-
keyCode: 'Esc'
86-
});
87-
window.webContents.sendInputEvent({
88-
type: 'char',
89-
keyCode: 'Esc'
90-
});
91-
window.webContents.sendInputEvent({
92-
type: 'keyUp',
93-
keyCode: 'Esc'
94-
});
95-
});
96-
});
97-
98-
app.on('browser-window-created', async function(e, window) {
99-
window.setBackgroundColor('#1A1D1F');
100-
window.setMenu(null);
101-
102-
window.webContents.setUserAgent(userAgent);
103-
104-
window.webContents.on('new-window', (event, url) => {
105-
event.preventDefault();
106-
BrowserWindow.getAllWindows()[0].loadURL(url);
41+
// Quit the application when all windows are closed
42+
app.on('window-all-closed', async () => {
43+
if (process.platform !== 'darwin') {
44+
app.quit();
45+
}
10746
});
108-
109-
});
110-
111-
app.on('will-quit', async () => {
112-
globalShortcut.unregisterAll();
113-
});
114-
115-
app.on('window-all-closed', async function() {
116-
if (process.platform !== 'darwin') {
117-
app.quit();
118-
}
11947
});

0 commit comments

Comments
 (0)