xugenyuan

ref |> 处理mpaas加回来,且进入首页不走升级

@@ -27,10 +27,6 @@ @@ -27,10 +27,6 @@
27 { 27 {
28 "name": "location_reason", 28 "name": "location_reason",
29 "value": " " 29 "value": " "
30 - },  
31 - {  
32 - "name": "STORE_PERSISTENT_DATA",  
33 - "value": "STORE_PERSISTENT_DATASTORE_PERSISTENT_DATASTORE_PERSISTENT_DATA"  
34 } 30 }
35 ] 31 ]
36 } 32 }
@@ -10,8 +10,8 @@ @@ -10,8 +10,8 @@
10 "@tingyun/harmonyos": "file:./src/main/ets/tingyunAPM/tingyun_0.0.6.har", 10 "@tingyun/harmonyos": "file:./src/main/ets/tingyunAPM/tingyun_0.0.6.har",
11 "@umeng/common": "^1.0.21", 11 "@umeng/common": "^1.0.21",
12 "@umeng/analytics": "^1.0.19", 12 "@umeng/analytics": "^1.0.19",
13 -// "@mpaas/udid": "0.0.3",  
14 -// "@mpaas/upgrade": "0.0.3",  
15 -// "@mpaas/framework": "0.0.3" 13 + "@mpaas/udid": "0.0.2",
  14 + "@mpaas/upgrade": "0.0.2",
  15 + "@mpaas/framework": "0.0.2"
16 } 16 }
17 } 17 }
1 -// import { MPUpgradeService } from '@mpaas/upgrade'  
2 -// import { upgradeRes } from '@mpaas/upgrade/src/main/ets/t4/a' 1 +import { MPUpgradeService } from '@mpaas/upgrade'
  2 +import { upgradeRes } from '@mpaas/upgrade/src/main/ets/t4/a'
3 import { AppUtils } from '../utils/AppUtils' 3 import { AppUtils } from '../utils/AppUtils'
4 import { SPHelper } from '../utils/SPHelper' 4 import { SPHelper } from '../utils/SPHelper'
5 5
@@ -16,7 +16,7 @@ export class MpaasUpgradeCheck { @@ -16,7 +16,7 @@ export class MpaasUpgradeCheck {
16 /// 默认提示框 16 /// 默认提示框
17 checkNewVersionAndShow() { 17 checkNewVersionAndShow() {
18 try { 18 try {
19 - // MPUpgradeService.checkNewVersionAndShow() 19 + MPUpgradeService.checkNewVersionAndShow()
20 } catch (error) { 20 } catch (error) {
21 console.log("mpaas upgrade fail", JSON.stringify(error)) 21 console.log("mpaas upgrade fail", JSON.stringify(error))
22 } 22 }
@@ -25,70 +25,69 @@ export class MpaasUpgradeCheck { @@ -25,70 +25,69 @@ export class MpaasUpgradeCheck {
25 checkNewVersion(): Promise<UpgradeTipContent | null> { 25 checkNewVersion(): Promise<UpgradeTipContent | null> {
26 26
27 return new Promise((resolve, fail) => { 27 return new Promise((resolve, fail) => {
28 - fail("a")  
29 - // MPUpgradeService.checkNewVersion().then((response)=>{  
30 - // let str = JSON.stringify(response)  
31 - // console.log("mpaas upgrade check", str)  
32 - //  
33 - // /*  
34 - // {  
35 - // "android64FileSize": 0,  
36 - // "downloadURL": "https://appgallery.huawei.com/#/app",  
37 - // "fileSize": 0,  
38 - // "fullMd5": "no md5",  
39 - // "guideMemo": "欢迎使用新版本",  
40 - // "isWifi": 0,  
41 - // "netType": "ALL",  
42 - // "newestVersion": "1.0.1",  
43 - // "resultStatus": 204,  
44 - // "silentType": 0,  
45 - // "upgradeVersion": "1.0.1"  
46 - // }*/  
47 - //  
48 - // let res = response as upgradeRes  
49 - //  
50 - // // AliUpgradeNewVersion = 201, /*当前使用的已是最新版本*/  
51 - // // AliUpgradeOneTime = 202, /*客户端已有新版本,单次提醒*/  
52 - // // AliUpgradeForceUpdate = 203, /*客户端已有新版本,强制升级(已废弃)*/  
53 - // // AliUpgradeEveryTime = 204, /*客户端已有新版本,多次提醒*/  
54 - // // AliUpgradeRejectLogin = 205, /*限制登录(已废弃)*/  
55 - // // AliUpgradeForceUpdateWithLogin = 206 /*客户端已有新版本,强制升级*/  
56 - //  
57 - // const currentAppVersoin = AppUtils.getAppVersionName()  
58 - //  
59 - // if (res.resultStatus == 201) {  
60 - // resolve(null)  
61 - // return  
62 - // }  
63 - //  
64 - // // 单次升级控制  
65 - // if (res.resultStatus == 202) {  
66 - // const oldOnceValue = SPHelper.default.getSync("upgradeOnceKey", false) as boolean  
67 - // if (true == oldOnceValue) {  
68 - // resolve(null)  
69 - // return  
70 - // }  
71 - // SPHelper.default.save("upgradeOnceKey", true)  
72 - // } else {  
73 - // SPHelper.default.save("upgradeOnceKey", false)  
74 - // }  
75 - //  
76 - // if (res.resultStatus == 202 || res.resultStatus == 204 || res.resultStatus == 206) {  
77 - // let content: UpgradeTipContent = {  
78 - // content: res.guideMemo,  
79 - // newVersion: res.upgradeVersion,  
80 - // downloadUrl: res.downloadURL,  
81 - // forceUpgrade: res.resultStatus == 206  
82 - // }  
83 - // resolve(content)  
84 - // return  
85 - // }  
86 - //  
87 - // resolve(null)  
88 - // }).catch((error: Error) => {  
89 - // console.log("mpaas upgrade fail", `name: ${error.name}, message: ${error.message}, \nstack: ${error.stack}`)  
90 - // fail("检测升级失败")  
91 - // }) 28 + MPUpgradeService.checkNewVersion().then((response)=>{
  29 + let str = JSON.stringify(response)
  30 + console.log("mpaas upgrade check", str)
  31 +
  32 + /*
  33 + {
  34 + "android64FileSize": 0,
  35 + "downloadURL": "https://appgallery.huawei.com/#/app",
  36 + "fileSize": 0,
  37 + "fullMd5": "no md5",
  38 + "guideMemo": "欢迎使用新版本",
  39 + "isWifi": 0,
  40 + "netType": "ALL",
  41 + "newestVersion": "1.0.1",
  42 + "resultStatus": 204,
  43 + "silentType": 0,
  44 + "upgradeVersion": "1.0.1"
  45 + }*/
  46 +
  47 + let res = response as upgradeRes
  48 +
  49 + // AliUpgradeNewVersion = 201, /*当前使用的已是最新版本*/
  50 + // AliUpgradeOneTime = 202, /*客户端已有新版本,单次提醒*/
  51 + // AliUpgradeForceUpdate = 203, /*客户端已有新版本,强制升级(已废弃)*/
  52 + // AliUpgradeEveryTime = 204, /*客户端已有新版本,多次提醒*/
  53 + // AliUpgradeRejectLogin = 205, /*限制登录(已废弃)*/
  54 + // AliUpgradeForceUpdateWithLogin = 206 /*客户端已有新版本,强制升级*/
  55 +
  56 + const currentAppVersoin = AppUtils.getAppVersionName()
  57 +
  58 + if (res.resultStatus == 201) {
  59 + resolve(null)
  60 + return
  61 + }
  62 +
  63 + // 单次升级控制
  64 + if (res.resultStatus == 202) {
  65 + const oldOnceValue = SPHelper.default.getSync("upgradeOnceKey", false) as boolean
  66 + if (true == oldOnceValue) {
  67 + resolve(null)
  68 + return
  69 + }
  70 + SPHelper.default.save("upgradeOnceKey", true)
  71 + } else {
  72 + SPHelper.default.save("upgradeOnceKey", false)
  73 + }
  74 +
  75 + if (res.resultStatus == 202 || res.resultStatus == 204 || res.resultStatus == 206) {
  76 + let content: UpgradeTipContent = {
  77 + content: res.guideMemo,
  78 + newVersion: res.upgradeVersion,
  79 + downloadUrl: res.downloadURL,
  80 + forceUpgrade: res.resultStatus == 206
  81 + }
  82 + resolve(content)
  83 + return
  84 + }
  85 +
  86 + resolve(null)
  87 + }).catch((error: Error) => {
  88 + console.log("mpaas upgrade fail", `name: ${error.name}, message: ${error.message}, \nstack: ${error.stack}`)
  89 + fail("检测升级失败")
  90 + })
92 }) 91 })
93 } 92 }
94 } 93 }
1 -// import { MPFramework } from '@mpaas/framework' 1 +import { MPFramework } from '@mpaas/framework'
2 import { common } from '@kit.AbilityKit'; 2 import { common } from '@kit.AbilityKit';
3 3
4 /* 4 /*
@@ -12,18 +12,17 @@ export class MpaasUtils { @@ -12,18 +12,17 @@ export class MpaasUtils {
12 12
13 // 启动时onCreate()方法调用 13 // 启动时onCreate()方法调用
14 static initApp(context: common.UIAbilityContext) { 14 static initApp(context: common.UIAbilityContext) {
15 - // MPFramework.create(context); 15 + MPFramework.create(context);
16 } 16 }
17 17
18 // 获取mPaaS utdid 18 // 获取mPaaS utdid
19 static async mpaasUtdid() { 19 static async mpaasUtdid() {
20 - // let utdid = await MPFramework.instance.udid  
21 - let utdid = "xxxxxxxxxx" 20 + let utdid = await MPFramework.instance.udid
22 return utdid 21 return utdid
23 } 22 }
24 23
25 // 登录和退出登录调用,用来管理白名单用 24 // 登录和退出登录调用,用来管理白名单用
26 static setupUserId(userId?: string) { 25 static setupUserId(userId?: string) {
27 - // MPFramework.instance.userId = userId 26 + MPFramework.instance.userId = userId
28 } 27 }
29 } 28 }
@@ -73,7 +73,7 @@ struct MainPage { @@ -73,7 +73,7 @@ struct MainPage {
73 this.pageShow = Math.random() 73 this.pageShow = Math.random()
74 74
75 // 升级检查 75 // 升级检查
76 - this.upgradeCheck() 76 + // this.upgradeCheck()
77 77
78 Logger.debug('setBarBackgroundColor','Top onPageShow ') 78 Logger.debug('setBarBackgroundColor','Top onPageShow ')
79 } 79 }