我想在电子桌面应用程序中实现通知的粘性行为,直到用户单击通知本身。
我正在使用node-notifier来实现此文档之后的行为,并使用ngx-electron来使用 ElectronService 将 main.js 文件导入角度组件文件中。
这是我的main.js文件:
const notifier = require('node-notifier')
exports.notifier = (msg) => {
notifier.notify({
title: 'Notify Me',
message: msg,
wait: true,
timeout: 1500000,
sound: true,
icon: './assets/images/logo.png'
});
app.component.ts:
import {ElectronService} from 'ngx-electron';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
public main_js : any;
constructor(private _electronService: ElectronService ) {
this.main_js = this._electronService.remote.require("./main.js");
this.getTasks();
}
getTasks() {
var message = 'New Task Assigned!!!';
this.main_js.notifier(message);
}
}
电子应用通知:
目前,我正在 Windows 平台上检查此通知行为,并且通知保持粘性,直到且除非用户采取任何操作,包括键盘上的任何按键或任何鼠标移动。
我希望通知卡在屏幕上,直到用户单击通知本身的关闭标签,而不是在单击屏幕的任何其他部分时关闭。