Add Windows notification area icon

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-10-10 22:46:41 +03:00
co-authored by Copilot
parent 959658c400
commit 2a23f4d40e
3 changed files with 35 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ This project has a layered architecture: a desktop Electron shell, a browser-ren
- `desktop/main.cjs` is the privileged process.
- It owns account storage, mail sync, IMAP/SMTP connectivity, DAV sync, and OpenPGP key handling.
- It can show native dialogs, notifications, and system prompts.
- It can show native dialogs, notifications, and system prompts. On Windows, its notification-area tray icon uses the packaged multi-resolution application icon and provides Open and Quit actions.
- `desktop/preload.cjs` exposes a minimal API to the renderer through `window.daybreakMail` and `window.pgpPrepareSend`.
### Renderer UI
+1 -1
View File
@@ -4,7 +4,7 @@ An Eternity Project mail client with **Eternity Daylight**, **Wasteland**, and E
## Desktop app
The Electron app runs in its own window. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Sender/domain and extracted message-link checks highlight selected phishing warning signs. Message links are shown separately from the body and require explicit confirmation before opening in a browser. On desktop and Android, incoming HTML is sanitized before display; external HTTPS images stay blocked until you explicitly load them for that message. Loading remote images can disclose your network address and message-open timing to their hosts. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. Windows builds use the app icon for the executable, window, and shortcuts. If Windows continues showing an old icon for an existing taskbar pin, unpin ep-mail, install or launch the updated build, then pin it again from the updated shortcut. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
The Electron app runs in its own window. On Windows, ep-mail also shows its icon in the notification area beside the clock; click it to open the app, or right-click for Open and Quit. With Node.js installed, run `npm install` and then `npm start`. Open **Mail account settings** to connect an IMAP/SMTP account. Each account can have its own outgoing signature, new-mail notification toggle, periodic sync interval (2–60 minutes; IDLE remains event-driven), and mail rules. Rules match incoming Inbox messages by sender and/or subject; the first matching rule archives, moves to Inbox/Archive/Trash, applies a label, or flags the message. Sender/domain and extracted message-link checks highlight selected phishing warning signs. Message links are shown separately from the body and require explicit confirmation before opening in a browser. On desktop and Android, incoming HTML is sanitized before display; external HTTPS images stay blocked until you explicitly load them for that message. Loading remote images can disclose your network address and message-open timing to their hosts. Settings, cached recent messages, offline drafts, and queued mail operations are stored with the encrypted account credentials. Search supports text, sender, subject, date range, attachment, and folder filters; a filtered online search scans up to the newest 5,000 messages in the selected folder. When offline, the app can read cached messages, save drafts, and queue supported message actions and sends for retry on the next successful sync. The app uses required STARTTLS for IMAP port 143 and SMTP port 587. Before preparing a new release, bump the version once with `npm run bump:build`; then build all platform targets for that same version. To package it on Windows, run `npm run dist:win`; the installer and portable `.exe` are written to `release/`. Windows builds use the app icon for the executable, window, and shortcuts. If Windows continues showing an old icon for an existing taskbar pin, unpin ep-mail, install or launch the updated build, then pin it again from the updated shortcut. To package on Linux, run `npm install` and `npm run dist:linux` on a Linux machine; this produces AppImage and Debian packages in `release/`.
The `.github/workflows/desktop-build.yml` workflow builds both Windows and Linux artifacts on their native GitHub-hosted runners when manually started from the Actions tab. Snoozed messages return to their original mailbox with a reminder; desktop reminders are checked while the app is running, and Android uses its periodic background worker.
+33 -2
View File
@@ -1,4 +1,4 @@
const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor } = require('electron');
const { app, BrowserWindow, shell, ipcMain, safeStorage, dialog, Notification, powerMonitor, Menu, Tray, nativeImage } = require('electron');
const path = require('node:path');
const fs = require('node:fs/promises');
const { ImapFlow } = require('imapflow');
@@ -27,6 +27,8 @@ const backgroundSyncFailures = new Map();
const flagSnapshots = new Map();
const idleWatchers = new Map();
const lastBackgroundSyncAt = new Map();
let windowsAppIcon = null;
let tray = null;
function updateAccountStore(update) {
const operation = accountStoreQueue.then(async () => {
@@ -1893,7 +1895,7 @@ function createWindow() {
backgroundColor: '#f4f5f1',
show: false,
autoHideMenuBar: true,
icon: path.join(__dirname, '..', process.platform === 'win32' ? 'icon.ico' : 'icon.svg'),
icon: windowsAppIcon || path.join(__dirname, '..', 'icon.svg'),
webPreferences: {
preload: path.join(__dirname, 'preload.cjs'),
contextIsolation: true,
@@ -1911,10 +1913,39 @@ function createWindow() {
window.webContents.on('will-navigate', (event, url) => {
if (!url.startsWith('file:')) event.preventDefault();
});
return window;
}
function showMainWindow() {
let window = BrowserWindow.getAllWindows().find(item => !item.isDestroyed());
if (!window) {
window = createWindow();
} else {
if (window.isMinimized()) window.restore();
window.show();
window.focus();
}
}
function createWindowsTray() {
tray = new Tray(windowsAppIcon.resize({ width: 16, height: 16 }));
tray.setToolTip('ep-mail');
tray.setContextMenu(Menu.buildFromTemplate([
{ label: 'Open ep-mail', click: showMainWindow },
{ type: 'separator' },
{ label: 'Quit ep-mail', click: () => app.quit() }
]));
tray.on('click', showMainWindow);
tray.on('double-click', showMainWindow);
}
app.whenReady().then(() => {
app.setAppUserModelId('studio.daybreak.mail');
if (process.platform === 'win32') {
windowsAppIcon = nativeImage.createFromPath(path.join(__dirname, '..', 'icon.ico'));
if (windowsAppIcon.isEmpty()) throw new Error('Could not load the Windows application icon.');
createWindowsTray();
}
createWindow();
const syncTimer = setInterval(() => {
void runBackgroundSync(true).catch(error => console.error('Periodic mail sync failed:', error));