feature/message-view-fixes: вложения, анимация тредов, настройки
- Скачивание вложений: IPC-канал messages:attachment:download, downloadAttachment() во всех провайдерах (IMAP/Gmail/Exchange) - Прогресс-бар скачивания через IPC-события attachment:progress - AttachmentStrip: чипы с именем/размером, indeterminate-бар, зелёный glow после скачивания, повторный клик открывает файл - Настройки: папка загрузок по умолчанию (app:getDownloadsFolder, app:chooseFolder, app:openFile), автосохранение без диалога - Плавная анимация раскрытия треда через JS-хуки scrollHeight - Убрать badge «Вложения» из MessageHeader (заменён на AttachmentStrip) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
291a6a90ca
commit
1c2dd36caf
14 changed files with 620 additions and 26 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 { 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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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<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 {
|
||||
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 }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
for (const messageId of messageIds) {
|
||||
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> {
|
||||
const addLabels: 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> {
|
||||
const lock = await this.client.getMailboxLock(folderId)
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,16 @@ export class AccountManager {
|
|||
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(
|
||||
accountId: string,
|
||||
folderId: string,
|
||||
|
|
|
|||
|
|
@ -70,6 +70,47 @@ function getThreadMessages(thread: Thread): import('@shared/types/message').Mess
|
|||
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<void> {
|
||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||
|
|
@ -331,7 +372,13 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
@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="threadUnreadOnly.has(thread.id) && getThreadMessages(thread).length === 0"
|
||||
|
|
@ -872,19 +919,5 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
|
|||
border-top: 1px solid rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
/* ── Анимация раскрытия ─────────────────────────────────── */
|
||||
.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);
|
||||
}
|
||||
/* Анимация раскрытия управляется JS-хуками через scrollHeight */
|
||||
</style>
|
||||
|
|
|
|||
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>
|
||||
|
|
@ -158,9 +158,6 @@ onUnmounted(() => {
|
|||
</Transition>
|
||||
|
||||
<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">
|
||||
<AppIcon name="flag" :size="11" /> Отмечено
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { computed } from 'vue'
|
|||
import { useMessagesStore } from '../../stores/messages.store'
|
||||
import MessageHeader from './MessageHeader.vue'
|
||||
import MessageBody from './MessageBody.vue'
|
||||
import AttachmentStrip from './AttachmentStrip.vue'
|
||||
import AppIcon from '../AppIcon.vue'
|
||||
|
||||
const messagesStore = useMessagesStore()
|
||||
|
|
@ -29,10 +30,14 @@ const selectedMessage = computed(() =>
|
|||
<span>Загрузка письма...</span>
|
||||
</div>
|
||||
|
||||
<MessageBody
|
||||
v-else-if="messagesStore.messageBody"
|
||||
:body="messagesStore.messageBody"
|
||||
/>
|
||||
<template v-else-if="messagesStore.messageBody">
|
||||
<AttachmentStrip
|
||||
v-if="messagesStore.messageBody.attachments.length > 0"
|
||||
:attachments="messagesStore.messageBody.attachments"
|
||||
:message-id="selectedMessage.id"
|
||||
/>
|
||||
<MessageBody :body="messagesStore.messageBody" />
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -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<string>(saved.accentColor ?? '#a8e600')
|
||||
const autoCheckInterval = ref<number>(saved.autoCheckInterval ?? 5)
|
||||
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
|
||||
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 }
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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<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>
|
||||
|
||||
<template>
|
||||
|
|
@ -102,6 +119,24 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
|||
</div>
|
||||
</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>
|
||||
<h2>Жесты</h2>
|
||||
|
|
@ -456,4 +491,71 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
|
|||
0 4px 14px rgba(0,0,0,0.5),
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ export interface IpcChannelMap {
|
|||
{ accountId: string; folderId: string; messageIds: string[] },
|
||||
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]
|
||||
|
||||
|
|
@ -36,6 +44,7 @@ export interface IpcChannelMap {
|
|||
export interface IpcEventMap {
|
||||
'mail:new': { accountId: string; folderId: string; envelope: MessageEnvelope }
|
||||
'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
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export interface IEmailProvider {
|
|||
listFolders(): Promise<FolderListResult>
|
||||
listMessages(options: MessageListOptions): Promise<MessageListResult>
|
||||
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>
|
||||
deleteMessages(folderId: string, messageIds: string[]): Promise<void>
|
||||
onNewMail(callback: (folderId: string, envelope: MessageEnvelope) => void): void
|
||||
|
|
|
|||
Loading…
Reference in a new issue