Мое электронное приложение не запускается без регистрации - PullRequest
1 голос
/ 08 ноября 2019

Так что я пытаюсь сделать электронное приложение с угловым (версия Typescript), и оно вообще не запустится, я встроил Electron-log, который ничего не делает (поэтому я думаю, что он вообще не запускается).

const path = require('path');
const url = require('url');
const log = require('electron-log');
log.transports.file.level = 'debug';
log.transports.file.format = '{h}:{i}:{s}:{ms} {text}';
log.transports.file.file = __dirname + './log.txt';
log.transports.file.streamConfig = { flags: 'w'};
log.info('message');
// Keep a global reference of the window object, if we don't the window will be closed
// automagically when the JS object is Garbage Collected. (GC from here on out)

let win;
try {
  const createWindow = () => {
    // set timeout to render the window not until the Angular compiler is ready to show the project
    //create the browser window
    win = new BrowserWindow({
      width: 800,
      height: 600,
      icon: path.join(__dirname, 'favicon.ico'),
    });

    //and load the app
    win.loadURL(url.format({
      pathname: path.join(__dirname, 'resources/app/angular-flask/index.html'),
      protocol: 'file:',
      slashes: true
    }));

    // Emitted when the window is closed
    win.on('closed', () => {
      // Dereference the window object
      win = null;
    });
  };

// This method will be called when Electron has finished initialization and is ready to
// create browser windows . Some API's can only be used after this event happens.
  app.on('ready', createWindow);

// Quit when all windows are closed
  app.on('windows-all-closed', () => {
    // On macOS applications might stay active untill user quits with cmd + Q
    if (process.platform !== 'darwin') {
      app.quit();
    }
  });


  app.on('activate', () => {
    // On macOS sometimes a window is recreated when the dock icon is clicked and there are no other
    // windows open
    if (win === null) {
      createWindow();
    }
  });
} catch(e) {

  log.error(e)
}

Выше приведен мой код электронного производства, также доступный на pastebin Может кто-нибудь объяснить, почему это может произойти, и предложить решение?

РЕДАКТИРОВАТЬ: Этоне работал, прежде чем я интегрировал электронный журнал. Кроме того, угловой интерфейс работает, когда я запускаю его через облегченный сервер npx.

EDIT2: Вот мой Package.json и мой обновленный код main.js Electron.prod.js Также я использую электронный упаковщик.

Ответы [ 2 ]

0 голосов
/ 14 ноября 2019

Итак, чтобы исправить мою проблему, я вернулся к учебнику Я проследил и проверил использованный там файл package.json, медленно добавив и обновив все, что у меня было, в этом package.json. Когда он все еще работал, я портировал его на свой собственный package.json, и с этим он работал.

0 голосов
/ 08 ноября 2019

Похоже, app не определено.

Можете ли вы попробовать добавить следующие строки в начале вашего файла.

const electron = require('electron');
const app = electron.app;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...