diff --git a/src/main/services/account-manager.ts b/src/main/services/account-manager.ts
index 0878702..c7509a1 100644
--- a/src/main/services/account-manager.ts
+++ b/src/main/services/account-manager.ts
@@ -1,4 +1,5 @@
-import { BrowserWindow } from 'electron'
+import { BrowserWindow, Notification, nativeImage, app } from 'electron'
+import { join } from 'node:path'
import type { AccountConfig, ImapCredentials } from '@shared/types/account'
import { AccountType } from '@shared/types/account'
import type { IEmailProvider, FolderListResult, MessageListResult } from '@shared/types/provider'
@@ -391,6 +392,31 @@ export class AccountManager {
if (this.mainWindow && !this.mainWindow.isDestroyed()) {
this.mainWindow.webContents.send('mail:new', { accountId, folderId, envelope })
}
+
+ if (Notification.isSupported()) {
+ const from = envelope.from.name || envelope.from.email || 'Новое письмо'
+ const subject = envelope.subject || '(без темы)'
+
+ const iconPath = app.isPackaged
+ ? join(process.resourcesPath, 'icon.png')
+ : join(app.getAppPath(), 'resources/icon.png')
+ const icon = nativeImage.createFromPath(iconPath)
+
+ const n = new Notification({
+ title: from,
+ body: subject,
+ icon: icon.isEmpty() ? undefined : icon,
+ silent: false,
+ })
+ n.on('click', () => {
+ if (this.mainWindow && !this.mainWindow.isDestroyed()) {
+ this.mainWindow.show()
+ this.mainWindow.focus()
+ this.mainWindow.webContents.send('notification:click', { accountId, folderId, messageId: envelope.id })
+ }
+ })
+ n.show()
+ }
})
}
}
diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue
index de269c6..a251bee 100644
--- a/src/renderer/src/App.vue
+++ b/src/renderer/src/App.vue
@@ -1,12 +1,39 @@
diff --git a/src/renderer/src/components/messages/MessageList.vue b/src/renderer/src/components/messages/MessageList.vue
index 9187763..81ad01f 100644
--- a/src/renderer/src/components/messages/MessageList.vue
+++ b/src/renderer/src/components/messages/MessageList.vue
@@ -214,12 +214,6 @@ function onExpandAfterLeave(el: Element): void {
// ── Refresh ───────────────────────────────────────────────
async function refresh(): Promise {
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
- // Проверяем новые письма во всех подключённых аккаунтах (не только активном)
- for (const acc of accountsStore.accounts) {
- if (accountsStore.connectionStatus[acc.id]?.connected) {
- invoke('messages:poll', { accountId: acc.id }).catch(() => {})
- }
- }
// Последовательно: loadMessages держит mailboxLock, STATUS упадёт если папка залочена параллельно
await messagesStore.loadMessages(accountsStore.activeAccountId, foldersStore.activeFolderId, 0)
await foldersStore.refreshUnreadCounts(accountsStore.activeAccountId)
diff --git a/src/renderer/src/components/notifications/NotificationContainer.vue b/src/renderer/src/components/notifications/NotificationContainer.vue
index 4f0f937..3756192 100644
--- a/src/renderer/src/components/notifications/NotificationContainer.vue
+++ b/src/renderer/src/components/notifications/NotificationContainer.vue
@@ -56,6 +56,12 @@ onMounted(() => {
const subject = envelope.subject || '(без темы)'
addToast({ from, subject, accountEmail: account.email, accountId, folderId, messageId: envelope.id })
})
+
+ on('notification:click', ({ accountId, folderId, messageId }) => {
+ accountsStore.setActive(accountId)
+ foldersStore.setActiveFolder(folderId)
+ messagesStore.selectMessage(messageId)
+ })
})