當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Notification.isSupported方法代碼示例

本文整理匯總了TypeScript中electron.Notification.isSupported方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Notification.isSupported方法的具體用法?TypeScript Notification.isSupported怎麽用?TypeScript Notification.isSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.Notification的用法示例。


在下文中一共展示了Notification.isSupported方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

  watcher.on(actions.notify, async (store, action) => {
    const {
      title = "itch",
      body,
      icon = DEFAULT_ICON,
      onClick,
    } = action.payload;

    if (Notification.isSupported()) {
      const n = new Notification({
        title,
        subtitle: null,
        body,
        icon: icon ? nativeImage.createFromPath(icon) : null,
        actions: null,
      });
      if (onClick) {
        n.on("click", e => {
          store.dispatch(actions.focusWindow({ window: "root" }));
          store.dispatch(onClick);
        });
      }
      n.show();
    } else {
      logger.warn(`Cannot show notification: ${body}`);
    }
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:27,代碼來源:notifications.ts

示例2: showNotification

import { Notification } from 'electron';
import { logManager } from './log-manager';
import config from './config';

const isDesktopNotificationSupported = Notification.isSupported();
const logger = logManager.getLogger('TrackItemService');

export function showNotification(body, title = 'Tockler', onClick = null) {
    if (isDesktopNotificationSupported) {
        logger.info('Showing notification:', body, title);
        const notification = new Notification({
            title,
            body,
            silent: false,
            icon: config.iconBig,
        });
        if (onClick) {
            notification.once('click', onClick);
        }
        notification.show();
    } else {
        logger.error('Notifications not supported');
    }
}
開發者ID:MayGo,項目名稱:backer-timetracker,代碼行數:24,代碼來源:notification.ts


注:本文中的electron.Notification.isSupported方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。