当前位置:网站首页>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
边栏推荐
- Comparaison de deux façons d'accéder à la base de données SQL Server (sqldatareader vs sqldataadapter)
- C#訪問SQL Server數據庫兩種方式的比較(SqlDataReader vs SqlDataAdapter)
- Occasionally, Flink data is overstocked, resulting in checkpoint failure
- Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
- Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())
- Summary of Android knowledge points and common interview questions
- Sort (simple description)
- Get to know handler again
- What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
- 将线程绑定在某个具体的CPU逻辑内核上运行
猜你喜欢

I once met a girl whom I most wanted to take care of all my life. Later... No later

Do you want the dialog box that pops up from the click?

Tutorial for beginners of small programs day01

Anchorgenerator for mmdet line by line interpretation

Linear-gradient()

Solution to the eighth training competition of 2020 Provincial Games

Guilin robust medical acquired 100% equity of Guilin Latex to fill the blank of latex product line

Explanation on the use of password profiteering cracking tool Hydra

Sort (simple description)

Harmonyos actual combat - ten thousand words long article understanding service card development process
随机推荐
Explanation on the use of password profiteering cracking tool Hydra
Flink sql -- No factory implements ‘org. apache. flink. table. delegation. ExecutorFactory‘.
Opencv learning notes-day14 drawing of image geometry (rect class rotatedrect class, rectangle drawing rectangle circle drawing circular function line drawing line function ellipse drawing elliptic fu
Get to know handler again
Handwriting sorter component
Code management related issues
Implementing custom drawer component in quick application
C#访问SQL Server数据库两种方式的比较(SqlDataReader vs SqlDataAdapter)
4. use ibinder interface flexibly for short-range communication
JPA naming rules
Talk about the job experience of kotlin cooperation process
float
Opencv learning notes -day1 (image reading display imread, imshow, namedwindow)
Deep understanding of kotlin collaboration context coroutinecontext
Use Huawei performance management service to configure the sampling rate on demand
Is it safe to open an account? How can anyone say that it is not reliable.
I once met a girl whom I most wanted to take care of all my life. Later... No later
Small program learning path 1 - getting to know small programs
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
Niuke IOI weekly competition 20 popularization group (problem solving)