electron updater.Class.AppUpdater
Electron-Builder / electron-updater / AppUpdater
继承自¶
TypedEmitter
<AppUpdaterEvents
,this
>
被扩展自¶
构造函数¶
new AppUpdater()¶
protected
new AppUpdater(options
,app
?):AppUpdater
参数¶
• options: undefined
| null
| AllPublishOptions
• app?: AppAdapter
返回值¶
覆盖¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).constructor
属性¶
_isUpdateSupported¶
protected
_isUpdateSupported:VerifyUpdateSupport
_logger¶
protected
_logger:Logger
=console
allowDowngrade¶
allowDowngrade:
boolean
=false
是否允许版本降级(当用户从 beta 频道想要返回到稳定频道时)。
仅当频道不同时才考虑(语义版本控制方面的预发布版本组件)。
默认值¶
false
allowPrerelease¶
allowPrerelease:
boolean
=false
仅 GitHub 提供程序。 是否允许更新到预发布版本。如果应用程序版本包含预发布组件(例如 0.12.1-alpha.1
,此处 alpha
是预发布组件),则默认为 true
,否则为 false
。
如果为 true
,则允许降级(allowDowngrade
将设置为 true
)。
app¶
protected
readonly
app:AppAdapter
autoDownload¶
autoDownload:
boolean
=true
是否在找到更新时自动下载更新。
默认值¶
true
autoInstallOnAppQuit¶
autoInstallOnAppQuit:
boolean
=true
是否在应用程序退出时自动安装下载的更新(如果之前未调用 quitAndInstall
)。
默认值¶
true
autoRunAppAfterInstall¶
autoRunAppAfterInstall:
boolean
=true
当以非静默模式运行安装程序时,是否在完成安装后运行应用程序。
默认值¶
true
currentVersion¶
readonly
currentVersion:SemVer
当前应用程序版本。
disableDifferentialDownload¶
disableDifferentialDownload:
boolean
=false
仅限 NSIS 禁用差异下载并始终执行安装程序的完整下载。
默认值¶
false
disableWebInstaller¶
disableWebInstaller:
boolean
=false
Web 安装程序文件可能没有签名验证,此开关可防止加载它们,除非需要。
当前为 false 以防止破坏当前 API,但它应该在允许破坏性更改的某个时候更改为默认 true。
默认值¶
false
downloadedUpdateHelper¶
protected
downloadedUpdateHelper:null
|DownloadedUpdateHelper
=null
forceDevUpdateConfig¶
forceDevUpdateConfig:
boolean
=false
允许开发人员强制更新程序在“dev”模式下工作,查找“dev-app-update.yml”而不是“app-update.yml” Dev:path.join(this.app.getAppPath(), "dev-app-update.yml")
Prod:path.join(process.resourcesPath!, "app-update.yml")
默认值¶
false
fullChangelog¶
fullChangelog:
boolean
=false
仅 GitHub 提供程序。 获取所有发行说明(从当前版本到最新版本),而不仅仅是最新的。
默认值¶
false
requestHeaders¶
requestHeaders:
null
|OutgoingHttpHeaders
=null
请求头。
signals¶
readonly
signals:UpdaterSignal
为了类型安全,您可以使用信号,例如 autoUpdater.signals.updateDownloaded(() => {})
而不是 autoUpdater.on('update-available', () => {})
stagingUserIdPromise¶
protected
readonly
stagingUserIdPromise:Lazy
<string
>
updateInfoAndProvider¶
protected
updateInfoAndProvider:null
|UpdateInfoAndProvider
=null
访问器¶
channel¶
get
channel():null
|string
获取更新频道。不返回更新配置中的 channel
,仅当之前设置过时才返回。
set
channel(value
):void
设置更新频道。覆盖更新配置中的 channel
。
allowDowngrade
将自动设置为 true
。如果此行为不适合您,请在此之后简单地显式设置 allowDowngrade
。
参数¶
• value: null
| string
返回值¶
null
| string
isUpdateSupported¶
get
isUpdateSupported():VerifyUpdateSupport
允许开发人员覆盖用于确定是否支持更新的默认逻辑。默认逻辑使用 semver
包将 UpdateInfo
最小系统版本与 os.release()
进行比较
set
isUpdateSupported(value
):void
参数¶
• value: VerifyUpdateSupport
返回值¶
logger¶
get
logger():null
|Logger
日志记录器。您可以传递 electron-log、winston 或另一个具有以下接口的日志记录器:{ info(), warn(), error() }
。如果您想禁用日志记录功能,请将其设置为 null
。
set
logger(value
):void
参数¶
• value: null
| Logger
返回值¶
null
| Logger
netSession¶
get
netSession():Session
返回值¶
Session
方法¶
addAuthHeader()¶
addAuthHeader(
token
):void
显式向请求头添加身份验证令牌的快捷方式
参数¶
• token: string
返回值¶
void
addListener()¶
addListener<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).addListener
checkForUpdates()¶
checkForUpdates():
Promise
<null
|UpdateCheckResult
>
询问服务器是否有更新。
返回值¶
Promise
<null
| UpdateCheckResult
>
如果更新程序被禁用,则为 null,否则为有关最新版本的信息
checkForUpdatesAndNotify()¶
checkForUpdatesAndNotify(
downloadNotification
?):Promise
<null
|UpdateCheckResult
>
参数¶
• downloadNotification?: DownloadNotification
返回值¶
Promise
<null
| UpdateCheckResult
>
differentialDownloadInstaller()¶
protected
differentialDownloadInstaller(fileInfo
,downloadUpdateOptions
,installerPath
,provider
,oldInstallerFileName
):Promise
<boolean
>
参数¶
• fileInfo: ResolvedUpdateFileInfo
• downloadUpdateOptions: DownloadUpdateOptions
• installerPath: string
• provider: Provider
<any
>
• oldInstallerFileName: string
返回值¶
Promise
<boolean
>
dispatchError()¶
protected
dispatchError(e
):void
参数¶
• e: Error
返回值¶
void
dispatchUpdateDownloaded()¶
protected
dispatchUpdateDownloaded(event
):void
参数¶
• event: UpdateDownloadedEvent
返回值¶
void
doDownloadUpdate()¶
abstract
protected
doDownloadUpdate(downloadUpdateOptions
):Promise
<string
[]>
参数¶
• downloadUpdateOptions: DownloadUpdateOptions
返回值¶
Promise
<string
[]>
downloadUpdate()¶
downloadUpdate(
cancellationToken
):Promise
<string
[]>
手动开始下载更新。如果 autoDownload
选项设置为 false
,则可以使用此方法。
参数¶
• cancellationToken: CancellationToken
= ...
返回值¶
Promise
<string
[]>
下载文件的路径。
emit()¶
emit<
U
>(event
, …args
):boolean
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• …args: Parameters
<AppUpdaterEvents
[U
]>
返回值¶
boolean
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).emit
eventNames()¶
eventNames<
U
>():U
[]
类型参数¶
• U extends keyof AppUpdaterEvents
返回值¶
U
[]
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).eventNames
executeDownload()¶
protected
executeDownload(taskOptions
):Promise
<string
[]>
参数¶
• taskOptions: DownloadExecutorTask
返回值¶
Promise
<string
[]>
getFeedURL()¶
getFeedURL():
undefined
|null
|string
返回值¶
undefined
| null
| string
getMaxListeners()¶
getMaxListeners():
number
返回值¶
number
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).getMaxListeners
getUpdateInfoAndProvider()¶
protected
getUpdateInfoAndProvider():Promise
<UpdateInfoAndProvider
>
返回值¶
Promise
<UpdateInfoAndProvider
>
isUpdaterActive()¶
isUpdaterActive():
boolean
返回值¶
boolean
listenerCount()¶
listenerCount(
type
):number
参数¶
• type: keyof AppUpdaterEvents
返回值¶
number
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).listenerCount
listeners()¶
listeners<
U
>(type
):AppUpdaterEvents
[U
][]
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• type: U
返回值¶
AppUpdaterEvents
[U
][]
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).listeners
off()¶
off<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).off
on()¶
on<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).on
once()¶
once<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).once
onUpdateAvailable()¶
protected
onUpdateAvailable(updateInfo
):void
参数¶
• updateInfo: UpdateInfo
返回值¶
void
prependListener()¶
prependListener<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).prependListener
prependOnceListener()¶
prependOnceListener<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).prependOnceListener
quitAndInstall()¶
abstract
quitAndInstall(isSilent
?,isForceRunAfter
?):void
重启应用程序并在下载更新后安装更新。它应该只在 update-downloaded
发出后调用。
注意: autoUpdater.quitAndInstall()
将首先关闭所有应用程序窗口,然后才在 app
上发出 before-quit
事件。这与正常的退出事件序列不同。
参数¶
• isSilent?: boolean
仅限 windows 以静默模式运行安装程序。默认为 false
。
• isForceRunAfter?: boolean
即使在静默安装时,也在完成后运行应用程序。不适用于 macOS。如果 isSilent
设置为 false
,则忽略(在这种情况下,您仍然可以将 autoRunAppAfterInstall
设置为 false
以防止在完成后运行应用程序)。
返回值¶
void
rawListeners()¶
rawListeners<
U
>(type
):AppUpdaterEvents
[U
][]
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• type: U
返回值¶
AppUpdaterEvents
[U
][]
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).rawListeners
removeAllListeners()¶
removeAllListeners(
event
?):this
参数¶
• event?: keyof AppUpdaterEvents
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).removeAllListeners
removeListener()¶
removeListener<
U
>(event
,listener
):this
类型参数¶
• U extends keyof AppUpdaterEvents
参数¶
• event: U
• listener: AppUpdaterEvents
[U
]
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).removeListener
setFeedURL()¶
setFeedURL(
options
):void
配置更新提供程序。如果值为 string
,则 GenericServerOptions 将设置为以该值作为 url
。
参数¶
• options: PublishConfiguration
| AllPublishOptions
如果您想覆盖 app-update.yml
中的配置。
返回值¶
void
setMaxListeners()¶
setMaxListeners(
n
):this
参数¶
• n: number
返回值¶
this
继承自¶
(EventEmitter as new () => TypedEmitter<AppUpdaterEvents>).setMaxListeners