【问题标题】:shows empty blank screen when creating electron app of existing angular app创建现有角度应用程序的电子应用程序时显示空白屏幕
【发布时间】:2019-08-24 12:49:44
【问题描述】:

我已经使用 Angular 6 开发了一个应用程序。现在我想用 Electron 构建桌面应用程序。我已按照所有步骤进行构建。当我运行“npm run electron-build”时,它会进行构建并显示空的白色窗口,它什么也不显示。我什至不明白是什么问题。 提前谢谢你。

// main.js

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

let win;

function createWindow () {
  win = new BrowserWindow({
    width: 600, 
    height: 600,
    backgroundColor: '#ffffff',
    icon: `file://${__dirname}/dist/assets/logo.png`
  })


  win.loadURL(`file://${__dirname}/dist/index.html`)

  win.on('closed', function () {
    win = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', function () {
  if (win === null) {
    createWindow()
  }
})

// package.json

"name": "demo-electron",
"version": "0.0.0",
"main": "main.js",
"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e",
  "electron": "electron .",
  "electron-build": "ng build --prod && electron ."
}
index.html

<base href="./">

我创建了一个 main.js,对 index.html 和 package.json 进行了更改。 系统配置 操作系统:Linux x64(Ubuntu 16), 节点 8.11.1 角 CLI:6.2.9 角度:6.1.10.

【问题讨论】:

    标签: javascript angular react-native vuejs2 electron


    【解决方案1】:

    尝试检查您在 dist 文件夹中的 index.html 位置并相应地更新 win.loadurl 路径。为我工作

    【讨论】:

      【解决方案2】:

      使用下面的命令

      1) npm install nw --nwjs_build_type=sdk

      如果上面的命令不起作用

      2)yarn add --dev nw@0.23.6-sdk-1

      【讨论】:

        猜你喜欢
        • 2020-05-14
        • 1970-01-01
        • 1970-01-01
        • 2022-11-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-04
        相关资源
        最近更新 更多