fix: установка иконки и очистка .desktop при каждом запуске на Linux
All checks were successful
Release / release (push) Successful in 2m10s

setupLinuxIntegration() при старте packaged-сборки:
- копирует icon.png из resourcesPath в hicolor (512/256/128)
- удаляет все appimagekit_*Aero_Mail.desktop
- пишет чистый aero-mail.desktop с Icon=aero-mail

Решает проблему устаревшей/отсутствующей иконки без ожидания обновления.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
vodyanoysh 2026-04-30 08:11:04 +07:00
parent 6ede4a8744
commit 173dac3ce9

View file

@ -1,6 +1,7 @@
import { app, BrowserWindow, shell, ipcMain, dialog, Menu, globalShortcut, clipboard } from 'electron'
import { join, basename } from 'node:path'
import { statSync } from 'node:fs'
import { statSync, mkdirSync, copyFileSync, writeFileSync, readdirSync, unlinkSync, existsSync } from 'node:fs'
import { homedir } from 'node:os'
import { AccountManager } from './services/account-manager'
import { registerAccountHandlers } from './ipc/accounts.handler'
import { registerFolderHandlers } from './ipc/folders.handler'
@ -142,7 +143,55 @@ ipcMain.handle('app:copyToClipboard', (_event, { text }: { text: string }) => {
clipboard.writeText(text)
})
function setupLinuxIntegration(): void {
if (process.platform !== 'linux' || !app.isPackaged) return
const home = homedir()
const appImagePath = process.env['APPIMAGE'] ?? ''
// Копируем иконку из ресурсов AppImage в hicolor-тему
const srcIcon = join(process.resourcesPath, 'icon.png')
if (existsSync(srcIcon)) {
for (const size of ['512x512', '256x256', '128x128']) {
const dir = join(home, `.local/share/icons/hicolor/${size}/apps`)
mkdirSync(dir, { recursive: true })
copyFileSync(srcIcon, join(dir, 'aero-mail.png'))
}
}
// Удаляем старые записи AppImageLauncher
const appsDir = join(home, '.local/share/applications')
mkdirSync(appsDir, { recursive: true })
try {
for (const f of readdirSync(appsDir)) {
if (/^appimagekit_.*Aero_Mail\.desktop$/.test(f)) {
unlinkSync(join(appsDir, f))
}
}
} catch (_) {}
// Пишем чистый desktop-файл
if (appImagePath) {
writeFileSync(
join(appsDir, 'aero-mail.desktop'),
[
'[Desktop Entry]',
'Name=Aero Mail',
`Exec=${appImagePath} --no-sandbox %U`,
'Terminal=false',
'Type=Application',
'Icon=aero-mail',
'StartupWMClass=Aero Mail',
'Comment=Desktop email client built with Vue 3 + Electron',
'Categories=Network;',
'',
].join('\n'),
)
}
}
app.whenReady().then(async () => {
setupLinuxIntegration()
await accountManager.initialize()
// Register all IPC handlers