gpt4 book ai didi

angular - Electron 通知

转载 作者:行者123 更新时间:2023-12-03 12:21:22 26 4
gpt4 key购买 nike

我正在尝试让通知适用于我使用 Angular 5 和 Electron 制作的 Electron 应用程序。到目前为止,我的 index.html 文件中有以下代码:

<script type="text/javascript">

function doNotify() {
new Notification( "Basic Notification", "Short message part");
}

window.onload = doNotify;
</script>

在我的 package.json 中,我的 appId 设置如下:
  "build": {
"appId":"com.myapp.id"
},

最后我在 main.js 中有这个:
app.setAppUserModelId("com.myapp.id");

正如我在某些地方读到的那样,这两者都是使通知起作用所必需的。我正在使用 Electron 锻造来构建一个松鼠安装程序,因为这也被提到需要通知才能工作。

我曾尝试在我的 Angular 组件中使用类似的通知代码,但也没有运气。我已经研究过节点通知器,但无法让它工作,主要是由于缺乏对它应该在 Angular-Electron 应用程序中的位置的了解。

在这一点上,我想要的只是让某种形式的桌面通知工作,但我找不到任何关于如何在 Angular-Electron 应用程序中做到这一点的资源。

最佳答案

您还可以使用 获取使用 angular 5 的 Electron 通知。 Electron 服务 Remote node-notifier模块为:

app.component.ts

import { ElectronService } from 'ngx-electron';

constructor(private databaseService: DatabaseService, private router: Router, private
_electronService: ElectronService){
}

ngOnInit(): void {
let main_js = this._electronService.remote.require("./main.js");
this.main_js.notifier("Message");
}

main.js
const notifier = require('node-notifier')

exports.notifier = (msg) => {
notifier.notify({
title: 'Notify Me',
message: msg,
wait: true
});

关于angular - Electron 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50772039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com