feature/compose: liquid glass UI + вложения файлов

- Полный редизайн ComposeView: glass card для полей, drag-drop оверлей,
  анимированные attachment-chips со счётчиком на кнопке скрепки
- Прикрепление файлов: диалог выбора (compose:pickFiles IPC) + drag & drop
- Attachment chips: иконка типа файла, имя, размер, крест для удаления
- ComposeData расширен полем attachments[], nodemailer передаёт файлы через path
- AppIcon: новые иконки pdf и image
- Правильный user-select: text внутри compose-окна

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
d.a.kolesov 2026-04-06 14:35:19 +07:00
parent b3a66604b1
commit 393a15fe9f
7 changed files with 807 additions and 245 deletions

View file

@ -1,5 +1,6 @@
import { app, BrowserWindow, shell, ipcMain, dialog, Menu, globalShortcut } from 'electron' import { app, BrowserWindow, shell, ipcMain, dialog, Menu, globalShortcut } from 'electron'
import { join } from 'node:path' import { join, basename } from 'node:path'
import { statSync } from 'node:fs'
import { AccountManager } from './services/account-manager' import { AccountManager } from './services/account-manager'
import { registerAccountHandlers } from './ipc/accounts.handler' import { registerAccountHandlers } from './ipc/accounts.handler'
import { registerFolderHandlers } from './ipc/folders.handler' import { registerFolderHandlers } from './ipc/folders.handler'
@ -55,6 +56,20 @@ ipcMain.handle('compose:getData', (event) => {
return session return session
}) })
ipcMain.handle('compose:pickFiles', async (event) => {
const win = BrowserWindow.fromWebContents(event.sender) ?? undefined
const result = await dialog.showOpenDialog(win!, {
properties: ['openFile', 'multiSelections'],
title: 'Прикрепить файлы'
})
if (result.canceled) return []
return result.filePaths.map((p) => ({
path: p,
filename: basename(p),
size: statSync(p).size
}))
})
function createWindow(): BrowserWindow { function createWindow(): BrowserWindow {
const iconPath = app.isPackaged const iconPath = app.isPackaged
? join(process.resourcesPath, 'icon.png') ? join(process.resourcesPath, 'icon.png')

View file

@ -279,7 +279,8 @@ export class ImapProvider implements IEmailProvider {
subject: compose.subject, subject: compose.subject,
text: compose.body, text: compose.body,
inReplyTo: compose.inReplyTo, inReplyTo: compose.inReplyTo,
references: compose.references references: compose.references,
attachments: compose.attachments?.map((a) => ({ path: a.path, filename: a.filename })) ?? []
}) })
// Сохраняем в папку Sent (best-effort) // Сохраняем в папку Sent (best-effort)
@ -328,7 +329,8 @@ export class ImapProvider implements IEmailProvider {
messageId, messageId,
inReplyTo: compose.inReplyTo, inReplyTo: compose.inReplyTo,
references: compose.references, references: compose.references,
date: new Date() date: new Date(),
attachments: compose.attachments?.map((a) => ({ path: a.path, filename: a.filename })) ?? []
}) })
const chunks: Buffer[] = [] const chunks: Buffer[] = []
await new Promise<void>((res, rej) => { await new Promise<void>((res, rej) => {

View file

@ -21,6 +21,8 @@ export type IconName =
| 'reply' | 'reply'
| 'forward' | 'forward'
| 'send' | 'send'
| 'pdf'
| 'image'
const props = defineProps<{ const props = defineProps<{
name: IconName name: IconName
@ -119,6 +121,18 @@ const paths: Record<IconName, string> = {
<line x1="22" y1="2" x2="11" y2="13"/> <line x1="22" y1="2" x2="11" y2="13"/>
<polygon points="22 2 15 22 11 13 2 9 22 2"/> <polygon points="22 2 15 22 11 13 2 9 22 2"/>
`, `,
pdf: `
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/>
<polyline points="14 2 14 8 20 8"/>
<line x1="9" y1="13" x2="9.01" y2="13" stroke-width="2.5"/>
<line x1="9" y1="17" x2="15" y2="17"/>
<line x1="12" y1="13" x2="15" y2="13"/>
`,
image: `
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
<circle cx="8.5" cy="8.5" r="1.5"/>
<polyline points="21 15 16 10 5 21"/>
`,
} }
</script> </script>

File diff suppressed because it is too large Load diff

View file

@ -44,6 +44,7 @@ export interface IpcChannelMap {
'compose:open': [ComposeSession, void] 'compose:open': [ComposeSession, void]
'compose:getData': [void, ComposeSession | null] 'compose:getData': [void, ComposeSession | null]
'compose:pickFiles': [void, { path: string; filename: string; size: number }[]]
'app:setZoom': [{ factor: number }, void] 'app:setZoom': [{ factor: number }, void]
} }

View file

@ -46,12 +46,19 @@ export interface MessageBody {
attachments: Attachment[] attachments: Attachment[]
} }
export interface ComposeAttachment {
path: string
filename: string
size: number
}
export interface ComposeData { export interface ComposeData {
to: string[] to: string[]
cc: string[] cc: string[]
bcc: string[] bcc: string[]
subject: string subject: string
body: string // plain text body: string // plain text
attachments?: ComposeAttachment[]
inReplyTo?: string // Message-ID оригинала (для ответа) inReplyTo?: string // Message-ID оригинала (для ответа)
references?: string // References header references?: string // References header
replyToMessageId?: string // ID письма в store (чтобы поставить \Answered) replyToMessageId?: string // ID письма в store (чтобы поставить \Answered)