Giter VIP home page Giter VIP logo

electron-hello-world's Introduction

Electron-Hello-World

Introduction

Electron-Hello-World is a simple application built using Electron, an open-source framework developed by GitHub. This application serves as a basic template for starting Electron projects and demonstrates how to create a minimalistic "Hello World" desktop application.

Features

  • Displays a minimalist window with a "Hello, World!" message.
  • Provides a foundation for building more complex Electron applications.

Installation

  1. Clone the repository to your local machine:

    git clone https://github.com/your-username/Electron-Hello-World.git
  2. Navigate into the project directory:

    cd Electron-Hello-World
  3. Install dependencies using npm:

    npm install

Usage

Once the installation is complete, you can run the Electron-Hello-World application by executing the following command in your terminal

npm start

This will launch the Electron application, displaying the "Hello, World!" message in a new window.

Contributing

Contributions are welcome! If you have any ideas for improvements or new features, feel free to open an issue or submit a pull request.

Licence

This project is licensed under the MIT License - see the LICENSE file for details.

Important Commands and codes

Required Tools

Node, NPM

Initialize Project

mkdir my-electron-app && cd my-electron-app
npm init

Install Electron

npm install electron --save-dev

Should add Gitignore for Node.js

Run Electron App

Update "scripts" on package,json as following

"scripts": {
    "start": "electron .", // Add this Line
    "test": "echo \"Error: no test specified\" && exit 1"
  },

Start App

npm run start

Basic App Code

main.js

const { app, BrowserWindow } = require('electron');

function createWindow() {
    const win = new BrowserWindow({
        height: 600,
        width: 800,
        webPreferences: {
            nodeIntegration: true,
            enableRemoteModule: true
        },
        icon: path.join(__dirname, 'assets', 'img', 'icon.png'),
        title: 'My App',
    });

    win.setTitle('My App');
    win.loadFile('views/index.html');
    win.webContents.openDevTools();
}

app.whenReady().then(createWindow);

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
});

app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) {
        createWindow();
    }
});

Packaging App

Install Electron Forge

npm install --save-dev @electron-forge/cli

Import Project to Forge

npx electron-forge import

Updating packages.json

  //...
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },
  //...

Creating a distributable

npm run make

More : Electron Tutorial

electron-hello-world's People

Contributors

pasansilva99 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.