electron

ContextBridge

It is dangerous if the browser can have free access to all nodejs’s functions. Therefore, it need to be specified which functions can renderer.js use, like the functions for OS interactions.

  • e.g. You cannot import path from node:path in renderer.js

Context bridges needs to be created in preload.js

  • contextBridge and ipcRenderer
  • contextBridge.exposeInMainWorld
    • expose the function in nodejs to renderer.js,
  • Use ipcMain to connect with the database

main.js, preload.js renderer.js

  • renderer.js handles HTML rendering, main.js handles all other app logic.
  • main.js injects the preload.js to the renderer.js, so renderer.js can use the exposed functions
  • add renderer.js as script inside index.html.

Electron Forge

The building process requires dpkg and fakeroot.

🌐Check out other language versions!
網站使用 Hugo 製作
模板 StackJimmy 設計