Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuchentong committed Jul 25, 2024
1 parent e434a96 commit 8089766
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/bootstrap/launch/app.launch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
function checkAppUpdate() {
const updateManager = uni.getUpdateManager()

updateManager.onUpdateReady(() => {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: ({ confirm }) => confirm && updateManager.applyUpdate(),
})
})

updateManager.onUpdateFailed(() => {
// 新的版本下载失败
})

updateManager.onCheckForUpdate(({ hasUpdate }) => {
// 请求完新版本信息的回调
if (hasUpdate) {
uni.showToast({
title: '检测到新版本,正在准备更新',
mask: true,
})
}
})
}

function setupAppShare() {
// #ifdef MP-WEIXIN
const descriptor = Object.getOwnPropertyDescriptor(wx, 'onAppRoute')
const onAppRoute = descriptor?.value

if (onAppRoute) {
onAppRoute(() => {
uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
})
})
}
// #endif
}

export function appLaunch() {
checkAppUpdate()
setupAppShare()
}
7 changes: 7 additions & 0 deletions src/bootstrap/launch/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { appLaunch } from './app.launch'
import { userLaunch } from './user.launch'

export async function launch() {
const store = useStore()

await appLaunch()
await userLaunch()

store.app.setReady()
}
3 changes: 3 additions & 0 deletions src/bootstrap/launch/user.launch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function userLaunch() {

}

0 comments on commit 8089766

Please sign in to comment.