Merge feature/message-view-fixes: вложения, анимация тредов, настройки
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
4fd2bf0f14
21 changed files with 1235 additions and 92 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { app, BrowserWindow, shell, ipcMain, Menu } from 'electron'
|
import { app, BrowserWindow, shell, ipcMain, dialog, Menu } from 'electron'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { AccountManager } from './services/account-manager'
|
import { AccountManager } from './services/account-manager'
|
||||||
import { registerAccountHandlers } from './ipc/accounts.handler'
|
import { registerAccountHandlers } from './ipc/accounts.handler'
|
||||||
|
|
@ -47,6 +47,18 @@ ipcMain.handle('app:setZoom', (event, { factor }: { factor: number }) => {
|
||||||
event.sender.setZoomFactor(Math.max(0.5, Math.min(3, factor)))
|
event.sender.setZoomFactor(Math.max(0.5, Math.min(3, factor)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('app:getDownloadsFolder', () => app.getPath('downloads'))
|
||||||
|
|
||||||
|
ipcMain.handle('app:chooseFolder', async () => {
|
||||||
|
const result = await dialog.showOpenDialog({ properties: ['openDirectory', 'createDirectory'] })
|
||||||
|
return result.canceled ? null : (result.filePaths[0] ?? null)
|
||||||
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('app:openFile', async (_event, { path }: { path: string }) => {
|
||||||
|
const err = await shell.openPath(path)
|
||||||
|
return err ? { success: false, error: err } : { success: true }
|
||||||
|
})
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
app.whenReady().then(async () => {
|
||||||
await accountManager.initialize()
|
await accountManager.initialize()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,33 @@
|
||||||
|
import { app, dialog, BrowserWindow } from 'electron'
|
||||||
|
import { writeFile, access } from 'fs/promises'
|
||||||
|
import { join, extname, basename } from 'path'
|
||||||
import { registerHandler } from './registry'
|
import { registerHandler } from './registry'
|
||||||
import type { AccountManager } from '../services/account-manager'
|
import type { AccountManager } from '../services/account-manager'
|
||||||
|
|
||||||
|
async function resolveDownloadPath(folder: string, filename: string): Promise<string> {
|
||||||
|
const ext = extname(filename)
|
||||||
|
const base = basename(filename, ext)
|
||||||
|
let resolved = join(folder, filename)
|
||||||
|
let counter = 1
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
await access(resolved)
|
||||||
|
// файл существует — добавляем суффикс
|
||||||
|
resolved = join(folder, `${base} (${counter})${ext}`)
|
||||||
|
counter++
|
||||||
|
} catch {
|
||||||
|
// файл не существует — путь свободен
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resolved
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendProgress(attachmentId: string, stage: 'downloading' | 'saving' | 'done' | 'error', progress: number, error?: string): void {
|
||||||
|
const win = BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0]
|
||||||
|
win?.webContents.send('attachment:progress', { attachmentId, stage, progress, error })
|
||||||
|
}
|
||||||
|
|
||||||
export function registerMessageHandlers(manager: AccountManager): void {
|
export function registerMessageHandlers(manager: AccountManager): void {
|
||||||
registerHandler('messages:list', async ({ accountId, folderId, offset, limit, unseenOnly }) => {
|
registerHandler('messages:list', async ({ accountId, folderId, offset, limit, unseenOnly }) => {
|
||||||
return manager.listMessages(accountId, folderId, offset, limit, unseenOnly ?? false)
|
return manager.listMessages(accountId, folderId, offset, limit, unseenOnly ?? false)
|
||||||
|
|
@ -17,4 +44,37 @@ export function registerMessageHandlers(manager: AccountManager): void {
|
||||||
registerHandler('messages:delete', async ({ accountId, folderId, messageIds }) => {
|
registerHandler('messages:delete', async ({ accountId, folderId, messageIds }) => {
|
||||||
await manager.deleteMessages(accountId, folderId, messageIds)
|
await manager.deleteMessages(accountId, folderId, messageIds)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
registerHandler('messages:attachment:download', async ({ accountId, folderId, messageId, attachmentId, filename, downloadFolder }) => {
|
||||||
|
try {
|
||||||
|
sendProgress(attachmentId, 'downloading', 10)
|
||||||
|
const data = await manager.downloadAttachment(accountId, folderId, messageId, attachmentId)
|
||||||
|
sendProgress(attachmentId, 'saving', 70)
|
||||||
|
|
||||||
|
let filePath: string
|
||||||
|
|
||||||
|
if (downloadFolder) {
|
||||||
|
// Папка задана — сохраняем без диалога
|
||||||
|
filePath = await resolveDownloadPath(downloadFolder, filename)
|
||||||
|
} else {
|
||||||
|
// Папка не задана — спрашиваем
|
||||||
|
const folder = app.getPath('downloads')
|
||||||
|
const win = BrowserWindow.getFocusedWindow() ?? BrowserWindow.getAllWindows()[0]
|
||||||
|
const result = await dialog.showSaveDialog(win, { defaultPath: join(folder, filename) })
|
||||||
|
if (result.canceled || !result.filePath) {
|
||||||
|
sendProgress(attachmentId, 'error', 0)
|
||||||
|
return { success: false }
|
||||||
|
}
|
||||||
|
filePath = result.filePath
|
||||||
|
}
|
||||||
|
|
||||||
|
await writeFile(filePath, data)
|
||||||
|
sendProgress(attachmentId, 'done', 100)
|
||||||
|
return { success: true, savedPath: filePath }
|
||||||
|
} catch (e) {
|
||||||
|
const msg = (e as Error).message
|
||||||
|
sendProgress(attachmentId, 'error', 0, msg)
|
||||||
|
return { success: false, error: msg }
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,10 @@ export class ExchangeProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async downloadAttachment(_folderId: string, _messageId: string, _attachmentId: string): Promise<Buffer> {
|
||||||
|
throw new Error('Attachment download not supported for Exchange accounts')
|
||||||
|
}
|
||||||
|
|
||||||
async deleteMessages(folderId: string, messageIds: string[]): Promise<void> {
|
async deleteMessages(folderId: string, messageIds: string[]): Promise<void> {
|
||||||
for (const messageId of messageIds) {
|
for (const messageId of messageIds) {
|
||||||
const msg = await EmailMessage.Bind(this.service, new ItemId(messageId))
|
const msg = await EmailMessage.Bind(this.service, new ItemId(messageId))
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,17 @@ export class GmailProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async downloadAttachment(_folderId: string, messageId: string, attachmentId: string): Promise<Buffer> {
|
||||||
|
const res = await this.gmail.users.messages.attachments.get({
|
||||||
|
userId: 'me',
|
||||||
|
messageId,
|
||||||
|
id: attachmentId
|
||||||
|
})
|
||||||
|
const data = res.data.data
|
||||||
|
if (!data) throw new Error('Attachment not found')
|
||||||
|
return Buffer.from(data, 'base64url')
|
||||||
|
}
|
||||||
|
|
||||||
async updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void> {
|
async updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void> {
|
||||||
const addLabels: string[] = []
|
const addLabels: string[] = []
|
||||||
const removeLabels: string[] = []
|
const removeLabels: string[] = []
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,22 @@ export class ImapProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer> {
|
||||||
|
const lock = await this.client.getMailboxLock(folderId)
|
||||||
|
try {
|
||||||
|
const download = await this.client.download(messageId, undefined, { uid: true })
|
||||||
|
if (!download) throw new Error('Message not found')
|
||||||
|
const parsed = await simpleParser(download.content)
|
||||||
|
const att = parsed.attachments.find(
|
||||||
|
(a) => (a.checksum ?? a.filename ?? '') === attachmentId || a.filename === attachmentId
|
||||||
|
)
|
||||||
|
if (!att) throw new Error('Attachment not found')
|
||||||
|
return att.content
|
||||||
|
} finally {
|
||||||
|
lock.release()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void> {
|
async updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void> {
|
||||||
const lock = await this.client.getMailboxLock(folderId)
|
const lock = await this.client.getMailboxLock(folderId)
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,16 @@ export class AccountManager {
|
||||||
return provider.fetchMessageBody(folderId, messageId)
|
return provider.fetchMessageBody(folderId, messageId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async downloadAttachment(
|
||||||
|
accountId: string,
|
||||||
|
folderId: string,
|
||||||
|
messageId: string,
|
||||||
|
attachmentId: string
|
||||||
|
): Promise<Buffer> {
|
||||||
|
const provider = this.getProvider(accountId)
|
||||||
|
return provider.downloadAttachment(folderId, messageId, attachmentId)
|
||||||
|
}
|
||||||
|
|
||||||
async updateFlags(
|
async updateFlags(
|
||||||
accountId: string,
|
accountId: string,
|
||||||
folderId: string,
|
folderId: string,
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,43 @@ textarea:focus {
|
||||||
background: rgba(255, 255, 255, 0.22);
|
background: rgba(255, 255, 255, 0.22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Custom tooltip ────────────────────────────────────── */
|
||||||
|
.app-tooltip {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 9999;
|
||||||
|
max-width: 220px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 11.5px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.4;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
white-space: nowrap;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
/* Liquid glass: тёмный непрозрачный фон + frosted border */
|
||||||
|
background:
|
||||||
|
linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%),
|
||||||
|
rgba(14, 14, 22, 0.92);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.16);
|
||||||
|
border-radius: 7px;
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.20),
|
||||||
|
0 0 0 1px rgba(0, 0, 0, 0.35),
|
||||||
|
0 6px 20px rgba(0, 0, 0, 0.50),
|
||||||
|
0 2px 6px rgba(0, 0, 0, 0.30);
|
||||||
|
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(4px) scale(0.96);
|
||||||
|
transition:
|
||||||
|
opacity 110ms ease,
|
||||||
|
transform 140ms cubic-bezier(0.34, 1.15, 0.64, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-tooltip--visible {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Utilities ─────────────────────────────────────────── */
|
/* ── Utilities ─────────────────────────────────────────── */
|
||||||
.truncate {
|
.truncate {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@ function close(): void {
|
||||||
<span class="app-title">Aero Mail</span>
|
<span class="app-title">Aero Mail</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="titlebar-controls">
|
<div class="titlebar-controls">
|
||||||
<button class="control-btn minimize" title="Свернуть" @click="minimize">
|
<button class="control-btn minimize" v-tooltip="'Свернуть'" @click="minimize">
|
||||||
─
|
─
|
||||||
</button>
|
</button>
|
||||||
<button class="control-btn maximize" title="Развернуть" @click="maximize">
|
<button class="control-btn maximize" v-tooltip="'Развернуть'" @click="maximize">
|
||||||
□
|
□
|
||||||
</button>
|
</button>
|
||||||
<button class="control-btn close" title="Закрыть" @click="close">
|
<button class="control-btn close" v-tooltip="'Закрыть'" @click="close">
|
||||||
✕
|
✕
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,12 @@ const allVisibleSelected = computed(() =>
|
||||||
// ── Threads ───────────────────────────────────────────────
|
// ── Threads ───────────────────────────────────────────────
|
||||||
const threads = computed<Thread[]>(() => buildThreads(messagesStore.filteredMessages))
|
const threads = computed<Thread[]>(() => buildThreads(messagesStore.filteredMessages))
|
||||||
|
|
||||||
const expandedThreadIds = ref(new Set<string>())
|
const expandedThreadIds = ref(new Set<string>())
|
||||||
|
const threadSortDesc = ref(new Map<string, boolean>()) // true = новые сверху
|
||||||
|
const threadUnreadOnly = ref(new Set<string>())
|
||||||
|
|
||||||
function toggleThread(thread: Thread): void {
|
function toggleThread(thread: Thread): void {
|
||||||
if (thread.messages.length === 1) {
|
if (thread.messages.length === 1) {
|
||||||
// Один элемент — открываем напрямую
|
|
||||||
messagesStore.selectMessage(thread.messages[0].id)
|
messagesStore.selectMessage(thread.messages[0].id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -42,13 +43,74 @@ function toggleThread(thread: Thread): void {
|
||||||
expandedThreadIds.value.delete(thread.id)
|
expandedThreadIds.value.delete(thread.id)
|
||||||
} else {
|
} else {
|
||||||
expandedThreadIds.value.add(thread.id)
|
expandedThreadIds.value.add(thread.id)
|
||||||
// Открываем последнее письмо треда
|
|
||||||
messagesStore.selectMessage(thread.latest.id)
|
messagesStore.selectMessage(thread.latest.id)
|
||||||
}
|
}
|
||||||
// trigger reactivity
|
|
||||||
expandedThreadIds.value = new Set(expandedThreadIds.value)
|
expandedThreadIds.value = new Set(expandedThreadIds.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleThreadSort(threadId: string): void {
|
||||||
|
const cur = threadSortDesc.value.get(threadId) ?? true
|
||||||
|
threadSortDesc.value = new Map(threadSortDesc.value.set(threadId, !cur))
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleThreadUnread(threadId: string): void {
|
||||||
|
const next = new Set(threadUnreadOnly.value)
|
||||||
|
if (next.has(threadId)) next.delete(threadId)
|
||||||
|
else next.add(threadId)
|
||||||
|
threadUnreadOnly.value = next
|
||||||
|
}
|
||||||
|
|
||||||
|
function getThreadMessages(thread: Thread): import('@shared/types/message').MessageEnvelope[] {
|
||||||
|
// thread.messages отсортированы buildThreads от старых к новым
|
||||||
|
let msgs = thread.messages
|
||||||
|
if (threadUnreadOnly.value.has(thread.id)) {
|
||||||
|
msgs = msgs.filter(m => !m.flags.seen)
|
||||||
|
}
|
||||||
|
const desc = threadSortDesc.value.get(thread.id) ?? true
|
||||||
|
return desc ? [...msgs].reverse() : [...msgs]
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Thread expand animation ───────────────────────────────
|
||||||
|
function onExpandEnter(el: Element, done: () => void): void {
|
||||||
|
const h = el as HTMLElement
|
||||||
|
h.style.overflow = 'hidden'
|
||||||
|
h.style.height = '0'
|
||||||
|
h.style.opacity = '0'
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
h.style.transition = 'height 300ms cubic-bezier(0.34, 1.05, 0.64, 1), opacity 220ms ease'
|
||||||
|
h.style.height = h.scrollHeight + 'px'
|
||||||
|
h.style.opacity = '1'
|
||||||
|
setTimeout(done, 300)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onExpandAfterEnter(el: Element): void {
|
||||||
|
const h = el as HTMLElement
|
||||||
|
h.style.height = ''
|
||||||
|
h.style.opacity = ''
|
||||||
|
h.style.overflow = ''
|
||||||
|
h.style.transition = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function onExpandLeave(el: Element, done: () => void): void {
|
||||||
|
const h = el as HTMLElement
|
||||||
|
h.style.overflow = 'hidden'
|
||||||
|
h.style.height = h.scrollHeight + 'px'
|
||||||
|
void h.offsetHeight
|
||||||
|
h.style.transition = 'height 240ms cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease'
|
||||||
|
h.style.height = '0'
|
||||||
|
h.style.opacity = '0'
|
||||||
|
setTimeout(done, 240)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onExpandAfterLeave(el: Element): void {
|
||||||
|
const h = el as HTMLElement
|
||||||
|
h.style.height = ''
|
||||||
|
h.style.opacity = ''
|
||||||
|
h.style.overflow = ''
|
||||||
|
h.style.transition = ''
|
||||||
|
}
|
||||||
|
|
||||||
// ── Refresh ───────────────────────────────────────────────
|
// ── Refresh ───────────────────────────────────────────────
|
||||||
async function refresh(): Promise<void> {
|
async function refresh(): Promise<void> {
|
||||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||||
|
|
@ -169,7 +231,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
v-if="activeUnread > 0 || messagesStore.unreadOnly"
|
v-if="activeUnread > 0 || messagesStore.unreadOnly"
|
||||||
class="message-count"
|
class="message-count"
|
||||||
:class="{ 'unread-active': messagesStore.unreadOnly }"
|
:class="{ 'unread-active': messagesStore.unreadOnly }"
|
||||||
title="Только непрочитанные"
|
v-tooltip="'Только непрочитанные'"
|
||||||
@click="messagesStore.toggleUnreadOnly()"
|
@click="messagesStore.toggleUnreadOnly()"
|
||||||
>
|
>
|
||||||
{{ activeUnread }}
|
{{ activeUnread }}
|
||||||
|
|
@ -178,7 +240,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
<button
|
<button
|
||||||
class="icon-btn select-mode-btn"
|
class="icon-btn select-mode-btn"
|
||||||
:class="{ active: selectMode }"
|
:class="{ active: selectMode }"
|
||||||
title="Режим выбора"
|
v-tooltip="'Режим выбора'"
|
||||||
@click="selectMode = !selectMode"
|
@click="selectMode = !selectMode"
|
||||||
>
|
>
|
||||||
<span class="select-icon" :class="{ checked: selectMode }">
|
<span class="select-icon" :class="{ checked: selectMode }">
|
||||||
|
|
@ -191,7 +253,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
class="icon-btn"
|
class="icon-btn"
|
||||||
:class="{ spinning: messagesStore.loading }"
|
:class="{ spinning: messagesStore.loading }"
|
||||||
:disabled="messagesStore.loading"
|
:disabled="messagesStore.loading"
|
||||||
title="Обновить"
|
v-tooltip="'Обновить'"
|
||||||
@click="refresh"
|
@click="refresh"
|
||||||
>
|
>
|
||||||
<AppIcon name="refresh" :size="14" />
|
<AppIcon name="refresh" :size="14" />
|
||||||
|
|
@ -304,12 +366,28 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
:thread="thread"
|
:thread="thread"
|
||||||
:expanded="expandedThreadIds.has(thread.id)"
|
:expanded="expandedThreadIds.has(thread.id)"
|
||||||
:selected="thread.messages.some(m => messagesStore.selectedMessageId === m.id)"
|
:selected="thread.messages.some(m => messagesStore.selectedMessageId === m.id)"
|
||||||
|
:sort-desc="threadSortDesc.get(thread.id) ?? true"
|
||||||
|
:unread-only="threadUnreadOnly.has(thread.id)"
|
||||||
@click="toggleThread(thread)"
|
@click="toggleThread(thread)"
|
||||||
|
@toggle-sort="toggleThreadSort(thread.id)"
|
||||||
|
@toggle-unread="toggleThreadUnread(thread.id)"
|
||||||
/>
|
/>
|
||||||
<Transition name="thread-expand">
|
<Transition
|
||||||
|
:css="false"
|
||||||
|
@enter="onExpandEnter"
|
||||||
|
@after-enter="onExpandAfterEnter"
|
||||||
|
@leave="onExpandLeave"
|
||||||
|
@after-leave="onExpandAfterLeave"
|
||||||
|
>
|
||||||
<div v-if="expandedThreadIds.has(thread.id)" class="thread-children">
|
<div v-if="expandedThreadIds.has(thread.id)" class="thread-children">
|
||||||
|
<div
|
||||||
|
v-if="threadUnreadOnly.has(thread.id) && getThreadMessages(thread).length === 0"
|
||||||
|
class="thread-empty-filter"
|
||||||
|
>
|
||||||
|
Нет непрочитанных писем
|
||||||
|
</div>
|
||||||
<MessageListItem
|
<MessageListItem
|
||||||
v-for="(msg, i) in thread.messages"
|
v-for="(msg, i) in getThreadMessages(thread)"
|
||||||
:key="msg.id"
|
:key="msg.id"
|
||||||
:message="msg"
|
:message="msg"
|
||||||
:selected="messagesStore.selectedMessageId === msg.id"
|
:selected="messagesStore.selectedMessageId === msg.id"
|
||||||
|
|
@ -317,7 +395,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
:select-mode="selectMode"
|
:select-mode="selectMode"
|
||||||
:swipe-left-action="settingsStore.swipeLeftAction"
|
:swipe-left-action="settingsStore.swipeLeftAction"
|
||||||
:swipe-right-action="settingsStore.swipeRightAction"
|
:swipe-right-action="settingsStore.swipeRightAction"
|
||||||
:class="['thread-child-item', { 'thread-child-last': i === thread.messages.length - 1 }]"
|
:class="['thread-child-item', { 'thread-child-last': i === getThreadMessages(thread).length - 1 }]"
|
||||||
@click="messagesStore.selectMessage(msg.id)"
|
@click="messagesStore.selectMessage(msg.id)"
|
||||||
@toggle-select="messagesStore.toggleSelect(msg.id)"
|
@toggle-select="messagesStore.toggleSelect(msg.id)"
|
||||||
@swipe-action="(action) => handleSwipeAction(action, msg.id)"
|
@swipe-action="(action) => handleSwipeAction(action, msg.id)"
|
||||||
|
|
@ -827,24 +905,19 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Пустое состояние при фильтрации */
|
||||||
|
.thread-empty-filter {
|
||||||
|
padding: 10px 14px;
|
||||||
|
font-size: 11.5px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-align: center;
|
||||||
|
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
/* Разделитель между соседними дочерними письмами */
|
/* Разделитель между соседними дочерними письмами */
|
||||||
.thread-children :deep(.thread-child-item:not(:first-child) .message-item) {
|
.thread-children :deep(.thread-child-item:not(:first-child) .message-item) {
|
||||||
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Анимация раскрытия ─────────────────────────────────── */
|
/* Анимация раскрытия управляется JS-хуками через scrollHeight */
|
||||||
.thread-expand-enter-active {
|
|
||||||
transition: opacity 180ms ease, transform 220ms cubic-bezier(0.34, 1.1, 0.64, 1);
|
|
||||||
}
|
|
||||||
.thread-expand-leave-active {
|
|
||||||
transition: opacity 140ms ease, transform 160ms ease;
|
|
||||||
}
|
|
||||||
.thread-expand-enter-from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-6px);
|
|
||||||
}
|
|
||||||
.thread-expand-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-4px);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,15 @@ const props = defineProps<{
|
||||||
thread: Thread
|
thread: Thread
|
||||||
selected: boolean
|
selected: boolean
|
||||||
expanded?: boolean
|
expanded?: boolean
|
||||||
|
sortDesc?: boolean // true = новые сверху (default)
|
||||||
|
unreadOnly?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{ click: [] }>()
|
defineEmits<{
|
||||||
|
click: []
|
||||||
|
toggleSort: []
|
||||||
|
toggleUnread: []
|
||||||
|
}>()
|
||||||
|
|
||||||
const isUnread = computed(() => props.thread.unreadCount > 0)
|
const isUnread = computed(() => props.thread.unreadCount > 0)
|
||||||
const dateDisplay = computed(() => formatMessageDate(props.thread.latest.date))
|
const dateDisplay = computed(() => formatMessageDate(props.thread.latest.date))
|
||||||
|
|
@ -57,7 +63,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Строка 2: тема + счётчик + шеврон раскрытия -->
|
<!-- Строка 2: тема + счётчик + фильтры + шеврон -->
|
||||||
<div class="thread-row2">
|
<div class="thread-row2">
|
||||||
<span class="thread-subject truncate" :class="{ bold: isUnread }">
|
<span class="thread-subject truncate" :class="{ bold: isUnread }">
|
||||||
{{ normalizedSubject }}
|
{{ normalizedSubject }}
|
||||||
|
|
@ -65,6 +71,46 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
<span v-if="thread.messages.length > 1" class="thread-count">
|
<span v-if="thread.messages.length > 1" class="thread-count">
|
||||||
{{ thread.messages.length }}
|
{{ thread.messages.length }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
<!-- Кнопки фильтрации — только когда тред раскрыт -->
|
||||||
|
<template v-if="expanded">
|
||||||
|
<!-- Сортировка по дате -->
|
||||||
|
<button
|
||||||
|
class="thread-filter-btn"
|
||||||
|
v-tooltip="sortDesc ? 'Новые сверху' : 'Старые сверху'"
|
||||||
|
@click.stop="$emit('toggleSort')"
|
||||||
|
>
|
||||||
|
<svg width="10" height="10" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2.5"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<template v-if="sortDesc">
|
||||||
|
<!-- Стрелка вниз (новые сверху) -->
|
||||||
|
<line x1="12" y1="5" x2="12" y2="19"/>
|
||||||
|
<polyline points="19 12 12 19 5 12"/>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<!-- Стрелка вверх (старые сверху) -->
|
||||||
|
<line x1="12" y1="19" x2="12" y2="5"/>
|
||||||
|
<polyline points="5 12 12 5 19 12"/>
|
||||||
|
</template>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Только непрочитанные -->
|
||||||
|
<button
|
||||||
|
class="thread-filter-btn"
|
||||||
|
:class="{ active: unreadOnly }"
|
||||||
|
v-tooltip="'Только непрочитанные'"
|
||||||
|
@click.stop="$emit('toggleUnread')"
|
||||||
|
>
|
||||||
|
<svg width="10" height="10" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<circle cx="12" cy="12" r="4"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
class="thread-chevron"
|
class="thread-chevron"
|
||||||
:class="{ open: expanded }"
|
:class="{ open: expanded }"
|
||||||
|
|
@ -92,7 +138,10 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
margin: 2px 5px;
|
margin: 2px 5px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
background: rgba(255, 255, 255, 0.025);
|
/* Идентично .message-item — никакого лишнего выделения */
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%),
|
||||||
|
#0c0c14;
|
||||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
transition:
|
transition:
|
||||||
|
|
@ -109,7 +158,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
|
|
||||||
.thread-card.unread {
|
.thread-card.unread {
|
||||||
background:
|
background:
|
||||||
linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.015) 100%),
|
linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.015) 100%),
|
||||||
#0d0d17;
|
#0d0d17;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,14 +189,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
}
|
}
|
||||||
|
|
||||||
.thread-item.selected::before {
|
.thread-item.selected::before {
|
||||||
content: '';
|
content: none;
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 20%;
|
|
||||||
bottom: 20%;
|
|
||||||
width: 2.5px;
|
|
||||||
border-radius: 2px;
|
|
||||||
background: var(--accent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.thread-item:not(.selected):hover {
|
.thread-item:not(.selected):hover {
|
||||||
|
|
@ -265,6 +307,36 @@ const snippet = computed(() => props.thread.latest.snippet || '')
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Кнопки фильтрации треда */
|
||||||
|
.thread-filter-btn {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
color var(--transition-fast),
|
||||||
|
border-color var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.thread-filter-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.10);
|
||||||
|
border-color: rgba(255, 255, 255, 0.16);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.thread-filter-btn.active {
|
||||||
|
color: var(--accent);
|
||||||
|
background: color-mix(in srgb, var(--accent) 14%, transparent);
|
||||||
|
border-color: color-mix(in srgb, var(--accent) 30%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
.thread-chevron {
|
.thread-chevron {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
|
|
|
||||||
324
src/renderer/src/components/preview/AttachmentStrip.vue
Normal file
324
src/renderer/src/components/preview/AttachmentStrip.vue
Normal file
|
|
@ -0,0 +1,324 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
|
import type { Attachment } from '@shared/types/message'
|
||||||
|
import { useIpc } from '../../composables/useIpc'
|
||||||
|
import { useAccountsStore } from '../../stores/accounts.store'
|
||||||
|
import { useFoldersStore } from '../../stores/folders.store'
|
||||||
|
import { useSettingsStore } from '../../stores/settings.store'
|
||||||
|
import AppIcon from '../AppIcon.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
attachments: Attachment[]
|
||||||
|
messageId: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { invoke, on } = useIpc()
|
||||||
|
const accountsStore = useAccountsStore()
|
||||||
|
const foldersStore = useFoldersStore()
|
||||||
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
|
interface AttState {
|
||||||
|
stage: 'idle' | 'downloading' | 'saving' | 'done' | 'saved' | 'error'
|
||||||
|
progress: number
|
||||||
|
savedPath?: string
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = ref(new Map<string, AttState>())
|
||||||
|
|
||||||
|
function getState(id: string): AttState {
|
||||||
|
return state.value.get(id) ?? { stage: 'idle', progress: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
function setState(id: string, s: Partial<AttState>): void {
|
||||||
|
const next = new Map(state.value)
|
||||||
|
next.set(id, { ...getState(id), ...s })
|
||||||
|
state.value = next
|
||||||
|
}
|
||||||
|
|
||||||
|
let unsubProgress: (() => void) | null = null
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
unsubProgress = on('attachment:progress', ({ attachmentId, stage, progress, error }) => {
|
||||||
|
setState(attachmentId, { stage, progress, error })
|
||||||
|
if (stage === 'done') {
|
||||||
|
// Зелёный glow держится 2 сек, потом чип остаётся в состоянии 'done' (показывает путь)
|
||||||
|
setTimeout(() => {
|
||||||
|
const cur = getState(attachmentId)
|
||||||
|
if (cur.stage === 'done') setState(attachmentId, { stage: 'saved' })
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
unsubProgress?.()
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatSize(bytes: number): string {
|
||||||
|
if (!bytes) return ''
|
||||||
|
if (bytes < 1024) return `${bytes} Б`
|
||||||
|
if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} КБ`
|
||||||
|
return `${(bytes / (1024 * 1024)).toFixed(1)} МБ`
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleClick(att: Attachment): Promise<void> {
|
||||||
|
const s = getState(att.id)
|
||||||
|
|
||||||
|
// Уже скачан — открываем файл
|
||||||
|
if ((s.stage === 'done' || s.stage === ('saved')) && s.savedPath) {
|
||||||
|
await invoke('app:openFile', { path: s.savedPath })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.stage === 'downloading' || s.stage === 'saving') return
|
||||||
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||||
|
|
||||||
|
setState(att.id, { stage: 'downloading', progress: 0, error: undefined, savedPath: undefined })
|
||||||
|
|
||||||
|
const res = await invoke('messages:attachment:download', {
|
||||||
|
accountId: accountsStore.activeAccountId,
|
||||||
|
folderId: foldersStore.activeFolderId,
|
||||||
|
messageId: props.messageId,
|
||||||
|
attachmentId: att.id,
|
||||||
|
filename: att.filename,
|
||||||
|
downloadFolder: settingsStore.downloadFolder || undefined,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (res.success && res.savedPath) {
|
||||||
|
setState(att.id, { savedPath: res.savedPath })
|
||||||
|
} else if (!res.success && res.error) {
|
||||||
|
setState(att.id, { stage: 'error', progress: 0, error: res.error })
|
||||||
|
setTimeout(() => setState(att.id, { stage: 'idle', progress: 0 }), 3000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="attachment-strip">
|
||||||
|
<div class="strip-label">
|
||||||
|
<AppIcon name="attachment" :size="11" class="strip-icon" />
|
||||||
|
<span>Вложения ({{ attachments.length }})</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="chips">
|
||||||
|
<button
|
||||||
|
v-for="att in attachments"
|
||||||
|
:key="att.id"
|
||||||
|
class="att-chip"
|
||||||
|
:class="{
|
||||||
|
'is-busy': getState(att.id).stage === 'downloading' || getState(att.id).stage === 'saving',
|
||||||
|
'is-done': getState(att.id).stage === 'done',
|
||||||
|
'is-saved': getState(att.id).stage === ('saved'),
|
||||||
|
'is-error': getState(att.id).stage === 'error',
|
||||||
|
}"
|
||||||
|
v-tooltip="getState(att.id).error
|
||||||
|
?? (getState(att.id).savedPath ? 'Нажмите чтобы открыть: ' + getState(att.id).savedPath : att.filename)"
|
||||||
|
@click="handleClick(att)"
|
||||||
|
>
|
||||||
|
<!-- Иконка состояния -->
|
||||||
|
<span class="att-icon">
|
||||||
|
<svg v-if="getState(att.id).stage === 'downloading' || getState(att.id).stage === 'saving'"
|
||||||
|
class="spinner-svg" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2.2" stroke-linecap="round" width="13" height="13">
|
||||||
|
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="getState(att.id).stage === 'done' || getState(att.id).stage === ('saved')"
|
||||||
|
viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
|
||||||
|
<polyline points="20 6 9 17 4 12"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else-if="getState(att.id).stage === 'error'"
|
||||||
|
viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
|
||||||
|
<circle cx="12" cy="12" r="10"/>
|
||||||
|
<line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
|
||||||
|
</svg>
|
||||||
|
<svg v-else viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="13" height="13">
|
||||||
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
|
||||||
|
<polyline points="7 10 12 15 17 10"/>
|
||||||
|
<line x1="12" y1="15" x2="12" y2="3"/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="att-name">{{ att.filename }}</span>
|
||||||
|
<span v-if="att.size" class="att-size">{{ formatSize(att.size) }}</span>
|
||||||
|
|
||||||
|
<!-- Прогресс-бар -->
|
||||||
|
<span
|
||||||
|
class="att-progress"
|
||||||
|
:class="{
|
||||||
|
active: getState(att.id).stage === 'downloading' || getState(att.id).stage === 'saving',
|
||||||
|
indeterminate: getState(att.id).stage === 'downloading' && getState(att.id).progress < 70,
|
||||||
|
}"
|
||||||
|
:style="{ '--pct': getState(att.id).progress + '%' }"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.attachment-strip {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 10px 16px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(255,255,255,0.025) 0%, rgba(255,255,255,0.01) 100%),
|
||||||
|
rgba(10, 10, 18, 0.4);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strip-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
font-size: 10.5px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.6px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.strip-icon { opacity: 0.7; }
|
||||||
|
|
||||||
|
.chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Чип ─────────────────────────────────── */
|
||||||
|
.att-chip {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 5px 10px 7px 8px; /* +2px снизу для прогресс-бара */
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.09);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.07),
|
||||||
|
0 2px 6px rgba(0, 0, 0, 0.2);
|
||||||
|
cursor: pointer;
|
||||||
|
max-width: 260px;
|
||||||
|
overflow: hidden;
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
border-color var(--transition-fast),
|
||||||
|
box-shadow var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip:hover:not(.is-busy) {
|
||||||
|
background: rgba(255, 255, 255, 0.09);
|
||||||
|
border-color: rgba(255, 255, 255, 0.16);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.10),
|
||||||
|
0 3px 10px rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip:active:not(.is-busy) {
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
transform: translateY(1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip.is-busy { cursor: default; }
|
||||||
|
|
||||||
|
/* Зелёный glow сразу после скачивания */
|
||||||
|
.att-chip.is-done {
|
||||||
|
border-color: rgba(74, 222, 128, 0.5);
|
||||||
|
background: rgba(74, 222, 128, 0.10);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(74, 222, 128, 0.15),
|
||||||
|
0 0 12px rgba(74, 222, 128, 0.18),
|
||||||
|
0 2px 8px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Приглушённый зелёный после glow — файл доступен */
|
||||||
|
.att-chip.is-saved {
|
||||||
|
border-color: rgba(74, 222, 128, 0.28);
|
||||||
|
background: rgba(74, 222, 128, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip.is-saved:hover {
|
||||||
|
border-color: rgba(74, 222, 128, 0.45);
|
||||||
|
background: rgba(74, 222, 128, 0.10);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(74, 222, 128, 0.12),
|
||||||
|
0 0 10px rgba(74, 222, 128, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip.is-error {
|
||||||
|
border-color: rgba(244, 71, 71, 0.35);
|
||||||
|
background: rgba(244, 71, 71, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Иконки ─────────────────────────────── */
|
||||||
|
.att-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
color: var(--text-muted);
|
||||||
|
transition: color var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-chip:hover:not(.is-busy):not(.is-error):not(.is-done):not(.is-saved) .att-icon,
|
||||||
|
.att-chip.is-busy .att-icon { color: var(--accent); }
|
||||||
|
|
||||||
|
.att-chip.is-done .att-icon,
|
||||||
|
.att-chip.is-saved .att-icon { color: #4ade80; }
|
||||||
|
|
||||||
|
.att-chip.is-error .att-icon { color: var(--danger); }
|
||||||
|
|
||||||
|
/* ── Текст ──────────────────────────────── */
|
||||||
|
.att-name {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-size {
|
||||||
|
flex-shrink: 0;
|
||||||
|
font-size: 10.5px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Прогресс-бар ───────────────────────── */
|
||||||
|
.att-progress {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 2px;
|
||||||
|
width: var(--pct, 0%);
|
||||||
|
background: var(--accent);
|
||||||
|
border-radius: 0 1px 1px 0;
|
||||||
|
opacity: 0;
|
||||||
|
transition: width 220ms ease, opacity 150ms ease;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.att-progress.active { opacity: 1; }
|
||||||
|
|
||||||
|
.att-progress.indeterminate {
|
||||||
|
width: 40% !important;
|
||||||
|
animation: indeterminate 1.4s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes indeterminate {
|
||||||
|
0% { left: -40%; }
|
||||||
|
100% { left: 120%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Спиннер */
|
||||||
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||||||
|
.spinner-svg { animation: spin 0.8s linear infinite; }
|
||||||
|
</style>
|
||||||
|
|
@ -8,20 +8,67 @@ const props = defineProps<{
|
||||||
|
|
||||||
const iframeRef = ref<HTMLIFrameElement | null>(null)
|
const iframeRef = ref<HTMLIFrameElement | null>(null)
|
||||||
|
|
||||||
|
// ── Исправление цветов HTML-писем (после загрузки iframe) ─
|
||||||
|
// postProcessHtml на DOMParser не видит CSS-классы.
|
||||||
|
// Правим ПОСЛЕ загрузки через getComputedStyle — он знает всё.
|
||||||
|
|
||||||
|
function rgbMatch(s: string): [number, number, number, number] | null {
|
||||||
|
const m = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/)
|
||||||
|
if (!m) return null
|
||||||
|
return [+m[1], +m[2], +m[3], m[4] !== undefined ? parseFloat(m[4]) : 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNearWhiteRgb(r: number, g: number, b: number): boolean {
|
||||||
|
return r >= 200 && g >= 200 && b >= 200
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixIframeColors(): void {
|
||||||
|
try {
|
||||||
|
const doc = iframeRef.value?.contentDocument
|
||||||
|
const view = iframeRef.value?.contentWindow
|
||||||
|
if (!doc?.body || !view) return
|
||||||
|
|
||||||
|
// Для каждого элемента: если getComputedStyle говорит что цвет текста
|
||||||
|
// близок к белому — ищем эффективный фон вверх по дереву.
|
||||||
|
// Если фон тоже светлый или прозрачный (дефолт белый) → делаем текст тёмным.
|
||||||
|
function effectiveBg(el: HTMLElement): [number, number, number] | null {
|
||||||
|
let node: HTMLElement | null = el
|
||||||
|
while (node) {
|
||||||
|
const c = rgbMatch(view.getComputedStyle(node).backgroundColor)
|
||||||
|
if (c && c[3] > 0.05) return [c[0], c[1], c[2]]
|
||||||
|
node = node.parentElement
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const all = doc.body.querySelectorAll<HTMLElement>('*')
|
||||||
|
for (const el of all) {
|
||||||
|
const fg = rgbMatch(view.getComputedStyle(el).color)
|
||||||
|
if (!fg || fg[3] < 0.3) continue
|
||||||
|
if (!isNearWhiteRgb(fg[0], fg[1], fg[2])) continue
|
||||||
|
|
||||||
|
// Текст белый — проверяем эффективный фон
|
||||||
|
const bg = effectiveBg(el)
|
||||||
|
if (!bg || isNearWhiteRgb(bg[0], bg[1], bg[2])) {
|
||||||
|
// Белый на белом/прозрачном → тёмный текст
|
||||||
|
el.style.setProperty('color', 'rgba(20, 20, 30, 0.88)', 'important')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch { /* sandbox или cross-origin */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Вычисленный HTML ───────────────────────────────────────
|
||||||
|
|
||||||
const processedHtml = computed(() => {
|
const processedHtml = computed(() => {
|
||||||
if (!props.body.html) return null
|
if (!props.body.html) return null
|
||||||
|
|
||||||
let html = props.body.html
|
let html = props.body.html
|
||||||
|
|
||||||
// Replace CID references with base64 data URLs
|
// Подставляем inline-изображения
|
||||||
for (const img of props.body.inlineImages) {
|
for (const img of props.body.inlineImages) {
|
||||||
html = html.replaceAll(
|
html = html.replaceAll(`cid:${img.cid}`, `data:${img.contentType};base64,${img.data}`)
|
||||||
`cid:${img.cid}`,
|
|
||||||
`data:${img.contentType};base64,${img.data}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap in a dark-themed document
|
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -110,7 +157,7 @@ const plainTextHtml = computed(() => {
|
||||||
|
|
||||||
const srcdoc = computed(() => processedHtml.value ?? plainTextHtml.value ?? '')
|
const srcdoc = computed(() => processedHtml.value ?? plainTextHtml.value ?? '')
|
||||||
|
|
||||||
// ── Ambient glow: извлекаем доминирующий цвет фона письма ──
|
// ── Ambient glow ───────────────────────────────────────────
|
||||||
|
|
||||||
function parseRgb(color: string): { r: number; g: number; b: number; a: number } | null {
|
function parseRgb(color: string): { r: number; g: number; b: number; a: number } | null {
|
||||||
const m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/)
|
const m = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/)
|
||||||
|
|
@ -145,19 +192,18 @@ const resizeObserver = new ResizeObserver(updateGlowPosition)
|
||||||
function onIframeLoad(): void {
|
function onIframeLoad(): void {
|
||||||
updateGlowPosition()
|
updateGlowPosition()
|
||||||
if (iframeRef.value) resizeObserver.observe(iframeRef.value)
|
if (iframeRef.value) resizeObserver.observe(iframeRef.value)
|
||||||
|
fixIframeColors()
|
||||||
try {
|
try {
|
||||||
const doc = iframeRef.value?.contentDocument
|
const doc = iframeRef.value?.contentDocument
|
||||||
const view = iframeRef.value?.contentWindow
|
const view = iframeRef.value?.contentWindow
|
||||||
if (!doc?.body || !view) return
|
if (!doc?.body || !view) return
|
||||||
|
|
||||||
// Пробуем body напрямую
|
|
||||||
const bodyColor = parseRgb(view.getComputedStyle(doc.body).backgroundColor)
|
const bodyColor = parseRgb(view.getComputedStyle(doc.body).backgroundColor)
|
||||||
if (bodyColor && bodyColor.a > 0.1 && bodyColor.r + bodyColor.g + bodyColor.b > 60) {
|
if (bodyColor && bodyColor.a > 0.1 && bodyColor.r + bodyColor.g + bodyColor.b > 60) {
|
||||||
setContentGlow(bodyColor.r, bodyColor.g, bodyColor.b, 0.26)
|
setContentGlow(bodyColor.r, bodyColor.g, bodyColor.b, 0.26)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Многие HTML-письма кладут фон в первый <table> или <td>
|
|
||||||
const firstEl = doc.body.querySelector<HTMLElement>('table, td, [bgcolor]')
|
const firstEl = doc.body.querySelector<HTMLElement>('table, td, [bgcolor]')
|
||||||
if (firstEl) {
|
if (firstEl) {
|
||||||
const raw = firstEl.getAttribute('bgcolor') ?? view.getComputedStyle(firstEl).backgroundColor
|
const raw = firstEl.getAttribute('bgcolor') ?? view.getComputedStyle(firstEl).backgroundColor
|
||||||
|
|
@ -172,7 +218,6 @@ function onIframeLoad(): void {
|
||||||
clearContentGlow()
|
clearContentGlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Сбрасываем свечение при смене письма
|
|
||||||
watch(() => props.body, () => clearContentGlow())
|
watch(() => props.body, () => clearContentGlow())
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed, ref, onMounted, onUnmounted } from 'vue'
|
||||||
import type { MessageEnvelope } from '@shared/types/message'
|
import type { MessageEnvelope, Address } from '@shared/types/message'
|
||||||
import { formatFullDate } from '../../utils/date'
|
import { formatFullDate } from '../../utils/date'
|
||||||
import AppIcon from '../AppIcon.vue'
|
import AppIcon from '../AppIcon.vue'
|
||||||
|
|
||||||
|
|
@ -8,47 +8,156 @@ const props = defineProps<{
|
||||||
message: MessageEnvelope
|
message: MessageEnvelope
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const fromDisplay = computed(() => {
|
|
||||||
const f = props.message.from
|
|
||||||
return f.name ? `${f.name} <${f.email}>` : f.email
|
|
||||||
})
|
|
||||||
|
|
||||||
const toDisplay = computed(() =>
|
|
||||||
props.message.to.map((a) => a.name || a.email).join(', ')
|
|
||||||
)
|
|
||||||
|
|
||||||
const ccDisplay = computed(() =>
|
|
||||||
props.message.cc.map((a) => a.name || a.email).join(', ')
|
|
||||||
)
|
|
||||||
|
|
||||||
const dateDisplay = computed(() => formatFullDate(props.message.date))
|
const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
|
|
||||||
|
// ── Contact popup ──────────────────────────────────────────
|
||||||
|
|
||||||
|
const activeContact = ref<Address | null>(null)
|
||||||
|
const popupStyle = ref({ top: '0px', left: '0px' })
|
||||||
|
const popupRef = ref<HTMLElement | null>(null)
|
||||||
|
const copyDone = ref(false)
|
||||||
|
|
||||||
|
const POPUP_WIDTH = 272
|
||||||
|
|
||||||
|
function openContact(addr: Address, event: MouseEvent): void {
|
||||||
|
// Если кликнули по уже открытому — закрываем
|
||||||
|
if (activeContact.value?.email === addr.email) {
|
||||||
|
activeContact.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const btn = event.currentTarget as HTMLElement
|
||||||
|
const header = btn.closest('.message-header') as HTMLElement
|
||||||
|
const btnRect = btn.getBoundingClientRect()
|
||||||
|
const headerRect = header.getBoundingClientRect()
|
||||||
|
|
||||||
|
let left = btnRect.left - headerRect.left
|
||||||
|
// Не выходим за правый край
|
||||||
|
left = Math.min(left, headerRect.width - POPUP_WIDTH - 8)
|
||||||
|
|
||||||
|
activeContact.value = addr
|
||||||
|
popupStyle.value = {
|
||||||
|
top: `${btnRect.bottom - headerRect.top + 6}px`,
|
||||||
|
left: `${Math.max(0, left)}px`,
|
||||||
|
}
|
||||||
|
copyDone.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function copyEmail(): Promise<void> {
|
||||||
|
if (!activeContact.value) return
|
||||||
|
await navigator.clipboard.writeText(activeContact.value.email)
|
||||||
|
copyDone.value = true
|
||||||
|
setTimeout(() => { copyDone.value = false }, 1800)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDocMousedown(e: MouseEvent): void {
|
||||||
|
if (popupRef.value && !popupRef.value.contains(e.target as Node)) {
|
||||||
|
// Если клик внутри header — не закрываем здесь, openContact разберётся
|
||||||
|
activeContact.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onKeydown(e: KeyboardEvent): void {
|
||||||
|
if (e.key === 'Escape') activeContact.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('mousedown', onDocMousedown)
|
||||||
|
document.addEventListener('keydown', onKeydown)
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
document.removeEventListener('mousedown', onDocMousedown)
|
||||||
|
document.removeEventListener('keydown', onKeydown)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="message-header">
|
<div class="message-header">
|
||||||
<h2 class="subject">{{ message.subject }}</h2>
|
<h2 class="subject">{{ message.subject }}</h2>
|
||||||
|
|
||||||
<div class="header-details">
|
<div class="header-details">
|
||||||
|
<!-- От -->
|
||||||
<div class="header-row">
|
<div class="header-row">
|
||||||
<span class="label">От:</span>
|
<span class="label">От:</span>
|
||||||
<span class="value">{{ fromDisplay }}</span>
|
<span class="value">
|
||||||
|
<button class="addr-chip" @click="openContact(message.from, $event)">
|
||||||
|
<span class="addr-name">{{ message.from.name || message.from.email }}</span>
|
||||||
|
<span v-if="message.from.name" class="addr-email-hint"><{{ message.from.email }}></span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Кому -->
|
||||||
<div class="header-row">
|
<div class="header-row">
|
||||||
<span class="label">Кому:</span>
|
<span class="label">Кому:</span>
|
||||||
<span class="value">{{ toDisplay }}</span>
|
<span class="value addr-list">
|
||||||
|
<button
|
||||||
|
v-for="addr in message.to"
|
||||||
|
:key="addr.email"
|
||||||
|
class="addr-chip"
|
||||||
|
@click="openContact(addr, $event)"
|
||||||
|
>
|
||||||
|
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="ccDisplay" class="header-row">
|
|
||||||
|
<!-- Копия -->
|
||||||
|
<div v-if="message.cc.length" class="header-row">
|
||||||
<span class="label">Копия:</span>
|
<span class="label">Копия:</span>
|
||||||
<span class="value">{{ ccDisplay }}</span>
|
<span class="value addr-list">
|
||||||
|
<button
|
||||||
|
v-for="addr in message.cc"
|
||||||
|
:key="addr.email"
|
||||||
|
class="addr-chip"
|
||||||
|
@click="openContact(addr, $event)"
|
||||||
|
>
|
||||||
|
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Дата -->
|
||||||
<div class="header-row">
|
<div class="header-row">
|
||||||
<span class="label">Дата:</span>
|
<span class="label">Дата:</span>
|
||||||
<span class="value">{{ dateDisplay }}</span>
|
<span class="value">{{ dateDisplay }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Мини-профиль контакта -->
|
||||||
|
<Transition name="popup">
|
||||||
|
<div
|
||||||
|
v-if="activeContact"
|
||||||
|
ref="popupRef"
|
||||||
|
class="contact-popup"
|
||||||
|
:style="popupStyle"
|
||||||
|
>
|
||||||
|
<div v-if="activeContact.name" class="popup-name">{{ activeContact.name }}</div>
|
||||||
|
<div class="popup-email-row">
|
||||||
|
<span class="popup-email">{{ activeContact.email }}</span>
|
||||||
|
<button
|
||||||
|
class="popup-copy"
|
||||||
|
:class="{ done: copyDone }"
|
||||||
|
v-tooltip="copyDone ? 'Скопировано!' : 'Скопировать email'"
|
||||||
|
@click.stop="copyEmail"
|
||||||
|
>
|
||||||
|
<!-- Copy icon -->
|
||||||
|
<svg v-if="!copyDone" width="13" height="13" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
|
||||||
|
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
||||||
|
</svg>
|
||||||
|
<!-- Checkmark icon -->
|
||||||
|
<svg v-else width="13" height="13" viewBox="0 0 24 24" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<polyline points="20 6 9 17 4 12"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
|
||||||
<div class="header-badges">
|
<div class="header-badges">
|
||||||
<span v-if="message.hasAttachments" class="badge">
|
|
||||||
<AppIcon name="attachment" :size="11" /> Вложения
|
|
||||||
</span>
|
|
||||||
<span v-if="message.flags.flagged" class="badge flagged">
|
<span v-if="message.flags.flagged" class="badge flagged">
|
||||||
<AppIcon name="flag" :size="11" /> Отмечено
|
<AppIcon name="flag" :size="11" /> Отмечено
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -60,6 +169,7 @@ const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
.message-header {
|
.message-header {
|
||||||
padding: 22px 26px 18px;
|
padding: 22px 26px 18px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
position: relative;
|
||||||
background:
|
background:
|
||||||
linear-gradient(180deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.012) 100%),
|
linear-gradient(180deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.012) 100%),
|
||||||
rgba(10, 10, 18, 0.5);
|
rgba(10, 10, 18, 0.5);
|
||||||
|
|
@ -81,7 +191,6 @@ const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
letter-spacing: -0.01em;
|
letter-spacing: -0.01em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Детали в стеклянной карточке */
|
|
||||||
.header-details {
|
.header-details {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
@ -102,17 +211,12 @@ const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
border-bottom: 1px solid rgba(255, 255, 255, 0.04);
|
||||||
transition: background var(--transition-fast);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-row:last-child {
|
.header-row:last-child {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-row:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
min-width: 52px;
|
min-width: 52px;
|
||||||
|
|
@ -121,7 +225,7 @@ const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
letter-spacing: 0.5px;
|
letter-spacing: 0.5px;
|
||||||
padding-top: 1px;
|
padding-top: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
|
|
@ -131,7 +235,147 @@ const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Бейджи */
|
/* Список адресов */
|
||||||
|
.addr-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 1px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Кликабельный адрес */
|
||||||
|
.addr-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 1px 7px 1px 6px;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
border-color var(--transition-fast),
|
||||||
|
color var(--transition-fast);
|
||||||
|
max-width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr-chip:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.07);
|
||||||
|
border-color: rgba(255, 255, 255, 0.10);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr-name {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 260px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addr-email-hint {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 11px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Попап контакта ──────────────────────────────────────── */
|
||||||
|
.contact-popup {
|
||||||
|
position: absolute;
|
||||||
|
width: 272px;
|
||||||
|
/* Непрозрачный тёмный фон — backdrop-filter не работает внутри блюренного родителя */
|
||||||
|
background:
|
||||||
|
linear-gradient(135deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.02) 100%),
|
||||||
|
rgb(18, 18, 30);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.16);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.22),
|
||||||
|
0 0 0 1px rgba(0, 0, 0, 0.4),
|
||||||
|
0 12px 40px rgba(0, 0, 0, 0.55),
|
||||||
|
0 4px 12px rgba(0, 0, 0, 0.35);
|
||||||
|
padding: 12px 14px;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-name {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-email-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-email {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 11.5px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
user-select: text;
|
||||||
|
-webkit-user-select: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-copy {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.09);
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
color var(--transition-fast),
|
||||||
|
border-color var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-copy:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.12);
|
||||||
|
border-color: rgba(255, 255, 255, 0.18);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-copy.done {
|
||||||
|
color: var(--accent);
|
||||||
|
background: color-mix(in srgb, var(--accent) 12%, transparent);
|
||||||
|
border-color: color-mix(in srgb, var(--accent) 28%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Анимация попапа ─────────────────────────────────────── */
|
||||||
|
.popup-enter-active {
|
||||||
|
transition: opacity 130ms ease, transform 160ms cubic-bezier(0.34, 1.2, 0.64, 1);
|
||||||
|
}
|
||||||
|
.popup-leave-active {
|
||||||
|
transition: opacity 100ms ease, transform 110ms ease;
|
||||||
|
}
|
||||||
|
.popup-enter-from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-5px) scale(0.97);
|
||||||
|
}
|
||||||
|
.popup-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-3px) scale(0.97);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Бейджи ──────────────────────────────────────────────── */
|
||||||
.header-badges {
|
.header-badges {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { computed } from 'vue'
|
||||||
import { useMessagesStore } from '../../stores/messages.store'
|
import { useMessagesStore } from '../../stores/messages.store'
|
||||||
import MessageHeader from './MessageHeader.vue'
|
import MessageHeader from './MessageHeader.vue'
|
||||||
import MessageBody from './MessageBody.vue'
|
import MessageBody from './MessageBody.vue'
|
||||||
|
import AttachmentStrip from './AttachmentStrip.vue'
|
||||||
import AppIcon from '../AppIcon.vue'
|
import AppIcon from '../AppIcon.vue'
|
||||||
|
|
||||||
const messagesStore = useMessagesStore()
|
const messagesStore = useMessagesStore()
|
||||||
|
|
@ -29,10 +30,14 @@ const selectedMessage = computed(() =>
|
||||||
<span>Загрузка письма...</span>
|
<span>Загрузка письма...</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MessageBody
|
<template v-else-if="messagesStore.messageBody">
|
||||||
v-else-if="messagesStore.messageBody"
|
<AttachmentStrip
|
||||||
:body="messagesStore.messageBody"
|
v-if="messagesStore.messageBody.attachments.length > 0"
|
||||||
/>
|
:attachments="messagesStore.messageBody.attachments"
|
||||||
|
:message-id="selectedMessage.id"
|
||||||
|
/>
|
||||||
|
<MessageBody :body="messagesStore.messageBody" />
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function getAccountColor(index: number): string {
|
||||||
:key="account.id"
|
:key="account.id"
|
||||||
class="account-btn"
|
class="account-btn"
|
||||||
:class="{ active: accountsStore.activeAccountId === account.id }"
|
:class="{ active: accountsStore.activeAccountId === account.id }"
|
||||||
:title="account.email"
|
v-tooltip="account.email"
|
||||||
@click="accountsStore.setActive(account.id)"
|
@click="accountsStore.setActive(account.id)"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|
@ -40,11 +40,11 @@ function getAccountColor(index: number): string {
|
||||||
|
|
||||||
<div class="spacer" />
|
<div class="spacer" />
|
||||||
|
|
||||||
<button class="account-btn add-btn" title="Добавить аккаунт" @click="emit('addAccount')">
|
<button class="account-btn add-btn" v-tooltip="'Добавить аккаунт'" @click="emit('addAccount')">
|
||||||
<AppIcon name="plus" :size="16" class="add-icon" />
|
<AppIcon name="plus" :size="16" class="add-icon" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button class="account-btn settings-btn" title="Настройки" @click="router.push('/settings')">
|
<button class="account-btn settings-btn" v-tooltip="'Настройки'" @click="router.push('/settings')">
|
||||||
<AppIcon name="settings" :size="15" class="settings-icon" />
|
<AppIcon name="settings" :size="15" class="settings-icon" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
106
src/renderer/src/directives/tooltip.ts
Normal file
106
src/renderer/src/directives/tooltip.ts
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
import type { ObjectDirective } from 'vue'
|
||||||
|
|
||||||
|
// Единственный DOM-элемент тултипа на весь app
|
||||||
|
let tipEl: HTMLDivElement | null = null
|
||||||
|
let showTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
let hideTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
|
function getEl(): HTMLDivElement {
|
||||||
|
if (!tipEl) {
|
||||||
|
tipEl = document.createElement('div')
|
||||||
|
tipEl.className = 'app-tooltip'
|
||||||
|
document.body.appendChild(tipEl)
|
||||||
|
}
|
||||||
|
return tipEl
|
||||||
|
}
|
||||||
|
|
||||||
|
function reposition(anchor: HTMLElement): void {
|
||||||
|
const tip = getEl()
|
||||||
|
const ar = anchor.getBoundingClientRect()
|
||||||
|
const tr = tip.getBoundingClientRect()
|
||||||
|
const gap = 7
|
||||||
|
const margin = 8
|
||||||
|
|
||||||
|
// По умолчанию — снизу по центру
|
||||||
|
let top = ar.bottom + gap
|
||||||
|
let left = ar.left + ar.width / 2 - tr.width / 2
|
||||||
|
|
||||||
|
// Не хватает места снизу — показываем сверху
|
||||||
|
if (top + tr.height + margin > window.innerHeight) {
|
||||||
|
top = ar.top - tr.height - gap
|
||||||
|
}
|
||||||
|
|
||||||
|
// Зажимаем горизонтально
|
||||||
|
left = Math.max(margin, Math.min(left, window.innerWidth - tr.width - margin))
|
||||||
|
|
||||||
|
tip.style.top = `${top}px`
|
||||||
|
tip.style.left = `${left}px`
|
||||||
|
}
|
||||||
|
|
||||||
|
function show(anchor: HTMLElement, text: string): void {
|
||||||
|
if (!text) return
|
||||||
|
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null }
|
||||||
|
|
||||||
|
const tip = getEl()
|
||||||
|
tip.textContent = text
|
||||||
|
|
||||||
|
// Ждём один кадр, чтобы браузер успел посчитать ширину текста
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
tip.classList.add('app-tooltip--visible')
|
||||||
|
reposition(anchor)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide(): void {
|
||||||
|
if (showTimer) { clearTimeout(showTimer); showTimer = null }
|
||||||
|
hideTimer = setTimeout(() => {
|
||||||
|
getEl().classList.remove('app-tooltip--visible')
|
||||||
|
}, 80)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Директива ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
interface TooltipState {
|
||||||
|
text: string
|
||||||
|
enter: () => void
|
||||||
|
leave: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const DATA_KEY = '__tooltip__'
|
||||||
|
|
||||||
|
export const vTooltip: ObjectDirective<HTMLElement & { [DATA_KEY]?: TooltipState }, string> = {
|
||||||
|
mounted(el, binding) {
|
||||||
|
const state: TooltipState = {
|
||||||
|
text: binding.value ?? '',
|
||||||
|
enter: () => {
|
||||||
|
showTimer = setTimeout(() => show(el, state.text), 350)
|
||||||
|
},
|
||||||
|
leave: () => {
|
||||||
|
if (showTimer) { clearTimeout(showTimer); showTimer = null }
|
||||||
|
hide()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
el[DATA_KEY] = state
|
||||||
|
|
||||||
|
// Убираем нативный тултип
|
||||||
|
el.removeAttribute('title')
|
||||||
|
|
||||||
|
el.addEventListener('mouseenter', state.enter)
|
||||||
|
el.addEventListener('mouseleave', state.leave)
|
||||||
|
el.addEventListener('mousedown', state.leave)
|
||||||
|
},
|
||||||
|
|
||||||
|
updated(el, binding) {
|
||||||
|
const state = el[DATA_KEY]
|
||||||
|
if (state) state.text = binding.value ?? ''
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeUnmount(el) {
|
||||||
|
const state = el[DATA_KEY]
|
||||||
|
if (state) {
|
||||||
|
el.removeEventListener('mouseenter', state.enter)
|
||||||
|
el.removeEventListener('mouseleave', state.leave)
|
||||||
|
el.removeEventListener('mousedown', state.leave)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ import { createApp } from 'vue'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
import { vTooltip } from './directives/tooltip'
|
||||||
import './assets/styles/variables.css'
|
import './assets/styles/variables.css'
|
||||||
import './assets/styles/base.css'
|
import './assets/styles/base.css'
|
||||||
|
|
||||||
|
|
@ -24,4 +25,5 @@ const router = createRouter({
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
app.directive('tooltip', vTooltip)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ function load(): {
|
||||||
accentColor?: string
|
accentColor?: string
|
||||||
autoCheckInterval?: number
|
autoCheckInterval?: number
|
||||||
uiScale?: number
|
uiScale?: number
|
||||||
|
downloadFolder?: string
|
||||||
} {
|
} {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}')
|
return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}')
|
||||||
|
|
@ -101,6 +102,14 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
const accentColor = ref<string>(saved.accentColor ?? '#a8e600')
|
const accentColor = ref<string>(saved.accentColor ?? '#a8e600')
|
||||||
const autoCheckInterval = ref<number>(saved.autoCheckInterval ?? 5)
|
const autoCheckInterval = ref<number>(saved.autoCheckInterval ?? 5)
|
||||||
const uiScale = ref<number>(saved.uiScale ?? 1.0)
|
const uiScale = ref<number>(saved.uiScale ?? 1.0)
|
||||||
|
const downloadFolder = ref<string>(saved.downloadFolder ?? '')
|
||||||
|
|
||||||
|
// Если папка не сохранена — подтягиваем системный Downloads
|
||||||
|
if (!downloadFolder.value) {
|
||||||
|
window.api.invoke('app:getDownloadsFolder').then((path) => {
|
||||||
|
if (!downloadFolder.value) downloadFolder.value = path
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Apply on init
|
// Apply on init
|
||||||
applyAccentColor(accentColor.value)
|
applyAccentColor(accentColor.value)
|
||||||
|
|
@ -116,7 +125,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
persist()
|
persist()
|
||||||
})
|
})
|
||||||
|
|
||||||
watch([swipeLeftAction, swipeRightAction, autoCheckInterval], persist)
|
watch([swipeLeftAction, swipeRightAction, autoCheckInterval, downloadFolder], persist)
|
||||||
|
|
||||||
function persist(): void {
|
function persist(): void {
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
||||||
|
|
@ -125,8 +134,9 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
accentColor: accentColor.value,
|
accentColor: accentColor.value,
|
||||||
autoCheckInterval: autoCheckInterval.value,
|
autoCheckInterval: autoCheckInterval.value,
|
||||||
uiScale: uiScale.value,
|
uiScale: uiScale.value,
|
||||||
|
downloadFolder: downloadFolder.value,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
return { swipeLeftAction, swipeRightAction, accentColor, autoCheckInterval, uiScale }
|
return { swipeLeftAction, swipeRightAction, accentColor, autoCheckInterval, uiScale, downloadFolder }
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { useAccountsStore } from '../stores/accounts.store'
|
||||||
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_QUICK_PICKS, AUTO_CHECK_INTERVALS, type SwipeAction } from '../stores/settings.store'
|
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_QUICK_PICKS, AUTO_CHECK_INTERVALS, type SwipeAction } from '../stores/settings.store'
|
||||||
import CustomSelect from '../components/CustomSelect.vue'
|
import CustomSelect from '../components/CustomSelect.vue'
|
||||||
import ColorPicker from '../components/ColorPicker.vue'
|
import ColorPicker from '../components/ColorPicker.vue'
|
||||||
|
import AppIcon from '../components/AppIcon.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const accountsStore = useAccountsStore()
|
const accountsStore = useAccountsStore()
|
||||||
|
|
@ -12,6 +13,22 @@ const settingsStore = useSettingsStore()
|
||||||
const swipeOptions: { value: SwipeAction; label: string }[] = (
|
const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[]
|
['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[]
|
||||||
).map((v) => ({ value: v, label: SWIPE_ACTION_LABELS[v] }))
|
).map((v) => ({ value: v, label: SWIPE_ACTION_LABELS[v] }))
|
||||||
|
|
||||||
|
async function chooseDownloadFolder(): Promise<void> {
|
||||||
|
const picked = await window.api.invoke('app:chooseFolder')
|
||||||
|
if (picked) settingsStore.downloadFolder = picked
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetDownloadFolder(): Promise<void> {
|
||||||
|
settingsStore.downloadFolder = await window.api.invoke('app:getDownloadsFolder')
|
||||||
|
}
|
||||||
|
|
||||||
|
function folderDisplayName(path: string): string {
|
||||||
|
if (!path) return ''
|
||||||
|
// Показываем последние 2 сегмента пути для читаемости
|
||||||
|
const parts = path.replace(/\\/g, '/').split('/').filter(Boolean)
|
||||||
|
return parts.length > 2 ? '…/' + parts.slice(-2).join('/') : path
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -52,7 +69,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
class="quick-dot"
|
class="quick-dot"
|
||||||
:class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }"
|
:class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }"
|
||||||
:style="{ '--dot-color': hex }"
|
:style="{ '--dot-color': hex }"
|
||||||
:title="hex"
|
v-tooltip="hex"
|
||||||
@click="settingsStore.accentColor = hex"
|
@click="settingsStore.accentColor = hex"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -79,7 +96,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
<button
|
<button
|
||||||
v-if="settingsStore.uiScale !== 1"
|
v-if="settingsStore.uiScale !== 1"
|
||||||
class="scale-reset"
|
class="scale-reset"
|
||||||
title="Сбросить"
|
v-tooltip="'Сбросить'"
|
||||||
@click="settingsStore.uiScale = 1"
|
@click="settingsStore.uiScale = 1"
|
||||||
>↺</button>
|
>↺</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -102,6 +119,24 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Вложения -->
|
||||||
|
<section>
|
||||||
|
<h2>Вложения</h2>
|
||||||
|
<p class="section-desc">Файлы будут сохраняться сюда автоматически без диалога</p>
|
||||||
|
<div class="folder-row setting-row">
|
||||||
|
<div class="folder-path">
|
||||||
|
<AppIcon name="folder" :size="14" class="folder-icon" />
|
||||||
|
<span class="folder-name" v-tooltip="settingsStore.downloadFolder">
|
||||||
|
{{ folderDisplayName(settingsStore.downloadFolder) || '…' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="folder-actions">
|
||||||
|
<button class="folder-btn" @click="chooseDownloadFolder">Изменить</button>
|
||||||
|
<button class="folder-btn reset" v-tooltip="'Сбросить в Downloads'" @click="resetDownloadFolder">↺</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Жесты -->
|
<!-- Жесты -->
|
||||||
<section>
|
<section>
|
||||||
<h2>Жесты</h2>
|
<h2>Жесты</h2>
|
||||||
|
|
@ -456,4 +491,71 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
0 4px 14px rgba(0,0,0,0.5),
|
0 4px 14px rgba(0,0,0,0.5),
|
||||||
inset 0 1px 0 rgba(255,255,255,0.3);
|
inset 0 1px 0 rgba(255,255,255,0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Папка загрузок */
|
||||||
|
.folder-row {
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-path {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-name {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-btn {
|
||||||
|
font-size: 11.5px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: var(--radius-full);
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.10);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
border-color var(--transition-fast),
|
||||||
|
color var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.10);
|
||||||
|
border-color: rgba(255, 255, 255, 0.18);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-btn.reset {
|
||||||
|
padding: 4px 9px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-btn.reset:hover {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ export interface IpcChannelMap {
|
||||||
{ accountId: string; folderId: string; messageIds: string[] },
|
{ accountId: string; folderId: string; messageIds: string[] },
|
||||||
void
|
void
|
||||||
]
|
]
|
||||||
|
'messages:attachment:download': [
|
||||||
|
{ accountId: string; folderId: string; messageId: string; attachmentId: string; filename: string; downloadFolder?: string },
|
||||||
|
{ success: boolean; savedPath?: string; error?: string }
|
||||||
|
]
|
||||||
|
|
||||||
|
'app:getDownloadsFolder': [void, string]
|
||||||
|
'app:chooseFolder': [void, string | null]
|
||||||
|
'app:openFile': [{ path: string }, { success: boolean; error?: string }]
|
||||||
|
|
||||||
'oauth:gmail': [void, { email: string; accessToken: string; refreshToken: string } | null]
|
'oauth:gmail': [void, { email: string; accessToken: string; refreshToken: string } | null]
|
||||||
|
|
||||||
|
|
@ -36,6 +44,7 @@ export interface IpcChannelMap {
|
||||||
export interface IpcEventMap {
|
export interface IpcEventMap {
|
||||||
'mail:new': { accountId: string; folderId: string; envelope: MessageEnvelope }
|
'mail:new': { accountId: string; folderId: string; envelope: MessageEnvelope }
|
||||||
'account:status': { accountId: string; connected: boolean; error?: string }
|
'account:status': { accountId: string; connected: boolean; error?: string }
|
||||||
|
'attachment:progress': { attachmentId: string; stage: 'downloading' | 'saving' | 'done' | 'error'; progress: number; error?: string }
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IpcChannel = keyof IpcChannelMap
|
export type IpcChannel = keyof IpcChannelMap
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export interface IEmailProvider {
|
||||||
listFolders(): Promise<FolderListResult>
|
listFolders(): Promise<FolderListResult>
|
||||||
listMessages(options: MessageListOptions): Promise<MessageListResult>
|
listMessages(options: MessageListOptions): Promise<MessageListResult>
|
||||||
fetchMessageBody(folderId: string, messageId: string): Promise<MessageBody>
|
fetchMessageBody(folderId: string, messageId: string): Promise<MessageBody>
|
||||||
|
downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer>
|
||||||
updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void>
|
updateFlags(folderId: string, messageIds: string[], flags: Partial<MessageFlags>): Promise<void>
|
||||||
deleteMessages(folderId: string, messageIds: string[]): Promise<void>
|
deleteMessages(folderId: string, messageIds: string[]): Promise<void>
|
||||||
onNewMail(callback: (folderId: string, envelope: MessageEnvelope) => void): void
|
onNewMail(callback: (folderId: string, envelope: MessageEnvelope) => void): void
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue