mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
// Loading required packages
|
|
require("./requires.js")
|
|
console.log(start);
|
|
|
|
|
|
// Initialising map to be used to store the functionality later on for reloadability
|
|
mapFunctions = new Map()
|
|
|
|
|
|
// Loading the Function Map
|
|
var path = `${mainDir}/services/modules`
|
|
var folders = fs.readdirSync(path).filter(function (file) {
|
|
return fs.statSync(path+'/'+file).isDirectory();
|
|
});
|
|
folders.forEach(element => {
|
|
var commandFiles = fs.readdirSync(`${path}/${element}`).filter(file => file.endsWith('.js') && !file.startsWith("index"));
|
|
for (const file of commandFiles) {
|
|
delete require.cache[require.resolve(`${path}/${element}/${file}`)];
|
|
const command = require(`${path}/${element}/${file}`);
|
|
mapFunctions.set(command.name, command);
|
|
}
|
|
});
|
|
|
|
|
|
|
|
// The startup information for the project, here you can add stuff that might be nice to see when the app starts
|
|
mapFunctions.get("Startup_function").function()
|
|
console.log("------------------------------------ Status ------------------------------------");
|
|
console.log(__dirname);
|
|
console.log(platform);
|
|
console.log(`The Startup took ${new Date() - start}ms`)
|
|
console.log(`${mapFunctions.size} Function modules loaded`);
|
|
console.log("--------------------------------------------------------------------------------");
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- //
|
|
|
|
const rl = readline.createInterface({
|
|
input: process.stdin,
|
|
output: process.stdout
|
|
});
|
|
|
|
|
|
rl.on("line", data =>{
|
|
const args = data.trim().split(" ");
|
|
const command = args.shift().toLowerCase();
|
|
mapFunctions.get("cliCommands").function(command, args)
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- //
|
|
|
|
let mainWindow;
|
|
|
|
function createWindow() {
|
|
mainWindow = new electron.BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
preload: `${mainDir}/electron/main/preload.js`
|
|
}
|
|
});
|
|
|
|
mainWindow.loadFile('./electron/main/index.html');
|
|
}
|
|
|
|
electron.app.whenReady().then(createWindow);
|
|
|
|
|
|
electron.ipcMain.on("extract", (event, args) => {
|
|
mapFunctions.get("extraction-video-to-audio").function(args)
|
|
}) |