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

index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>百度</title>
<style type="text/css">
*{margin:0px; padding: 0px;}
#iframe{width: 100%; height: 100%; position: absolute; top:0px; right:0px; bottom:0px; left:0px;}
</style>
</head>
<body>
<iframe id="iframe" frameborder="0" src="https://www.baidu.com/"></iframe>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</body>
</html>
main.js
// Modules to control application life and create native browser window
const {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 mainWindow function 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 文件就是打包好的客户端文件。
electron---项目打包的更多相关文章
- electron 项目的打包方式,以及 jquery 插件的修改使用
< 一 > 应用打包 1,首先确定安装了 node 和 npm 2,全局安装打包依赖 => npm i electron-packager -g 3,打包命令 electron-p ...
- electron教程(四): 使用electron-builder或electron-packager将项目打包为可执行桌面程序(.exe)
我的electron教程系列 electron教程(一): electron的安装和项目的创建 electron教程(二): http服务器, ws服务器, 子进程管理 electron教程(三): ...
- Electron – 基础学习(3): 项目打包成exe桌面应用 之electron-builder
前次用 electron-packager 打包成功,这次改用 electron-builder 打包,然后根据项目中实际需要进行选择使用. 第一步:全局安装 electron-builder,便于系 ...
- Electron+Vue – 基础学习(2): 项目打包成exe桌面应用
项目创建完成,启动正常,接下来就是项目打包了.将测试Demo打包成exe桌面应用,点击exe文件,运行项目. 书接上文,创建项目有三种方式 Git拷贝.直接创建:通过electron社群提供的命令行工 ...
- Electron – 基础学习(2): 项目打包成exe桌面应用 之electron-packager
项目创建完成,启动正常,接下来就是项目打包了.将测试Demo打包成exe桌面应用,点击exe文件,运行项目. 书接上文,创建项目有三种方式 Git拷贝.直接创建:通过electron社群提供的命令行工 ...
- react-electron 项目打包体积尽可能减小的方法
当一个react-electron项目做好之后就可以开始进行打包,首先就是打包react,这个自然不用多说,不过事先要记住一点,项目目录主进程文件main.js最好放在根目录,再执行打包命令 npm ...
- 图解使用VS的安装项目打包程序
背景 这段时间一直在做客户端程序的打包程序,遇到各种坑.因为以前没有任何这方面的经验,历经各种折腾,费尽九牛二虎之力总算是完成了. 虽然没有太多技术含量,但是因为挺繁琐的,所以还是在此记录一下. 由于 ...
- 将 java 项目打包成可运行的 jar 包(main 函数带参数),并上传到 linux 服务器上运行
一.概述 java项目有两种架构,一种是 B/S 架构的,一种是 C/S 架构的. 对于 B/S 架构来说,我们常见的 java ee 即是 B/S 架构,通常,开发人员会在本地进行开发,然后将项目打 ...
- maven 项目打包 及window下部署到tomcat
1.maven项目打包 2.将war文件拷贝到tomcat目录webapps下(不要再建目录)3.将必要的jar文件拷贝到tomcat目录libx下 war包 或jar 包 会生成到项目所在路径 的t ...
- Storm系列(三):创建Maven项目打包提交wordcount到Storm集群
在上一篇博客中,我们通过Storm.Net.Adapter创建了一个使用Csharp编写的Storm Topology - wordcount.本文将介绍如何编写Java端的程序以及如何发布到测试的S ...
随机推荐
- 关于Spring IOC (DI-依赖注入)你需要知道的一切
<Spring入门经典>这本书无论对于初学者或者有经验的工程师还是很值一看的,最近花了点时间回顾了Spring的内容,在此顺带记录一下,本篇主要与spring IOC相关 ,这篇博文适合初 ...
- CentOS 7源码安装MYSQL-5.6
一. 环境准备 Linux CentOS7.3系统一台主机即可: MYSQL官网:https://www.mysql.com/ MYSQL软件下载:http://ftp.kaist.ac.kr/mys ...
- E. Little Pony and Expected Maximum(组合期望)
题目描述: Little Pony and Expected Maximum time limit per test 1 second memory limit per test 256 megaby ...
- python测试开发django-rest-framework-63.基于函数的视图(@api_view())
前言 上一篇讲了基于类的视图,在REST framework中,你也可以使用常规的基于函数的视图.它提供了一组简单的装饰器,用来包装你的视图函数, 以确保视图函数会收到Request(而不是Djang ...
- python变量选中后高亮显示
file>settings>editor>color scheme>general>code>identifier under caret>backgroun ...
- 关于吲哚美辛(NSAIDS)对袢利尿药的影响。
吲哚美辛 一方面是解热镇痛抗炎药,是最强的PG合成酶抑制药之一,另一方面,吲哚美辛可于袢利尿药如呋塞米.依他尼酸竞争近曲小管有机酸分泌途径,可以影响后者的排泄和作用. 吲哚美辛可以抑制前列腺素的合成, ...
- SpringBoot第三节(thymeleaf的配置与SpringBoot注解大全)
Springboot默认是不支持JSP的,默认使用thymeleaf模板引擎.所以这里介绍一下Springboot使用Thymeleaf的实例以及遇到的问题. 1.配置与使用 1.1:在applica ...
- 过滤器的API
1.API a.生命周期(和servletcontext相似): (1)创建:服务器启动的时候创建(执行init方法). (2)销毁:服务器关闭的时候销毁(执行destory方法). b.filter ...
- GoCN每日新闻(2019-10-03)
GoCN每日新闻(2019-10-03) 国庆专辑:GopherChina祝大家国庆节快乐 GoCN每日新闻(2019-10-03) 1. 垃圾回收器如何监控你的应用程序 https://medium ...
- CSS — BEM 命名规范
推荐阅读: https://juejin.im/post/5b925e616fb9a05cdd2ce70d 1 什么是 BEM 命名规范 Bem 是块(block).元素(element).修饰符(m ...