uniapp打包成window

小灰灰 2022-11-01 01:39 292阅读 0赞

在这里插入图片描述

在这里插入图片描述
main.js

  1. const { app, BrowserWindow} = require('electron')
  2. const path = require('path')
  3. const url = require('url')
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. let win
  7. function createWindow () {
  8. // Create the browser window.
  9. // win = new BrowserWindow({width: 800, height: 600})
  10. win = new BrowserWindow({ fullscreen: true})
  11. // and load the index.html of the app.
  12. win.loadURL(url.format({
  13. pathname: path.join(__dirname, 'index.html'),
  14. protocol: 'file:',
  15. slashes: true
  16. }))
  17. // Open the DevTools.
  18. // win.webContents.openDevTools()
  19. // Emitted when the window is closed.
  20. win.on('closed', () => {
  21. // Dereference the window object, usually you would store windows
  22. // in an array if your app supports multi windows, this is the time
  23. // when you should delete the corresponding element.
  24. win = null
  25. })
  26. }
  27. // This method will be called when Electron has finished
  28. // initialization and is ready to create browser windows.
  29. // Some APIs can only be used after this event occurs.
  30. app.on('ready', createWindow)
  31. // Quit when all windows are closed.
  32. app.on('window-all-closed', () => {
  33. // On macOS it is common for applications and their menu bar
  34. // to stay active until the user quits explicitly with Cmd + Q
  35. if (process.platform !== 'darwin') {
  36. app.quit()
  37. }
  38. })
  39. app.on('activate', () => {
  40. // On macOS it's common to re-create a window in the app when the
  41. // dock icon is clicked and there are no other windows open.
  42. if (win === null) {
  43. createWindow()
  44. }
  45. })
  46. // In this file you can include the rest of your app's specific main process
  47. // code. You can also put them in separate files and require them here.

package.json

  1. {
  2. "name" : "app-name",
  3. "version" : "0.1.0",
  4. "main" : "main.js"
  5. }

在这里插入图片描述

  1. electron-packager . hikari-cloud-desktop --win --out hikari-cloud-desktop --arch=x64 --electron-version 1.4.14 --overwrite --ignore=node_modules

发表评论

表情:
评论列表 (有 0 条评论,292人围观)

还没有评论,来说两句吧...

相关阅读

    相关 uniapp打包 app

    uniapp 云打包 app,记录一下 1、注册 dcloud 开发者 首先需要注册一个 dcloud 开发者的账号 dcloud开发者中心:[https://dev.d