electron 打包js_Electron JS简介

news/2024/7/10 2:41:45 标签: java, python, vue, linux, javascript

electron 打包js

To better understand this article, you should have some basic knowledge of vanilla JavaScript and/or Node.Js.

为了更好地理解本文,您应该具有香草JavaScript和/或Node.Js的一些基本知识。

Note: Ensure you have Node.Js installed before proceeding with the environment set up for Electron JS.

注意:在继续为Electron JS设置环境之前, 确保已安装Node.Js。

什么是Electron JS? (What is Electron JS?)

Electron JS (electronjs.org) is an open-source framework that enables the use of web technologies (HTML, CSS, and JavaScript) to create native desktop applications or software for Windows, Mac, and Linux platforms.

Electron JS ( electronjs.org )是一个开放源代码框架,该框架允许使用Web技术( HTML , CSS和JavaScript )创建适用于Windows,Mac和Linux平台的本地桌面应用程序或软件。

It was previously called native shell and it is owned by GitHub.

它以前被称为本机外壳 ,并由GitHub拥有。

Electron JS uses web pages as its graphical user interface. Electron JS is very important because it solves the following progress,

Electron JS使用网页作为其图形用户界面。 Electron JS非常重要,因为它解决了以下问题,

  1. It saves the time to learn a different programming language out of JavaScript stack like C# or Java to build native desktop applications.

    它节省了从JavaScript堆栈(如C#或Java)中学习其他编程语言以构建本机桌面应用程序的时间。

  2. Electron JS applications also have access to native platform features like accessing the file system, creating a native menu, global shortcuts, and is equally offline by default.

    Electron JS应用程序还可以访问本机平台功能,例如访问文件系统,创建本机菜单,全局快捷方式,并且默认情况下处于离线状态。

Just like a Node.Js app, Electron JS apps use package.json file as a starting point when development is concerned.

就像Node.Js应用程序一样,Electron JS应用程序将package.json文件用作开发方面的起点。

Examples of software built with Electron JS framework include: VS code, atom, and postman.

使用Electron JS框架构建的软件示例包括: VS代码atompostman

入门 (Getting Started)

To get started with the Electron JS, open a command line to your project's folder or directory and run the following command: npm install electron - -save-dev

要开始使用Electron JS ,请在项目的文件夹或目录中打开命令行,然后运行以下命令: npm install electro--save-dev

Electron JS (1)

This command will create a node_modules folder in your project's directory.

此命令将在项目目录中创建一个node_modules文件夹。

Wait for a while as it installs successfully!. Make sure you have an internet connection when executing the command.

等待一段时间,因为它成功安装! 执行命令时,请确保您具有Internet连接。

After successful installation, edit your package.json file and set it up as seen below;

成功安装后,编辑package.json文件并按如下所示进行设置;

Electron JS (2)
  • If you don't find a package.json file in your project's directory, run the command npm init in that same directory.

    如果在项目目录中找不到package.json文件,请在同一目录中运行命令npm init 。

  • From the package.json, notice the main value and the start value which represents the source code file and the start command (Electron .) respectively.

    的package.json,分别通知值和表示的源代码文件和开始命令开始值( 电子)。

  • Also notice we decided to put the main file in the src folder just for a clean folder structure.

    还要注意,我们决定将文件放在src文件夹中,只是为了获得一个干净的文件夹结构。

  • Finally, open that same directory in a command-line terminal and run the command npm install to install all dependencies. This command also requires an internet connection.

    最后,在命令行终端中打开同一目录,然后运行命令npm install安装所有依赖项。 此命令还需要Internet连接。

So that's it friends. We're now ready to run a demo code to ensure everything worked.

就是朋友。 现在,我们准备运行演示代码,以确保一切正常。

const electron = require ('electron')

const app = electron.app // electron module
const BrowserWindow = electron.BrowserWindow //enables UI
let mainWindow
app.on ('ready', _ => {
    mainWindow = new BrowserWindow({
        height : 400,
        width : 400
    })

    mainWindow.loadURL (`file://${__dirname}/index.html`)

    mainWindow.on ('closed', _ => { //detect if window is closed.
        console.log ('closed!')
        mainWindow = null
    })

})

  • Write a simple index.html file and save it in the src folder.

    编写一个简单的index.html文件,并将其保存在src文件夹中。

  • Open the directory in a command-line terminal, then run the code npm start

    在命令行终端中打开目录,然后运行代码npm start

  • Finally, take a cup of coffee and watch the electron magic. Ha Ha Ha!

    最后,喝杯咖啡,观看电子魔术。 哈哈哈!

Electron JS (3)

翻译自: https://www.includehelp.com/electron-js/introduction.aspx

electron 打包js


http://www.niftyadmin.cn/n/1253838.html

相关文章

[HEOI2016/TJOI2016]字符串(后缀数组+二分+主席树/后缀自动机+倍增+线段树合并)...

后缀数组解法: 先二分最长前缀长度 \(len\),然后从 \(rnk[c]\) 向左右二分 \(l\) 和 \(r\) 使 \([l,r]\) 的 \(height\geq len\),然后在主席树上查 \(sa[l..r]\) 是否有 \(a..b\) 中的任意一个数。时间复杂度 \(O(n\log^2 n)\) \(Code\ Below…

wpa psk模式_WPA的完整形式是什么?

wpa psk模式WPA:Wi-Fi保护访问 (WPA: Wi-Fi Protected Access) WPA is an abbreviation of Wi-Fi Protected Access. It is a security protocol or also known as encryption protocol which was created to take the place of the Wired Equivalent Privacy (WEP)…

lcd驱动 线模式 帧模式_LCD的完整形式是什么?

lcd驱动 线模式 帧模式LCD:液晶显示器 (LCD: Liquid Crystal Display) LCD is an abbreviation of "Liquid Crystal Display". LCD是“液晶显示器”的缩写。 It is a flat panel display or electronically modulated optical video display that uses t…

cdp 持续数据保护_什么是CDP(哥伦比亚数据产品)?

cdp 持续数据保护CDP:哥伦比亚数据产品 (CDP: Columbia Data Products) CDP is an abbreviation of "Columbia Data Products". It was a data security based corporation which intended to manufacture a number of the foremost IBM PC clones in 197…

blob模式识别_BLOB的完整形式是什么?

blob模式识别BLOB:二进制大对象 (BLOB: Binary Large Object) BLOB is an abbreviation of Binary Large Object. It is a collection of binary data accumulated and stored in a database management system that consists of a complex data type. It reserves …

[题解]洛谷P1443 马的遍历

原题 传送门 思路 BFS大力搜索 代码 #include<cstdio> #include<cstring> #include<queue> using namespace std;int dist[401][401],n,m,sx,sy;int nx[] {-2,-1,1,2,2,1,-1,-2},ny[] {1,2,2,1,-1,-2,-2,-1};struct Node {int x,y; };int main() {scanf(&quo…

python中矩阵坐标范围_Python | 矩阵范围

python中矩阵坐标范围The range of a matrix can be defined as the difference between the maximum and minimum among the elements of the matrix. In NumPy, we have provided with an inbuilt function for this operation i.e. numpy.ptp(). It returns the range of th…

[转]Mybatis foreach 批量操作

原文地址:https://blog.csdn.net/jason5186/article/details/40896043 foreach属性属性 描述item 循环体中的具体对象。支持属性的点路径访问&#xff0c;如item.age,item.info.details。具体说明&#xff1a;在list和数组中是其中的对象&#xff0c;在map中是value。该参…