Created
July 29, 2018 17:51
-
-
Save iagocavalcante/433b4399f4832aa0342fb28ebe2913f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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