-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e434a96
commit 8089766
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function userLaunch() { | ||
|
||
} |