• electron-开机自启动,启用操作系统气泡提示,有任务时,阻止电脑休眠



    //
    开机自启动 const exeName = path.basename(process.execPath); ipcMain.on('boot-start', (event, args) => { if (!app.isPackaged) { app.setLoginItemSettings({ openAtLogin: args, path: process.execPath }); } else { app.setLoginItemSettings({ openAtLogin: args }); } }); app.setLoginItemSettings({ openAtLogin: app.getLoginItemSettings().openAtLogin, openAsHidden: false, path: process.execPath, args: [ '--processStart', `"${exeName}"`, ] });

    操作系统气泡提示,下载依赖 ,

    npm i node-notifier --save

    在electron-bootstrap.ts中引用

    const notifier = require('node-notifier');

    app.setAppUserModelId(process.execPath);
            ipcMain.on('send-notification', (event, args) => {
              notifier.notify(
                {
                  title: args.title,
                  message: args.message,
                  icon: path.join(__dirname, 'src/favicon.png'),
                  sound: true,
                  wait: true,
                  appName : ''
                },
                function (err, response) {
                  // Response is response from notification
                  console.log(err);
                  console.log(response);
                }
              );
              notifier.on('click', function (notifierObject, options, event) {
                // Triggers if `wait: true` and user clicks notification
                console.log(notifierObject);
              });
    
              notifier.on('timeout', function (notifierObject, options) {
                // Triggers if `wait: true` and notification closes
                console.log(notifierObject);
              });
            });

    阻止电脑休眠,在渲染进程触发。

    ipcMain.on('prevent-power-sleep', (event, args) => {
              const id = powerSaveBlocker.start('prevent-display-sleep');
              if (args) {
                powerSaveBlocker.stop(id);
              }
              console.log('powerSaveBlocker start>>>' + powerSaveBlocker.isStarted(id));
            });
  • 相关阅读:
    MongoDB的特殊操作
    MongoDB的$作为下标的用法
    MongoDB之$关键字,以及$修饰器$set,$inc,$push,$pull,$pop
    MongoDB的数据类型
    MongoDB的增删改查
    Drozer快速使用指南
    [安全分析报告]使用某科技公司客服系统的风险分析
    某客服系统上传漏洞导致服务器被拿下(续)
    YS端对端之间SSL通信安全问题
    某客服系统上传漏洞导致服务器被拿下
  • 原文地址:https://www.cnblogs.com/huangmin1992/p/13063816.html
Copyright © 2020-2023  润新知