我正在使用角电子创建桌面应用程序
我使用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)
怎么了?
发布于 2019-08-25 02:46:02
是remote.require('electron-updater').autoUpdater.checkForUpdates()
https://stackoverflow.com/questions/57642667
复制相似问题