A preliminary study of Windows Electron

Source: Internet
Author: User

Recently idle to have nothing to do, play with electron.

1, installation Nodejs

: http://nodejs.cn/download/, download 64-bit. After the installation is complete, open the C:\Program files\nodejs\node_modules\npm directory, edit the NPMRC file, and add Electron_mirror= "https://npm.taobao.org/mirrors/electron/". Add an electron image.

2. Create a new folder Desktopapp, and then create a new three files:

Main.js Main logic files

Index.html page File

Package.json Nodejs Standard File

Under the Desktopapp folder, run the NPM install electron. After the installation is complete, automatically generate: Package-lock.json and Node_modules folders.

3. main.js file

Const ELECTRON = require (' electron '); Const app=Electron.app;const Browserwindow=Electron. Browserwindow;varMainWindow =NULL; App.on (' Window-all-closed ',function() {  if(Process.platform! = ' Darwin ') {app.quit (); }}); App.on (' Ready ',function() {MainWindow=NewBrowserwindow ({width:800, height:600}); Mainwindow.loadurl (' file://' + __dirname + '/index.html '); Mainwindow.on (' Closed ',function() {MainWindow=NULL; });});

4. Package.json file

{  "name": "Desktopapp",  "version": "0.1.0",  "main": "Main.js",  "Dependencies": {    "electron": "^1.6.11"  }}

5. index.html File

<!DOCTYPE HTML><HTML>  <Head>    <title>Hello world!</title>  </Head>  <Body>    <H1>Hello world!</H1>We are using Io.js<Script>document.write (process.version)</Script>and Electron<Script>document.write (process.versions['Electron'])</Script>. </Body></HTML>

6. Operation:

c:\> D:\DesktopApp\node_modules\electron\dist\electron.exe D:\DesktopApp

(Executes the project using an EXE file of a locally installed electron)

A preliminary study of Windows Electron

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.