Skip to content

Instantly share code, notes, and snippets.

@iagocavalcante
Created July 29, 2018 17:51
Show Gist options
  • Save iagocavalcante/433b4399f4832aa0342fb28ebe2913f2 to your computer and use it in GitHub Desktop.
Save iagocavalcante/433b4399f4832aa0342fb28ebe2913f2 to your computer and use it in GitHub Desktop.
import { app, BrowserWindow, ipcMain, autoUpdater, dialog } from 'electron'
import server from './server/server.js'
import fs from 'fs'
/**
* Set `__statics` path to static files in production;
* The reason we are setting it here is that the path needs to be evaluated at runtime
*/
if (process.env.PROD) {
global.__statics = require('path').join(__dirname, 'statics').replace(/\\/g, '\\\\')
}
const defaultPath = `${app.getPath('downloads')}/Ytdown/`.replace(/\\/g, '/')
let mainWindow
function createWindow () {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
width: 1000,
height: 600,
useContentSize: true,
frame: process.env.PROD ? false : true,
webPreferences: {
webSecurity: false
}
})
mainWindow.loadURL(process.env.APP_URL)
mainWindow.on('closed', () => {
mainWindow = null
})
server.listen(defaultPath)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment