mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-08 21:51:28 +03:00
Added splash screen
This commit is contained in:
@@ -1,34 +1,62 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const url = require('url');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
let win;
|
||||
let splashWindow;
|
||||
|
||||
function createWindow() {
|
||||
function createSplashWindow() {
|
||||
splashWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
frame: false,
|
||||
alwaysOnTop: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
})
|
||||
splashWindow.loadFile('public/assets/splash.html')
|
||||
splashWindow.on('closed', () => {
|
||||
splashWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
function createMainWindow() {
|
||||
win = new BrowserWindow(
|
||||
{
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
nodeIntegration: true,
|
||||
contextIsolation: true,
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
},
|
||||
icon: path.join(__dirname, 'favicon.ico'),
|
||||
show: false
|
||||
});
|
||||
|
||||
// load the dist folder from Angular
|
||||
win.loadURL('http://localhost:17442')
|
||||
|
||||
// The following is optional and will open the DevTools:
|
||||
// win.webContents.openDevTools()
|
||||
|
||||
win.on('closed', () => {
|
||||
win = null;
|
||||
});
|
||||
}
|
||||
|
||||
const serverProcess = spawn('node', ['app.js']); //, {cwd: 'backend'});
|
||||
function createWindow() {
|
||||
const serverProcess = spawn('node', [path.join(__dirname, 'app.js')]); //, {cwd: 'backend'});
|
||||
|
||||
createMainWindow();
|
||||
createSplashWindow();
|
||||
|
||||
// Log the server output to the console
|
||||
serverProcess.stdout.on('data', (data) => {
|
||||
if (data.toString().includes('started on PORT')) {
|
||||
splashWindow.close()
|
||||
// load the dist folder from Angular
|
||||
win.loadURL('http://localhost:17442')
|
||||
win.show()
|
||||
}
|
||||
console.log(`Server output: ${data}`);
|
||||
});
|
||||
|
||||
@@ -36,6 +64,10 @@ function createWindow() {
|
||||
serverProcess.stderr.on('data', (data) => {
|
||||
console.error(`Server error: ${data}`);
|
||||
});
|
||||
|
||||
process.on('uncaughtException', (error) => {
|
||||
console.error('Uncaught exception:', error);
|
||||
});
|
||||
}
|
||||
|
||||
app.on('ready', createWindow);
|
||||
|
||||
Reference in New Issue
Block a user