最近公司研发了一套内部使用的办公系统包括移动端+PC端,系统是基于javaWeb开发的,PC端要求制做一个可安装文件以方便员工使用(url路径记着有些麻烦),html
因而想到了electron。因为以前用过因此window的exe包很容易就生成了,到了mac时候出现了一些问题........因此记录下过程.java
简单介绍下:node
Electron是由Github开发,用HTML,CSS和JavaScript来构建跨平台桌面应用程序的一个开源库。 Electron经过将Chromium和Node.js合并到同一个运行时环境中,并将其打包为Mac,Windows和Linux系统下的应用来实现这一目的。web Electron于2013年做为构建Github上可编程的文本编辑器Atom的框架而被开发出来。这两个项目在2014春季开源。npm |
由于是基于node的,因此预先要安装node环境,具体安装就不说了........编程
1. 快速生成新项目json
npm init 这时候在目录下会生成.json文件,个人文件package.jsonwindows
{ |
2.安装electron框架
npm install --save-dev electron
3.建立main.js
const electron = require('electron') const path = require('path') // Keep a global reference of the window object, if you don't, the window will function createWindow () { // and load the index.html of the app. // Open the DevTools. // Emitted when the window is closed. // This method will be called when Electron has finished // Quit when all windows are closed. app.on('activate', function () { |
4.最后直接执行命令
npm run-script package
ok,当前路径下会生成一个dist的文件夹.app应用已经生成