uniapp项目打包为桌面应用的方法步骤
作者:China_Lzw 发布时间:2024-04-29 13:16:04
标签:uniapp,打包,桌面应用
安装electron
cnpm install electron -g
安装electron-packager
cnpm install electron-packager -g
uniapp的manifest.json修改
H5打包
H5文件夹下新建package.json和main.js
新建package.json
{
"name" : "app-name",
"version" : "0.1.0",
"main" : "main.js"
}
新建main.js
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
// 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 win
function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
// Open the DevTools.
// win.webContents.openDevTools()
// Emitted when the window is closed.
win.on('closed', () => {
// 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.
win = 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', () => {
// On macOS 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', () => {
// On macOS 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 (win === 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.
打包
建议使用cmd,本人使用powershell和git hash有踩坑
按shift+右键根目录,或者cd 你的目录
cmd命令行进入H5目录,输入打包命令
electron-packager . 可执行文件的文件名 --win --out 打包成的文件夹名 --arch=x64位还是32位 --electron-version版本号(不是你的h5版本号,是electron版本号) --overwrite --ignore=node_modules
打包示例
electron-packager . MyApp --win --out MyApp --arch=x64 --electron-version 1.0.0 --overwrite --ignore=node_modules
参考
https://ext.dcloud.net.cn/plugin?id=2905
https://www.cnblogs.com/shangrao/p/14661884.html
来源:uniapp项目打包为桌面应用


猜你喜欢
- 对于什么是好设计,一万个人那里至少有一万零一个答案。每个人都有自己的答案,有的人还不止一个答案。老师说,一定要在设计里灌注自己的思想,有了自
- 装完sql server 2005后却没有找到ms的示例数据库northwind 后来查看安装光盘发现sql server 2005种只有a
- 一 卷积操作:在pytorch搭建起网络时,大家通常都使用已有的框架进行训练,在网络中使用最多就是卷积操作,最熟悉不过的就是torch.nn
- 经过漫长的等待,近日,微软终于发布了Silverlight 2正式版的发布不仅让微软有了更多和Flash叫板的机会,同时也将RIA(Rich
- 组件之间传值/调用方法的几种方式(一)父组件向子组件传值==props1.在父组件中使用子组件的地方绑定数据<children :me
- 一、程序的组织结构任何简单的或者复杂的算法都可以由顺序结构、选择结构和循环结构这三种基本结构组合而成二、顺序结构程序从上到下顺序地执行代码,
- 1.删除序列相同元素并保持顺序如果仅仅就是想消除重复元素,通常可以简单的构造一个集合,利用集合之间元素互不相同的特性就可以消除重复,但是这种
- 调用JSON.stringify将对象转为对应的字符串时,如果包含时间对象,时间对象会被转换为国家标准时间(ISO),而不是当前国家区域的时
- 本文实例讲述了C#使用Socket快速判断数据库连接是否正常的方法。分享给大家供大家参考。具体分析如下:大家在做项目的时候,一般都是和数据库
- 我还我还是有必要改一个标题,(原题为 让你想不通的"bug"),以免有同学误会。先看代码。看完之后我有个问题提问一下,看
- TensorFlow是一个采用数据流图(data flow graphs),用于数值计算的开源软件库。节点(Nodes)在图中表示数学操作,
- a=1 #1 为对象,def func(x): print('x的地址{}'.form
- 最近在工作遇到一个难题。我所在的测试组有一套PC软件前端自动化工程,在进行自动化测试时,需要在一台古老的xp机器上运行,但这台古老的xp机器
- 本文实例讲述了PHP完全二叉树定义与实现方法。分享给大家供大家参考,具体如下:若设二叉树的深度为h,除第 h 层外,其它各层 (1~h-1)
- Python中一切都是对象。类提供了创建新类型对象的机制。这篇教程中,我们不谈类和面向对象的基本知识,而专注在更好地理解Python面向对象
- 对于手动管理内存的语言,比如 C/C++,调用著名的malloc和new函数可以在堆上分配一块内存,这块内存的使用和销毁的责任都在程序员。一
- 本文实例讲述了python自动化测试之setUp与tearDown的用法,分享给大家供大家参考。具体如下:实例代码如下:class Roma
- 下一步是将新创建的应用程序与项目相关联。为此,您需要编辑 myproj 文件夹中的 settings.py 文件,将字符串“myproj.m
- 引言这两天遭遇了手机号登录相关的压测需求,算是比较棘手的。主要原因有两个,第一:之前从来没有接手过这个项目,不熟悉各种规则;第二:数据量偏大
- 一.Sobel算子Sobel算子是一种用于边缘检测的离散微分算子,它结合了高斯平滑和微分求导。该算子用于计算图像明暗程度近似值,根据图像边缘