Changed default host from localhost to 127.0.0.1
Made dev shortcuts not global Added host and port arguments in electron launcher
This commit is contained in:
parent
00e2d0724b
commit
2a005b513f
35
index.js
35
index.js
@ -1,14 +1,20 @@
|
|||||||
const { app, BrowserWindow, globalShortcut, ipcMain, shell, dialog, Menu} = require('electron')
|
const { app, BrowserWindow, ipcMain, shell, dialog, Menu, MenuItem } = require('electron')
|
||||||
const contextMenu = require('electron-context-menu')
|
const contextMenu = require('electron-context-menu')
|
||||||
const WindowStateManager = require('electron-window-state-manager')
|
const WindowStateManager = require('electron-window-state-manager')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
const yargs = require('yargs/yargs')
|
||||||
|
const { hideBin } = require('yargs/helpers')
|
||||||
|
const argv = yargs(hideBin(process.argv)).options({
|
||||||
|
port: { type: 'string', default: '6595' },
|
||||||
|
host: { type: 'string', default: '127.0.0.1' },
|
||||||
|
dev: { type: 'boolean', default: false}
|
||||||
|
}).argv
|
||||||
|
|
||||||
const PORT = process.env.PORT || '6595'
|
const PORT = process.env.DEEMIX_PORT || argv.port
|
||||||
|
|
||||||
function isDev() {
|
process.env.DEEMIX_PORT = PORT
|
||||||
return process.argv[2] == '--dev';
|
process.env.DEEMIX_HOST = argv.host
|
||||||
}
|
|
||||||
|
|
||||||
let win
|
let win
|
||||||
const windowState = new WindowStateManager('mainWindow', {
|
const windowState = new WindowStateManager('mainWindow', {
|
||||||
@ -33,13 +39,16 @@ function createWindow () {
|
|||||||
|
|
||||||
win.setMenu(null)
|
win.setMenu(null)
|
||||||
|
|
||||||
if (isDev()){
|
if (argv.dev){
|
||||||
globalShortcut.register('f5', function() {
|
const menu = new Menu()
|
||||||
win.reload()
|
menu.append(new MenuItem({
|
||||||
})
|
label: 'DevTools',
|
||||||
globalShortcut.register('f12', function() {
|
submenu: [
|
||||||
win.webContents.openDevTools()
|
{ role: 'reload', accelerator: 'f5', click: () => { win.reload() } },
|
||||||
})
|
{ role: 'devtools', accelerator: 'f12', click: () => { win.webContents.toggleDevTools() } }
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
Menu.setApplicationMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open links in external browser
|
// Open links in external browser
|
||||||
@ -48,7 +57,7 @@ function createWindow () {
|
|||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
|
|
||||||
win.loadURL(`http://localhost:${PORT}`)
|
win.loadURL(`http://${argv.host}:${PORT}`)
|
||||||
|
|
||||||
if (windowState.maximized) {
|
if (windowState.maximized) {
|
||||||
win.maximize();
|
win.maximize();
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
"electron-window-state-manager": "^0.3.2",
|
"electron-window-state-manager": "^0.3.2",
|
||||||
"cookie-parser": "1.4.5",
|
"cookie-parser": "1.4.5",
|
||||||
"debug": "2.6.9",
|
"debug": "2.6.9",
|
||||||
"deemix": "3.0.0",
|
"deemix": "3.0.1",
|
||||||
"deezer-js": "1.0.0",
|
"deezer-js": "1.0.0",
|
||||||
"dotenv": "8.2.0",
|
"dotenv": "8.2.0",
|
||||||
"express": "4.17.1",
|
"express": "4.17.1",
|
||||||
|
6
server/dist/app.js
vendored
6
server/dist/app.js
vendored
@ -21,10 +21,10 @@ const errors_1 = require("./helpers/errors");
|
|||||||
// TODO: Remove type assertion while keeping correct types
|
// TODO: Remove type assertion while keeping correct types
|
||||||
const argv = yargs_1.default(helpers_1.hideBin(process.argv)).options({
|
const argv = yargs_1.default(helpers_1.hideBin(process.argv)).options({
|
||||||
port: { type: 'string', default: '6595' },
|
port: { type: 'string', default: '6595' },
|
||||||
host: { type: 'string', default: 'localhost' }
|
host: { type: 'string', default: '127.0.0.1' }
|
||||||
}).argv;
|
}).argv;
|
||||||
const DEEMIX_PORT = port_1.normalizePort((_a = process.env.PORT) !== null && _a !== void 0 ? _a : argv.port);
|
const DEEMIX_PORT = port_1.normalizePort((_a = process.env.DEEMIX_PORT) !== null && _a !== void 0 ? _a : argv.port);
|
||||||
const DEEMIX_HOST = (_b = process.env.HOST) !== null && _b !== void 0 ? _b : argv.host;
|
const DEEMIX_HOST = (_b = process.env.DEEMIX_HOST) !== null && _b !== void 0 ? _b : argv.host;
|
||||||
const debug = debug_1.default('deemix-gui:server');
|
const debug = debug_1.default('deemix-gui:server');
|
||||||
exports.app = express_1.default();
|
exports.app = express_1.default();
|
||||||
exports.wss = new ws_1.Server({ noServer: true });
|
exports.wss = new ws_1.Server({ noServer: true });
|
||||||
|
@ -19,11 +19,11 @@ import { consoleInfo } from './helpers/errors'
|
|||||||
// TODO: Remove type assertion while keeping correct types
|
// TODO: Remove type assertion while keeping correct types
|
||||||
const argv = yargs(hideBin(process.argv)).options({
|
const argv = yargs(hideBin(process.argv)).options({
|
||||||
port: { type: 'string', default: '6595' },
|
port: { type: 'string', default: '6595' },
|
||||||
host: { type: 'string', default: 'localhost' }
|
host: { type: 'string', default: '127.0.0.1' }
|
||||||
}).argv as Arguments
|
}).argv as Arguments
|
||||||
|
|
||||||
const DEEMIX_PORT = normalizePort(process.env.PORT ?? argv.port)
|
const DEEMIX_PORT = normalizePort(process.env.DEEMIX_PORT ?? argv.port)
|
||||||
const DEEMIX_HOST = process.env.HOST ?? argv.host
|
const DEEMIX_HOST = process.env.DEEMIX_HOST ?? argv.host
|
||||||
|
|
||||||
const debug = initDebug('deemix-gui:server')
|
const debug = initDebug('deemix-gui:server')
|
||||||
export const app: Application = express()
|
export const app: Application = express()
|
||||||
|
@ -2269,10 +2269,10 @@ decompress-response@^6.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mimic-response "^3.1.0"
|
mimic-response "^3.1.0"
|
||||||
|
|
||||||
deemix@3.0.0:
|
deemix@3.0.1:
|
||||||
version "3.0.0"
|
version "3.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/deemix/-/deemix-3.0.0.tgz#4a0ae0d5ebb75331b8909f60bbe444a0557ae201"
|
resolved "https://registry.yarnpkg.com/deemix/-/deemix-3.0.1.tgz#692f14b799000516d1b91fa768c145978bbe1b5e"
|
||||||
integrity sha512-tRtx6brWVm2ZMh79E61gXQGs2tD7h12TL9jmrRtucK9fZxZl59mH4S0QIZeLLovjF4/13MCWwtx/QvFLauM96g==
|
integrity sha512-wxI3aRs2NELf7U/bEEd0MMJkKxqEt5Y+U5B3xNjHp3hzmq6BTt5C50q8qBL7hE6vaytkG/P4HX7oFJmJVoYyUw==
|
||||||
dependencies:
|
dependencies:
|
||||||
async "^3.2.0"
|
async "^3.2.0"
|
||||||
crypto "^1.0.1"
|
crypto "^1.0.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user