我使用angular-electron创建了一个桌面应用程序,
我electron-builder
用于打包支持使用电子更新器自动更新
通过从入口点调用函数,一切正常main.ts
import {autoUpdater} from 'electron-updater';
autoUpdater.checkForUpdatesAndNotify();
我想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)
怎么了 ?