MpaasUpgradeCheck.ets
3.14 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// import { MPUpgradeService } from '@mpaas/upgrade'
// import { upgradeRes } from '@mpaas/upgrade/src/main/ets/t4/a'
import { AppUtils } from '../utils/AppUtils'
import { SPHelper } from '../utils/SPHelper'
export interface UpgradeTipContent {
content: string
newVersion: string
downloadUrl: string
forceUpgrade: boolean
}
export class MpaasUpgradeCheck {
/// 默认提示框
checkNewVersionAndShow() {
try {
// MPUpgradeService.checkNewVersionAndShow()
} catch (error) {
console.log("mpaas upgrade fail", JSON.stringify(error))
}
}
checkNewVersion(): Promise<UpgradeTipContent | null> {
return new Promise((resolve, fail) => {
fail("a")
// MPUpgradeService.checkNewVersion().then((response)=>{
// let str = JSON.stringify(response)
// console.log("mpaas upgrade check", str)
//
// /*
// {
// "android64FileSize": 0,
// "downloadURL": "https://appgallery.huawei.com/#/app",
// "fileSize": 0,
// "fullMd5": "no md5",
// "guideMemo": "欢迎使用新版本",
// "isWifi": 0,
// "netType": "ALL",
// "newestVersion": "1.0.1",
// "resultStatus": 204,
// "silentType": 0,
// "upgradeVersion": "1.0.1"
// }*/
//
// let res = response as upgradeRes
//
// // AliUpgradeNewVersion = 201, /*当前使用的已是最新版本*/
// // AliUpgradeOneTime = 202, /*客户端已有新版本,单次提醒*/
// // AliUpgradeForceUpdate = 203, /*客户端已有新版本,强制升级(已废弃)*/
// // AliUpgradeEveryTime = 204, /*客户端已有新版本,多次提醒*/
// // AliUpgradeRejectLogin = 205, /*限制登录(已废弃)*/
// // AliUpgradeForceUpdateWithLogin = 206 /*客户端已有新版本,强制升级*/
//
// const currentAppVersoin = AppUtils.getAppVersionName()
//
// if (res.resultStatus == 201) {
// resolve(null)
// return
// }
//
// // 单次升级控制
// if (res.resultStatus == 202) {
// const oldOnceValue = SPHelper.default.getSync("upgradeOnceKey", false) as boolean
// if (true == oldOnceValue) {
// resolve(null)
// return
// }
// SPHelper.default.save("upgradeOnceKey", true)
// } else {
// SPHelper.default.save("upgradeOnceKey", false)
// }
//
// if (res.resultStatus == 202 || res.resultStatus == 204 || res.resultStatus == 206) {
// let content: UpgradeTipContent = {
// content: res.guideMemo,
// newVersion: res.upgradeVersion,
// downloadUrl: res.downloadURL,
// forceUpgrade: res.resultStatus == 206
// }
// resolve(content)
// return
// }
//
// resolve(null)
// }).catch((error: Error) => {
// console.log("mpaas upgrade fail", `name: ${error.name}, message: ${error.message}, \nstack: ${error.stack}`)
// fail("检测升级失败")
// })
})
}
}