当前位置: 首页>>代码示例>>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;未经允许,请勿转载。