本文整理汇总了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}`);
}
});
示例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();
}
示例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();
}
示例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);
}
});
示例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');
}
}
示例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));