+
95
-

uniapp如何开发electron桌面程序?

uniapp如何开发electron桌面程序?

网友回复

+
15
-

自己打包h5网页,然后把发布的h5放到electron目录自己去打包。具体步骤如下:

1、安装electron

cnpm install electron -g

2、安装electron-packager

cnpm install electron-packager -g

3、hbuilder中对uniapp的manifest.json修改

4、hbuilder中运行H5打包

5、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: 'f...

点击查看剩余70%

我知道答案,我要回答