[mod] 熱更新調整
This commit is contained in:
parent
3846fa7844
commit
5fb9bad702
@ -11,6 +11,8 @@ export default class LocalStorageData {
|
||||
// =======================================================================================
|
||||
public get CompileVersion(): string { return cc.sys.localStorage.getItem("CompileVersion"); }
|
||||
public set CompileVersion(value: string) { cc.sys.localStorage.setItem("CompileVersion", value.toString()); }
|
||||
public get BundleVersion(): string { return cc.sys.localStorage.getItem("BundleVersion"); }
|
||||
public set BundleVersion(value: string) { cc.sys.localStorage.setItem("BundleVersion", value.toString()); }
|
||||
public get ComboDeviceID(): string { return cc.sys.localStorage.getItem("ComboDeviceID") || ""; }
|
||||
public set ComboDeviceID(value: string) { cc.sys.localStorage.setItem("ComboDeviceID", value); }
|
||||
public get BundleUrl(): string { return cc.sys.localStorage.getItem("BundleUrl"); }
|
||||
|
@ -30,6 +30,7 @@ export default class HUDM extends cc.Component {
|
||||
private _updating: boolean = false;
|
||||
private _canRetry: boolean = false;
|
||||
private _isChangeUrl: boolean = false;
|
||||
private _isNewBundle: boolean = false;
|
||||
private _path: string = "Bundle";
|
||||
private _customManifest: string = "";
|
||||
private _storagePath: string = "";
|
||||
@ -46,6 +47,7 @@ export default class HUDM extends cc.Component {
|
||||
}
|
||||
HUDM._instance = this;
|
||||
this._updatePanel = params[0];
|
||||
this._isNewBundle = params[1];
|
||||
// let packageUrl: string = `https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/${BusinessTypeSetting.COMPILE_VERSION}`;
|
||||
let packageUrl: string = BusinessTypeSetting.UsePatch;
|
||||
|
||||
@ -201,7 +203,7 @@ export default class HUDM extends cc.Component {
|
||||
while (this._needUpdateData === null) {
|
||||
yield null;
|
||||
}
|
||||
if (this._isChangeUrl && ((!this._needUpdateData.IsNeedUpdate && this._needUpdateData.TotalBytes !== "failed") || this._needUpdateData.TotalBytes === "0 B")) {
|
||||
if ((this._isChangeUrl || this._isNewBundle) && ((!this._needUpdateData.IsNeedUpdate && this._needUpdateData.TotalBytes !== "failed") || this._needUpdateData.TotalBytes === "0 B")) {
|
||||
if (jsb.fileUtils.isFileExist(this._storagePath)) {
|
||||
let isremoveDirectory: boolean = jsb.fileUtils.removeDirectory(this._storagePath);
|
||||
let isremoveDirectory_temp: boolean = jsb.fileUtils.removeDirectory(this._storagePath + "_temp");
|
||||
|
@ -40,15 +40,17 @@ export default class Manager extends cc.Component {
|
||||
}
|
||||
|
||||
private *_init(): IterableIterator<any> {
|
||||
new LocalStorageData();
|
||||
let isNewBundle: boolean = yield* this.CheckBundleVersion();
|
||||
console.log(`BUNDLE VERSION: ${LocalStorageData.Instance.BundleVersion}`);
|
||||
console.log(`COMPILE VERSION: ${BusinessTypeSetting.COMPILE_VERSION}`);
|
||||
this.Version.string = `Ver ${BusinessTypeSetting.COMPILE_VERSION}`;
|
||||
BusinessTypeSetting.UsePatch = `https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/${BusinessTypeSetting.NEXT_VERSION}`;
|
||||
BusinessTypeSetting.UsePatch = `https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/${BusinessTypeSetting.MajorVersion}.${BusinessTypeSetting.MinorVersion}`;
|
||||
cc.debug.setDisplayStats(false);
|
||||
|
||||
new LocalStorageData();
|
||||
new NativeClass(this.webview);
|
||||
if (cc.sys.isNative) {
|
||||
new HUDM(this.UpdatePanel.getComponentInChildren(UpdatePanel));
|
||||
if (cc.sys.isNative && isNewBundle) {
|
||||
new HUDM(this.UpdatePanel.getComponentInChildren(UpdatePanel), isNewBundle);
|
||||
let needUpdateData: Enum_HUDM.NeedUpdateDataObj = yield* HUDM.Instance.CheckUpdate();
|
||||
if (needUpdateData.IsNeedUpdate) {
|
||||
this.UpdatePanel.active = true;
|
||||
@ -181,5 +183,65 @@ export default class Manager extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
/** 判斷更改Bundle版號.清除BUNDLE記錄 */
|
||||
public *CheckBundleVersion(): IterableIterator<any> {
|
||||
let isNewBundle: boolean = false;
|
||||
let remote_version: string = "0";
|
||||
let versionLoadEnd: boolean = false;
|
||||
let fileName: string = "BundleVersion";
|
||||
let fileFormat: string = ".txt";
|
||||
let fileVersion: string = `?v=${Date.now()}`;
|
||||
let fileUrl: string = `https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/${fileName}${fileFormat}${fileVersion}`;
|
||||
cc.assetManager.loadRemote(fileUrl, (err: Error, res: cc.TextAsset) => {
|
||||
if (!err) {
|
||||
remote_version = res.text;
|
||||
versionLoadEnd = true;
|
||||
console.log(`${fileName}.txt loaded`);
|
||||
} else {
|
||||
console.error(`[Error] ${fileName}載入失敗`);
|
||||
}
|
||||
});
|
||||
while (!versionLoadEnd) {
|
||||
yield null;
|
||||
}
|
||||
let oldBundleVersion: string = LocalStorageData.Instance.BundleVersion || "0.0.0";
|
||||
let newBundleVersion: string = remote_version;
|
||||
if (oldBundleVersion) {
|
||||
let IsUpdate: boolean = this.VersionCompareHandle(oldBundleVersion, newBundleVersion) < 0 ? true : false;
|
||||
if (IsUpdate) {
|
||||
console.warn(`change bundle version. ${oldBundleVersion} -> ${newBundleVersion}`);
|
||||
isNewBundle = true;
|
||||
}
|
||||
}
|
||||
LocalStorageData.Instance.BundleVersion = newBundleVersion;
|
||||
return isNewBundle;
|
||||
}
|
||||
|
||||
public VersionCompareHandle(versionA: string, versionB: string): number {
|
||||
// console.log("Ver A " + versionA + "VerB " + versionB);
|
||||
let vA: string[] = versionA.split(".");
|
||||
let vB: string[] = versionB.split(".");
|
||||
|
||||
// 長度不相等,則進行更新
|
||||
if (vA.length !== vB.length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (let i: number = 0; i < vA.length; ++i) {
|
||||
let a: number = +vA[i];
|
||||
let b: number = +vB[i] || 0;
|
||||
if (a === b) {
|
||||
// 數字相同,則跳過
|
||||
continue;
|
||||
} else {
|
||||
// 數字不同,則進行更新
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// 長度相等且數字相等,則不更新
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ export default class BusinessTypeSetting {
|
||||
public static readonly Revision: number = 0;
|
||||
/** 編譯版本 */
|
||||
public static readonly COMPILE_VERSION: string = `${BusinessTypeSetting.MajorVersion}.${BusinessTypeSetting.MinorVersion}.${BusinessTypeSetting.Revision}`;
|
||||
public static readonly NEXT_VERSION: string = `${BusinessTypeSetting.MajorVersion}.${BusinessTypeSetting.MinorVersion}.${BusinessTypeSetting.Revision + 1}`;
|
||||
|
||||
/** 資源伺服器網址 */
|
||||
public static UsePatch: string = null;
|
||||
|
@ -1,11 +1,12 @@
|
||||
@echo off
|
||||
|
||||
set Ver=3.0.1
|
||||
set MainVer=3.0
|
||||
set BundleVer=3.0.1
|
||||
set START1=%~dp0\build\jsb-default\remote-assets
|
||||
set START2=%~dp0\remote-assets
|
||||
set END=W:\web\MyWeb\Resources\App\JMKA\update\remote-assets\%Ver%
|
||||
set END=W:\web\MyWeb\Resources\App\JMKA\update\remote-assets\%MainVer%
|
||||
|
||||
node version_generator.js -v %Ver% -u https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/%Ver%/ -s build/jsb-default/remote-assets -d remote-assets
|
||||
node version_generator.js -v %BundleVer% -u https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/%MainVer%/ -s build/jsb-default/remote-assets -d remote-assets
|
||||
|
||||
@REM rmdir /s /q %END%
|
||||
@REM del /f "%END%"
|
||||
|
@ -1 +1 @@
|
||||
{"packageUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/","remoteManifestUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/project.manifest","remoteVersionUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/version.manifest","version":"3.0.1","assets":{"src/assets/Plugins/responsivevoice.js":{"size":104943,"md5":"9f71d303fc7feda51261c2bf856ad4f1"},"src/assets/Script/Engine/Component/Animation/SkeletonExt.js":{"size":1161,"md5":"7e27cb40c535213460334d5f536e16b9"},"src/cocos2d-jsb.js":{"size":2995026,"md5":"8f7fa2615af9cf7f2121cf3077b97c0a"},"src/settings.js":{"size":500,"md5":"d989547c4773fe77c3dac0293e87e174"},"assets/main/config.json":{"size":1720,"md5":"4f2027d695a724c279c1f4faaea59ae9"},"assets/main/import/02/0254af710.json":{"size":281,"md5":"e859c04502eab6f53d55174bbd4f1d3d"},"assets/main/import/06/06cf73164.json":{"size":36298,"md5":"208e5254dfe5589ad716071ab641bfb5"},"assets/main/index.js":{"size":439011,"md5":"29d0658eb6fae91ff1254d061bdf5f5d"},"assets/main/native/2d/2ddfe005-2129-41d8-aeec-2b1f51f02962.png":{"size":2290,"md5":"740ebade1729539882383360b2066d36"},"assets/main/native/34/3459ab36-782c-4c4e-8aef-7280aff8b272.png":{"size":18969,"md5":"96e39d211db65235f425ba3957b723b0"},"assets/main/native/70/700faa17-11a6-46cd-aeb5-d6900bc264f8.png":{"size":3765,"md5":"60ab4dfb6d3e8a147753b5665dcba27a"},"assets/main/native/71/71561142-4c83-4933-afca-cb7a17f67053.png":{"size":1050,"md5":"72c8f8527cdbe8246b8223a54f409ca3"},"assets/main/native/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.png":{"size":1114,"md5":"49624805cb214b8d78d34a0c03dfbd00"},"assets/main/native/c3/c39ea496-96eb-4dc5-945a-e7c919b77c21.png":{"size":2548,"md5":"c3b93af99c4a65d85ad414e8e46dbfd5"},"assets/main/native/ca/caaaf9ff-5036-4232-a8a7-88b80b2e4c88.png":{"size":1829,"md5":"e3e1ef9049e7c82cbb696bc4e8cfa64b"},"assets/main/native/e5/e56254ca-0ee4-42ea-b69e-d2e57804a4f1.jpg":{"size":5809,"md5":"8fbe8a70e5b43c90bed44cf38e0e2a50"}},"searchPaths":[]}
|
||||
{"packageUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/","remoteManifestUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/project.manifest","remoteVersionUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/version.manifest","version":"3.1","assets":{"src/assets/Plugins/responsivevoice.js":{"size":104943,"md5":"9f71d303fc7feda51261c2bf856ad4f1"},"src/assets/Script/Engine/Component/Animation/SkeletonExt.js":{"size":1161,"md5":"7e27cb40c535213460334d5f536e16b9"},"src/cocos2d-jsb.js":{"size":2995026,"md5":"8f7fa2615af9cf7f2121cf3077b97c0a"},"src/settings.js":{"size":500,"md5":"d989547c4773fe77c3dac0293e87e174"},"assets/main/config.json":{"size":1720,"md5":"4f2027d695a724c279c1f4faaea59ae9"},"assets/main/import/02/0254af710.json":{"size":281,"md5":"e859c04502eab6f53d55174bbd4f1d3d"},"assets/main/import/06/06cf73164.json":{"size":36298,"md5":"208e5254dfe5589ad716071ab641bfb5"},"assets/main/index.js":{"size":438903,"md5":"326c1799c4ce005357ea688eb7abea00"},"assets/main/native/2d/2ddfe005-2129-41d8-aeec-2b1f51f02962.png":{"size":2290,"md5":"740ebade1729539882383360b2066d36"},"assets/main/native/34/3459ab36-782c-4c4e-8aef-7280aff8b272.png":{"size":18969,"md5":"96e39d211db65235f425ba3957b723b0"},"assets/main/native/70/700faa17-11a6-46cd-aeb5-d6900bc264f8.png":{"size":3765,"md5":"60ab4dfb6d3e8a147753b5665dcba27a"},"assets/main/native/71/71561142-4c83-4933-afca-cb7a17f67053.png":{"size":1050,"md5":"72c8f8527cdbe8246b8223a54f409ca3"},"assets/main/native/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.png":{"size":1114,"md5":"49624805cb214b8d78d34a0c03dfbd00"},"assets/main/native/c3/c39ea496-96eb-4dc5-945a-e7c919b77c21.png":{"size":2548,"md5":"c3b93af99c4a65d85ad414e8e46dbfd5"},"assets/main/native/ca/caaaf9ff-5036-4232-a8a7-88b80b2e4c88.png":{"size":1829,"md5":"e3e1ef9049e7c82cbb696bc4e8cfa64b"},"assets/main/native/e5/e56254ca-0ee4-42ea-b69e-d2e57804a4f1.jpg":{"size":5809,"md5":"8fbe8a70e5b43c90bed44cf38e0e2a50"}},"searchPaths":[]}
|
@ -1 +1 @@
|
||||
{"packageUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/","remoteManifestUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/project.manifest","remoteVersionUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0.1/version.manifest","version":"3.0.1"}
|
||||
{"packageUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/","remoteManifestUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/project.manifest","remoteVersionUrl":"https://jianmiau.tk/Resources/App/JMKA/update/remote-assets/3.0/version.manifest","version":"3.1"}
|
Loading…
Reference in New Issue
Block a user