提交 a96c49ba 编写于 作者: 徐晓伟's avatar 徐晓伟

Notification

上级 d491f81f
......@@ -21,6 +21,9 @@
<button @click="newRendererToRenderer">直接向其他进程发送消息</button>
<span>请查看其他进程控制台</span>
<br>
<button @click="basicNoti">Notification 基本通知</button>
<button @click="advancedNoti">Notification 高级通知</button>
<br>
<HelloWorld msg="Welcome to Your Vue.js App"/>
</template>
......@@ -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')
})
}
}
}
......
......@@ -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 } }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册