diff --git a/docs/upgrade-center.md b/docs/upgrade-center.md index 56c364628cebc7b319243abc7319716904a3f59d..2f574870c4f61e5e37a89c551227a88e95cccd6b 100644 --- a/docs/upgrade-center.md +++ b/docs/upgrade-center.md @@ -325,6 +325,60 @@ App升级中心 uni-upgrade-center,提供了 App 的版本更新服务。包 **注意** 在 uni-app x 的 app-Android 端没有 wgt 更新,也不会检测到 wgt 包的更新 +#### 在 HarmonyOS Next 中使用升级中心 @uni-upgrade-center-app-harmonyos + +**安装指引** + +步骤 1 - 5 可以参考 [uni-app 的使用指引](#uni-upgrade-center-app-uni-app),然后接下来的步骤为: + +1. 在需要使用的地方引入 js 和组件,一般为首页: + ```js + import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'; + // #ifdef APP-HARMONY + import upgradePopupVue from '@/uni_modules/uni-upgrade-center-app/pages/upgrade-popup.vue'; + // #endif + ``` +2. 在 `components` 中声明组件,并新建方法来供 template 调用(也可以在 onLoad 生命周期中调用): + + ```js + export default { + // ... + components: { + // #ifdef APP-HARMONY + upgradePopupVue + // #endif + }, + methods: { + checkVersion() { + // #ifdef APP-PLUS + checkUpdate() + // #endif + // #ifdef APP-HARMONY + checkUpdate(this.$refs.upgradePopup) + // #endif + .then((res) => { + console.log('res: ', JSON.stringify(res)); + }) + .catch((e) => { + console.log('e: ', JSON.stringify(e), e); + }); + } + } + // ... + } + ``` +3. 在 `template` 中使用 `button` 组件来触发升级检测: + + ```vue + + ``` + #### 更新下载安装`check-update.ts` > 该函数在utils目录下