增加版本信息获取工具类.

可以在项目代码中直接使用 import um = require('UpdateManager') 然后调用相关接口.
This commit is contained in:
andrewlu
2021-02-03 21:34:58 +08:00
parent ae6566c8dd
commit ef915a121e
10 changed files with 201 additions and 84 deletions

View File

@@ -105,7 +105,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 700,
"height": 255.6
"height": 75.6
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -117,7 +117,7 @@
"ctor": "Float64Array",
"array": [
0,
0,
282.58,
0,
0,
0,
@@ -156,9 +156,9 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "这是Bundle2,修改此bundle 并上传更新包,然后运行查看效果.\n当前版本V4",
"_N$string": "这是Bundle2,修改此bundle 并上传更新包,然后运行查看效果.\n当前版本V4",
"_fontSize": 60,
"_string": "",
"_N$string": "",
"_fontSize": 30,
"_lineHeight": 60,
"_enableWrapText": true,
"_N$file": null,
@@ -193,8 +193,9 @@
"__id__": 1
},
"_enabled": true,
"label": null,
"text": "hello",
"label": {
"__id__": 3
},
"_id": ""
},
{

View File

@@ -1,28 +1,21 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
//@ts-ignore
import UpdateManager = require('UpdateManager');
@ccclass
export default class NewClass extends cc.Component {
@property(cc.Label)
label: cc.Label = null;
@property
text: string = 'hello';
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
start() {
if (UpdateManager.getUpdateFlag()) {
this.label.string = UpdateManager.cur_ver_desc;
UpdateManager.resetUpdateFlag();
} else {
this.label.string = "未发现新版本,\n当前版本:" + UpdateManager.cur_ver_name;
}
console.log('>>>>>>>>>>>>>>>>>>>>>', UpdateManager.cur_ver_code);
}
// update (dt) {}
}