软化血管吃什么药最好| 手指肿胀什么原因| 食管ca是什么意思| 什么样的人不能吃海参| 偶发室性早搏什么意思| 性感染有什么症状| 感康是什么| 女生安全期是什么意思| 多吃玉米有什么好处和坏处| 尿隐血阴性是什么意思| 怀孕什么时候可以同房| 马拉色菌毛囊炎用什么药治疗最好| 宁夏有什么特产| 乳头内陷挂什么科| 一般什么原因做宫腔镜| 唾液有臭味是什么原因| 点子是什么意思| 肠镜挂什么科| 入睡困难吃什么药效果最好| 验孕棒阳性代表什么| 壁虎吃什么| 鳄龟吃什么食物| 尿道口下裂是什么样子| 口臭严重是什么原因| 明矾是什么东西| 西米露是什么材料做的| 神经性头痛吃什么药好| 碱水是什么| 猫咪飞机耳是什么意思| 听什么歌写作业快| 什么是皮包公司| 糖类抗原是检查什么的| 孕妇吃海带有什么好处| 过敏性鼻炎吃什么中药| saa是什么检查| 什么是引流| ct能检查出什么| dsa是什么检查| 微量元素检查挂什么科| 血常规用什么颜色的试管| 安赛蜜是什么| 尿痛流脓吃什么药| 四季豆为什么叫四季豆| 什么样的肚子疼是癌| 狗男和什么属相最配| 腮腺炎是什么| 共情是什么意思| noxa20是什么药| 头上长虱子什么原因引起的| 胆囊粗糙是什么意思| 俄狄浦斯情结是什么意思| 梦见把头发剪短了是什么意思| 劳伦斯属于什么档次| 钙片吃多了有什么副作用| 手背麻木是什么原因| 手为什么会掉皮| 燃气灶什么品牌好| 0n是什么意思| 拉肚子吃什么好得快| 太监是什么| 幼儿急疹是什么原因引起的| 普通健康证都检查什么| 尿蛋白定量是什么意思| 痛风不能吃什么东西| 补维生素吃什么药最好| 有什么水能代替美瞳水| 凌波鱼是什么鱼| 北洋军阀是什么意思| 幽灵蛛为什么不能打死| 杯弓蛇影是什么物理现象| 肺疼是什么原因| 空调自动关机什么原因| 传度是什么意思| 血红蛋白浓度偏高是什么意思| 六月二十三号是什么星座| 宦游人是什么意思| 左眼皮跳是什么预兆| 脑供血不足吃什么食物好| 鲁迅原名是什么| 长得标致是什么意思| 吃枸杞有什么功效| 玫琳凯属于什么档次| 苯磺酸氨氯地平片什么时候吃| 火把节是什么时候| 西洋参不能和什么一起吃| 清心寡欲下一句是什么| 孕妇梦见洪水是什么意思| 节育环要什么时候取才是最佳时期| 至是什么意思| 各自安好什么意思| 一度房室传导阻滞是什么意思| 酷盖是什么意思| 皮肤为什么会变黑| 例假可以吃什么水果| 肉鸽是什么意思| 什么是rpa| 小鸡仔吃什么| 985211是什么意思| 玄米是什么米| 小肠气挂什么科| 流连忘返的返是什么意思| 洁身自爱是什么生肖| 后下药什么时候下| 12月15号是什么星座| 独善其身是什么意思啊| 心肝火旺吃什么中成药| 腰疼是什么病| 端午节晚上吃什么| 生殖器疱疹是什么| 圆是什么图形| 茵陈有什么功效| 鼻咽癌是什么| pretty什么意思| 茄子与什么相克| 囗腔溃疡吃什么维生素| 女人吃榴莲有什么好处| diamond是什么牌子| 样板间是什么意思| 裤子前浪后浪是什么| 脚臭用什么洗效果最好| 低钾会有什么症状| 低聚木糖是什么| 眼角下面长斑是什么原因引起的| 溜号是什么意思| 匹夫是什么意思| 菊花是什么季节| 春梦是什么意思| 条形码的数字代表什么| 样板间是什么意思| 做脑部ct挂什么科| 眼镜发明之前眼镜蛇叫什么| 梦到前妻预示什么| 早上出汗是什么原因| 征字五行属什么| 身体出现小红点是什么原因| 黄热病是什么病| 什么是太监| 纯碱是什么| 嘴唇上起泡是什么原因| 为什么月经迟迟不来又没怀孕| 变色龙吃什么食物| 感冒咳嗽吃什么食物好| 吴五行属什么| 南京菜属于什么菜系| 胃发炎吃什么药好得快| 宇宙的外面是什么| 鹿茸和什么泡酒壮阳| 2222是什么意思| 咖啡烘培度有什么区别| 二尖瓣轻度反流是什么意思| 阳光明媚下一句接什么| 治妇科炎症用什么药好| px是什么意思| bq是什么意思啊| 喉咙干痒咳嗽吃什么药| 眼压高什么症状| 甲骨文是写在什么上面的| 两胸中间疼是什么原因| 乳头是什么| 梦见很多人是什么意思| 黄精配什么提高性功能| 梗阻是什么意思| 梦见莲藕是什么意思| 煲仔饭用什么米最好| 排卵期有什么感觉| 痰盂是什么意思| 中耳炎不能吃什么食物| 类似蜈蚣的虫子叫什么| 8月12日是什么星座| 阴虱用什么药物| ct查什么| 咽炎吃什么消炎药最好| 三焦指的是什么器官| 梦见输液是什么意思| 茹是什么意思| 老人嘴唇发紫是什么原因| 鸡蛋不能和什么食物一起吃| 舌苔发白是什么情况| 什么地坐着| 小猫的胡须有什么作用| 壑是什么意思| 篦子是什么东西| 虎是什么结构| 精子为什么叫怂| 子宫增大是什么原因| 中央处理器由什么组成| 天麻是什么样子| 总胆固醇高有什么症状| mri是什么检查| 菊花的功效是什么| 补白蛋白吃什么食物最快最好| 孩子结膜炎用什么眼药水| 魔芋是什么东西做的| 梦见呕吐是什么意思| 子宫粘连是什么原因引起的| 废品收入计入什么科目| 姜太公钓鱼愿者上钩是什么意思| 怀孕白细胞高是什么原因| 督察是什么级别| 怕空调冷风什么原因| 里急后重什么意思| 前列腺炎是什么原因引起| 上胸围90下胸围80是什么罩杯| 睡醒口干口苦是什么原因| 喝红酒有什么好处| 暗物质是什么东西| 老想放屁是什么原因| 壬字五行属什么| 靶向药是什么药| 方案是什么意思| 重度贫血是什么原因引起的| 830是什么意思| 什么样的白带是怀孕了| 妮字五行属什么| 财库是什么意思| 属猪适合佩戴什么饰品| 营业员是什么| 心脑供血不足吃什么药效果最好| 什么叫护理| 开髓引流是什么| 什么食物胶原蛋白含量高| 雄黄是什么东西| 韩世忠为什么不救岳飞| 贲临是什么意思| 植树节是什么季节| 心肌炎是什么症状| 奇亚籽在中国叫什么| wonderflower是什么牌子| 冬至穿什么衣服| 84年属什么生肖| 唇炎应该挂什么科室| 翻白草长什么样| 麻腮风疫苗什么时候打| 左肾积水是什么意思| 双肺多发结节是什么意思| 伤骨头了吃什么好得快| 溶血性黄疸是什么原因引起的| 发烧喝什么饮料比较好| n是什么牌子的鞋| 陈醋和蜂蜜一起喝有什么好处| 鼻塞黄鼻涕吃什么药| 阴道炎用什么洗液| 吃什么补锌| 司仪是什么意思| 辛巳五行属什么| 白带拉丝是什么原因| 腿弯处的筋痛是什么原因| 医保和社保有什么区别| 什么叫辟谷| 女性适合喝什么茶| 干咳吃什么食物好| 嬗变是什么意思| 血管堵塞有什么办法可以疏通| 交杯酒是什么意思| 头上的旋有什么说法| 卵巢囊肿术后吃什么食物好| 日柱代表什么| 孕妇喝什么牛奶| 老百姓是什么意思| 琏是什么意思| 红细胞压积偏低是什么意思| 意蕴什么意思| 晚上七点半是什么时辰| 甘油三酯高是什么| 百度
Skip to main content

在习近平新时代中国特色社会主义思想指引下——新时代新气象新作为

百度   彭纯要求,必须从严要求,促进真抓实干。

Each operating system has its own mechanism to display notifications to users. Electron's notification APIs are cross-platform, but are different for each process type.

If you want to use a renderer process API in the main process or vice-versa, consider using inter-process communication.

Usage?

Below are two examples showing how to display notifications for each process type.

Show notifications in the main process?

Main process notifications are displayed using Electron's Notification module. Notification objects created using this module do not appear unless their show() instance method is called.

Main Process
const { Notification } = require('electron')

const NOTIFICATION_TITLE = 'Basic Notification'
const NOTIFICATION_BODY = 'Notification from the Main process'

new Notification({
title: NOTIFICATION_TITLE,
body: NOTIFICATION_BODY
}).show()

Here's a full example that you can open with Electron Fiddle:

const { app, BrowserWindow, Notification } = require('electron/main')

function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})

win.loadFile('index.html')
}

const NOTIFICATION_TITLE = 'Basic Notification'
const NOTIFICATION_BODY = 'Notification from the Main process'

function showNotification () {
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
}

app.whenReady().then(createWindow).then(showNotification)

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

Show notifications in the renderer process?

Notifications can be displayed directly from the renderer process with the web Notifications API.

Renderer Process
const NOTIFICATION_TITLE = 'Title'
const NOTIFICATION_BODY =
'Notification from the Renderer process. Click to log to console.'
const CLICK_MESSAGE = 'Notification clicked'

new Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY }).onclick =
() => console.log(CLICK_MESSAGE)

Here's a full example that you can open with Electron Fiddle:

const NOTIFICATION_TITLE = 'Title'
const NOTIFICATION_BODY = 'Notification from the Renderer process. Click to log to console.'
const CLICK_MESSAGE = 'Notification clicked!'

new window.Notification(NOTIFICATION_TITLE, { body: NOTIFICATION_BODY })
.onclick = () => { document.getElementById('output').innerText = CLICK_MESSAGE }

Platform considerations?

While code and user experience across operating systems are similar, there are subtle differences.

Windows?

For notifications on Windows, your Electron app needs to have a Start Menu shortcut with an AppUserModelID and a corresponding ToastActivatorCLSID.

Electron attempts to automate the work around the AppUserModelID and ToastActivatorCLSID. When Electron is used together with Squirrel.Windows (e.g. if you're using electron-winstaller), shortcuts will automatically be set correctly.

In production, Electron will also detect that Squirrel was used and will automatically call app.setAppUserModelId() with the correct value. During development, you may have to call app.setAppUserModelId() yourself.

Notifications in development

To quickly bootstrap notifications during development, adding node_modules\electron\dist\electron.exe to your Start Menu also does the trick. Navigate to the file in Explorer, right-click and 'Pin to Start Menu'. Then, call app.setAppUserModelId(process.execPath) in the main process to see notifications.

Use advanced notifications?

Windows also allow for advanced notifications with custom templates, images, and other flexible elements.

To send those notifications from the main process, you can use the userland module electron-windows-notifications, which uses native Node addons to send ToastNotification and TileNotification objects.

While notifications including buttons work with electron-windows-notifications, handling replies requires the use of electron-windows-interactive-notifications, which helps with registering the required COM components and calling your Electron app with the entered user data.

Query notification state?

To detect whether or not you're allowed to send a notification, use the userland module windows-notification-state.

This module allows you to determine ahead of time whether or not Windows will silently throw the notification away.

macOS?

Notifications are straightforward on macOS, but you should be aware of Apple's Human Interface guidelines regarding notifications.

Note that notifications are limited to 256 bytes in size and will be truncated if you exceed that limit.

Query notification state?

To detect whether or not you're allowed to send a notification, use the userland module macos-notification-state.

This module allows you to detect ahead of time whether or not the notification will be displayed.

Linux?

Notifications are sent using libnotify, which can show notifications on any desktop environment that follows Desktop Notifications Specification, including Cinnamon, Enlightenment, Unity, GNOME, and KDE.

百度