dsr/src/main.ts

36 lines
808 B
TypeScript
Raw Normal View History

2023-07-29 16:23:38 +02:00
import { BrowserWindow, app, ipcMain } from "electron";
import path = require("path");
2023-07-29 19:23:18 +02:00
import ffmpegPath = require("ffmpeg-static");
2023-07-28 02:46:49 +02:00
2023-07-28 02:32:18 +02:00
const createWindow = () => {
const win = new BrowserWindow({
2023-07-29 19:23:18 +02:00
width: 1280,
height: 720,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
},
2023-07-28 02:32:18 +02:00
});
2023-07-29 15:30:41 +02:00
win.loadFile(path.join(path.resolve(__dirname, ".."), "pages", "index.html"));
2023-07-29 19:23:18 +02:00
win.webContents.openDevTools(); // debug
2023-07-28 02:32:18 +02:00
};
2023-07-29 15:30:41 +02:00
2023-07-28 02:32:18 +02:00
app.whenReady().then(() => {
2023-07-29 19:23:18 +02:00
ipcMain.handle("ffmpeg", () => ffmpegPath);
2023-07-29 20:20:55 +02:00
ipcMain.handle("argv", () => process.argv);
2023-07-29 16:23:38 +02:00
2023-07-28 02:32:18 +02:00
createWindow();
app.on("activate", () => {
2023-07-29 19:23:18 +02:00
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on("window-all-closed", () => {
2023-07-29 19:23:18 +02:00
if (process.platform !== "darwin") {
app.quit();
}
2023-07-28 02:32:18 +02:00
});