Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
fixed eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroX-DG committed Sep 2, 2020
1 parent edc8104 commit 042e84e
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 117 deletions.
74 changes: 37 additions & 37 deletions app/app-main.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
const { app, Menu, ipcMain } = require("electron");
const { app, Menu, ipcMain } = require('electron')

let mainWindow = null;
let mainWindow = null

const gotTheLock = app.requestSingleInstanceLock();
const gotTheLock = app.requestSingleInstanceLock()

if (!gotTheLock) {
app.quit();
app.quit()
} else {
app.on("second-instance", (event, commandLine, workingDirectory) => {
app.on('second-instance', (event, commandLine, workingDirectory) => {
if (mainWindow) {
if (process.platform === "win32") {
mainWindow.minimize();
mainWindow.restore();
if (process.platform === 'win32') {
mainWindow.minimize()
mainWindow.restore()
}
mainWindow.show();
mainWindow.focus();
mainWindow.show()
mainWindow.focus()
}
});
})

app.on("ready", () => {
mainWindow = require("./app-window")(app);
require("./app-tray")(app, mainWindow);
ipcMain.on("bringToFront", () => {
if (process.platform === "win32") {
mainWindow.minimize();
mainWindow.restore();
app.on('ready', () => {
mainWindow = require('./app-window')(app)
require('./app-tray')(app, mainWindow)
ipcMain.on('bringToFront', () => {
if (process.platform === 'win32') {
mainWindow.minimize()
mainWindow.restore()
}
mainWindow.show();
mainWindow.focus();
});
const template = require("./app-menu")(app, mainWindow);
const menu = Menu.buildFromTemplate(template);
mainWindow.show()
mainWindow.focus()
})
const template = require('./app-menu')(app, mainWindow)
const menu = Menu.buildFromTemplate(template)
switch (process.platform) {
case "darwin":
Menu.setApplicationMenu(menu);
break;
case "win32":
mainWindow.setMenu(menu);
break;
case "linux":
Menu.setApplicationMenu(menu);
mainWindow.setMenu(menu);
break;
case 'darwin':
Menu.setApplicationMenu(menu)
break
case 'win32':
mainWindow.setMenu(menu)
break
case 'linux':
Menu.setApplicationMenu(menu)
mainWindow.setMenu(menu)
break
}
});
})

app.on("before-quit", () => {
mainWindow.shouldQuit();
});
app.on('before-quit', () => {
mainWindow.shouldQuit()
})
}
70 changes: 35 additions & 35 deletions app/app-window.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const electron = require("electron");
const BrowserWindow = electron.BrowserWindow;
const path = require("path");
const Store = require("electron-store");
const store = new Store();
const _ = require("lodash");
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const Store = require('electron-store')
const store = new Store()
const _ = require('lodash')

const showMenu = process.platform !== "win32";
const windowSize = store.get("windowsize") || { width: 1080, height: 720 };
let mainWindow = null;
let isQuitting = false;
const showMenu = process.platform !== 'win32'
const windowSize = store.get('windowsize') || { width: 1080, height: 720 }
let mainWindow = null
let isQuitting = false

function createWindow(app) {
function createWindow (app) {
mainWindow = new BrowserWindow({
width: windowSize.width,
height: windowSize.height,
Expand All @@ -20,49 +20,49 @@ function createWindow(app) {
webPreferences: {
zoomFactor: 1.0,
nodeIntegration: true,
blinkFeatures: "OverlayScrollbars"
blinkFeatures: 'OverlayScrollbars'
},
icon: path.resolve(__dirname, "../resources/icon/icon512.png")
});
icon: path.resolve(__dirname, '../resources/icon/icon512.png')
})

const url = "file://" + path.resolve(__dirname, "./index.html");
const url = 'file://' + path.resolve(__dirname, './index.html')

mainWindow.loadURL(url);
mainWindow.on("resize", _.throttle(storeWindowSize, 500));
if (process.env.NODE_ENV === "dev") {
mainWindow.webContents.openDevTools();
mainWindow.loadURL(url)
mainWindow.on('resize', _.throttle(storeWindowSize, 500))
if (process.env.NODE_ENV === 'dev') {
mainWindow.webContents.openDevTools()
}
const screen = electron.screen.getPrimaryDisplay();
const screen = electron.screen.getPrimaryDisplay()
if (
windowSize.width >= screen.size.width &&
windowSize.height >= screen.size.height - 1
) {
mainWindow.maximize();
mainWindow.maximize()
}
// prevent the app from quitting
mainWindow.on("close", e => {
mainWindow.on('close', e => {
if (!isQuitting) {
e.preventDefault();
mainWindow.blur();
if (process.platform === "darwin") {
app.hide();
e.preventDefault()
mainWindow.blur()
if (process.platform === 'darwin') {
app.hide()
} else {
mainWindow.hide();
mainWindow.hide()
}
}
});
})

mainWindow.shouldQuit = function() {
isQuitting = true;
};
mainWindow.shouldQuit = function () {
isQuitting = true
}

return mainWindow;
return mainWindow
}

function storeWindowSize() {
function storeWindowSize () {
try {
store.set("windowsize", mainWindow.getBounds());
store.set('windowsize', mainWindow.getBounds())
} catch (e) {}
}

module.exports = createWindow;
module.exports = createWindow
90 changes: 45 additions & 45 deletions scripts/dev.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
process.env.NODE_ENV = "dev";
const webpack = require("webpack");
const WebpackDevServer = require("webpack-dev-server");
const config = require("./webpack.config");
const signale = require("signale");
const { spawn } = require("child_process");
const electron = require("electron");
const port = 8000;
let server = null;
process.env.NODE_ENV = 'dev'
const webpack = require('webpack')
const WebpackDevServer = require('webpack-dev-server')
const config = require('./webpack.config')
const signale = require('signale')
const { spawn } = require('child_process')
const electron = require('electron')
const port = 8000
let server = null

const options = {
publicPath: config.output.publicPath,
hot: true,
inline: true,
quiet: true,
sockHost: "localhost",
sockHost: 'localhost',
sockPort: port
};
}

function startServer() {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
config.entry.main.unshift("webpack/hot/dev-server");
const compiler = webpack(config);
server = new WebpackDevServer(compiler, options);
function startServer () {
config.plugins.push(new webpack.HotModuleReplacementPlugin())
config.entry.main.unshift('webpack/hot/dev-server')
const compiler = webpack(config)
server = new WebpackDevServer(compiler, options)

return new Promise((resolve, reject) => {
server.listen(port, "localhost", function(err) {
server.listen(port, 'localhost', function (err) {
if (err) {
reject(err);
reject(err)
}
signale.success(`Webpack Dev Server listening at localhost:${port}`);
signale.watch(`Waiting for webpack to bundle...`);
compiler.hooks.done.tap("done", stats => {
signale.success(`Webpack Dev Server listening at localhost:${port}`)
signale.watch(`Waiting for webpack to bundle...`)
compiler.hooks.done.tap('done', stats => {
if (!stats.hasErrors()) {
signale.success(`Bundle success !`);
resolve();
signale.success(`Bundle success !`)
resolve()
} else {
reject(stats.compilation.errors[0]);
reject(stats.compilation.errors[0])
}
});
});
});
})
})
})
}

function startElectron() {
spawn(electron, ["--hot", "./index.js"], {
stdio: "inherit",
function startElectron () {
spawn(electron, ['--hot', './index.js'], {
stdio: 'inherit',
windowsHide: false
})
.on("close", () => {
server.close();
.on('close', () => {
server.close()
})
.on("error", err => {
signale.error(err);
server.close();
.on('error', err => {
signale.error(err)
server.close()
})
.on("disconnect", () => {
server.close();
.on('disconnect', () => {
server.close()
})
.on('exit', () => {
server.close()
})
.on("exit", () => {
server.close();
});
}

startServer()
.then(() => {
startElectron();
signale.success("Electron started");
startElectron()
signale.success('Electron started')
})
.catch(err => {
signale.error(err);
process.exit(1);
});
signale.error(err)
process.exit(1)
})

0 comments on commit 042e84e

Please sign in to comment.