LaunchMgr.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * 背包数据管理
  3. */
  4. let LaunchMgr = {
  5. /**
  6. * 初始化
  7. *
  8. * @author Pyden
  9. * @date 2019-03-21
  10. */
  11. init () {
  12. if (CC_EDITOR) {
  13. return;
  14. }
  15. this.initLocalStorage();
  16. },
  17. /**
  18. * 获取管理器的本地存储值
  19. *
  20. * @author Wetion
  21. * @date 2019-03-27
  22. * @param {String} key
  23. * @returns {object}
  24. */
  25. getStorageValue (key) {
  26. if (!this._localStorage) {
  27. G.LogUtils.error('Bug:用户本地存储不存在');
  28. return;
  29. }
  30. return this._localStorage.getValue(key);
  31. },
  32. /**
  33. * 设置管理器本地存储值
  34. *
  35. * @author Wetion
  36. * @date 2019-03-27
  37. * @param {String} key
  38. * @param {object} value
  39. */
  40. setStorageValue (key, value) {
  41. if (!this._localStorage) {
  42. G.LogUtils.error('Bug:用户本地存储不存在');
  43. return;
  44. }
  45. this._localStorage.setValue(key, value);
  46. },
  47. /**
  48. * 批量设置管理器本地存储值
  49. *
  50. * @author Wetion
  51. * @date 2019-03-27
  52. * @param {Object} values
  53. */
  54. setStorageValues (values) {
  55. if (!this._localStorage) {
  56. G.LogUtils.error('Bug:用户本地存储不存在');
  57. return;
  58. }
  59. this._localStorage.setValues(values);
  60. },
  61. getPatform () {
  62. if (cc.sys.platform == cc.sys.ANDROID) {
  63. return '1';
  64. } else {
  65. return '2';
  66. }
  67. },
  68. // 热更新临时缓存文件夹
  69. getHotfixPath () {
  70. return jsb.fileUtils.getWritablePath() + this._getHotfixPathName();
  71. },
  72. // 热更新临时缓存文件夹,热更新未完成时,下载文件在该文件夹
  73. getHotfixTempPath () {
  74. return jsb.fileUtils.getWritablePath() + this._getHotfixPathTempName();
  75. },
  76. _getHotfixPathName () {
  77. return 'remote-assets';
  78. },
  79. _getHotfixPathTempName () {
  80. return this._getHotfixPathName() + '_temp';
  81. }
  82. };
  83. module.exports = LaunchMgr;