You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.1 KiB

2 years ago
  1. /**
  2. * This file is loaded via the <script> tag in the index.html file and will
  3. * be executed in the renderer process for that window. No Node.js APIs are
  4. * available in this process because `nodeIntegration` is turned off and
  5. * `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
  6. * to expose Node.js functionality from the main process.
  7. */
  8. let {ipcRenderer} = require("electron");
  9. const log = require('electron-log');
  10. log.transports.file.level = 'info'
  11. log.transports.file.maxSize = 10024300 // 文件最大不超过 10M
  12. log.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}'// 输出格式
  13. let date = new Date()
  14. let dateStr = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
  15. log.transports.file.resolvePath = () => 'log\\' + dateStr+ '.log';
  16. // 监听回复事件
  17. ipcRenderer.on("lc-print-pre-message-reply",(event,arg)=>{
  18. console.log(event);
  19. console.log('args:'+arg);
  20. log.info('args:'+arg)
  21. })
  22. let btnPre = document.querySelector("#btn");
  23. btnPre.onclick=function(){
  24. ipcRenderer.send("lc-print-pre-message","this is a input parameters");
  25. }