-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the main.js and refactor with src files
- Loading branch information
Showing
4 changed files
with
174 additions
and
132 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
const { app, BrowserWindow, Tray, Menu, ipcMain } = require('electron'); | ||
const shell = require('electron').shell; | ||
|
||
// Handle creating/removing shortcuts on Windows when installing/uninstalling. | ||
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require | ||
app.quit(); | ||
} | ||
|
||
|
||
const createWindow = () => { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 340, | ||
resizable: false, | ||
height: 500, | ||
maximizable: false, | ||
frame: false, | ||
enableLargerThanScreen: false, | ||
opacity: 0.90, | ||
titleBarStyle: "hidden", | ||
webPreferences: { | ||
nodeIntegration: true | ||
}, | ||
}); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadFile('src/index.html'); | ||
|
||
// Open the DevTools. | ||
// mainWindow.webContents.openDevTools(); | ||
|
||
// var menu = Menu.buildFromTemplate([ | ||
// { | ||
// label: 'Menu', | ||
// submenu: [ | ||
// { | ||
// label: 'Hello', | ||
// click() { | ||
// console.log('World'); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Hide from everybody', | ||
// click() { | ||
// app.hide(createWindow); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Tray On/Off', | ||
// click() { | ||
// tray.hide(); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Exit', | ||
// click(){ | ||
// app.quit; | ||
// } | ||
// } | ||
// ] | ||
// } | ||
// ]) | ||
|
||
// Menu.setApplicationMenu(menu); | ||
}; | ||
|
||
app.whenReady().then(createWindow); | ||
|
||
// app.dock.hide(); | ||
|
||
let tray = null; | ||
|
||
app.on('ready', () => { | ||
tray = new Tray('public/assets/logo_16x16.png'); | ||
const contextMenu = Menu.buildFromTemplate([ | ||
{ | ||
label: 'Opacidade Settings', | ||
submenu: [ | ||
{ | ||
label: 'Opacidade +', | ||
}, | ||
{ | ||
label: 'Opacidade -' , | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'Sair', | ||
click (){ | ||
createWindow.call(createWindow); | ||
} | ||
} | ||
]); | ||
tray.setToolTip('Electron App'); | ||
tray.setContextMenu(contextMenu); | ||
|
||
// const loginBtn = document.getElementById('loginBtn'); | ||
|
||
// loginBtn.addEventListener('click', () => { | ||
// console.log('Button clicked'); | ||
// }); | ||
|
||
// const loginBtn = document.querySelector('loginBtn').addEventListener( | ||
// 'click', () => { | ||
// console.log('Button clicked'); | ||
// } | ||
// ); | ||
}); | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
//app.on('ready', createWindow); | ||
|
||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', () => { | ||
// On OS X it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
// if (process.platform !== 'darwin') { | ||
// app.quit(); | ||
// } | ||
}); | ||
|
||
app.on('activate', () => { | ||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and import them here. | ||
ipcMain.on('btnclick', function(event,arg) { | ||
console.log(arg.username); | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,133 +1,38 @@ | ||
const { app, BrowserWindow, Tray, Menu } = require('electron'); | ||
const { resolve } = require('path'); | ||
const { BrowserView } = require('electron').remote; | ||
const { ipcRenderer, remote, BrowserWindow } = require('electron'); | ||
|
||
// Handle creating/removing shortcuts on Windows when installing/uninstalling. | ||
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require | ||
app.quit(); | ||
} | ||
|
||
const createWindow = () => { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 340, | ||
resizable: false, | ||
height: 500, | ||
maximizable: false, | ||
frame: false, | ||
enableLargerThanScreen: false, | ||
opacity: 0.90, | ||
titleBarStyle: "hidden", | ||
webPreferences: { | ||
nodeIntegration: true | ||
}, | ||
}); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadFile('src/index.html'); | ||
|
||
// Open the DevTools. | ||
// mainWindow.webContents.openDevTools(); | ||
|
||
// var menu = Menu.buildFromTemplate([ | ||
// { | ||
// label: 'Menu', | ||
// submenu: [ | ||
// { | ||
// label: 'Hello', | ||
// click() { | ||
// console.log('World'); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Hide from everybody', | ||
// click() { | ||
// app.hide(createWindow); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Tray On/Off', | ||
// click() { | ||
// tray.hide(); | ||
// } | ||
// }, | ||
// { | ||
// label: 'Exit', | ||
// click(){ | ||
// app.quit; | ||
// } | ||
// } | ||
// ] | ||
// } | ||
// ]) | ||
const loginBtn = document.getElementById('loginBtn'); | ||
|
||
Menu.setApplicationMenu(menu); | ||
let userNotification = { | ||
title: String, | ||
body: 'Your login was made successfully', | ||
}; | ||
|
||
app.whenReady().then(createWindow); | ||
|
||
// app.dock.hide(); | ||
|
||
let tray = null; | ||
|
||
app.on('ready', () => { | ||
tray = new Tray('public/assets/logo_16x16.png'); | ||
const contextMenu = Menu.buildFromTemplate([ | ||
{ | ||
label: 'Opacidade Settings', | ||
submenu: [ | ||
{ | ||
label: 'Opacidade +', | ||
}, | ||
{ | ||
label: 'Opacidade -' , | ||
} | ||
] | ||
}, | ||
{ | ||
label: 'Sair', | ||
click (){ | ||
createWindow.call(createWindow); | ||
} | ||
} | ||
]); | ||
tray.setToolTip('Electron App'); | ||
tray.setContextMenu(contextMenu); | ||
|
||
// const loginBtn = document.getElementById('loginBtn'); | ||
|
||
// loginBtn.addEventListener('click', () => { | ||
// console.log('Button clicked'); | ||
// }); | ||
|
||
// const loginBtn = document.querySelector('loginBtn').addEventListener( | ||
// 'click', () => { | ||
// console.log('Button clicked'); | ||
// } | ||
// ); | ||
}); | ||
|
||
// This method will be called when Electron has finished | ||
// initialization and is ready to create browser windows. | ||
// Some APIs can only be used after this event occurs. | ||
//app.on('ready', createWindow); | ||
|
||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', () => { | ||
// On OS X it is common for applications and their menu bar | ||
// to stay active until the user quits explicitly with Cmd + Q | ||
// if (process.platform !== 'darwin') { | ||
// app.quit(); | ||
// } | ||
}); | ||
|
||
app.on('activate', () => { | ||
// On OS X it's common to re-create a window in the app when the | ||
// dock icon is clicked and there are no other windows open. | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
// Handle creating/removing shortcuts on Windows when installing/uninstalling. | ||
// loginBtn.addEventListener('click', () => { | ||
// console.log('Button clicked'); | ||
// }); | ||
|
||
loginBtn.addEventListener( | ||
'click', () => { | ||
let userLogin = { | ||
username: document.getElementById('usernameField').value, | ||
password: document.getElementById('passwordField').value, | ||
}; | ||
const myNotification = new window.Notification( | ||
userNotification.title = `Olá ${userLogin.username}`, | ||
userNotification, | ||
); | ||
// console.log(userLogin); | ||
// let window = remote.getCurrentWindow(); | ||
// window.close(); | ||
ipcRenderer.send("btnclick", userLogin); | ||
|
||
let win = remote.getCurrentWindow(); | ||
win.hide(); | ||
} | ||
}); | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and import them here. | ||
); | ||
// document.querySelector('loginBtn').addEventListener( | ||
// 'click', () => { | ||
// console.log('Button clicked'); | ||
// } | ||
// ); |