Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Windows平台上启用电子应用程序通知的粘性行为_Javascript_Angular_Notifications_Electron_Node Notifier - Fatal编程技术网

Javascript 在Windows平台上启用电子应用程序通知的粘性行为

Javascript 在Windows平台上启用电子应用程序通知的粘性行为,javascript,angular,notifications,electron,node-notifier,Javascript,Angular,Notifications,Electron,Node Notifier,我想在电子桌面应用程序中实现通知的粘性行为,直到用户点击通知本身。 我正在使用节点通知程序实现以下行为,并使用ElectronService在角度组件文件中导入main.js文件 这是我的main.js文件: const notifier = require('node-notifier') exports.notifier = (msg) => { notifier.notify({ title: 'Notify Me', message: msg, wait: tru

我想在电子桌面应用程序中实现通知的粘性行为,直到用户点击通知本身。

我正在使用节点通知程序实现以下行为,并使用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'
});
应用程序组件.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);
  }
}
电子应用程序通知

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平台上检查此通知行为,除非用户采取任何操作,包括键盘上的任何按键或任何鼠标移动,否则通知将保持粘性


我希望在用户单击通知本身的关闭标签之前,通知一直粘贴在屏幕上,而不是在单击屏幕的任何其他部分时关闭。

好吧,我无法在屏幕上实现通知的粘性行为 电子。然而,我已经找到了一个令人敬畏的替代品 和节点通知程序的组合

最好的一点是,它在WindowsLinux 平台般的魅力最终会带来跨平台的功能。我还没有在mac上测试过,也许它能用 也有。以下是我的测试代码:

应用程序组件.ts

从“ngx electron”导入{ElectronService};
@组成部分({
选择器:“应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent实现OnInit{
公共主要设施:任何;
建造商(专用电子服务:电子服务){
this.main_js=this.eelectronservice.remote.require(“/main.js”);
this.getTasks();
}
getTasks(){
var消息='已分配新任务!!!';
this.main_js.notifier(消息);
}

}
我已经更新了答案。也许它能帮助你知道