-
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.
- Loading branch information
Thiago Waib Castello Branco
committed
Sep 6, 2024
1 parent
750f531
commit e9594ca
Showing
3 changed files
with
36 additions
and
28 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
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 |
---|---|---|
|
@@ -157,4 +157,3 @@ btnCopy.onclick = () => { | |
window.onload = () => { | ||
generatePassword(); | ||
} | ||
|
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,50 +1,57 @@ | ||
// Modules to control application life and create native browser window | ||
// Importa os módulos do Electron | ||
const { app, BrowserWindow } = require('electron') | ||
const path = require('node:path') | ||
|
||
//Tenta carregar o electron-reloader | ||
//Faz uma tentativa de carregar o módulo de hot-reload do Electron | ||
try { | ||
require('electron-reloader')(module) | ||
} catch (_) {} | ||
|
||
/** | ||
* Cria a Janela principal da Aplicação | ||
*/ | ||
const createWindow = () => { | ||
// Create the browser window. | ||
// Cria uma Janela da Aplicação | ||
const mainWindow = new BrowserWindow({ | ||
width: 1024, | ||
height: 768, | ||
icon: __dirname + './assets/icon.png', | ||
movable: true, | ||
resizable: false, | ||
minimizable: true, | ||
maximizable: false, | ||
fullscreenable: false, | ||
}) | ||
|
||
width: 1024, // Largura Padrão da Janela | ||
height: 768, // Altura Padrão da Janela | ||
icon: __dirname + './assets/icon.png', // Icone da Aplicação | ||
movable: true, // A Janela pode ser movida? | ||
resizable: false, // A Janela pode ter suas dimensões redimensiondas? | ||
minimizable: true, // A Janela pode ser Minimizada? | ||
maximizable: false, // A Janela pode ser Maximizada? | ||
}); | ||
|
||
// Remove o Menu Superior [FILE, EDIT, VIEW, WINDOW, HELP] | ||
mainWindow.removeMenu(); | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadFile('./src/view/generator.html') | ||
// Carrega o arquivo HTML default para a Janela Principal | ||
mainWindow.loadFile('./src/view/generator.html'); | ||
|
||
// Open the DevTools. | ||
mainWindow.webContents.openDevTools() | ||
// Abre o DevTools quando o usuário aperta F1 | ||
mainWindow.webContents.on("before-input-event", (event, input) => { | ||
if(input.key === 'F1') { | ||
if(!mainWindow.webContents.isDevToolsOpened()) { | ||
mainWindow.webContents.openDevTools(); | ||
} | ||
} | ||
}) | ||
} | ||
|
||
// 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. | ||
// Método executado quando o Electron termina de carregar a aplicação | ||
app.whenReady().then(() => { | ||
createWindow() | ||
|
||
createWindow(); // Cria a Janela principal da Aplicação | ||
|
||
// No macOS, é comum recriar a janela no APP quando | ||
// o icone da barra de tarefas é clicado, e não tem nenhuma outra janela aberat | ||
app.on('activate', () => { | ||
// On macOS 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() | ||
}) | ||
}) | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
// Finaliza a aplicação quando todas as janelas estão fechadas | ||
// EXCETO no macOS, onde é comum para as aplicações ficarem ativas | ||
// até o usuário explicitamente fechá-las através do CMD+Q | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') app.quit() | ||
}) |