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