当前位置:网站首页>Electron, which can wrap web page programs into desktop applications
Electron, which can wrap web page programs into desktop applications
2022-06-30 09:25:00 【LongtengGensSupreme】
Electron It's a use JavaScript、HTML and CSS Building a framework for desktop applications , Embedded Chromium,Nodejs, It can be used JavaScript Write the same code , Local applications published to different platforms , Support Windows、macOS,Linux.
Through it, we can package some web pages we use everyday , Make it an application that can be clicked on the desktop , Just click it when you want to use it , Don't open Google 、 Microsoft and other browsers , It is so troublesome to enter a web page into a website . Let's take a look at the actual code examples and demonstration effects .
1、 install node,npm

2、 Create a new folder , Name the project name , such as my-electron-app, Switch to this directory and run the command :
mkdir my-electron-app && cd my-electron-app
npm initSome code files will be generated in this directory , among package.json There are some descriptions of the project and the author , most important of all main:main.js, The main entry of the table name program is main.js File code .

3、 take electron Install package into development dependency ,
npm install --save-dev electron4、 In the project directory package.json In the configuration file scripts Add a start command :

5, New in project directory main.js file , Add code
const path = require('path')
const { app, BrowserWindow } = require('electron');
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600
})
win.loadURL('https://music.163.com/')
}
app.whenReady().then(() => {
createWindow()
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})Here's an example , We packaged Netease cloud music web pages into desktop applications , Click the icon to open Netease cloud music .
6、 Carry out orders , Run to see the effect
7、 Here is the introduction of Electron Simple usage examples of , There are more and deeper applications that you can imagine .
Link to the original text : Today's headline
边栏推荐
- Use Huawei performance management service to configure the sampling rate on demand
- RPC understanding
- Opencv learning notes -day13 pixel value statistics calculation of maximum and minimum values, average values and standard deviations (use of minmaxloc() and meanstddev() functions)
- Interpretation of source code demand:a rotation equivariant detector for aerial object detection
- Flutter theme (skin) changes
- How to format an UTC date to use the Z (Zulu) zone designator in php?
- Talk about how the kotlin process started?
- Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
- Applet learning path 2 - event binding
- 将线程绑定在某个具体的CPU逻辑内核上运行
猜你喜欢

Couldn't load this key (openssh ssh-2 private key (old PEM format))

Dart asynchronous task

Talk about the kotlin cooperation process and the difference between job and supervisorjob

Solution to the eighth training competition of 2020 Provincial Games

5. Messager framework and imessager interface

ES6 learning path (II) let & const

Advanced technology management -- how managers design and build echelons

Rew acoustic test (I): microphone calibration

Wechat development tool (applet)

Opencv learning notes-day6-7 (scroll bar operation demonstration is used to adjust image brightness and contrast, and createtrackbar() creates a scroll bar function)
随机推荐
Talk about how the kotlin collaboration process establishes structured concurrency
ES6 learning path (III) deconstruction assignment
Is it safe to open an account? How can anyone say that it is not reliable.
Interpretation of orientedrcnn papers
ES6 learning road 5 symbol
Deep Learning with Pytorch - autograd
Maxiouassigner of mmdet line by line interpretation
Use V-IF with V-for
Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line
4. use ibinder interface flexibly for short-range communication
Deep Learning with Pytorch-Train A Classifier
Express の Hello World
Interpretation of source code demand:a rotation equivariant detector for aerial object detection
Abstract factory pattern
Talk about writing
Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
Understanding of MVVM and MVC
Concatapter tutorial
[paid promotion] collection of frequently asked questions, FAQ of recommended list
Comparaison de deux façons d'accéder à la base de données SQL Server (sqldatareader vs sqldataadapter)