Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public startup(): void {
// hook up to GH
autoUpdater.setFeedURL({
repo: 'BotFramework-Emulator',
owner: 'Microsoft',
provider: 'github'
});
// we only want to grab v4 if it is a release
autoUpdater.allowPrerelease = false;
// prompt user explicitly to download
autoUpdater.autoDownload = false;
// mute built-in logger
autoUpdater.logger = null;
autoUpdater.on('checking-for-update', () => {
this.emit('checking-for-update');
});
!function updateHandle () {
let message = {
error: '检查更新出错',
checking: '正在检查更新……',
updateAva: '检测到新版本,正在下载……',
updateNotAva: '现在使用的就是最新版本,不用更新',
};
const uploadUrl = "http://192.168.3.8:3000/download/"; // 下载地址,不加后面的**.exe
autoUpdater.setFeedURL(uploadUrl);
autoUpdater.on('error', function (error) {
console.log(autoUpdater.error);
sendUpdateMessage("error", error)
});
autoUpdater.on('checking-for-update', function () {
sendUpdateMessage("checking-for-update", message.checking)
});
autoUpdater.on('update-available', function (info) {
sendUpdateMessage("update-available", info)
});
autoUpdater.on('update-not-available', function (info) {
sendUpdateMessage("update-not-available", message.updateNotAva)
});
// 更新下载进度事件
autoUpdater.on('download-progress', function (progressObj) {
function updateHandler(mainWindow){
let message = {
error: '检查更新出错!',
checking: '正在检查更新...',
updateAva: '检测到新版本,正在下载...',
updateNotAva: '当前为最新版本!',
downloaded: '下载已完成!'
};
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater.setFeedURL(uploadUrl);
autoUpdater.on('error', (error) => {
sendUpdateMessage(mainWindow, message.error)
return new Error(error)
});
autoUpdater.on('checking-for-update', () => {
sendUpdateMessage(mainWindow, message.checking)
});
autoUpdater.on('update-available', (info) => {
sendUpdateMessage(mainWindow, message.updateAva)
});
autoUpdater.on('update-not-available', (info) => {
sendUpdateMessage(mainWindow, message.updateNotAva)
});
// 更新下载进度事件
autoUpdater.on('download-progress', (progressObj) => {
globalShortcut.register('Escape', () => {
if (tray.window && tray.window.isFocused()) {
tray.window.blur(); // Need to reopen in windowOS
tray.hideWindow(); // Need to reopen in macOS
}
});
});
tray.on('hide', () => {
/**
* If you don't this, Escape key doesn't active another application.
*/
globalShortcut.unregister('Escape');
});
autoUpdater.setFeedURL({
provider: 'github',
owner: 'hyunmoahn',
protocol: 'https',
repo: 'tiny-timer',
});
checkUpdate() {
const data = {
provider: 'github',
owner: 'zxch3n',
repo: 'PomodoroLogger'
} as GithubOptions;
autoUpdater.setFeedURL(data);
autoUpdater.autoDownload = false;
autoUpdater.checkForUpdates();
}
public async checkForUpdates(userInitiated: boolean): Promise {
const settings = getSettings().framework;
this.allowPrerelease = !!settings.usePrereleases;
this.autoDownload = !!settings.autoUpdate;
this._userInitiated = userInitiated;
electronUpdater.setFeedURL({
repo: this.repo,
owner: 'Microsoft',
provider: 'github',
});
try {
await electronUpdater.checkForUpdates();
TelemetryService.trackEvent('update_check', {
auto: !userInitiated,
prerelease: this.allowPrerelease,
});
} catch (e) {
throw new Error(`There was an error while checking for the latest update: ${e}`);
}
}