import Vnmf from '../../index' declare module '../../index' { namespace updateWeChatApp { interface Option { /** Interface call successful callback function */ success?: (res: VnmfGeneral.CallbackResult) => void /** Interface call failure recovery function */ fail?: (res: VnmfGeneral.CallbackResult) => void /** The callback function of the interface call (Call success 、Failure will be executed ) */ complete?: (res: VnmfGeneral.CallbackResult) => void } } namespace UpdateManager { /** Request to the background of WeChat to check the recovery function of the update result event event event */ type OnCheckForUpdateCallback = ( result: OnCheckForUpdateResult, ) => void interface OnCheckForUpdateResult { /** Whether there is a new version */ hasUpdate: boolean } } /** UpdateManager Object ,Used to manage updates ,accessible Vnmf.getUpdateManager Interface acquisition instance 。 * * **Tips** * - You can pass the WeChat developer tool 「Compile mode 」Lower 「Next compilation simulation update 」Switch to debug * - Mini Program Development Edition /There is no experience version 「Version 」concept ,So it is impossible to develop a version /Experience version test renewal update situation * @supported weapp, tt * @example * ```tsx * const updateManager = Vnmf.getUpdateManager() * * updateManager.onCheckForUpdate(function (res) { * // Request the callback of the new version of the information * console.log(res.hasUpdate) * }) * * updateManager.onUpdateReady(function () { * wx.showModal({ * title: 'Update prompt ', * content: 'The new version is ready ,Whether to restart the application ?', * success: function (res) { * if (res.confirm) { * // The new version has been downloaded ,transfer applyUpdate Apply a new version and restart * updateManager.applyUpdate() * } * } * }) * }) * * updateManager.onUpdateFailed(function () { * // New version download failed * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html */ interface UpdateManager { /** Forced mini -programs restart and use the new version 。After downloading the new version of the applet (Immediately receive `onUpdateReady` Call back )transfer 。 * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.applyUpdate.html */ applyUpdate(): void /** Surveillance from WeChat background request for checking the update results event event 。WeChat automatically check and update when the applet is cold. ,No need to be triggered by developers 。 * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onCheckForUpdate.html */ onCheckForUpdate( /** Request to the background of WeChat to check the recovery function of the update result event event event */ callback: UpdateManager.OnCheckForUpdateCallback, ): void /** There is a version update event in the listening applet 。Client actively trigger download (No developer triggers need to be triggered ),After downloading successfully * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onUpdateReady.html */ onUpdateReady( /** The recovery function of the small program has a version update event */ callback: (res: VnmfGeneral.CallbackResult) => void, ): void /** Listening mini program update failure event 。Small program has a new version ,Client actively trigger download (No developer triggers need to be triggered ),download failed (May be the reason for network )Backwage * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.onUpdateFailed.html */ onUpdateFailed( /** The recovery function of the mini -program update failure event */ callback: (res: VnmfGeneral.CallbackResult) => void, ): void } interface VnmfStatic { /** Update client version 。When judging the client version of the user applet is too low ,You can use this interface to jump to the update WeChat page 。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.updateWeChatApp.html */ updateWeChatApp(option: updateWeChatApp.Option): Promise /** * Obtain **Unique global **Version update manager ,Used to manage applet updates 。 * About the update mechanism of mini -programs ,Can view [Operating mechanism ](https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/operating-mechanism.html)Documentation 。 * @example * ```tsx * const updateManager = Vnmf.getUpdateManager() * updateManager.onCheckForUpdate(function (res) { * // Request the callback of the new version of the information * console.log(res.hasUpdate) * }) * updateManager.onUpdateReady(function () { * Vnmf.showModal({ * title: 'Update prompt ', * content: 'The new version is ready ,Whether to restart the application ?', * success: function (res) { * if (res.confirm) { * // The new version has been downloaded ,transfer applyUpdate Apply a new version and restart * updateManager.applyUpdate() * } * } * }) * }) * updateManager.onUpdateFailed(function () { * // New version download failed * }) * ``` * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/update/wx.getUpdateManager.html */ getUpdateManager(): UpdateManager } }