简体   繁体   English

将 Electron 应用程序自动更新到特定(非最新)版本

[英]Auto-update Electron app to a specific (non-latest) version

I need to support a special release per user (or group), and I want each user will auto-update to a new available release only if it's suitable for him (by some kind of logic in the backend).我需要支持每个用户(或组)的特殊版本,并且我希望每个用户只有在适合他时(通过后端的某种逻辑)才会自动更新到新的可用版本。 I've tried to do so by using electron-builder's electron-updater module , and also by using Electron's autoUpdater built in module, but it seems that both always fetch the latest version when calling autoUpdater.checkForUpdates .我尝试通过使用 electron-builder 的electron-updater module以及使用Electron 的内置模块 autoUpdater来做到这一点,但似乎两者在调用autoUpdater.checkForUpdates时总是获取最新版本。

I've seen that when deploying my own update server , some of them (such as nuts) support a download url for a specific version.我看到在部署自己的更新服务器时,其中一些(例如 nuts)支持特定版本的下载 url。 as described using nuts如使用坚果所述

Specific version for detected platform: http://download.myapp.com/download/1.1.0检测平台的具体版本:http: //download.myapp.com/download/1.1.0

but there seem to be no support to request a specific version in the app itself using autoUpdater.但似乎不支持使用 autoUpdater 在应用程序本身中请求特定版本。

summarizing all this up: How can I achieve auto-update to a specific release other than latest?总结这一切:我怎样才能自动更新到特定版本而不是最新版本?

The solution for me was channels .对我来说解决方案是channels

appUpdater.channel (getter and setter) appUpdater.channel (getter 和 setter)

Define the channel which the Auto-Updater will follow (see the auto-update with channels tutorial) using appUpdater.channel = 'beta' or get the current channel with currentChannel = appUpdater.channel .使用appUpdater.channel = 'beta'或使用currentChannel = appUpdater.channel获取当前频道,定义自动更新程序将遵循的频道(请参阅带频道的自动更新教程)。

Note that channels are not supported when using GitHub as a provider (for now), as described in electron-builder autoUpdate documentation :请注意,如electron-builder autoUpdate 文档中所述,使用 GitHub 作为提供者时(目前)不支持频道:

channel String - Get the update channel. channel String - 获取更新频道。 Not applicable for GitHub .不适用于 GitHub Doesn't return channel from the update configuration, only if was previously set.不从更新配置返回通道,只有在之前设置的情况下。

You can set the channel name to anything, and can even dynamically (if needed) direct your users to pull updates from that channel.您可以将频道名称设置为任何内容,甚至可以动态(如果需要)指示您的用户从该频道中提取更新。

You can also edit the {your-channel-name}.latest file manually and add parameters that will help you determine whether the current "asking for update" user should consume the certain version (in the update-available event from the updateInfo parameter for example).您还可以手动编辑{your-channel-name}.latest文件并添加参数,这些参数将帮助您确定当前“请求更新”用户是否应该使用特定版本(在updateInfo参数的update-available事件中例子)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM