如何在主渲染进程外调用 electron-updater

How to call electron-updater outside the main rendering process

我正在使用 angular-electron
创建桌面应用程序 我正在使用 electron-builder 打包支持 electron-updater

的自动更新

通过从入口点调用函数,一切正常 main.ts

import {autoUpdater} from 'electron-updater';
autoUpdater.checkForUpdatesAndNotify();

我想从 angular 调用 checkForUpdatesAndNotify 以便用户可以通过单击按钮手动检查更新。
首先,我尝试了与 main.ts 中相同的方法,但找不到该方法。所以我试图通过 remote 获取它,但我仍然遇到错误。

import { remote } from 'electron';

@Injectable()
export class UpdaterService {
  console.log('try update');
  remote.require('electron-updater').checkForUpdatesAndNotify();
  console.log('success');
}

uncaught TypeError: remote.require(...).checkForUpdatesAndNotify is not a function
    at SafeSubscriber._next (updater.service.ts:17)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:192)
    at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:130)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:76)
    at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at MergeMapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/mergeMap.js.MergeMapSubscriber.notifyNext (mergeMap.js:84)
    at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:15)
    at InnerSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)
    at ThrowIfEmptySubscriber.push../node_modules/rxjs/_esm5/internal/operators/throwIfEmpty.js.ThrowIfEmptySubscriber._next (throwIfEmpty.js:32)
    at ThrowIfEmptySubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:53)

怎么了?

remote.require('electron-updater').autoUpdater.checkForUpdates()