Close btn working
This commit is contained in:
parent
e34000e84e
commit
1769d18c6d
3 changed files with 20 additions and 4 deletions
|
@ -8,7 +8,7 @@
|
||||||
<div id="titlebar" class="draggable container-fluid mt-2">
|
<div id="titlebar" class="draggable container-fluid mt-2">
|
||||||
<div class="row justify-content-end">
|
<div class="row justify-content-end">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button type="button" class="btn-close" onclick="closeApp()"></button>
|
<button type="button" class="btn-close" id="closeBtn"></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
14
src/main.js
14
src/main.js
|
@ -1,4 +1,4 @@
|
||||||
const { app, BrowserWindow, Menu } = require('electron');
|
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
|
@ -37,10 +37,20 @@ const createWindow = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set up close window handler for our custom close button.
|
||||||
|
const closeWindow = (event) => {
|
||||||
|
const webContents = event.sender;
|
||||||
|
const window = BrowserWindow.fromWebContents(webContents);
|
||||||
|
window?.close();
|
||||||
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.on('ready', createWindow);
|
app.on('ready', () => {
|
||||||
|
ipcMain.on('CLOSE_WINDOW', closeWindow);
|
||||||
|
createWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// 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
|
// for applications and their menu bar to stay active until the user quits
|
||||||
|
|
|
@ -32,7 +32,7 @@ import './icons/flaticon.css'
|
||||||
|
|
||||||
import './assets/ldom.min'
|
import './assets/ldom.min'
|
||||||
|
|
||||||
const { app } = require('electron')
|
const { app, ipcRenderer } = require('electron')
|
||||||
import { Safari } from './models/Safari'
|
import { Safari } from './models/Safari'
|
||||||
import { UI } from './models/UI'
|
import { UI } from './models/UI'
|
||||||
import { Body } from './models/Body'
|
import { Body } from './models/Body'
|
||||||
|
@ -60,6 +60,12 @@ if (!journal) {
|
||||||
safari.watchJournalDir()
|
safari.watchJournalDir()
|
||||||
journal.watch()
|
journal.watch()
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- close window handler ---- */
|
||||||
|
|
||||||
|
$('#closeBtn').on('click', () => {
|
||||||
|
ipcRenderer.send('CLOSE_WINDOW')
|
||||||
|
})
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- build body list ---- */
|
/* ------------------------------------------------------------------------- build body list ---- */
|
||||||
|
|
||||||
journal.once('BUILD_BODY_LIST', () => {
|
journal.once('BUILD_BODY_LIST', () => {
|
||||||
|
|
Loading…
Reference in a new issue