ref |> Revert "ref |> mPaaS升级工具封装"
This reverts commit aaef3950.
Showing
7 changed files
with
27 additions
and
146 deletions
| @@ -54,4 +54,4 @@ export { NetworkType } from './src/main/ets/network/NetworkType' | @@ -54,4 +54,4 @@ export { NetworkType } from './src/main/ets/network/NetworkType' | ||
| 54 | 54 | ||
| 55 | export { MpaasUtils } from './src/main/ets/mpaas/MpaasUtils' | 55 | export { MpaasUtils } from './src/main/ets/mpaas/MpaasUtils' |
| 56 | 56 | ||
| 57 | -export { MpaasUpgradeCheck, UpgradeTipContent } from './src/main/ets/mpaas/MpaasUpgradeCheck' | ||
| 57 | +export { MpaasUpgradeCheck } from './src/main/ets/mpaas/MpaasUpgradeCheck' |
| 1 | import { MPUpgradeService } from '@mpaas/upgrade' | 1 | import { MPUpgradeService } from '@mpaas/upgrade' |
| 2 | -import { upgradeRes } from '@mpaas/upgrade/src/main/ets/t4/a' | ||
| 3 | -import { AppUtils } from '../utils/AppUtils' | ||
| 4 | -import { SPHelper } from '../utils/SPHelper' | ||
| 5 | - | ||
| 6 | -export interface UpgradeTipContent { | ||
| 7 | - | ||
| 8 | - content: string | ||
| 9 | - newVersion: string | ||
| 10 | - downloadUrl: string | ||
| 11 | - forceUpgrade: boolean | ||
| 12 | -} | 2 | +import { MpaasUtils } from './MpaasUtils' |
| 13 | 3 | ||
| 14 | export class MpaasUpgradeCheck { | 4 | export class MpaasUpgradeCheck { |
| 15 | 5 | ||
| @@ -22,72 +12,33 @@ export class MpaasUpgradeCheck { | @@ -22,72 +12,33 @@ export class MpaasUpgradeCheck { | ||
| 22 | } | 12 | } |
| 23 | } | 13 | } |
| 24 | 14 | ||
| 25 | - checkNewVersion(): Promise<UpgradeTipContent | null> { | 15 | + async checkNewVersion() { |
| 16 | + const utdid = await MpaasUtils.mpaasUtdid() | ||
| 17 | + console.log("mpaas utdid: ", utdid) | ||
| 26 | 18 | ||
| 27 | - return new Promise((resolve, fail) => { | ||
| 28 | - MPUpgradeService.checkNewVersion().then((response)=>{ | ||
| 29 | - let str = JSON.stringify(response) | ||
| 30 | - console.log("mpaas upgrade check", str) | ||
| 31 | - | ||
| 32 | - /* | 19 | + MPUpgradeService.checkNewVersion().then((response)=>{ |
| 20 | + let str = JSON.stringify(response) | ||
| 21 | + console.log("mpaas upgrade check", str) | ||
| 22 | + AlertDialog.show( | ||
| 33 | { | 23 | { |
| 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 | 24 | + title: '升级检测结果', |
| 25 | + message: str, | ||
| 26 | + autoCancel: true, | ||
| 27 | + offset: { dx: 0, dy: -20 }, | ||
| 28 | + gridCount: 3, | ||
| 29 | + confirm: { | ||
| 30 | + value: '确认', | ||
| 31 | + action: () => { | ||
| 32 | + console.info('upgrade result',response) | ||
| 33 | + } | ||
| 34 | + }, | ||
| 35 | + cancel: () => { | ||
| 36 | + console.info('Closed callbacks') | ||
| 81 | } | 37 | } |
| 82 | - resolve(content) | ||
| 83 | - return | ||
| 84 | } | 38 | } |
| 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 | - }) | 39 | + ) |
| 40 | + }).catch((error: Error) => { | ||
| 41 | + console.log("mpaas upgrade fail", `name: ${error.name}, message: ${error.message}, \nstack: ${error.stack}`) | ||
| 91 | }) | 42 | }) |
| 92 | } | 43 | } |
| 93 | } | 44 | } |
| 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 | -/* | ||
| 5 | -对接mpaas注意: | ||
| 6 | -* 1、后台创建mpaas.config,需要包名。放到rawfile目录 | ||
| 7 | -* 2、网关加密hs_1222.png图片,放到rawfile目录 | ||
| 8 | -* 3. 配置和加密图片,需要包名和签名对应,否则无法使用 | ||
| 9 | - * */ | ||
| 10 | - | ||
| 11 | export class MpaasUtils { | 4 | export class MpaasUtils { |
| 12 | 5 | ||
| 13 | // 启动时onCreate()方法调用 | 6 | // 启动时onCreate()方法调用 |
| @@ -53,16 +53,5 @@ export class AppUtils { | @@ -53,16 +53,5 @@ export class AppUtils { | ||
| 53 | } | 53 | } |
| 54 | return ''; | 54 | return ''; |
| 55 | } | 55 | } |
| 56 | - | ||
| 57 | - static getFingerprint(): string { | ||
| 58 | - try { | ||
| 59 | - let bundleInfo = | ||
| 60 | - bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO); | ||
| 61 | - let finger = bundleInfo.signatureInfo.fingerprint; | ||
| 62 | - } catch (e) { | ||
| 63 | - Logger.warn(TAG, 'get app signatureinfo error:' + e?.message); | ||
| 64 | - } | ||
| 65 | - return ''; | ||
| 66 | - } | ||
| 67 | } | 56 | } |
| 68 | 57 |
| @@ -5,7 +5,7 @@ import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeChe | @@ -5,7 +5,7 @@ import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeChe | ||
| 5 | import router from '@ohos.router'; | 5 | import router from '@ohos.router'; |
| 6 | import { promptAction } from '@kit.ArkUI'; | 6 | import { promptAction } from '@kit.ArkUI'; |
| 7 | import { HWLocationUtils } from 'wdHwAbility/Index'; | 7 | import { HWLocationUtils } from 'wdHwAbility/Index'; |
| 8 | -import { UpgradeTipDialog } from "./upgradePage/UpgradeTipDialog" | 8 | + |
| 9 | 9 | ||
| 10 | const TAG = 'MainPage'; | 10 | const TAG = 'MainPage'; |
| 11 | 11 | ||
| @@ -16,7 +16,6 @@ struct MainPage { | @@ -16,7 +16,6 @@ struct MainPage { | ||
| 16 | @Provide pageHide: number = -1 | 16 | @Provide pageHide: number = -1 |
| 17 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() | 17 | private breakpointSystem: BreakpointSystem = new BreakpointSystem() |
| 18 | @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; | 18 | @StorageLink('currentBreakpoint') @Watch('watchCurrentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_XS; |
| 19 | - upgradeDialogController?: CustomDialogController | ||
| 20 | 19 | ||
| 21 | watchCurrentBreakpoint() { | 20 | watchCurrentBreakpoint() { |
| 22 | Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`); | 21 | Logger.info(TAG, `watchCurrentBreakpoint, this.currentBreakpoint: ${this.currentBreakpoint}`); |
| @@ -45,25 +44,8 @@ struct MainPage { | @@ -45,25 +44,8 @@ struct MainPage { | ||
| 45 | Logger.info(TAG, 'onPageShow'); | 44 | Logger.info(TAG, 'onPageShow'); |
| 46 | this.pageShow = Math.random() | 45 | this.pageShow = Math.random() |
| 47 | 46 | ||
| 48 | - // TODO: 升级检查,暂时不开放 | ||
| 49 | - // this.upgradeCheck() | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - upgradeCheck() { | ||
| 53 | const mpaas = new MpaasUpgradeCheck() | 47 | const mpaas = new MpaasUpgradeCheck() |
| 54 | - mpaas.checkNewVersion().then((data) => { | ||
| 55 | - if (data != null) { | ||
| 56 | - | ||
| 57 | - this.upgradeDialogController = new CustomDialogController({ | ||
| 58 | - builder: UpgradeTipDialog({ | ||
| 59 | - tipContent:data | ||
| 60 | - }) | ||
| 61 | - }) | ||
| 62 | - this.upgradeDialogController?.open() | ||
| 63 | - } | ||
| 64 | - }).catch(() => { | ||
| 65 | - | ||
| 66 | - }) | 48 | + mpaas.checkNewVersion() |
| 67 | } | 49 | } |
| 68 | 50 | ||
| 69 | onBackPress() { | 51 | onBackPress() { |
| 1 | -import { UpgradeTipContent } from 'wdKit/Index' | ||
| 2 | - | ||
| 3 | -@Preview | ||
| 4 | -@CustomDialog | ||
| 5 | -export struct UpgradeTipDialog { | ||
| 6 | - private tipContent: UpgradeTipContent = {} as UpgradeTipContent | ||
| 7 | - cancel?: () => void | ||
| 8 | - confirm?: () => void | ||
| 9 | - controller: CustomDialogController | ||
| 10 | - | ||
| 11 | - build() { | ||
| 12 | - Column() { | ||
| 13 | - Text(this.tipContent.content).fontSize(20).margin({ top: 10, bottom: 10 }) | ||
| 14 | - Flex({ justifyContent: FlexAlign.SpaceAround }) { | ||
| 15 | - Button('cancel') | ||
| 16 | - .onClick(() => { | ||
| 17 | - this.controller.close() | ||
| 18 | - if (this.cancel) { | ||
| 19 | - this.cancel() | ||
| 20 | - } | ||
| 21 | - }).backgroundColor(0xffffff).fontColor(Color.Black) | ||
| 22 | - Button('立即升级') | ||
| 23 | - .onClick(() => { | ||
| 24 | - this.controller.close() | ||
| 25 | - if (this.confirm) { | ||
| 26 | - this.confirm() | ||
| 27 | - } | ||
| 28 | - }).backgroundColor(0xffffff).fontColor(Color.Red) | ||
| 29 | - }.margin({ bottom: 10 }) | ||
| 30 | - } | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - | ||
| 34 | -} |
1.16 KB
-
Please register or login to post a comment