Mac中的电子应用程序渲染问题

时间:2020-06-16 12:33:20

标签: javascript reactjs electron macos-catalina

我已经在窗户上开发了电子应用程序。在Windows和Linux上运行正常。但是在MacOS Catalina中给出了错误。

当我执行 npm start 时,应用程序启动,但是所有元素都被禁用。在网络中,它显示ENABLE JAVASCRIPT。

我是电子初学者。请让我知道Mac是否需要一些额外的配置,或者我出了问题。

这是我的electron.js文件

const { app, BrowserWindow } = require('electron');
const path = require("path");
const isDev = require("electron-is-dev");
let mainWindow;

function createWindow () {
  // Create the browser window.
  mainWindow = new BrowserWindow({
    width: 1200,
    height: 800,
    icon: ""
  });

  // and load the index.html of the app.
  mainWindow.loadURL(
      isDev ? "http://localhost:3000" : `file://${path.join(__dirname, "../build/index.html")}`
  );
  mainWindow.on("closed", () => (mainWindow = null));

  // 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.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('certificate-error', (event, webContents, url, error, certificate, callback) => {
  // On certificate error we disable default behaviour (stop loading the page)
  // and we then say "it is all fine - true" to the callback
  event.preventDefault();
  callback(true);
});

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 (mainWindow === 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.

0 个答案:

没有答案
相关问题