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 { join } from 'node:path'
import { join, basename } from 'node:path'
import { statSync } from 'node:fs'
import { AccountManager } from './services/account-manager'
import { registerAccountHandlers } from './ipc/accounts.handler'
import { registerFolderHandlers } from './ipc/folders.handler'
@ -55,6 +56,20 @@ ipcMain.handle('compose:getData', (event) => {
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 {
const iconPath = app.isPackaged
? join(process.resourcesPath, 'icon.png')

View file

@ -279,7 +279,8 @@ export class ImapProvider implements IEmailProvider {
subject: compose.subject,
text: compose.body,
inReplyTo: compose.inReplyTo,
references: compose.references
references: compose.references,
attachments: compose.attachments?.map((a) => ({ path: a.path, filename: a.filename })) ?? []
})
// Сохраняем в папку Sent (best-effort)
@ -320,15 +321,16 @@ export class ImapProvider implements IEmailProvider {
const transporter = nodemailer.createTransport({ streamTransport: true, newline: 'unix' })
const mail = await transporter.sendMail({
from,
to: compose.to.join(', '),
cc: compose.cc.length ? compose.cc.join(', ') : undefined,
bcc: compose.bcc.length ? compose.bcc.join(', ') : undefined,
subject: compose.subject,
text: compose.body,
to: compose.to.join(', '),
cc: compose.cc.length ? compose.cc.join(', ') : undefined,
bcc: compose.bcc.length ? compose.bcc.join(', ') : undefined,
subject: compose.subject,
text: compose.body,
messageId,
inReplyTo: compose.inReplyTo,
references: compose.references,
date: new Date()
inReplyTo: compose.inReplyTo,
references: compose.references,
date: new Date(),
attachments: compose.attachments?.map((a) => ({ path: a.path, filename: a.filename })) ?? []
})
const chunks: Buffer[] = []
await new Promise<void>((res, rej) => {

View file

@ -21,6 +21,8 @@ export type IconName =
| 'reply'
| 'forward'
| 'send'
| 'pdf'
| 'image'
const props = defineProps<{
name: IconName
@ -119,6 +121,18 @@ const paths: Record<IconName, string> = {
<line x1="22" y1="2" x2="11" y2="13"/>
<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>

File diff suppressed because it is too large Load diff

View file

@ -42,8 +42,9 @@ export interface IpcChannelMap {
'messages:search': [{ accountId: string; query: string; limit: number }, MessageEnvelope[]]
'messages:send': [{ accountId: string; compose: ComposeData }, { success: boolean; error?: string }]
'compose:open': [ComposeSession, void]
'compose:getData': [void, ComposeSession | null]
'compose:open': [ComposeSession, void]
'compose:getData': [void, ComposeSession | null]
'compose:pickFiles': [void, { path: string; filename: string; size: number }[]]
'app:setZoom': [{ factor: number }, void]
}

View file

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