diff --git a/src/main/index.ts b/src/main/index.ts index 6f8b347..fb3d330 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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 { AccountManager } from './services/account-manager' 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))) }) +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 () => { await accountManager.initialize() diff --git a/src/main/ipc/messages.handler.ts b/src/main/ipc/messages.handler.ts index 009cfd8..047291d 100644 --- a/src/main/ipc/messages.handler.ts +++ b/src/main/ipc/messages.handler.ts @@ -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 type { AccountManager } from '../services/account-manager' +async function resolveDownloadPath(folder: string, filename: string): Promise { + 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 { registerHandler('messages:list', async ({ accountId, folderId, offset, limit, unseenOnly }) => { 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 }) => { 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 } + } + }) } diff --git a/src/main/providers/exchange.provider.ts b/src/main/providers/exchange.provider.ts index c1a2515..c5b50c2 100644 --- a/src/main/providers/exchange.provider.ts +++ b/src/main/providers/exchange.provider.ts @@ -160,6 +160,10 @@ export class ExchangeProvider implements IEmailProvider { } } + async downloadAttachment(_folderId: string, _messageId: string, _attachmentId: string): Promise { + throw new Error('Attachment download not supported for Exchange accounts') + } + async deleteMessages(folderId: string, messageIds: string[]): Promise { for (const messageId of messageIds) { const msg = await EmailMessage.Bind(this.service, new ItemId(messageId)) diff --git a/src/main/providers/gmail.provider.ts b/src/main/providers/gmail.provider.ts index 20d7a64..29c65ba 100644 --- a/src/main/providers/gmail.provider.ts +++ b/src/main/providers/gmail.provider.ts @@ -110,6 +110,17 @@ export class GmailProvider implements IEmailProvider { } } + async downloadAttachment(_folderId: string, messageId: string, attachmentId: string): Promise { + 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): Promise { const addLabels: string[] = [] const removeLabels: string[] = [] diff --git a/src/main/providers/imap.provider.ts b/src/main/providers/imap.provider.ts index 1b029a7..ba8434c 100644 --- a/src/main/providers/imap.provider.ts +++ b/src/main/providers/imap.provider.ts @@ -197,6 +197,22 @@ export class ImapProvider implements IEmailProvider { } } + async downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise { + 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): Promise { const lock = await this.client.getMailboxLock(folderId) try { diff --git a/src/main/services/account-manager.ts b/src/main/services/account-manager.ts index 464bb28..cb76bab 100644 --- a/src/main/services/account-manager.ts +++ b/src/main/services/account-manager.ts @@ -141,6 +141,16 @@ export class AccountManager { return provider.fetchMessageBody(folderId, messageId) } + async downloadAttachment( + accountId: string, + folderId: string, + messageId: string, + attachmentId: string + ): Promise { + const provider = this.getProvider(accountId) + return provider.downloadAttachment(folderId, messageId, attachmentId) + } + async updateFlags( accountId: string, folderId: string, diff --git a/src/renderer/src/assets/styles/base.css b/src/renderer/src/assets/styles/base.css index 533c403..0d816e7 100644 --- a/src/renderer/src/assets/styles/base.css +++ b/src/renderer/src/assets/styles/base.css @@ -108,6 +108,43 @@ textarea:focus { 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 ─────────────────────────────────────────── */ .truncate { overflow: hidden; diff --git a/src/renderer/src/components/layout/TitleBar.vue b/src/renderer/src/components/layout/TitleBar.vue index e5df2e3..b33fab6 100644 --- a/src/renderer/src/components/layout/TitleBar.vue +++ b/src/renderer/src/components/layout/TitleBar.vue @@ -18,13 +18,13 @@ function close(): void { Aero Mail
- - -
diff --git a/src/renderer/src/components/messages/MessageList.vue b/src/renderer/src/components/messages/MessageList.vue index e9c8cf9..32fd283 100644 --- a/src/renderer/src/components/messages/MessageList.vue +++ b/src/renderer/src/components/messages/MessageList.vue @@ -30,11 +30,12 @@ const allVisibleSelected = computed(() => // ── Threads ─────────────────────────────────────────────── const threads = computed(() => buildThreads(messagesStore.filteredMessages)) -const expandedThreadIds = ref(new Set()) +const expandedThreadIds = ref(new Set()) +const threadSortDesc = ref(new Map()) // true = новые сверху +const threadUnreadOnly = ref(new Set()) function toggleThread(thread: Thread): void { if (thread.messages.length === 1) { - // Один элемент — открываем напрямую messagesStore.selectMessage(thread.messages[0].id) return } @@ -42,13 +43,74 @@ function toggleThread(thread: Thread): void { expandedThreadIds.value.delete(thread.id) } else { expandedThreadIds.value.add(thread.id) - // Открываем последнее письмо треда messagesStore.selectMessage(thread.latest.id) } - // trigger reactivity 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 ─────────────────────────────────────────────── async function refresh(): Promise { if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return @@ -169,7 +231,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis v-if="activeUnread > 0 || messagesStore.unreadOnly" class="message-count" :class="{ 'unread-active': messagesStore.unreadOnly }" - title="Только непрочитанные" + v-tooltip="'Только непрочитанные'" @click="messagesStore.toggleUnreadOnly()" > {{ activeUnread }} @@ -178,7 +240,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis + + + + + diff --git a/src/renderer/src/components/preview/MessageBody.vue b/src/renderer/src/components/preview/MessageBody.vue index cfc607c..0895a60 100644 --- a/src/renderer/src/components/preview/MessageBody.vue +++ b/src/renderer/src/components/preview/MessageBody.vue @@ -8,20 +8,67 @@ const props = defineProps<{ const iframeRef = ref(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('*') + 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(() => { if (!props.body.html) return null let html = props.body.html - // Replace CID references with base64 data URLs + // Подставляем inline-изображения for (const img of props.body.inlineImages) { - html = html.replaceAll( - `cid:${img.cid}`, - `data:${img.contentType};base64,${img.data}` - ) + html = html.replaceAll(`cid:${img.cid}`, `data:${img.contentType};base64,${img.data}`) } - // Wrap in a dark-themed document return ` @@ -110,7 +157,7 @@ const plainTextHtml = computed(() => { const srcdoc = computed(() => processedHtml.value ?? plainTextHtml.value ?? '') -// ── Ambient glow: извлекаем доминирующий цвет фона письма ── +// ── Ambient glow ─────────────────────────────────────────── 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.]+))?/) @@ -145,19 +192,18 @@ const resizeObserver = new ResizeObserver(updateGlowPosition) function onIframeLoad(): void { updateGlowPosition() if (iframeRef.value) resizeObserver.observe(iframeRef.value) + fixIframeColors() try { const doc = iframeRef.value?.contentDocument const view = iframeRef.value?.contentWindow if (!doc?.body || !view) return - // Пробуем body напрямую const bodyColor = parseRgb(view.getComputedStyle(doc.body).backgroundColor) if (bodyColor && bodyColor.a > 0.1 && bodyColor.r + bodyColor.g + bodyColor.b > 60) { setContentGlow(bodyColor.r, bodyColor.g, bodyColor.b, 0.26) return } - // Многие HTML-письма кладут фон в первый или
const firstEl = doc.body.querySelector('table, td, [bgcolor]') if (firstEl) { const raw = firstEl.getAttribute('bgcolor') ?? view.getComputedStyle(firstEl).backgroundColor @@ -172,7 +218,6 @@ function onIframeLoad(): void { clearContentGlow() } -// Сбрасываем свечение при смене письма watch(() => props.body, () => clearContentGlow()) onUnmounted(() => { diff --git a/src/renderer/src/components/preview/MessageHeader.vue b/src/renderer/src/components/preview/MessageHeader.vue index 69808e0..3f76596 100644 --- a/src/renderer/src/components/preview/MessageHeader.vue +++ b/src/renderer/src/components/preview/MessageHeader.vue @@ -1,6 +1,6 @@ diff --git a/src/renderer/src/components/sidebar/AccountSwitcher.vue b/src/renderer/src/components/sidebar/AccountSwitcher.vue index 1d601e3..d508f06 100644 --- a/src/renderer/src/components/sidebar/AccountSwitcher.vue +++ b/src/renderer/src/components/sidebar/AccountSwitcher.vue @@ -27,7 +27,7 @@ function getAccountColor(index: number): string { :key="account.id" class="account-btn" :class="{ active: accountsStore.activeAccountId === account.id }" - :title="account.email" + v-tooltip="account.email" @click="accountsStore.setActive(account.id)" > - - diff --git a/src/renderer/src/directives/tooltip.ts b/src/renderer/src/directives/tooltip.ts new file mode 100644 index 0000000..8e53010 --- /dev/null +++ b/src/renderer/src/directives/tooltip.ts @@ -0,0 +1,106 @@ +import type { ObjectDirective } from 'vue' + +// Единственный DOM-элемент тултипа на весь app +let tipEl: HTMLDivElement | null = null +let showTimer: ReturnType | null = null +let hideTimer: ReturnType | 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 = { + 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) + } + }, +} diff --git a/src/renderer/src/main.ts b/src/renderer/src/main.ts index d76a600..29ba2cd 100644 --- a/src/renderer/src/main.ts +++ b/src/renderer/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue' import { createPinia } from 'pinia' import { createRouter, createWebHashHistory } from 'vue-router' import App from './App.vue' +import { vTooltip } from './directives/tooltip' import './assets/styles/variables.css' import './assets/styles/base.css' @@ -24,4 +25,5 @@ const router = createRouter({ const app = createApp(App) app.use(createPinia()) app.use(router) +app.directive('tooltip', vTooltip) app.mount('#app') diff --git a/src/renderer/src/stores/settings.store.ts b/src/renderer/src/stores/settings.store.ts index 6d9a7d2..9621fb9 100644 --- a/src/renderer/src/stores/settings.store.ts +++ b/src/renderer/src/stores/settings.store.ts @@ -85,6 +85,7 @@ function load(): { accentColor?: string autoCheckInterval?: number uiScale?: number + downloadFolder?: string } { try { return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}') @@ -101,6 +102,14 @@ export const useSettingsStore = defineStore('settings', () => { const accentColor = ref(saved.accentColor ?? '#a8e600') const autoCheckInterval = ref(saved.autoCheckInterval ?? 5) const uiScale = ref(saved.uiScale ?? 1.0) + const downloadFolder = ref(saved.downloadFolder ?? '') + + // Если папка не сохранена — подтягиваем системный Downloads + if (!downloadFolder.value) { + window.api.invoke('app:getDownloadsFolder').then((path) => { + if (!downloadFolder.value) downloadFolder.value = path + }) + } // Apply on init applyAccentColor(accentColor.value) @@ -116,7 +125,7 @@ export const useSettingsStore = defineStore('settings', () => { persist() }) - watch([swipeLeftAction, swipeRightAction, autoCheckInterval], persist) + watch([swipeLeftAction, swipeRightAction, autoCheckInterval, downloadFolder], persist) function persist(): void { localStorage.setItem(STORAGE_KEY, JSON.stringify({ @@ -125,8 +134,9 @@ export const useSettingsStore = defineStore('settings', () => { accentColor: accentColor.value, autoCheckInterval: autoCheckInterval.value, uiScale: uiScale.value, + downloadFolder: downloadFolder.value, })) } - return { swipeLeftAction, swipeRightAction, accentColor, autoCheckInterval, uiScale } + return { swipeLeftAction, swipeRightAction, accentColor, autoCheckInterval, uiScale, downloadFolder } }) diff --git a/src/renderer/src/views/SettingsView.vue b/src/renderer/src/views/SettingsView.vue index 493bfae..d62d164 100644 --- a/src/renderer/src/views/SettingsView.vue +++ b/src/renderer/src/views/SettingsView.vue @@ -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 CustomSelect from '../components/CustomSelect.vue' import ColorPicker from '../components/ColorPicker.vue' +import AppIcon from '../components/AppIcon.vue' const router = useRouter() const accountsStore = useAccountsStore() @@ -12,6 +13,22 @@ const settingsStore = useSettingsStore() const swipeOptions: { value: SwipeAction; label: string }[] = ( ['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[] ).map((v) => ({ value: v, label: SWIPE_ACTION_LABELS[v] })) + +async function chooseDownloadFolder(): Promise { + const picked = await window.api.invoke('app:chooseFolder') + if (picked) settingsStore.downloadFolder = picked +} + +async function resetDownloadFolder(): Promise { + 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 +}