electron Package 后电子成型器总是显示白色

64jmpszr  于 2022-12-08  发布在  Electron
关注(0)|答案(1)|浏览(146)

我今天开始使用Electron,当我使用electron-builder的时候,它通常会让我感到困惑。每次我运行“npm run dist”,它都会创建一个安装程序,安装程序会给予我一个空白的白色执行文件。是不是因为我的index.html在一个“site”文件夹而不是主文件夹中?Image of dependency (dist is the folder made when building)
package.json

{
  "name": "governmentmayhem",
  "version": "2.0.0",
  "description": "Government Mayhem v2 by harrup and Troxx",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "dist": "electron-builder",
    "electron-pack": "electron-builder --win -p always"
  },
  "build": {
    "appId": "com.electron.app",
    "win": {
      "target": "nsis",
      "icon": "site/assets/logo.ico"
    },
    "extraFiles": [
      "site"
    ]
  },
  "author": "harrup and Troxx",
  "license": "ISC",
  "devDependencies": {
    "electron": "^20.0.3",
    "electron-builder": "^23.3.3"
  },
  "dependencies": {
    "asar": "^3.2.0",
    "path": "^0.12.7"
  }
}

主目录. js

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

const createWindow = () => {
    const win = new BrowserWindow({
        width: 1280,
        height: 720,
        minWidth: 1280,
        minHeight: 720,
    });

    win.setAspectRatio(16/9)
    win.setMenu(null);
    win.setIcon('site/assets/logo.ico')

    const dir = path.join(__dirname, 'site/index.html');
    win.loadURL(`file://${dir}`);
}

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

app.on('ready', createWindow)
vyswwuz2

vyswwuz21#

我设法修复它只是简单地重做整个项目。不知道它是如何被修复的,但以前的项目有许多随机安装的依赖项(电子打包程序,网址和路径)。只是尝试使您的项目干净,我猜。

相关问题