-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
45 lines (40 loc) · 959 Bytes
/
app.js
File metadata and controls
45 lines (40 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import PageModal from 'libs/page.js'
import 'libs/pageDecorator.js'
App({
// 系统信息
sysInfo: null,
// 页面栈, 注意使用:仅需要通信的页面加入栈中
pages: new PageModal(),
onLaunch(opt) {
// 检查新版本
checkVersion()
// 获取设备信息
this.sysInfo = wx.getSystemInfoSync()
},
// 404 redirect
onPageNotFound(res) {
wx.switchTab({
url: '/pages/home/index',
})
},
})
/**
* checkVersionn
*/
function checkVersion() {
if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) { })
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,重启体验新功能?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
}
}