当前位置:网站首页>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
边栏推荐
- Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which
- Solution to the eighth training competition of 2020 Provincial Games
- About MySQL Boolean and tinyint (1)
- Unsupportedclassversionerror is reported when starting jar package. How to repair it
- Pytorch for former Torch users - Tensors
- Express - static resource request
- Opencv learning notes -day8 (keyboard typing (waitkey()); Wait for typing) action: triggers some action when the appropriate character is typed using the keyboard)
- JVM tuning related commands and explanations
- Set, map and modularity
- Get to know handler again
猜你喜欢

Rew acoustic test (III): generate test signal

Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)

Pytorch BERT

Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)

Wechat development tool (applet)

ES6 learning path (II) let & const

Talking about kotlin process exception handling mechanism

QT connection to Shentong database

Advanced technology management -- how managers design and build echelons

Talk about the kotlin cooperation process and the difference between job and supervisorjob
随机推荐
Detailed explanation of pipline of mmdetection
Flutter theme (skin) changes
快应用中实现自定义抽屉组件
Deep understanding of continuation principle
Implementing custom drawer component in quick application
Mmdet line by line deltaxywhbboxcoder
QT downloading files through URL
Linear-gradient()
Wechat development tool (applet)
ES6 learning road 5 symbol
Talk about how the kotlin process started?
Treatment process record of Union Medical College Hospital (Dongdan hospital area)
Esp32 things (V): analysis of common API of esp32 of Swiss Army knife
Talk about the job experience of kotlin cooperation process
Explanation on the use of password profiteering cracking tool Hydra
Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
桂林 穩健醫療收購桂林乳膠100%股權 填補乳膠產品線空白
Rew acoustic test (II): offline test
JPA naming rules
Talk about how the kotlin collaboration process establishes structured concurrency