Compare commits
No commits in common. "bb25b0616d79b42e8b7550a5b858519c319c0346" and "3c9c4344bc8cee64b2e2907a5023ef64744816a3" have entirely different histories.
bb25b0616d
...
3c9c4344bc
17 changed files with 53 additions and 856 deletions
|
|
@ -1,98 +0,0 @@
|
||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
paths-ignore:
|
|
||||||
- '**.md'
|
|
||||||
- '.forgejo/**'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: docker
|
|
||||||
|
|
||||||
container:
|
|
||||||
image: node:20-bookworm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout (full history for tags)
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Determine next version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
LATEST=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -1)
|
|
||||||
if [ -z "$LATEST" ]; then
|
|
||||||
# First release — use version from package.json
|
|
||||||
NEW=$(node -p "require('./package.json').version")
|
|
||||||
else
|
|
||||||
IFS='.' read -r maj min pat <<< "${LATEST#v}"
|
|
||||||
NEW="${maj}.${min}.$((pat + 1))"
|
|
||||||
fi
|
|
||||||
echo "version=$NEW" >> $GITHUB_OUTPUT
|
|
||||||
echo "tag=v$NEW" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Set version in package.json
|
|
||||||
run: npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
|
|
||||||
|
|
||||||
- name: Build Linux AppImage
|
|
||||||
run: npm run build:linux
|
|
||||||
env:
|
|
||||||
# Подавляем попытку electron-builder публиковать на GitHub
|
|
||||||
GH_TOKEN: ""
|
|
||||||
|
|
||||||
- name: Find built AppImage
|
|
||||||
id: artifact
|
|
||||||
run: |
|
|
||||||
APPIMAGE=$(ls dist/*.AppImage | head -1)
|
|
||||||
echo "path=$APPIMAGE" >> $GITHUB_OUTPUT
|
|
||||||
echo "name=$(basename $APPIMAGE)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
env:
|
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
|
||||||
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
git config user.email "ci@vodyanoysh.ru"
|
|
||||||
git config user.name "Forgejo CI"
|
|
||||||
git remote set-url origin "https://x-token:${GIT_TOKEN}@git.vodyanoysh.ru/vodyanoy/aero-mail.git"
|
|
||||||
git tag "$TAG"
|
|
||||||
git push origin "$TAG"
|
|
||||||
|
|
||||||
- name: Create Forgejo release
|
|
||||||
id: release
|
|
||||||
env:
|
|
||||||
TAG: ${{ steps.version.outputs.tag }}
|
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
BODY=$(cat <<'NOTES'
|
|
||||||
Автоматический релиз.
|
|
||||||
NOTES
|
|
||||||
)
|
|
||||||
|
|
||||||
RELEASE=$(curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Aero Mail ${TAG}\",\"body\":\"${BODY}\",\"draft\":false,\"prerelease\":false}" \
|
|
||||||
"https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail/releases")
|
|
||||||
|
|
||||||
echo "id=$(echo "$RELEASE" | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Upload AppImage to release
|
|
||||||
env:
|
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
RELEASE_ID: ${{ steps.release.outputs.id }}
|
|
||||||
ASSET_PATH: ${{ steps.artifact.outputs.path }}
|
|
||||||
ASSET_NAME: ${{ steps.artifact.outputs.name }}
|
|
||||||
run: |
|
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary @"${ASSET_PATH}" \
|
|
||||||
"https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}"
|
|
||||||
21
CLAUDE.md
21
CLAUDE.md
|
|
@ -1,26 +1,5 @@
|
||||||
# Aero Mail — Developer Notes
|
# Aero Mail — Developer Notes
|
||||||
|
|
||||||
## Agent team
|
|
||||||
|
|
||||||
Sub-agents live in `.claude/agents/`. Use `claude --agent <name>` or mention the agent in your request.
|
|
||||||
|
|
||||||
| Agent | When to use |
|
|
||||||
|-------|-------------|
|
|
||||||
| `architect` | **First** for any complex/cross-cutting feature: designs IPC contract, data model, plan — before coding starts |
|
|
||||||
| `backend` | Main process: IMAP/SMTP, IPC handlers, account-manager, credential-store, CalDAV |
|
|
||||||
| `frontend` | Renderer: Vue components, Pinia stores, composables, CSS |
|
|
||||||
| `test` | Vitest setup, writing unit/integration tests |
|
|
||||||
| `review` | Security audit, code review, performance analysis |
|
|
||||||
| `devops` | Build, packaging, electron-builder, CI, auto-update |
|
|
||||||
|
|
||||||
**Routing heuristic**:
|
|
||||||
- New feature touching IPC or both processes → `architect` first, then `backend` + `frontend`
|
|
||||||
- Bug or small change only in `src/main/` → `backend` directly
|
|
||||||
- Bug or small change only in `src/renderer/` → `frontend` directly
|
|
||||||
- "write tests / fix tests" → `test`
|
|
||||||
- "review / audit / check for bugs" → `review`
|
|
||||||
- "build / package / CI" → `devops`
|
|
||||||
|
|
||||||
## Stack
|
## Stack
|
||||||
|
|
||||||
Electron 35 + Vue 3 Composition API + Pinia + TypeScript + electron-vite.
|
Electron 35 + Vue 3 Composition API + Pinia + TypeScript + electron-vite.
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { readFileSync } from 'fs'
|
|
||||||
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import { config as dotenv } from 'dotenv'
|
import { config as dotenv } from 'dotenv'
|
||||||
|
|
||||||
dotenv()
|
dotenv()
|
||||||
|
|
||||||
const pkg = JSON.parse(readFileSync('package.json', 'utf-8')) as { version: string }
|
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
main: {
|
main: {
|
||||||
plugins: [externalizeDepsPlugin()],
|
plugins: [externalizeDepsPlugin()],
|
||||||
|
|
@ -32,9 +29,6 @@ export default defineConfig({
|
||||||
},
|
},
|
||||||
renderer: {
|
renderer: {
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
define: {
|
|
||||||
__APP_VERSION__: JSON.stringify(pkg.version)
|
|
||||||
},
|
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@shared': resolve('src/shared'),
|
'@shared': resolve('src/shared'),
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ import { registerAccountHandlers } from './ipc/accounts.handler'
|
||||||
import { registerFolderHandlers } from './ipc/folders.handler'
|
import { registerFolderHandlers } from './ipc/folders.handler'
|
||||||
import { registerMessageHandlers } from './ipc/messages.handler'
|
import { registerMessageHandlers } from './ipc/messages.handler'
|
||||||
import { registerCalendarHandlers } from './ipc/calendar.handler'
|
import { registerCalendarHandlers } from './ipc/calendar.handler'
|
||||||
import { registerUpdaterHandlers } from './ipc/updater.handler'
|
|
||||||
import { updater } from './services/updater'
|
|
||||||
import type { ComposeSession } from '@shared/types/message'
|
import type { ComposeSession } from '@shared/types/message'
|
||||||
|
|
||||||
const accountManager = new AccountManager()
|
const accountManager = new AccountManager()
|
||||||
|
|
@ -150,14 +148,9 @@ app.whenReady().then(async () => {
|
||||||
registerFolderHandlers(accountManager)
|
registerFolderHandlers(accountManager)
|
||||||
registerMessageHandlers(accountManager)
|
registerMessageHandlers(accountManager)
|
||||||
registerCalendarHandlers(accountManager)
|
registerCalendarHandlers(accountManager)
|
||||||
registerUpdaterHandlers()
|
|
||||||
|
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
if (app.isPackaged) {
|
|
||||||
setTimeout(() => updater.checkForUpdates(), 10_000)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,6 @@ 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'
|
||||||
|
|
||||||
function assertId(value: unknown, name: string): asserts value is string {
|
|
||||||
if (typeof value !== 'string' || value.length === 0) {
|
|
||||||
throw new Error(`Invalid IPC argument: ${name} must be a non-empty string`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertIds(value: unknown, name: string): asserts value is string[] {
|
|
||||||
if (!Array.isArray(value) || value.length === 0 || value.some((v) => typeof v !== 'string')) {
|
|
||||||
throw new Error(`Invalid IPC argument: ${name} must be a non-empty string array`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveDownloadPath(folder: string, filename: string): Promise<string> {
|
async function resolveDownloadPath(folder: string, filename: string): Promise<string> {
|
||||||
const ext = extname(filename)
|
const ext = extname(filename)
|
||||||
const base = basename(filename, ext)
|
const base = basename(filename, ext)
|
||||||
|
|
@ -42,18 +30,14 @@ function sendProgress(attachmentId: string, stage: 'downloading' | 'saving' | 'd
|
||||||
|
|
||||||
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 }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
assertId(folderId, 'folderId')
|
|
||||||
return manager.listMessages(accountId, folderId, offset, limit, unseenOnly ?? false)
|
return manager.listMessages(accountId, folderId, offset, limit, unseenOnly ?? false)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:poll', async ({ accountId }) => {
|
registerHandler('messages:poll', async ({ accountId }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
await manager.pollNewMessages(accountId)
|
await manager.pollNewMessages(accountId)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:send', async ({ accountId, compose }) => {
|
registerHandler('messages:send', async ({ accountId, compose }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
try {
|
try {
|
||||||
await manager.sendMessage(accountId, compose)
|
await manager.sendMessage(accountId, compose)
|
||||||
return { success: true }
|
return { success: true }
|
||||||
|
|
@ -63,28 +47,18 @@ export function registerMessageHandlers(manager: AccountManager): void {
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:search', async ({ accountId, query, limit }) => {
|
registerHandler('messages:search', async ({ accountId, query, limit }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
return manager.searchMessages(accountId, query, limit)
|
return manager.searchMessages(accountId, query, limit)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:body', async ({ accountId, folderId, messageId }) => {
|
registerHandler('messages:body', async ({ accountId, folderId, messageId }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
assertId(folderId, 'folderId')
|
|
||||||
assertId(messageId, 'messageId')
|
|
||||||
return manager.fetchMessageBody(accountId, folderId, messageId)
|
return manager.fetchMessageBody(accountId, folderId, messageId)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:setFlags', async ({ accountId, folderId, messageIds, flags }) => {
|
registerHandler('messages:setFlags', async ({ accountId, folderId, messageIds, flags }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
assertId(folderId, 'folderId')
|
|
||||||
assertIds(messageIds, 'messageIds')
|
|
||||||
await manager.updateFlags(accountId, folderId, messageIds, flags)
|
await manager.updateFlags(accountId, folderId, messageIds, flags)
|
||||||
})
|
})
|
||||||
|
|
||||||
registerHandler('messages:delete', async ({ accountId, folderId, messageIds }) => {
|
registerHandler('messages:delete', async ({ accountId, folderId, messageIds }) => {
|
||||||
assertId(accountId, 'accountId')
|
|
||||||
assertId(folderId, 'folderId')
|
|
||||||
assertIds(messageIds, 'messageIds')
|
|
||||||
await manager.deleteMessages(accountId, folderId, messageIds)
|
await manager.deleteMessages(accountId, folderId, messageIds)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { registerHandler } from './registry'
|
|
||||||
import { updater } from '../services/updater'
|
|
||||||
|
|
||||||
export function registerUpdaterHandlers(): void {
|
|
||||||
registerHandler('update:check', () => updater.checkForUpdates())
|
|
||||||
|
|
||||||
registerHandler('update:download', async () => {
|
|
||||||
updater.downloadUpdate()
|
|
||||||
})
|
|
||||||
|
|
||||||
registerHandler('update:install', async () => {
|
|
||||||
updater.installUpdate()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
@ -55,19 +55,10 @@ export class ImapProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
async connect(): Promise<void> {
|
async connect(): Promise<void> {
|
||||||
let timeoutId: ReturnType<typeof setTimeout> | undefined
|
const timeout = new Promise<never>((_, reject) =>
|
||||||
const timeoutPromise = new Promise<never>((_, reject) => {
|
setTimeout(() => reject(new Error('Connection timed out (10s)')), 10_000)
|
||||||
timeoutId = setTimeout(() => reject(new Error('Connection timed out (10s)')), 10_000)
|
)
|
||||||
})
|
await Promise.race([this.client.connect(), timeout])
|
||||||
try {
|
|
||||||
await Promise.race([this.client.connect(), timeoutPromise])
|
|
||||||
} catch (err) {
|
|
||||||
// Close any socket imapflow opened or is opening (timeout race case)
|
|
||||||
this.client.logout().catch(() => {})
|
|
||||||
throw err
|
|
||||||
} finally {
|
|
||||||
clearTimeout(timeoutId)
|
|
||||||
}
|
|
||||||
this.connected = true
|
this.connected = true
|
||||||
// Запускаем в фоне; промис await-ится в sendMessage() — гарантия что имя готово к отправке
|
// Запускаем в фоне; промис await-ится в sendMessage() — гарантия что имя готово к отправке
|
||||||
this.senderNamePromise = this.fetchSenderName().catch(() => null)
|
this.senderNamePromise = this.fetchSenderName().catch(() => null)
|
||||||
|
|
@ -241,9 +232,6 @@ export class ImapProvider implements IEmailProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer> {
|
async downloadAttachment(folderId: string, messageId: string, attachmentId: string): Promise<Buffer> {
|
||||||
// TODO: имапфлоу поддерживает частичный download по part-номеру из BODYSTRUCTURE
|
|
||||||
// (client.download(uid, '2', {uid:true})). Оптимизация требует хранить part в Attachment.id
|
|
||||||
// и пробрасывать через IPC. Сейчас скачивается всё письмо целиком.
|
|
||||||
const lock = await this.client.getMailboxLock(folderId)
|
const lock = await this.client.getMailboxLock(folderId)
|
||||||
try {
|
try {
|
||||||
const download = await this.client.download(messageId, undefined, { uid: true })
|
const download = await this.client.download(messageId, undefined, { uid: true })
|
||||||
|
|
@ -330,10 +318,8 @@ export class ImapProvider implements IEmailProvider {
|
||||||
? ImapProvider.textToHtml(compose.body) + compose.htmlBody
|
? ImapProvider.textToHtml(compose.body) + compose.htmlBody
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
|
||||||
console.log('[SMTP] host=%s port=%d secure=%s from=%j to=%j',
|
console.log('[SMTP] host=%s port=%d secure=%s from=%j to=%j',
|
||||||
smtpHost, smtpPort, smtpSecure, from, compose.to)
|
smtpHost, smtpPort, smtpSecure, from, compose.to)
|
||||||
}
|
|
||||||
|
|
||||||
const info = await transporter.sendMail({
|
const info = await transporter.sendMail({
|
||||||
from,
|
from,
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,13 @@ export class AccountManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
async testConnection(config: AccountConfig): Promise<{ success: boolean; error?: string }> {
|
async testConnection(config: AccountConfig): Promise<{ success: boolean; error?: string }> {
|
||||||
const provider = this.createProvider(config)
|
|
||||||
try {
|
try {
|
||||||
|
const provider = this.createProvider(config)
|
||||||
await provider.connect()
|
await provider.connect()
|
||||||
|
await provider.disconnect()
|
||||||
return { success: true }
|
return { success: true }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return { success: false, error: (error as Error).message }
|
return { success: false, error: (error as Error).message }
|
||||||
} finally {
|
|
||||||
provider.disconnect().catch(() => {})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -276,24 +275,22 @@ export class AccountManager {
|
||||||
// ── Auto-reconnect ──────────────────────────────────────
|
// ── Auto-reconnect ──────────────────────────────────────
|
||||||
|
|
||||||
private async withAutoReconnect<T>(accountId: string, fn: () => Promise<T>): Promise<T> {
|
private async withAutoReconnect<T>(accountId: string, fn: () => Promise<T>): Promise<T> {
|
||||||
let originalError: unknown
|
|
||||||
try {
|
try {
|
||||||
return await fn()
|
return await fn()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
originalError = err
|
|
||||||
const code = (err as { code?: string }).code ?? ''
|
const code = (err as { code?: string }).code ?? ''
|
||||||
if (!RECONNECT_CODES.has(code)) throw err
|
if (!RECONNECT_CODES.has(code)) throw err
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.reconnectAccount(accountId)
|
await this.reconnectAccount(accountId)
|
||||||
} catch (reconnectErr) {
|
} catch (reconnectErr) {
|
||||||
console.error(`[AccountManager] reconnect failed for ${accountId}:`, reconnectErr)
|
console.error(`[AccountManager] reconnect failed for ${accountId}:`, reconnectErr)
|
||||||
throw new Error(`Reconnect failed: ${(reconnectErr as Error).message}`, { cause: originalError })
|
throw reconnectErr
|
||||||
}
|
}
|
||||||
|
|
||||||
return await fn()
|
return await fn()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async reconnectAccount(accountId: string): Promise<void> {
|
private async reconnectAccount(accountId: string): Promise<void> {
|
||||||
// Убиваем старый провайдер
|
// Убиваем старый провайдер
|
||||||
|
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
import { app, BrowserWindow } from 'electron'
|
|
||||||
import { createWriteStream, chmodSync, copyFileSync, mkdirSync } from 'fs'
|
|
||||||
import { join } from 'path'
|
|
||||||
import { homedir } from 'os'
|
|
||||||
import https from 'https'
|
|
||||||
import http from 'http'
|
|
||||||
import { URL } from 'url'
|
|
||||||
|
|
||||||
const REPO_API = 'https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail/releases/latest'
|
|
||||||
|
|
||||||
interface ReleaseAsset {
|
|
||||||
name: string
|
|
||||||
browser_download_url: string
|
|
||||||
size: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Release {
|
|
||||||
tag_name: string
|
|
||||||
name: string
|
|
||||||
body: string
|
|
||||||
assets: ReleaseAsset[]
|
|
||||||
}
|
|
||||||
|
|
||||||
function compareSemver(a: string, b: string): number {
|
|
||||||
const parse = (v: string): number[] => v.replace(/^v/, '').split('.').map(Number)
|
|
||||||
const [aMaj, aMin, aPat] = parse(a)
|
|
||||||
const [bMaj, bMin, bPat] = parse(b)
|
|
||||||
if (aMaj !== bMaj) return aMaj - bMaj
|
|
||||||
if (aMin !== bMin) return aMin - bMin
|
|
||||||
return aPat - bPat
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchJson<T>(url: string): Promise<T> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const parsed = new URL(url)
|
|
||||||
https.get(
|
|
||||||
{ hostname: parsed.hostname, path: parsed.pathname + parsed.search, headers: { 'User-Agent': `AeroMail/${app.getVersion()}` } },
|
|
||||||
(res) => {
|
|
||||||
if (res.statusCode !== 200) {
|
|
||||||
reject(new Error(`HTTP ${res.statusCode}`))
|
|
||||||
res.resume()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let data = ''
|
|
||||||
res.on('data', (chunk: string) => { data += chunk })
|
|
||||||
res.on('end', () => {
|
|
||||||
try { resolve(JSON.parse(data) as T) } catch (e) { reject(e) }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
).on('error', reject)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function downloadFile(
|
|
||||||
url: string,
|
|
||||||
destPath: string,
|
|
||||||
totalSize: number,
|
|
||||||
onProgress: (percent: number, transferred: number, total: number) => void
|
|
||||||
): Promise<void> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const follow = (currentUrl: string): void => {
|
|
||||||
const parsed = new URL(currentUrl)
|
|
||||||
const proto = parsed.protocol === 'https:' ? https : http
|
|
||||||
proto.get(currentUrl, { headers: { 'User-Agent': `AeroMail/${app.getVersion()}` } }, (res) => {
|
|
||||||
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
|
|
||||||
follow(res.headers.location!)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (res.statusCode !== 200) {
|
|
||||||
reject(new Error(`Download failed: HTTP ${res.statusCode}`))
|
|
||||||
res.resume()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const file = createWriteStream(destPath)
|
|
||||||
let transferred = 0
|
|
||||||
res.on('data', (chunk: Buffer) => {
|
|
||||||
transferred += chunk.length
|
|
||||||
const percent = totalSize > 0 ? Math.round((transferred / totalSize) * 100) : 0
|
|
||||||
onProgress(percent, transferred, totalSize)
|
|
||||||
})
|
|
||||||
res.pipe(file)
|
|
||||||
file.on('finish', () => file.close(() => resolve()))
|
|
||||||
file.on('error', (e) => { reject(e) })
|
|
||||||
res.on('error', (e) => { reject(e) })
|
|
||||||
}).on('error', reject)
|
|
||||||
}
|
|
||||||
follow(url)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UpdaterService {
|
|
||||||
private downloadedPath: string | null = null
|
|
||||||
|
|
||||||
private send(channel: string, data: unknown): void {
|
|
||||||
const win = BrowserWindow.getAllWindows()[0]
|
|
||||||
win?.webContents.send(channel, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkForUpdates(): Promise<{ hasUpdate: boolean; version?: string; notes?: string }> {
|
|
||||||
try {
|
|
||||||
const release = await fetchJson<Release>(REPO_API)
|
|
||||||
const currentVersion = app.getVersion()
|
|
||||||
|
|
||||||
if (compareSemver(release.tag_name, currentVersion) > 0) {
|
|
||||||
const version = release.tag_name.replace(/^v/, '')
|
|
||||||
const notes = release.body ?? ''
|
|
||||||
this.send('update:available', { version, notes })
|
|
||||||
return { hasUpdate: true, version, notes }
|
|
||||||
}
|
|
||||||
|
|
||||||
this.send('update:not-available', {})
|
|
||||||
return { hasUpdate: false }
|
|
||||||
} catch (e) {
|
|
||||||
const error = (e as Error).message
|
|
||||||
this.send('update:error', { error })
|
|
||||||
return { hasUpdate: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async downloadUpdate(): Promise<void> {
|
|
||||||
try {
|
|
||||||
const release = await fetchJson<Release>(REPO_API)
|
|
||||||
const asset = release.assets.find((a) => a.name.endsWith('.AppImage'))
|
|
||||||
if (!asset) throw new Error('No AppImage asset in release')
|
|
||||||
|
|
||||||
const destDir = join(homedir(), '.cache', 'aero-mail', 'updates')
|
|
||||||
mkdirSync(destDir, { recursive: true })
|
|
||||||
const destPath = join(destDir, asset.name)
|
|
||||||
|
|
||||||
await downloadFile(asset.browser_download_url, destPath, asset.size, (percent, transferred, total) => {
|
|
||||||
this.send('update:progress', { percent, transferred, total })
|
|
||||||
})
|
|
||||||
|
|
||||||
chmodSync(destPath, 0o755)
|
|
||||||
this.downloadedPath = destPath
|
|
||||||
this.send('update:downloaded', {})
|
|
||||||
} catch (e) {
|
|
||||||
const error = (e as Error).message
|
|
||||||
this.send('update:error', { error })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
installUpdate(): void {
|
|
||||||
if (!this.downloadedPath) return
|
|
||||||
|
|
||||||
const appImagePath = process.env['APPIMAGE']
|
|
||||||
if (appImagePath) {
|
|
||||||
try {
|
|
||||||
copyFileSync(this.downloadedPath, appImagePath)
|
|
||||||
chmodSync(appImagePath, 0o755)
|
|
||||||
app.relaunch()
|
|
||||||
} catch {
|
|
||||||
app.relaunch({ execPath: this.downloadedPath })
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
app.relaunch({ execPath: this.downloadedPath })
|
|
||||||
}
|
|
||||||
|
|
||||||
app.exit(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updater = new UpdaterService()
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { onMounted, onUnmounted, watch } from 'vue'
|
||||||
import { useAccountsStore } from './stores/accounts.store'
|
import { useAccountsStore } from './stores/accounts.store'
|
||||||
import { useSettingsStore } from './stores/settings.store'
|
import { useSettingsStore } from './stores/settings.store'
|
||||||
import { useIpc } from './composables/useIpc'
|
import { useIpc } from './composables/useIpc'
|
||||||
import UpdateBanner from './components/UpdateBanner.vue'
|
|
||||||
|
|
||||||
const accountsStore = useAccountsStore()
|
const accountsStore = useAccountsStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
|
@ -39,5 +38,4 @@ onUnmounted(() => { if (pollTimer) clearInterval(pollTimer) })
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<router-view />
|
<router-view />
|
||||||
<UpdateBanner />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,178 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { useUpdaterStore } from '../stores/updater.store'
|
|
||||||
|
|
||||||
const updater = useUpdaterStore()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Transition name="banner">
|
|
||||||
<div
|
|
||||||
v-if="updater.available && !updater.dismissed"
|
|
||||||
class="update-banner"
|
|
||||||
>
|
|
||||||
<div class="banner-body">
|
|
||||||
<div class="banner-icon">↑</div>
|
|
||||||
<div class="banner-text">
|
|
||||||
<span class="banner-title">Доступна версия {{ updater.version }}</span>
|
|
||||||
<span v-if="updater.downloading" class="banner-sub">
|
|
||||||
Загрузка… {{ updater.percent }}%
|
|
||||||
</span>
|
|
||||||
<span v-else-if="updater.downloaded" class="banner-sub">Готово к установке</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="banner-progress-wrap" v-if="updater.downloading">
|
|
||||||
<div class="banner-progress-bar" :style="{ width: updater.percent + '%' }" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="banner-actions">
|
|
||||||
<button
|
|
||||||
v-if="!updater.downloading && !updater.downloaded"
|
|
||||||
class="btn-primary"
|
|
||||||
@click="updater.download()"
|
|
||||||
>Скачать</button>
|
|
||||||
<button
|
|
||||||
v-if="updater.downloaded"
|
|
||||||
class="btn-primary"
|
|
||||||
@click="updater.install()"
|
|
||||||
>Установить и перезапустить</button>
|
|
||||||
<button
|
|
||||||
v-if="!updater.downloading"
|
|
||||||
class="btn-dismiss"
|
|
||||||
@click="updater.dismiss()"
|
|
||||||
>✕</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Transition>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.update-banner {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 24px;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
z-index: 9000;
|
|
||||||
min-width: 340px;
|
|
||||||
max-width: 480px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-body {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
padding: 10px 14px;
|
|
||||||
border-radius: 12px;
|
|
||||||
background: color-mix(in srgb, var(--accent) 12%, rgba(12, 12, 20, 0.92));
|
|
||||||
border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
|
|
||||||
box-shadow:
|
|
||||||
0 8px 32px rgba(0, 0, 0, 0.5),
|
|
||||||
inset 0 1px 0 rgba(255, 255, 255, 0.12);
|
|
||||||
backdrop-filter: blur(24px);
|
|
||||||
-webkit-backdrop-filter: blur(24px);
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-icon {
|
|
||||||
font-size: 16px;
|
|
||||||
color: var(--accent);
|
|
||||||
font-weight: 700;
|
|
||||||
flex-shrink: 0;
|
|
||||||
width: 24px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-text {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-title {
|
|
||||||
font-size: 12.5px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-sub {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-progress-wrap {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 2px;
|
|
||||||
background: rgba(255, 255, 255, 0.08);
|
|
||||||
border-radius: 0 0 12px 12px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-progress-bar {
|
|
||||||
height: 100%;
|
|
||||||
background: var(--accent);
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
border-radius: 0 0 12px 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 6px;
|
|
||||||
align-items: center;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary {
|
|
||||||
font-size: 11.5px;
|
|
||||||
font-weight: 600;
|
|
||||||
padding: 4px 12px;
|
|
||||||
border-radius: var(--radius-full);
|
|
||||||
background: var(--accent);
|
|
||||||
color: var(--accent-text);
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: opacity var(--transition-fast), transform var(--transition-fast);
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:hover {
|
|
||||||
opacity: 0.88;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-primary:active {
|
|
||||||
transform: translateY(1px);
|
|
||||||
opacity: 0.75;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-dismiss {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
padding: 2px 6px;
|
|
||||||
border-radius: 6px;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: color var(--transition-fast), background var(--transition-fast);
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-dismiss:hover {
|
|
||||||
color: var(--text-secondary);
|
|
||||||
background: rgba(255, 255, 255, 0.07);
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-enter-active,
|
|
||||||
.banner-leave-active {
|
|
||||||
transition: opacity 0.25s ease, transform 0.25s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-enter-from,
|
|
||||||
.banner-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateX(-50%) translateY(12px);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch, onMounted, onUnmounted } from 'vue'
|
import { computed, ref, onMounted, onUnmounted } from 'vue'
|
||||||
import type { MessageEnvelope, Address } 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'
|
||||||
|
|
@ -47,27 +47,6 @@ function handleForward(): void {
|
||||||
|
|
||||||
const dateDisplay = computed(() => formatFullDate(props.message.date))
|
const dateDisplay = computed(() => formatFullDate(props.message.date))
|
||||||
|
|
||||||
// ── Collapse recipients ────────────────────────────────────
|
|
||||||
|
|
||||||
const COLLAPSE_THRESHOLD = 10
|
|
||||||
|
|
||||||
const toExpanded = ref(false)
|
|
||||||
const ccExpanded = ref(false)
|
|
||||||
|
|
||||||
const visibleTo = computed(() =>
|
|
||||||
toExpanded.value ? props.message.to : props.message.to.slice(0, COLLAPSE_THRESHOLD)
|
|
||||||
)
|
|
||||||
const visibleCc = computed(() =>
|
|
||||||
ccExpanded.value ? props.message.cc : props.message.cc.slice(0, COLLAPSE_THRESHOLD)
|
|
||||||
)
|
|
||||||
const hiddenToCount = computed(() => Math.max(0, props.message.to.length - COLLAPSE_THRESHOLD))
|
|
||||||
const hiddenCcCount = computed(() => Math.max(0, props.message.cc.length - COLLAPSE_THRESHOLD))
|
|
||||||
|
|
||||||
watch(() => props.message.id, () => {
|
|
||||||
toExpanded.value = false
|
|
||||||
ccExpanded.value = false
|
|
||||||
})
|
|
||||||
|
|
||||||
// ── Contact popup ──────────────────────────────────────────
|
// ── Contact popup ──────────────────────────────────────────
|
||||||
|
|
||||||
const activeContact = ref<Address | null>(null)
|
const activeContact = ref<Address | null>(null)
|
||||||
|
|
@ -150,27 +129,13 @@ onUnmounted(() => {
|
||||||
<span class="label">Кому:</span>
|
<span class="label">Кому:</span>
|
||||||
<span class="value addr-list">
|
<span class="value addr-list">
|
||||||
<button
|
<button
|
||||||
v-for="addr in visibleTo"
|
v-for="addr in message.to"
|
||||||
:key="addr.email"
|
:key="addr.email"
|
||||||
class="addr-chip"
|
class="addr-chip"
|
||||||
@click="openContact(addr, $event)"
|
@click="openContact(addr, $event)"
|
||||||
>
|
>
|
||||||
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
v-if="hiddenToCount > 0 && !toExpanded"
|
|
||||||
class="addr-chip addr-chip--more"
|
|
||||||
@click="toExpanded = true"
|
|
||||||
>
|
|
||||||
<span class="addr-name">и ещё {{ hiddenToCount }}...</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="toExpanded && message.to.length > COLLAPSE_THRESHOLD"
|
|
||||||
class="addr-chip addr-chip--more"
|
|
||||||
@click="toExpanded = false"
|
|
||||||
>
|
|
||||||
<span class="addr-name">свернуть</span>
|
|
||||||
</button>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -179,27 +144,13 @@ onUnmounted(() => {
|
||||||
<span class="label">Копия:</span>
|
<span class="label">Копия:</span>
|
||||||
<span class="value addr-list">
|
<span class="value addr-list">
|
||||||
<button
|
<button
|
||||||
v-for="addr in visibleCc"
|
v-for="addr in message.cc"
|
||||||
:key="addr.email"
|
:key="addr.email"
|
||||||
class="addr-chip"
|
class="addr-chip"
|
||||||
@click="openContact(addr, $event)"
|
@click="openContact(addr, $event)"
|
||||||
>
|
>
|
||||||
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
<span class="addr-name">{{ addr.name || addr.email }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
v-if="hiddenCcCount > 0 && !ccExpanded"
|
|
||||||
class="addr-chip addr-chip--more"
|
|
||||||
@click="ccExpanded = true"
|
|
||||||
>
|
|
||||||
<span class="addr-name">и ещё {{ hiddenCcCount }}...</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
v-if="ccExpanded && message.cc.length > COLLAPSE_THRESHOLD"
|
|
||||||
class="addr-chip addr-chip--more"
|
|
||||||
@click="ccExpanded = false"
|
|
||||||
>
|
|
||||||
<span class="addr-name">свернуть</span>
|
|
||||||
</button>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -418,19 +369,6 @@ onUnmounted(() => {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.addr-chip--more {
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-style: italic;
|
|
||||||
border-color: rgba(255, 255, 255, 0.07);
|
|
||||||
background: rgba(255, 255, 255, 0.03);
|
|
||||||
}
|
|
||||||
|
|
||||||
.addr-chip--more:hover {
|
|
||||||
color: var(--accent);
|
|
||||||
background: color-mix(in srgb, var(--accent) 10%, transparent);
|
|
||||||
border-color: color-mix(in srgb, var(--accent) 30%, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Попап контакта ──────────────────────────────────────── */
|
/* ── Попап контакта ──────────────────────────────────────── */
|
||||||
.contact-popup {
|
.contact-popup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
||||||
2
src/renderer/src/env.d.ts
vendored
2
src/renderer/src/env.d.ts
vendored
|
|
@ -1,7 +1,5 @@
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
declare const __APP_VERSION__: string
|
|
||||||
|
|
||||||
declare module '*.vue' {
|
declare module '*.vue' {
|
||||||
import type { DefineComponent } from 'vue'
|
import type { DefineComponent } from 'vue'
|
||||||
const component: DefineComponent<object, object, unknown>
|
const component: DefineComponent<object, object, unknown>
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,24 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
const searchLoading = ref(false)
|
const searchLoading = ref(false)
|
||||||
const isSearchActive = computed(() => searchQuery.value.trim().length > 0)
|
const isSearchActive = computed(() => searchQuery.value.trim().length > 0)
|
||||||
|
|
||||||
|
// Отслеживание новых писем между обновлениями
|
||||||
|
const knownIds = new Map<string, Set<string>>() // key = accountId:folderId
|
||||||
|
const newArrivals = ref<Array<{ accountId: string; folderId: string; envelope: MessageEnvelope }>>([])
|
||||||
|
|
||||||
|
function detectNewMessages(accountId: string, folderId: string, fresh: MessageEnvelope[]): void {
|
||||||
|
const key = `${accountId}:${folderId}`
|
||||||
|
const prev = knownIds.get(key)
|
||||||
|
const nextIds = new Set(fresh.map(m => m.id))
|
||||||
|
knownIds.set(key, nextIds)
|
||||||
|
|
||||||
|
if (!prev) return
|
||||||
|
|
||||||
|
const arrived = fresh.filter(m => !prev.has(m.id) && !m.flags.seen)
|
||||||
|
if (arrived.length > 0) {
|
||||||
|
newArrivals.value = arrived.map(envelope => ({ accountId, folderId, envelope }))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const filteredMessages = computed(() =>
|
const filteredMessages = computed(() =>
|
||||||
unreadOnly.value ? messages.value.filter((m) => !m.flags.seen) : messages.value
|
unreadOnly.value ? messages.value.filter((m) => !m.flags.seen) : messages.value
|
||||||
)
|
)
|
||||||
|
|
@ -78,6 +96,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
|
detectNewMessages(accountId, folderId, result.messages)
|
||||||
messages.value = result.messages
|
messages.value = result.messages
|
||||||
if (unreadOnly.value) {
|
if (unreadOnly.value) {
|
||||||
// result.total — это точное число непрочитанных из SEARCH UNSEEN
|
// result.total — это точное число непрочитанных из SEARCH UNSEEN
|
||||||
|
|
@ -91,12 +110,8 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
|
|
||||||
// Предзагрузка тел первых 10 писем в фоне (только в обычном режиме)
|
// Предзагрузка тел первых 10 писем в фоне (только в обычном режиме)
|
||||||
if (!unreadOnly.value) {
|
if (!unreadOnly.value) {
|
||||||
if ('requestIdleCallback' in window) {
|
|
||||||
requestIdleCallback(() => prefetchBodies(accountId, folderId, 10), { timeout: 3000 })
|
|
||||||
} else {
|
|
||||||
setTimeout(() => prefetchBodies(accountId, folderId, 10), 600)
|
setTimeout(() => prefetchBodies(accountId, folderId, 10), 600)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
messages.value.push(...result.messages)
|
messages.value.push(...result.messages)
|
||||||
}
|
}
|
||||||
|
|
@ -111,22 +126,18 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
.slice(0, count)
|
.slice(0, count)
|
||||||
.filter((m) => !getCachedBody(`${accountId}:${folderId}:${m.id}`))
|
.filter((m) => !getCachedBody(`${accountId}:${folderId}:${m.id}`))
|
||||||
|
|
||||||
// Параллельность ограничена 2 — иначе 10 одновременных mailbox-lock запросов
|
|
||||||
// блокируют любое взаимодействие пользователя с IMAP на время предзагрузки
|
|
||||||
const CONCURRENCY = 2
|
|
||||||
for (let i = 0; i < toFetch.length; i += CONCURRENCY) {
|
|
||||||
const batch = toFetch.slice(i, i + CONCURRENCY)
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
batch.map(async (msg) => {
|
toFetch.map(async (msg) => {
|
||||||
const key = `${accountId}:${folderId}:${msg.id}`
|
const key = `${accountId}:${folderId}:${msg.id}`
|
||||||
try {
|
try {
|
||||||
const body = await invoke('messages:body', { accountId, folderId, messageId: msg.id })
|
const body = await invoke('messages:body', { accountId, folderId, messageId: msg.id })
|
||||||
setCachedBody(key, body)
|
setCachedBody(key, body)
|
||||||
} catch { /* фоновая предзагрузка — ошибки не критичны */ }
|
} catch {
|
||||||
|
// фоновая предзагрузка — ошибки не критичны
|
||||||
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
async function loadMore(): Promise<void> {
|
async function loadMore(): Promise<void> {
|
||||||
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
if (!accountsStore.activeAccountId || !foldersStore.activeFolderId) return
|
||||||
|
|
@ -329,9 +340,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
selectedIds.value = new Set()
|
selectedIds.value = new Set()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-load messages when folder changes (debounced 150ms — против дребезга при навигации клавишами)
|
// Auto-load messages when folder changes
|
||||||
let folderLoadTimer: ReturnType<typeof setTimeout> | null = null
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => foldersStore.activeFolderId,
|
() => foldersStore.activeFolderId,
|
||||||
(folderId) => {
|
(folderId) => {
|
||||||
|
|
@ -341,18 +350,8 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
messages.value = []
|
messages.value = []
|
||||||
totalCount.value = 0
|
totalCount.value = 0
|
||||||
unreadOnly.value = false
|
unreadOnly.value = false
|
||||||
if (folderLoadTimer !== null) {
|
|
||||||
clearTimeout(folderLoadTimer)
|
|
||||||
folderLoadTimer = null
|
|
||||||
}
|
|
||||||
if (folderId && accountsStore.activeAccountId) {
|
if (folderId && accountsStore.activeAccountId) {
|
||||||
const snapAccountId = accountsStore.activeAccountId
|
loadMessages(accountsStore.activeAccountId, folderId)
|
||||||
folderLoadTimer = setTimeout(() => {
|
|
||||||
folderLoadTimer = null
|
|
||||||
if (foldersStore.activeFolderId === folderId && accountsStore.activeAccountId === snapAccountId) {
|
|
||||||
loadMessages(snapAccountId, folderId)
|
|
||||||
}
|
|
||||||
}, 150)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -409,6 +408,7 @@ export const useMessagesStore = defineStore('messages', () => {
|
||||||
messageBody,
|
messageBody,
|
||||||
loading,
|
loading,
|
||||||
loadingBody,
|
loadingBody,
|
||||||
|
newArrivals,
|
||||||
searchQuery,
|
searchQuery,
|
||||||
searchResults,
|
searchResults,
|
||||||
searchLoading,
|
searchLoading,
|
||||||
|
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
import { ref } from 'vue'
|
|
||||||
import { defineStore } from 'pinia'
|
|
||||||
import { useIpc } from '../composables/useIpc'
|
|
||||||
|
|
||||||
export const useUpdaterStore = defineStore('updater', () => {
|
|
||||||
const { invoke, on } = useIpc()
|
|
||||||
|
|
||||||
const available = ref(false)
|
|
||||||
const version = ref('')
|
|
||||||
const notes = ref('')
|
|
||||||
const checking = ref(false)
|
|
||||||
const downloading = ref(false)
|
|
||||||
const percent = ref(0)
|
|
||||||
const downloaded = ref(false)
|
|
||||||
const dismissed = ref(false)
|
|
||||||
const error = ref('')
|
|
||||||
|
|
||||||
on('update:available', (data) => {
|
|
||||||
available.value = true
|
|
||||||
version.value = data.version
|
|
||||||
notes.value = data.notes
|
|
||||||
dismissed.value = false
|
|
||||||
})
|
|
||||||
|
|
||||||
on('update:progress', (data) => {
|
|
||||||
downloading.value = true
|
|
||||||
percent.value = data.percent
|
|
||||||
})
|
|
||||||
|
|
||||||
on('update:downloaded', () => {
|
|
||||||
downloading.value = false
|
|
||||||
downloaded.value = true
|
|
||||||
percent.value = 100
|
|
||||||
})
|
|
||||||
|
|
||||||
on('update:error', (data) => {
|
|
||||||
downloading.value = false
|
|
||||||
checking.value = false
|
|
||||||
error.value = data.error
|
|
||||||
})
|
|
||||||
|
|
||||||
on('update:not-available', () => {
|
|
||||||
checking.value = false
|
|
||||||
})
|
|
||||||
|
|
||||||
async function check(): Promise<void> {
|
|
||||||
checking.value = true
|
|
||||||
error.value = ''
|
|
||||||
try {
|
|
||||||
await invoke('update:check')
|
|
||||||
} finally {
|
|
||||||
checking.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function download(): void {
|
|
||||||
downloading.value = true
|
|
||||||
percent.value = 0
|
|
||||||
invoke('update:download')
|
|
||||||
}
|
|
||||||
|
|
||||||
function install(): void {
|
|
||||||
invoke('update:install')
|
|
||||||
}
|
|
||||||
|
|
||||||
function dismiss(): void {
|
|
||||||
dismissed.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
return { available, version, notes, checking, downloading, percent, downloaded, dismissed, error, check, download, install, dismiss }
|
|
||||||
})
|
|
||||||
|
|
@ -7,7 +7,6 @@ import CustomSelect from '../components/CustomSelect.vue'
|
||||||
import ColorPicker from '../components/ColorPicker.vue'
|
import ColorPicker from '../components/ColorPicker.vue'
|
||||||
import AppIcon from '../components/AppIcon.vue'
|
import AppIcon from '../components/AppIcon.vue'
|
||||||
import EditAccountDialog from '../components/accounts/EditAccountDialog.vue'
|
import EditAccountDialog from '../components/accounts/EditAccountDialog.vue'
|
||||||
import { useUpdaterStore } from '../stores/updater.store'
|
|
||||||
import type { AccountConfig } from '@shared/types/account'
|
import type { AccountConfig } from '@shared/types/account'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
@ -15,7 +14,6 @@ const accountsStore = useAccountsStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
const editingAccount = ref<AccountConfig | null>(null)
|
const editingAccount = ref<AccountConfig | null>(null)
|
||||||
const updaterStore = useUpdaterStore()
|
|
||||||
|
|
||||||
const swipeOptions: { value: SwipeAction; label: string }[] = (
|
const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[]
|
['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[]
|
||||||
|
|
@ -188,58 +186,6 @@ function folderDisplayName(path: string): string {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Обновления -->
|
|
||||||
<div class="section">
|
|
||||||
<div class="section-label">Приложение</div>
|
|
||||||
<div class="section-body">
|
|
||||||
<div class="row">
|
|
||||||
<span class="col-label">Версия</span>
|
|
||||||
<div class="col-value update-row-content">
|
|
||||||
<span class="version-badge">v{{ __APP_VERSION__ }}</span>
|
|
||||||
<span v-if="updaterStore.available" class="update-available-dot" v-tooltip="'Доступно обновление'">●</span>
|
|
||||||
<div class="row-actions">
|
|
||||||
<button
|
|
||||||
class="action-btn"
|
|
||||||
:disabled="updaterStore.checking"
|
|
||||||
@click="updaterStore.check()"
|
|
||||||
>{{ updaterStore.checking ? 'Проверка…' : 'Проверить обновления' }}</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="updaterStore.error" class="row error-row">
|
|
||||||
<span class="col-label"></span>
|
|
||||||
<span class="col-value update-error">{{ updaterStore.error }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="updaterStore.available && !updaterStore.downloaded && !updaterStore.downloading" class="row">
|
|
||||||
<span class="col-label"></span>
|
|
||||||
<div class="col-value">
|
|
||||||
<span class="update-note">Доступна версия {{ updaterStore.version }}</span>
|
|
||||||
<div class="row-actions">
|
|
||||||
<button class="action-btn" @click="updaterStore.download()">Скачать</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="updaterStore.downloading" class="row">
|
|
||||||
<span class="col-label"></span>
|
|
||||||
<div class="col-value update-progress-row">
|
|
||||||
<div class="update-progress-track">
|
|
||||||
<div class="update-progress-fill" :style="{ width: updaterStore.percent + '%' }" />
|
|
||||||
</div>
|
|
||||||
<span class="update-pct">{{ updaterStore.percent }}%</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="updaterStore.downloaded" class="row">
|
|
||||||
<span class="col-label"></span>
|
|
||||||
<div class="col-value">
|
|
||||||
<span class="update-note">Обновление загружено</span>
|
|
||||||
<div class="row-actions">
|
|
||||||
<button class="action-btn" @click="updaterStore.install()">Установить и перезапустить</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -668,77 +614,4 @@ function folderDisplayName(path: string): string {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Обновления ──────────────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
.update-row-content {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.version-badge {
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-family: var(--font-mono);
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-available-dot {
|
|
||||||
color: var(--accent);
|
|
||||||
font-size: 10px;
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-note {
|
|
||||||
font-size: 11.5px;
|
|
||||||
color: var(--accent);
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-error {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--danger);
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-row {
|
|
||||||
background: rgba(255, 85, 85, 0.04);
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-progress-row {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-progress-track {
|
|
||||||
flex: 1;
|
|
||||||
height: 3px;
|
|
||||||
border-radius: var(--radius-full);
|
|
||||||
background: rgba(255, 255, 255, 0.10);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-progress-fill {
|
|
||||||
height: 100%;
|
|
||||||
background: var(--accent);
|
|
||||||
border-radius: var(--radius-full);
|
|
||||||
transition: width 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.update-pct {
|
|
||||||
font-size: 11px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-muted);
|
|
||||||
font-variant-numeric: tabular-nums;
|
|
||||||
min-width: 30px;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -59,21 +59,12 @@ export interface IpcChannelMap {
|
||||||
{ accountId: string },
|
{ accountId: string },
|
||||||
{ path: string; status: number; note: string }[]
|
{ path: string; status: number; note: string }[]
|
||||||
]
|
]
|
||||||
|
|
||||||
'update:check': [void, { hasUpdate: boolean; version?: string; notes?: string }]
|
|
||||||
'update:download': [void, void]
|
|
||||||
'update:install': [void, void]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 }
|
'attachment:progress': { attachmentId: string; stage: 'downloading' | 'saving' | 'done' | 'error'; progress: number; error?: string }
|
||||||
'update:available': { version: string; notes: string }
|
|
||||||
'update:not-available': Record<string, never>
|
|
||||||
'update:progress': { percent: number; transferred: number; total: number }
|
|
||||||
'update:downloaded': Record<string, never>
|
|
||||||
'update:error': { error: string }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IpcChannel = keyof IpcChannelMap
|
export type IpcChannel = keyof IpcChannelMap
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue