fix: ensure assets-build is included in production bundle and implement robust tray icon path resolution for AppImage
This commit is contained in:
@@ -93,14 +93,43 @@ const initBackend = () => {
|
||||
|
||||
// --- System Tray ---
|
||||
const createTray = () => {
|
||||
const assetsDir = path.join(__dirname, '..', 'assets-build');
|
||||
const possibleIcons = ['icon.svg', 'icon.png'];
|
||||
let iconPath = '';
|
||||
for (const name of possibleIcons) {
|
||||
const fullPath = path.join(assetsDir, name);
|
||||
if (fs.existsSync(fullPath)) { iconPath = fullPath; break; }
|
||||
// Try to find the icon in various standard locations
|
||||
const possiblePaths = [
|
||||
path.join(__dirname, '..', 'assets-build'), // Dev
|
||||
path.join(process.resourcesPath, 'assets-build'), // Packaged (External)
|
||||
path.join(app.getAppPath(), 'dist', 'assets-build'), // Packaged (Internal dist)
|
||||
path.join(app.getAppPath(), 'assets-build') // Packaged (Internal root)
|
||||
];
|
||||
|
||||
let assetsDir = '';
|
||||
for (const p of possiblePaths) {
|
||||
if (fs.existsSync(p)) {
|
||||
assetsDir = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!iconPath) return;
|
||||
|
||||
const possibleIcons = ['icon.png', 'icon.svg'];
|
||||
let iconPath = '';
|
||||
|
||||
if (assetsDir) {
|
||||
for (const name of possibleIcons) {
|
||||
const fullPath = path.join(assetsDir, name);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
iconPath = fullPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`[Tray] Resolved assets directory: ${assetsDir || 'NOT FOUND'}`);
|
||||
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
|
||||
|
||||
if (!iconPath) {
|
||||
console.warn(`[Tray] FAILED: No valid icon found in searched paths.`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
|
||||
tray = new Tray(icon);
|
||||
|
||||
Reference in New Issue
Block a user