Initial commit of YouTube Downloader application, including core functionality for downloading videos, user authentication, and Docker support. Added configuration files, environment setup, and basic UI components using Astro.js and Tailwind CSS.

This commit is contained in:
Peter Meier
2025-12-22 10:59:01 +01:00
parent 79d8a95391
commit 486639aaea
31 changed files with 13078 additions and 132 deletions

91
electron/main.cjs Normal file
View File

@@ -0,0 +1,91 @@
const { app, BrowserWindow } = require("electron");
const { spawn } = require("child_process");
const path = require("path");
let mainWindow;
let astroProcess;
// Prüfe ob wir im Development-Modus sind
const isDev = process.env.NODE_ENV === "development" || !app.isPackaged;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
},
autoHideMenuBar: true,
titleBarStyle: "default",
});
if (isDev) {
// Im Development-Modus: Verbinde zu lokalem Dev-Server
mainWindow.loadURL("http://localhost:4321");
mainWindow.webContents.openDevTools();
} else {
// Im Production-Modus: Starte lokalen Server und verbinde
startLocalServer();
}
mainWindow.on("closed", () => {
mainWindow = null;
});
}
function startLocalServer() {
const serverPath = path.join(__dirname, "../dist/server/entry.mjs");
// Starte den Astro-Server
astroProcess = spawn("node", [serverPath], {
cwd: path.join(__dirname, ".."),
env: {
...process.env,
PORT: "4321",
},
});
astroProcess.stdout.on("data", (data) => {
console.log(`Server: ${data}`);
if (data.toString().includes("Local") || data.toString().includes("4321")) {
// Warte kurz, dann lade die Seite
setTimeout(() => {
mainWindow.loadURL("http://localhost:4321");
}, 2000);
}
});
astroProcess.stderr.on("data", (data) => {
console.error(`Server Error: ${data}`);
});
astroProcess.on("close", (code) => {
console.log(`Server process exited with code ${code}`);
});
}
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on("window-all-closed", () => {
if (astroProcess) {
astroProcess.kill();
}
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("before-quit", () => {
if (astroProcess) {
astroProcess.kill();
}
});