58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
const { ArgumentParser } = require('argparse')
|
|
const { app, BrowserWindow } = require('electron')
|
|
const path = require('path')
|
|
const fs = require('fs')
|
|
|
|
let win;
|
|
let config;
|
|
|
|
const parser = new ArgumentParser({
|
|
description: 'Freechat Electron Client'
|
|
})
|
|
|
|
parser.add_argument('-c', '--config', {help: 'Specify config path'})
|
|
|
|
console.log(parser.parse_args())
|
|
function createWin() {
|
|
let win = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
minWidth: 640,
|
|
minHeight: 480,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
preload: path.join(__dirname + 'preload.js')
|
|
},
|
|
autoHideMenuBar: true,
|
|
})
|
|
|
|
win.loadFile('pages/index.html');
|
|
if(process.platform !== 'darwin') {
|
|
win.removeMenu();
|
|
}
|
|
win.on('closed', () => {
|
|
win = null
|
|
});
|
|
}
|
|
|
|
function load_config(config_path) {
|
|
}
|
|
|
|
app.on('ready', createWin);
|
|
|
|
// on mac just because the windows are closed doesn't mean the application is too
|
|
// ! The toolbar keeps things alive against its will
|
|
app.on('window-all-closed', () => {
|
|
if(process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
});
|
|
|
|
app.on('activate', () => {
|
|
if(win === null) {
|
|
createWin();
|
|
load_config('./example-dev-config.json'); // for now
|
|
}
|
|
});
|
|
|