RemoteUpdateInfoCtrl.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const SceneCtrlBase = require('SceneCtrlBase');
  2. const JMLoadProgressBar = require('JMLoadProgressBar');
  3. // 等待版本信息返回
  4. // 主要是延长版本更新timeout时间
  5. cc.Class({
  6. extends: SceneCtrlBase,
  7. editor: {
  8. menu: 'Launch/RemoteUpdateInfoCtrl'
  9. },
  10. properties: {
  11. loadProgressBar: JMLoadProgressBar
  12. },
  13. onLoad () {
  14. this._super();
  15. this._endScene = false;
  16. // 等待《获取远程更新信息请求》10秒
  17. this.simulatorProgress(10, 1);
  18. },
  19. update () {
  20. if (this._endScene) {
  21. return;
  22. }
  23. if (G.RemoteUpdateInfoMgr.isReadyRemoteInfo) {
  24. if (G.RemoteUpdateInfoMgr.isHotUpdate) {
  25. if (G.RemoteUpdateInfoMgr.isReadyHotUpdate) {
  26. if (G.RemoteUpdateInfoMgr.isSmallHotUpdate || G.RemoteUpdateInfoMgr.isBigHotUpdate) {
  27. // 热更新
  28. G.LogUtils.log('有热更新,进入热更新场景');
  29. this._loadScene('scene_update_hot');
  30. return;
  31. } else {
  32. G.LogUtils.log('无更新,进入登录场景');
  33. this._loadScene('scene_login');
  34. return;
  35. }
  36. }
  37. } else if (G.RemoteUpdateInfoMgr.isVersionUpdate) {
  38. // 版本更新
  39. G.LogUtils.log('有版本更新,进入版本更新场景');
  40. this._loadScene('scene_update_version');
  41. return;
  42. } else {
  43. G.LogUtils.log('无更新,进入登录场景');
  44. this._loadScene('scene_login');
  45. return;
  46. }
  47. }
  48. if (this.loadProgressBar.progressBar.progress == 1) {
  49. G.LogUtils.log('超时,进入登录场景');
  50. this._loadScene('scene_login');
  51. }
  52. },
  53. // 模拟进度
  54. simulatorProgress (duration, progress) {
  55. this.loadProgressBar.setProgress(duration, progress);
  56. },
  57. _loadScene (sceneName) {
  58. this._endScene = true;
  59. G.AppUtils.loadScene(sceneName);
  60. }
  61. });