update
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { sys } from 'cc'
|
||||
|
||||
import ManifestConfig from '../config/ManifestConfig'
|
||||
|
||||
import EventManager from './EventManager'
|
||||
import HotUpdate from './HotUpdate'
|
||||
|
||||
@@ -8,7 +10,7 @@ export default class VersionManager {
|
||||
|
||||
public static Config_Game_Name: Array<string> = ['游戏大厅']
|
||||
|
||||
//热更文件下载来后存放文件夹
|
||||
// 热更文件下载来后存放文件夹
|
||||
public static Config_Key: Array<string> = ['main-remote-asset']
|
||||
|
||||
private static Config_ManifestName: string = 'project.manifest'
|
||||
@@ -18,10 +20,10 @@ export default class VersionManager {
|
||||
public iosStoreUrl: string = ''
|
||||
public apkStoreUrl: string = ''
|
||||
|
||||
public nowVersion: string = ManifestConfig.version //网页显示版本号,如果是热更会替换改值
|
||||
public nowVersion: string = ManifestConfig.version // 网页显示版本号,如果是热更会替换改值
|
||||
public targetVersion: string = '1.0.0'
|
||||
|
||||
public isOpenHotUpdate: boolean = true //是否打开热更
|
||||
public isOpenHotUpdate: boolean = true // 是否打开热更
|
||||
|
||||
private hotUpdateList: Array<HotUpdate> = []
|
||||
|
||||
@@ -33,27 +35,21 @@ export default class VersionManager {
|
||||
|
||||
public reInitAll() {
|
||||
this.releaseAll()
|
||||
for (let i = 0; i < VersionManager.Config_Key.length; i++) {
|
||||
this.reInit(i)
|
||||
}
|
||||
for (let i = 0; i < VersionManager.Config_Key.length; i++) this.reInit(i)
|
||||
}
|
||||
|
||||
public releaseAll() {
|
||||
for (let i = 0; i < VersionManager.Config_Key.length; i++) {
|
||||
if (this.hotUpdateList[i]) {
|
||||
this.hotUpdateList[i].disposeUpdate()
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < VersionManager.Config_Key.length; i++)
|
||||
if (this.hotUpdateList[i]) this.hotUpdateList[i].disposeUpdate()
|
||||
}
|
||||
|
||||
public reInit(index: number) {
|
||||
if (!this.hotUpdateList[index]) {
|
||||
this.hotUpdateList[index] = new HotUpdate()
|
||||
}
|
||||
if (!this.hotUpdateList[index]) this.hotUpdateList[index] = new HotUpdate()
|
||||
|
||||
this.hotUpdateList[index].init(
|
||||
index,
|
||||
VersionManager.Config_Key[index],
|
||||
VersionManager.Config_ManifestName
|
||||
VersionManager.Config_ManifestName,
|
||||
)
|
||||
if (!this.isOpenHotUpdate) {
|
||||
this.hotUpdateList[index].isCheck = true
|
||||
@@ -63,15 +59,15 @@ export default class VersionManager {
|
||||
|
||||
public checkUpdate(keyIndex: number) {
|
||||
if (keyIndex < this.hotUpdateList.length) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (sys.isNative) {
|
||||
if (keyIndex == this.noUpdateIndex) {
|
||||
//在大厅热更,不用子游戏热更了
|
||||
if (keyIndex === this.noUpdateIndex) {
|
||||
// 在大厅热更,不用子游戏热更了
|
||||
hotUpdate.isCheck = true
|
||||
hotUpdate.isFinishUpdate = true
|
||||
EventManager.instance.dispatchEvent(
|
||||
HotUpdate.Event_On_ALREADY_UP_TO_DATE,
|
||||
VersionManager.Config_Key[keyIndex]
|
||||
VersionManager.Config_Key[keyIndex],
|
||||
)
|
||||
} else {
|
||||
hotUpdate.checkUpdate()
|
||||
@@ -81,28 +77,27 @@ export default class VersionManager {
|
||||
hotUpdate.isFinishUpdate = true
|
||||
EventManager.instance.dispatchEvent(
|
||||
HotUpdate.Event_On_ALREADY_UP_TO_DATE,
|
||||
VersionManager.Config_Key[keyIndex]
|
||||
VersionManager.Config_Key[keyIndex],
|
||||
)
|
||||
}
|
||||
} else {
|
||||
EventManager.instance.dispatchEvent(
|
||||
HotUpdate.Event_On_ALREADY_UP_TO_DATE,
|
||||
VersionManager.Config_Key[keyIndex]
|
||||
VersionManager.Config_Key[keyIndex],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public startUpdate(keyIndex: number) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
hotUpdate.startUpdate()
|
||||
}
|
||||
|
||||
public isCheck(keyIndex: number) {
|
||||
if (keyIndex < this.hotUpdateList.length) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex == this.noUpdateIndex) {
|
||||
return true
|
||||
}
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex === this.noUpdateIndex) return true
|
||||
|
||||
return hotUpdate.isCheck
|
||||
}
|
||||
return true
|
||||
@@ -110,10 +105,9 @@ export default class VersionManager {
|
||||
|
||||
public needUpdate(keyIndex: number) {
|
||||
if (keyIndex < this.hotUpdateList.length) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex == this.noUpdateIndex) {
|
||||
return false
|
||||
}
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex === this.noUpdateIndex) return false
|
||||
|
||||
return hotUpdate.needUpdate
|
||||
}
|
||||
return false
|
||||
@@ -121,7 +115,7 @@ export default class VersionManager {
|
||||
|
||||
public isUpdating(keyIndex: number) {
|
||||
if (keyIndex < this.hotUpdateList.length) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
return hotUpdate.isUpdating
|
||||
}
|
||||
return false
|
||||
@@ -129,10 +123,9 @@ export default class VersionManager {
|
||||
|
||||
public isFinishUpdate(keyIndex: number) {
|
||||
if (keyIndex < this.hotUpdateList.length) {
|
||||
let hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex == this.noUpdateIndex) {
|
||||
return true
|
||||
}
|
||||
const hotUpdate: HotUpdate = this.hotUpdateList[keyIndex]
|
||||
if (keyIndex === this.noUpdateIndex) return true
|
||||
|
||||
return hotUpdate.isFinishUpdate
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user