fix desktop tray icon telegram topics and checkin intervals
This commit is contained in:
@@ -7,12 +7,17 @@ describe('desktop icon assets', () => {
|
||||
const {
|
||||
DESKTOP_BUILD_ICON_RELATIVE_PATH,
|
||||
DESKTOP_RUNTIME_ICON_RELATIVE_PATH,
|
||||
DESKTOP_TRAY_TEMPLATE_ICON_RELATIVE_PATH,
|
||||
getDesktopRuntimeIconPath,
|
||||
getDesktopTrayIconPath,
|
||||
} = await import('./iconAssets.js');
|
||||
|
||||
expect(DESKTOP_RUNTIME_ICON_RELATIVE_PATH).toBe(join('dist', 'web', 'desktop-icon.png'));
|
||||
expect(DESKTOP_BUILD_ICON_RELATIVE_PATH).toBe(join('build', 'desktop-icon.png'));
|
||||
expect(DESKTOP_TRAY_TEMPLATE_ICON_RELATIVE_PATH).toBe(join('dist', 'web', 'desktop-tray-template.png'));
|
||||
expect(getDesktopRuntimeIconPath('/app')).toBe(join('/app', 'dist', 'web', 'desktop-icon.png'));
|
||||
expect(getDesktopTrayIconPath('/app', 'darwin')).toBe(join('/app', 'dist', 'web', 'desktop-tray-template.png'));
|
||||
expect(getDesktopTrayIconPath('/app', 'win32')).toBe(join('/app', 'dist', 'web', 'desktop-icon.png'));
|
||||
});
|
||||
|
||||
it('points electron-builder at the generated desktop package icon', async () => {
|
||||
|
||||
@@ -2,8 +2,19 @@ import { join } from 'node:path';
|
||||
|
||||
export const DESKTOP_RUNTIME_ICON_RELATIVE_PATH = join('dist', 'web', 'desktop-icon.png');
|
||||
export const DESKTOP_BUILD_ICON_RELATIVE_PATH = join('build', 'desktop-icon.png');
|
||||
export const DESKTOP_TRAY_TEMPLATE_ICON_RELATIVE_PATH = join('dist', 'web', 'desktop-tray-template.png');
|
||||
export const DESKTOP_ICON_PUBLIC_PATH = '/desktop-icon.png';
|
||||
|
||||
export function getDesktopRuntimeIconPath(appPath: string) {
|
||||
return join(appPath, DESKTOP_RUNTIME_ICON_RELATIVE_PATH);
|
||||
}
|
||||
|
||||
export function getDesktopTrayTemplateIconPath(appPath: string) {
|
||||
return join(appPath, DESKTOP_TRAY_TEMPLATE_ICON_RELATIVE_PATH);
|
||||
}
|
||||
|
||||
export function getDesktopTrayIconPath(appPath: string, platform = process.platform) {
|
||||
return platform === 'darwin'
|
||||
? getDesktopTrayTemplateIconPath(appPath)
|
||||
: getDesktopRuntimeIconPath(appPath);
|
||||
}
|
||||
|
||||
+11
-3
@@ -21,7 +21,7 @@ import {
|
||||
resolveDesktopServerWorkingDir,
|
||||
waitForServerReady,
|
||||
} from './runtime.js';
|
||||
import { getDesktopRuntimeIconPath } from './iconAssets.js';
|
||||
import { getDesktopRuntimeIconPath, getDesktopTrayIconPath } from './iconAssets.js';
|
||||
|
||||
const { autoUpdater } = electronUpdater;
|
||||
|
||||
@@ -52,7 +52,7 @@ function getServerEntryPath() {
|
||||
}
|
||||
|
||||
function getTrayIconPath() {
|
||||
return getDesktopRuntimeIconPath(app.getAppPath());
|
||||
return getDesktopTrayIconPath(app.getAppPath(), process.platform);
|
||||
}
|
||||
|
||||
function getWindowIconPath() {
|
||||
@@ -121,7 +121,15 @@ function buildTrayMenu() {
|
||||
|
||||
function setupTray() {
|
||||
if (tray) return;
|
||||
const trayImage = nativeImage.createFromPath(getTrayIconPath());
|
||||
let trayImage = nativeImage.createFromPath(getTrayIconPath());
|
||||
if (process.platform === 'darwin' && !trayImage.isEmpty()) {
|
||||
trayImage = trayImage.resize({
|
||||
width: 18,
|
||||
height: 18,
|
||||
quality: 'best',
|
||||
});
|
||||
trayImage.setTemplateImage(true);
|
||||
}
|
||||
tray = new Tray(trayImage);
|
||||
tray.setToolTip('Metapi');
|
||||
tray.setContextMenu(buildTrayMenu());
|
||||
|
||||
Reference in New Issue
Block a user