forge.config.js

module.exports = {

  packagerConfig: {

    asar: true,

  },

  rebuildConfig: {},

  makers: [

    {

      name: '@electron-forge/maker-squirrel',

      config: {},

    },

    {

      name: '@electron-forge/maker-zip',

      platforms: ['darwin'],

    },

    {

      name: '@electron-forge/maker-deb',

      config: {},

    },

    {

      name: '@electron-forge/maker-rpm',

      config: {},

    },

  ],

  plugins: [

    {

      name: '@electron-forge/plugin-auto-unpack-natives',

      config: {},

    },

  ],

};

 index.html

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>WHY's  Electron Document</title>

  </head>

  <style>

    * {

      margin: 0;

      padding: 0;

    }

    html,

    body,

    #webgraph {

      width: 100%;

      height: 100%;

      overflow: hidden;

    }

  </style>

  <body>

    why 的 electron

    <button οnclick="myclick()">发送</button>

  </body>

  <script>

    function myclick(){

  console.info('click')

    }

  </script>

</html>

 main.js

// Modules to control application life and create native browser window

const { app, BrowserWindow } = require('electron')

const path = require('path')

try {

    require('electron-reloader')(module, {});

} catch (_) { }

function createWindow () {

    // Create the browser window.

    const mainWindow = new BrowserWindow({

        width: 800,

        height: 600,

        webPreferences: {

            nodeIntegration: true,

            contextIsolation: false,

            preload: path.join(__dirname, 'preload.js')

        }

    })

    // and load the index.html of the app.

    mainWindow.loadFile('index.html')

    // Open the DevTools.

    mainWindow.webContents.openDevTools()

}

// 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.whenReady().then(() => {

    createWindow()

    app.on('activate', function () {

        // 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 (BrowserWindow.getAllWindows().length === 0) createWindow()

    })

})

// Quit when all windows are closed, except on macOS. There, it's common

// for applications and their menu bar to stay active until the user quits

// explicitly with Cmd + Q.

app.on('window-all-closed', function () {

    if (process.platform !== 'darwin') app.quit()

})

// 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-forge start",

    "package": "electron-forge package",

    "make": "electron-forge make"

  },

  "repository": "https://github.com/electron/electron-quick-start",

  "keywords": [

    "Electron",

    "quick",

    "start",

    "tutorial",

    "demo"

  ],

  "author": "WHY",

  "license": "CC0-1.0",

  "devDependencies": {

    "@electron-forge/cli": "^6.4.2",

    "@electron-forge/maker-deb": "^6.4.2",

    "@electron-forge/maker-rpm": "^6.4.2",

    "@electron-forge/maker-squirrel": "^6.4.2",

    "@electron-forge/maker-zip": "^6.4.2",

    "@electron-forge/plugin-auto-unpack-natives": "^6.4.2",

    "electron": "^26.0.0",

    "electron-reloader": "^1.2.3"

  },

  "dependencies": {

    "electron-squirrel-startup": "^1.0.0"

  }

}

Debugger attached. Checking your system Debugger attached. Locating application Loading configuration Preparing native dependencies [3s] Running generateAssets hook

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部