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


TypeScript electron.Notification類代碼示例

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


在下文中一共展示了Notification類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Notification

	(_event: ElectronEvent, {id, title, body, icon, silent}: NotificationEvent) => {
		const notification = new Notification({
			title,
			body,
			hasReply: true,
			icon: nativeImage.createFromDataURL(icon),
			silent
		});

		notifications.set(id, notification);

		notification.on('click', () => {
			mainWindow.show();
			sendAction('notification-callback', {callbackName: 'onclick', id});

			notifications.delete(id);
		});

		notification.on('reply', (_event, reply: string) => {
			// We use onclick event used by messenger to go to the right convo
			sendBackgroundAction('notification-reply-callback', {callbackName: 'onclick', id, reply});

			notifications.delete(id);
		});

		notification.on('close', () => {
			sendAction('notification-callback', {callbackName: 'onclose', id});

			notifications.delete(id);
		});

		notification.show();
	}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:33,代碼來源:index.ts

示例3: showNotification

	function showNotification(title: string, body: string = title, listener?: () => void) {
		const notification = new Notification({
			title: title,
			body: body
		});
		
		if (listener) {
			notification.addListener('click', listener);
		}
		notification.show();
	}
開發者ID:SanderRonde,項目名稱:youtube-music-app,代碼行數:11,代碼來源:updater.ts

示例4: require

		fs.writeFile(STORED_DATA_FILE, JSON.stringify(secrets), (err) => {
			if (err) {
				const Notification = require('electron').Notification;
				const notification = new Notification({
					title: 'Could not store secrets',
					body: 'Could not store secrets'
				});
				notification.show();
				resolve(null);
			} else {
				resolve(null);
			}
		});
開發者ID:SanderRonde,項目名稱:youtube-music-app,代碼行數:13,代碼來源:getSecrets.ts

示例5: showNotification

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,代碼行數:17,代碼來源:notification.ts

示例6: function

app.on('ready', helpers.createWindow(mainView, [800, 600], function () {
    menu = helpers.renderAppMenu(template);

    var msg: Electron.Notification = new Notification({ title: "Task Finish", body: "test task finished!" });
    msg.show();
}, true));
開發者ID:SMRUCC,項目名稱:GCModeller.Workbench,代碼行數:6,代碼來源:main.ts


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