博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
electron---项目打包
阅读量:6676 次
发布时间:2019-06-25

本文共 2787 字,大约阅读时间需要 9 分钟。

创建一个应用目录:app,里面需要有必要的三个文件:

index.html

百度

main.js

// Modules to control application life and create native browser windowconst {app, BrowserWindow} = require('electron')if(require('electron-squirrel-startup')) return;// Keep a global reference of the window object, if you don't, the window will// be closed automatically when the JavaScript object is garbage collected.let mainWindowfunction createWindow () {  // Create the browser window.  mainWindow = new BrowserWindow({width: 800, height: 600})  // and load the index.html of the app.  mainWindow.loadFile('index.html')  // Open the DevTools.  // mainWindow.webContents.openDevTools()  // Emitted when the window is closed.  mainWindow.on('closed', function () {    // Dereference the window object, usually you would store windows    // in an array if your app supports multi windows, this is the time    // when you should delete the corresponding element.    mainWindow = null  })}// This method will be called when Electron has finished// initialization and is ready to create browser windows.// Some APIs can only be used after this event occurs.app.on('ready', createWindow)// Quit when all windows are closed.app.on('window-all-closed', function () {  // On OS X it is common for applications and their menu bar  // to stay active until the user quits explicitly with Cmd + Q  if (process.platform !== 'darwin') {    app.quit()  }})app.on('activate', function () {  // On OS X it's common to re-create a window in the app when the  // dock icon is clicked and there are no other windows open.  if (mainWindow === null) {    createWindow()  }})// In this file you can include the rest of your app's specific main process// code. You can also put them in separate files and require them here.

package.json

{  "name": "electron-quick-start",  "version": "1.0.0",  "description": "A minimal Electron application",  "main": "main.js",  "scripts": {    "start": "electron .",    "packager": "electron-packager . electron-quick-start --overwrite --win=x32 --out  ./HelloWorldApp --arch=x64 --app-version=1.0.0 --electron-version=2.0.0"  },  "repository": "https://github.com/electron/electron-quick-start",  "keywords": [    "Electron",    "quick",    "start",    "tutorial",    "demo"  ],  "author": "GitHub",  "license": "CC0-1.0",  "devDependencies": {    "electron": "^2.0.0",    "electron-packager": "^12.2.0",    "electron-winstaller": "^2.7.0"  },  "dependencies": {    "electron-squirrel-startup": "^1.0.0"  }}

首先需要先安装:

npm install

在项目目录运行: 

electron-packager . electron-quick-start --overwrite --win=x32 --out  ./HelloWorldApp --arch=x64 --app-version=1.0.0 --electron-version=2.0.0

就会看到多了个:HelloWorldApp,在这个目录下的 electron-quick-start-win32-x64 目录下的 .exe 文件就是打包好的客户端文件。

转载于:https://www.cnblogs.com/e0yu/p/10918050.html

你可能感兴趣的文章
jquery.datatables.js的使用,读取后端传来的json到table中
查看>>
★宣传广告变成社会标准
查看>>
linux下配置JDK
查看>>
CSS3 改变文本选中的默认颜色
查看>>
iOS网络 POST通过JSON传数据到后台
查看>>
SpringBoot集成Spring Data JPA以及读写分离
查看>>
配置VIM显示行号
查看>>
数组指针和指针数组的区别
查看>>
android基础组建之broadcastReceiver
查看>>
Mac Eclipse SVN 安装
查看>>
configure: error: OpenSSL headers not found.
查看>>
sql server创建数据库代码模板
查看>>
绘制三维散点图
查看>>
ThreadLocal
查看>>
简单的号码抽奖程序
查看>>
流动的数据,使用 RxJS 构造复杂单页应用的数据逻辑
查看>>
理解 Java 的 GC 与 幽灵引用
查看>>
2015年个人计划
查看>>
用源码包搭建LNMP架构
查看>>
第十三讲:tapestry form组件
查看>>