electron launcher
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.

38 lines
1.1 KiB

4 years ago
3 years ago
4 years ago
4 years ago
3 years ago
  1. // All of the Node.js APIs are available in the preload process.
  2. // It has the same sandbox as a Chrome extension.
  3. const {ipcRenderer} = require('electron')
  4. window.currentFrame ="platform";
  5. window.api = [
  6. "showSuspensionWindow",
  7. "resizeWindow",
  8. "setUnReadMessage",
  9. "getUnReadMessage",
  10. "windowMoveHandle",
  11. "exitSystem",
  12. "openDevTools",
  13. "hideMainWindow",
  14. "showMainWindow",
  15. "minimize",
  16. "hideSuspensionWindow"
  17. ].reduce((acc, apiName) => {
  18. acc[apiName] = (...params) => {
  19. return ipcRenderer.send(apiName, ...params)
  20. }
  21. return acc
  22. }, {
  23. on: ipcRenderer.on.bind(ipcRenderer),
  24. send: ipcRenderer.send.bind(ipcRenderer),
  25. removeListener: ipcRenderer.removeListener.bind(ipcRenderer)
  26. });
  27. ipcRenderer.on('getUnReadMessage', (e, args) => {
  28. window.getUnReadMessage(args[0]);
  29. });
  30. // window.addEventListener("keydown", e => {
  31. // const {altKey, ctrlKey, keyCode} = e;
  32. // if (altKey && ctrlKey && keyCode === 70) {
  33. // const currentWindow = require('electron').remote.getCurrentWindow();
  34. // currentWindow && currentWindow.toggleDevTools();
  35. // e.preventDefault();
  36. // }
  37. // })