最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Properly using Electron - Stack Overflow

programmeradmin2浏览0评论

I want to get into Electron, and I have already started learning about it, however I don't think I quite understand how I am supposed to use it. From what I gathered, with Electron I am able to create cross-desktop applications (Chromium) with HTML, CSS and Javascript and do tasks in the background (NodeJS).

What confuses me is the following:

  • How am I supposed to use this with my server?

For example, I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system (with MongoDB). It has HTML files for logging in and registering.

I am not sure how to use this with my Electron app, as the matter of fact, I don't quite understand how to actually use Electron. Should I move all of my login/register application code to the Electron application, or should I use Electron to somehow connect to my login/registration application and load the websites?

  • If I were to move my code to my Electron app, would it cause security issues?

I want to get into Electron, and I have already started learning about it, however I don't think I quite understand how I am supposed to use it. From what I gathered, with Electron I am able to create cross-desktop applications (Chromium) with HTML, CSS and Javascript and do tasks in the background (NodeJS).

What confuses me is the following:

  • How am I supposed to use this with my server?

For example, I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system (with MongoDB). It has HTML files for logging in and registering.

I am not sure how to use this with my Electron app, as the matter of fact, I don't quite understand how to actually use Electron. Should I move all of my login/register application code to the Electron application, or should I use Electron to somehow connect to my login/registration application and load the websites?

  • If I were to move my code to my Electron app, would it cause security issues?
Share Improve this question asked Nov 29, 2017 at 16:36 Grim ReaperGrim Reaper 5614 gold badges6 silver badges23 bronze badges 2
  • Could you share your code please? It will be easier to help! – edkeveked Commented Nov 29, 2017 at 16:37
  • My question isn't really for a specific code, I just gave an example of what I want to do. If it is really needed, this is the code (from the tutorial I was following): github./bradtraversy/loginapp This is a login/registration app, and I am not sure what to do with Electron at this point, hence, this thread :) – Grim Reaper Commented Nov 29, 2017 at 16:42
Add a ment  | 

3 Answers 3

Reset to default 5

How am I supposed to use this with my server?

You need to think about separating the application as a stand-alone desktop app (that acts as a client-side application) vs the server for your API and backend logic which are hosted by a cloud provider.

By doing this, you can focus on the separation of concerns for the desktop (electron) application as well as ensuring servers (such as API, authentication, and other backend logic) are well optimised and serving as multiple workers of themselves.

If I were to move my code to my Electron app, would it cause security issues?

There are some security concerns with an Electron application development if you do not regularly update your Node version (such as memory buffer overflow attacks).

Another issue to consider is how the Electron munity serves and resolves issues of permissions for the client-side app and the regular file permissions which are granted when the user installs your app.

As a developer, the onus is on you to ensure third-party libraries are not damaging the user's puter. (imagine installing a library dependency whose purpose is to maliciously delete the entire file system).

I built a simple NodeJS application that uses Passport and a few other modules to create a login/registration system

For authentication, you can serve responses from your API based on the client-side requests/Posts that you provide to the authentication service. You don't necessarily have to provide/install the authentication server into your Electron app, as this can be somewhat troublesome for the user to update, as well as it exposes your authentication service for others to reverse-engineer/crack.

You can simply start your Electron Journey with Basic app which allows you to play with it.

Best part about electron is - You can run it anywhere (Mac, Windows & Linux)

Do a checkout

git clone https://github./geek4teck/electron-quick-start

Change your Current Working Directory to electron-quick-start

cd electron-quick-start

You can then run

npm install

(Make sure nodejs is installed)

You can then run

npm start

which should start a basic browserwindow and should show your current node, npm version etc.

Hope this helps

certainly the best Tutorial I've seen for electronjs is The Electron API Demos app which is the official tutorial from electron and pletely FREE :)

just download the main tutorial application which is named "ElectronAPIDemosSetup.exe" from GitHub (of course you can download "Electron API Demos-win32-ia32" and "electron-api-demos-2.0.2" to view and play with source codes) then run it and enjoy...

just as an additional hint I attached a screenshot from application here:

发布评论

评论列表(0)

  1. 暂无评论