本文整理汇总了TypeScript中electron.Tray.setImage方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tray.setImage方法的具体用法?TypeScript Tray.setImage怎么用?TypeScript Tray.setImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.Tray
的用法示例。
在下文中一共展示了Tray.setImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateFolderStatus
const sync = (folder: Folder) => {
// console.log('rsync', [/*'--dry-run', */'-avz', '--delete', folder.path, folder.remote]);
if (foldersSyncing.filter(item => item.path === folder.path).length) {
if (!foldersToSync.filter(item => item.path === folder.path).length) {
foldersToSync.push(folder);
}
return;
}
foldersSyncing.push(folder);
tray.setImage(`${__dirname}/../menu-working-inverted.png`);
if (mainWindow) {
mainWindow.webContents.send('action', updateFolderStatus(folder.path, FolderStatus.Sycing));
}
rsync(folder.path, folder.remote).then(code => {
console.log('close', folder, code);
if (mainWindow) {
mainWindow.webContents.send('action', updateFolderStatus(folder.path, FolderStatus.Idle));
}
foldersSyncing.splice(findIndex(foldersSyncing, item => item.path === folder.path), 1);
const folderIndex = findIndex(foldersToSync, item => item.path === folder.path);
if (folderIndex !== -1) {
foldersToSync.splice(folderIndex, 1);
sync(folder);
} else if (!foldersSyncing.length) {
tray.setImage(`${__dirname}/../menu-inverted.png`);
}
});
};
示例2: createTrayIcon
function createTrayIcon(status: ConnectionStatus) {
const isConnected = status === ConnectionStatus.CONNECTED;
const trayIconImage = isConnected ? trayIconImages.connected : trayIconImages.disconnected;
if (tray) {
tray.setImage(trayIconImage);
} else {
tray = new Tray(trayIconImage);
tray.on('click', () => {
if (!mainWindow) {
createWindow();
return;
}
if (mainWindow.isMinimized() || !mainWindow.isVisible()) {
mainWindow.restore();
mainWindow.show();
mainWindow.focus();
} else {
mainWindow.hide();
}
});
tray.setToolTip('Outline');
}
// Retrieve localized strings, falling back to the pre-populated English default.
const statusString = isConnected ? localizedStrings['connected-server-state'] :
localizedStrings['disconnected-server-state'];
const quitString = localizedStrings['quit'];
const menuTemplate = [
{label: statusString, enabled: false}, {type: 'separator'} as MenuItemConstructorOptions,
{label: quitString, click: quitApp}
];
tray.setContextMenu(Menu.buildFromTemplate(menuTemplate));
}
示例3: initTray
initTray(trayIcon = new Tray(nativeImage.createEmpty())) {
const IMAGE_ROOT = path.join(app.getAppPath(), 'img');
let trayPng = 'tray.png';
let trayBadgePng = 'tray.badge.png';
if (EnvironmentUtil.platform.IS_LINUX) {
trayPng = `tray${EnvironmentUtil.linuxDesktop.isGnome ? '.gnome' : '@3x'}.png`;
trayBadgePng = `tray.badge${EnvironmentUtil.linuxDesktop.isGnome ? '.gnome' : '@3x'}.png`;
}
const iconPaths = {
badge: path.join(IMAGE_ROOT, 'taskbar.overlay.png'),
tray: path.join(IMAGE_ROOT, 'tray-icon/tray', trayPng),
trayWithBadge: path.join(IMAGE_ROOT, 'tray-icon/tray-with-badge', trayBadgePng),
};
this.icons = {
badge: nativeImage.createFromPath(iconPaths.badge),
tray: nativeImage.createFromPath(iconPaths.tray),
trayWithBadge: nativeImage.createFromPath(iconPaths.trayWithBadge),
};
this.trayIcon = trayIcon;
this.trayIcon.setImage(this.icons.tray);
this.buildTrayMenu();
}
示例4:
ipc.on('unread-count', (_: any, unreadCount: number) => {
if (is.macos) {
app.dock.setBadge(unreadCount ? unreadCount.toString() : '')
}
if ((is.linux || is.windows) && tray) {
const icon = unreadCount ? 'tray-icon-unread.png' : 'tray-icon.png'
const iconPath = path.join(__dirname, '..', 'static', icon)
tray.setImage(iconPath)
}
})
示例5:
setBadge: (shouldDisplayUnread: boolean) => {
if (is.macos || !tray) {
return;
}
const icon = shouldDisplayUnread ? 'IconTrayUnread.png' : 'IconTray.png';
const iconPath = path.join(__dirname, '..', 'static', icon);
tray.setImage(iconPath);
}
示例6: updateIcons
private updateIcons(win: Electron.BrowserWindow, count?: number) {
if (this.icons) {
const trayImage = count ? this.icons.trayWithBadge : this.icons.tray;
if (this.trayIcon) {
this.trayIcon.setImage(trayImage);
}
const overlayImage = count ? this.icons.badge : null;
win.setOverlayIcon(overlayImage, locale.getText('unreadMessages'));
}
}
示例7: rsync
rsync(folder.path, folder.remote).then(code => {
console.log('close', folder, code);
if (mainWindow) {
mainWindow.webContents.send('action', updateFolderStatus(folder.path, FolderStatus.Idle));
}
foldersSyncing.splice(findIndex(foldersSyncing, item => item.path === folder.path), 1);
const folderIndex = findIndex(foldersToSync, item => item.path === folder.path);
if (folderIndex !== -1) {
foldersToSync.splice(folderIndex, 1);
sync(folder);
} else if (!foldersSyncing.length) {
tray.setImage(`${__dirname}/../menu-inverted.png`);
}
});