Skip to content

Commit

Permalink
feat: close button
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 18, 2024
1 parent 775e02c commit 2234f93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 5 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ ipcMain.on('mini', () => {
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
app.quit();
});

app.on('activate', () => {
Expand Down Expand Up @@ -115,3 +113,7 @@ ipcMain.on('height', (_event, height) => {
mainWindow.setSize(WIDTH, height);
mainWindow.setResizable(false);
});

ipcMain.on('close', (_event) => {
app.quit();
});
15 changes: 14 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,22 @@ async function syncHeight() {
setInterval(i, 20)
}


async function closeButton() {
const target = await waitForElm(".noselect.button-minimize");
const buttonContainer = document.createElement('div');
buttonContainer.innerHTML = '<button ontouchstart="" class="noselect button-close"><span></span></button>';
const button = buttonContainer.firstChild;
button.addEventListener("click", () => {
ipcRenderer.send('close');
});
target.parentNode.appendChild(button);
}

document.addEventListener("DOMContentLoaded", (event) => {
closeButton();
syncHeight();
minimizeButton();
drag();
})
}, { once: true })

0 comments on commit 2234f93

Please sign in to comment.