Installing Electron cnpm install electron -g Install electron-packager cnpm install electron-packager -g uniapp's manifest.json modification H5 packaging Create package.json and main.js in the H5 folder Create a new package.json { "name" : "app-name", "version" : "0.1.0", "main" : "main.js" } Create main.js const {app, BrowserWindow} = require('electron') const path = require('path') const url = require('url') // Keep a global reference to 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. Pack It is recommended to use cmd. I have encountered some problems using powershell and git hash. Press shift+right click on the root directory, or cd to your directory. Enter the H5 directory using the cmd command line and enter the packaging command electron-packager . Executable file name --win --out packaged folder name --arch=x64 or 32-bit --electron-version version number (not your h5 version number, but the electron version number) --overwrite --ignore=node_modules Packaging Example electron-packager . MyApp --win --out MyApp --arch=x64 --electron-version 1.0.0 --overwrite --ignore=node_modules refer to https://ext.dcloud.net.cn/plugin?id=2905 This concludes this article about the steps to package the uniapp project as a desktop application. For more relevant uniapp project packaging content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
Classification of CSS styles 1. Internal style --...
This article example shares the specific code of ...
This article example shares the specific code of ...
Note: It is recommended that the virtual machine ...
MySQL supports hash and btree indexes. InnoDB and...
Docker installation 1. Requirements: Linux kernel...
question The code has no prompt: Many non-front-e...
This article example shares the specific code of ...
Triggers can cause other SQL code to run before o...
<br />Original text: http://blog.rexsong.com...
I'm very happy. When encountering this proble...
There are four types of positioning in CSS, which...
The process of installing MySQL database and conf...
1. Add a user . First, use the adduser command to...
Similar to the code hosting service provided by G...