feat: 小程序版本更新检测——新版本发布后旧版本冷启动静默下载+弹窗引导重启;版本v1.4.3

This commit is contained in:
Hermes Agent
2026-09-19 19:06:45 +08:00
parent acca4fe379
commit 9ea09c95f2
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -9,6 +9,30 @@ import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
onLaunch(() => {
initTheme()
// #ifdef MP-WEIXIN
// 版本更新检测:新版本发布后,旧版本用户冷启动时静默下载、弹窗引导重启
const um = uni.getUpdateManager && uni.getUpdateManager()
if (um) {
um.onUpdateReady(() => {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
confirmText: '立即重启',
cancelText: '稍后',
success: (m) => {
if (m.confirm) um.applyUpdate()
},
})
})
um.onUpdateFailed(() => {
uni.showModal({
title: '更新提示',
content: '新版本下载失败,请删除当前小程序后重新搜索打开',
showCancel: false,
})
})
}
// #endif
})
onShow(() => {})
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "宇之然AI维度",
"appid": "wxdad62baf4ccd09e3",
"versionName": "1.4.2",
"versionName": "1.4.3",
"versionCode": "100",
"description": "AI 知识探索社区 — 从5个维度系统理解人工智能",
"uni-app": {