В провайдерах папок в electronic.service.ts у меня есть код:
import { Injectable } from '@angular/core';
// If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, webFrame, remote, BrowserWindow } from 'electron';
import * as childProcess from 'child_process';
import * as fs from 'fs';
@Injectable()
export class ElectronService {
ipcRenderer: typeof ipcRenderer;
webFrame: typeof webFrame;
remote: typeof remote;
childProcess: typeof childProcess;
win: BrowserWindow;
fs: typeof fs;
constructor() {
// Conditional imports
if (this.isElectron()) {
this.ipcRenderer = window.require('electron').ipcRenderer;
this.webFrame = window.require('electron').webFrame;
this.remote = window.require('electron').remote;
this.win = window.require('electron').remote.getCurrentWindow();
this.childProcess = window.require('child_process');
this.fs = window.require('fs');
}
}
isElectron = () => {
return window && window.process && window.process.type;
}
}
В компоненте у меня есть метод:
import { ElectronService } from '../../providers/electron.service';
toggleFullScreen() {
const flag = !this.electron.win.isFullScreen();
this.electron.win.show();
this.electron.win.setFullScreen(flag);
this.storeService.isFullScreen = this.electron.win.isFullScreen();
}
Когда я пишу в своем проекте
win: BrowserWindow;
Я получаю ошибку Невозможно найти имя 'BrowserWindow'.Что случилось?Я импортировал {ipcRenderer, webFrame, remote, BrowserWindow} из «электрона»;Вместо этого я не могу переписать
win: typeof BrowserWindow;
, потому что в методе toggleFullScreen () не будет возможности метод isFullScreen (), show (), setFullScreen ().Приложение работает хорошо в режиме разработки, но у меня есть ошибка, и я не могу создать исполняемый файл.Как это исправить?