diff --git a/public/programming.png b/public/programming.png new file mode 100644 index 0000000000000000000000000000000000000000..c68fdb69efb11b98f5258a1df8908bc4d99b9178 Binary files /dev/null and b/public/programming.png differ diff --git a/src/App.vue b/src/App.vue index f58f93fad4fd6fe1d2d773496ef04cb707fdf0a5..e498639b9d52ef38a89b6d3f964fdd0d40d4494c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,6 +21,9 @@ 请查看其他进程控制台
+ + +
@@ -144,7 +147,51 @@ export default { }) // eslint-disable-next-line no-undef win.loadFile(path.join(__static, 'new_index.html') - ) + ) + }, + basicNoti() { + const notificationBasic = {title: '基本通知', body: '短消息部分'} + const myNotification = new window.Notification(notificationBasic.title, notificationBasic) + console.log(myNotification) + myNotification.onclick = () => { + console.log('onclick') + } + myNotification.onclose = () => { + console.log('onclose') + } + myNotification.onerror = () => { + console.log('onerror') + } + myNotification.onshow = () => { + console.log('onshow') + } + myNotification.addEventListener('click', () => { + console.log('addEventListener click') + }) + }, + advancedNoti() { + const notificationAdvanced = { + title: 'Notification with image', + body: 'Short message plus a custom image', + icon: 'programming.png' + } + const myNotification = new window.Notification(notificationAdvanced.title, notificationAdvanced) + console.log(myNotification) + myNotification.onclick = () => { + console.log('onclick') + } + myNotification.onclose = () => { + console.log('onclose') + } + myNotification.onerror = () => { + console.log('onerror') + } + myNotification.onshow = () => { + console.log('onshow') + } + myNotification.addEventListener('click', () => { + console.log('addEventListener click') + }) } } } diff --git a/src/background.js b/src/background.js index 06695c1dd998e11323b1c449745ce766897706ac..ad78196362e6eda0e63476544ea15021007dc222 100644 --- a/src/background.js +++ b/src/background.js @@ -9,6 +9,10 @@ import {autoUpdater} from 'electron-updater' require('@electron/remote/main').initialize() +// 标识 +// 如果 Windows 屏蔽了、或者不提示 Notification,可尝试修改 app.setAppUserModelId() +app.setAppUserModelId("cn.com.xuxiaowei.electron"); + // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ { scheme: 'app', privileges: { secure: true, standard: true } }