- Скачивание вложений: 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>
84 lines
2.3 KiB
TypeScript
84 lines
2.3 KiB
TypeScript
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'
|
|
import { registerFolderHandlers } from './ipc/folders.handler'
|
|
import { registerMessageHandlers } from './ipc/messages.handler'
|
|
import { registerOAuthHandlers } from './ipc/oauth.handler'
|
|
|
|
const accountManager = new AccountManager()
|
|
|
|
function createWindow(): BrowserWindow {
|
|
const mainWindow = new BrowserWindow({
|
|
width: 1280,
|
|
height: 800,
|
|
minWidth: 900,
|
|
minHeight: 600,
|
|
backgroundColor: '#1e1e1e',
|
|
webPreferences: {
|
|
preload: join(__dirname, '../preload/index.js'),
|
|
sandbox: false,
|
|
contextIsolation: true,
|
|
nodeIntegration: false
|
|
}
|
|
})
|
|
|
|
accountManager.setMainWindow(mainWindow)
|
|
|
|
// Open external links in browser
|
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
|
shell.openExternal(url)
|
|
return { action: 'deny' }
|
|
})
|
|
|
|
// Load the renderer
|
|
if (process.env.ELECTRON_RENDERER_URL) {
|
|
mainWindow.loadURL(process.env.ELECTRON_RENDERER_URL)
|
|
} else {
|
|
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
|
}
|
|
|
|
return mainWindow
|
|
}
|
|
|
|
Menu.setApplicationMenu(null)
|
|
|
|
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()
|
|
|
|
// Register all IPC handlers
|
|
registerAccountHandlers(accountManager)
|
|
registerFolderHandlers(accountManager)
|
|
registerMessageHandlers(accountManager)
|
|
registerOAuthHandlers()
|
|
|
|
createWindow()
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow()
|
|
}
|
|
})
|
|
})
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
})
|