Dev mode
This commit is contained in:
parent
9ad745879e
commit
12903c7088
26
main.js
26
main.js
@ -7,6 +7,8 @@ const ioHook = require('iohook')
|
|||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
|
let devMode = false
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
@ -19,9 +21,15 @@ function createWindow () {
|
|||||||
webviewTag: true
|
webviewTag: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (process.argv.length === 3) {
|
||||||
|
if (process.argv[2] === 'dev'){
|
||||||
|
devMode = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devMode === false){
|
||||||
mainWindow.setMenu(null)
|
mainWindow.setMenu(null)
|
||||||
|
}
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
@ -103,7 +111,8 @@ function unmuteMic() {
|
|||||||
|
|
||||||
app.on('ready', event => {
|
app.on('ready', event => {
|
||||||
ioHook.start();
|
ioHook.start();
|
||||||
muteMic()
|
|
||||||
|
console.log(`Dev Mode: ${devMode}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
ioHook.on('mousedown', event => {
|
ioHook.on('mousedown', event => {
|
||||||
@ -119,14 +128,17 @@ ioHook.on('mouseup', event => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('asynchronous-message', (event, arg) => {
|
ipcMain.on('asynchronous-message', (event, msg) => {
|
||||||
if (arg === 'connected') {
|
if (msg === 'connected') {
|
||||||
isConnected = true
|
isConnected = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg === 'disconnected') {
|
if (msg === 'disconnected') {
|
||||||
isConnected = false
|
isConnected = false
|
||||||
isTalking = false
|
isTalking = false
|
||||||
}
|
}
|
||||||
console.log(arg)
|
|
||||||
|
if (msg === 'DOMready') {
|
||||||
|
mainWindow.webContents.send('devMode', devMode)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "Discord Sandboxed with Push-to-Talk",
|
"description": "Discord Sandboxed with Push-to-Talk",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron . dev",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"package-win": "electron-builder --win --publish never"
|
"package-win": "electron-builder --win --publish never"
|
||||||
},
|
},
|
||||||
|
17
renderer.js
17
renderer.js
@ -2,7 +2,9 @@ const { ipcRenderer } = require('electron')
|
|||||||
|
|
||||||
onload = () => {
|
onload = () => {
|
||||||
const webview = document.querySelector('webview')
|
const webview = document.querySelector('webview')
|
||||||
//webview.openDevTools()
|
|
||||||
|
ipcRenderer.send('asynchronous-message', 'DOMready')
|
||||||
|
|
||||||
webview.addEventListener('console-message', (e) => {
|
webview.addEventListener('console-message', (e) => {
|
||||||
if (e.message === "Constructed RTCPeerConnection") {
|
if (e.message === "Constructed RTCPeerConnection") {
|
||||||
console.log("Connected to server")
|
console.log("Connected to server")
|
||||||
@ -15,16 +17,23 @@ onload = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('ping', (event, message) => {
|
ipcRenderer.on('ping', (event, msg) => {
|
||||||
if (message === 'mic-open'){
|
if (msg === 'mic-open'){
|
||||||
console.log("talking")
|
console.log("talking")
|
||||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
|
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyDown'});
|
||||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
|
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
|
||||||
}
|
}
|
||||||
if (message === 'mic-closed'){
|
if (msg === 'mic-closed'){
|
||||||
console.log("not talking")
|
console.log("not talking")
|
||||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
|
webview.sendInputEvent({keyCode: 'Backspace', type: 'keyUp'});
|
||||||
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
|
webview.sendInputEvent({keyCode: 'Backspace', type: 'char'});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcRenderer.on('devMode', (event, msg) => {
|
||||||
|
console.log(`Dev Mode: ${msg}`)
|
||||||
|
if (msg === true) {
|
||||||
|
webview.openDevTools()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user