node -v

npm -v

安装node环境

my-electron-app/

├── package.json

├── main.js

└── index.html

为您的项目创建一个文件夹并安装 Electron:

mkdir my-electron-app && cd my-electron-app

npm init -y

npm i --save-dev electron

main.js代码:

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

function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
}) win.loadFile('index.html')
} app.whenReady().then(createWindow) app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
}) app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

  index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body style="background: white;">
<h1>Hello World!</h1>
<p>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</p>
</body>
</html>

  package.json

{
"name": "my-electron-app",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron ."
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^11.2.2"
}
}

  启动:npm start 命令行

最新文章

  1. Struts2第一个入门案例
  2. 2.5 C#的数据类型
  3. 【LeetCode】#7 Reverse Integer
  4. Swift 值类型和引用类型
  5. 完全偶图K(3,3)与完全图K5是否存在平面表示
  6. 解除SQL对组件&quot;Ad Hoc Distributed Queries&quot;的&quot;STATEMENT&#39;OpenRowset OpenDatasource&quot;的访问
  7. 安装rkhunter
  8. mysql 操作日期函数【增加,减少时间】
  9. 私有pod简记
  10. [Apio2012]dispatching
  11. element 如何自定义主题
  12. 如何搭一个vue项目
  13. ftp 传输问题
  14. 使用React改版网站
  15. 使用JDBC+POI把Excel中的数据导出到MySQL
  16. 对称(DES/AES)与非对称(RSA/SSL/数字证书)加密介绍及实际应用
  17. Redis的强大之处
  18. flow类型检查
  19. mysql获取表列信息、主键信息
  20. Linux中read命令的用法—(6/30)

热门文章

  1. 阿里云服务器上在docker部署jenkins
  2. 2020.12.20-Codeforces Round #105补题
  3. C 输入输出函数
  4. AES解密尾部出现乱码问题
  5. 自动化键盘,python
  6. 设计模式 - Bridge 桥模式
  7. TT模板的作用及使用
  8. error: ‘int64_t’ does not name a type
  9. Python pip 和pip3区别 联系
  10. lvs 四层负载相关