当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Tray.setImage方法代码示例

本文整理汇总了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`);
        }
    });
};
开发者ID:istvan-antal,项目名称:copycat,代码行数:31,代码来源:main.ts

示例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));
}
开发者ID:hlyu368,项目名称:outline-client,代码行数:32,代码来源:index.ts

示例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();
  }
开发者ID:wireapp,项目名称:wire-desktop,代码行数:28,代码来源:TrayHandler.ts

示例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)
    }
  })
开发者ID:,项目名称:,代码行数:12,代码来源:

示例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);
	}
开发者ID:kusamakura,项目名称:caprine,代码行数:9,代码来源:tray.ts

示例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'));
    }
  }
开发者ID:wireapp,项目名称:wire-desktop,代码行数:12,代码来源:TrayHandler.ts

示例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`);
        }
    });
开发者ID:istvan-antal,项目名称:copycat,代码行数:15,代码来源:main.ts


注:本文中的electron.Tray.setImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。