a09d98b4f81486ae56ffac23161a2c8c02812821.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCString, _decorator, StringFormatFunction, VMCustom, VMEnv, _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _crd, ccclass, property, menu, help, VMProgress;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfStringFormatFunction(extras) {
  8. _reporterNs.report("StringFormatFunction", "./StringFormat", _context.meta, extras);
  9. }
  10. function _reportPossibleCrUseOfVMCustom(extras) {
  11. _reporterNs.report("VMCustom", "./VMCustom", _context.meta, extras);
  12. }
  13. function _reportPossibleCrUseOfVMEnv(extras) {
  14. _reporterNs.report("VMEnv", "./VMEnv", _context.meta, extras);
  15. }
  16. return {
  17. setters: [function (_unresolved_) {
  18. _reporterNs = _unresolved_;
  19. }, function (_cc) {
  20. _cclegacy = _cc.cclegacy;
  21. __checkObsolete__ = _cc.__checkObsolete__;
  22. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  23. CCString = _cc.CCString;
  24. _decorator = _cc._decorator;
  25. }, function (_unresolved_2) {
  26. StringFormatFunction = _unresolved_2.StringFormatFunction;
  27. }, function (_unresolved_3) {
  28. VMCustom = _unresolved_3.VMCustom;
  29. }, function (_unresolved_4) {
  30. VMEnv = _unresolved_4.VMEnv;
  31. }],
  32. execute: function () {
  33. _crd = true;
  34. _cclegacy._RF.push({}, "2a50eqI7JZNV5Sh0y/Qd9C6", "VMProgress", undefined);
  35. /*
  36. * @Author: dgflash
  37. * @Date: 2022-08-11 14:45:44
  38. * @LastEditors: dgflash
  39. * @LastEditTime: 2022-08-11 15:43:34
  40. */
  41. __checkObsolete__(['CCString', '_decorator']);
  42. ({
  43. ccclass,
  44. property,
  45. menu,
  46. help
  47. } = _decorator);
  48. _export("default", VMProgress = (_dec = menu('OopsFramework/Mvvm/VM-Progress (进度条)'), _dec2 = help('https://gitee.com/dgflash/oops-framework/wikis/pages?sort_id=12037843&doc_id=2873565'), _dec3 = property({
  49. visible: false,
  50. override: true
  51. }), _dec4 = property({
  52. type: [CCString],
  53. tooltip: '第一个值是min 值,第二个值 是 max 值,会计算出两者的比例'
  54. }), _dec5 = property({
  55. visible: function () {
  56. // @ts-ignore
  57. return this.componentProperty === 'string';
  58. },
  59. tooltip: '字符串格式化,和 VMLabel 的字段一样,需要填入对应的格式化字符串'
  60. }), ccclass(_class = _dec(_class = _dec2(_class = (_class2 = class VMProgress extends (_crd && VMCustom === void 0 ? (_reportPossibleCrUseOfVMCustom({
  61. error: Error()
  62. }), VMCustom) : VMCustom) {
  63. constructor(...args) {
  64. super(...args);
  65. _initializerDefineProperty(this, "watchPath", _descriptor, this);
  66. _initializerDefineProperty(this, "watchPathArr", _descriptor2, this);
  67. this.templateMode = true;
  68. _initializerDefineProperty(this, "stringFormat", _descriptor3, this);
  69. }
  70. onLoad() {
  71. if (this.watchPathArr.length < 2 || this.watchPathArr[0] == '[min]' || this.watchPathArr[1] == '[max]') {
  72. console.error('VMProgress must have two values!');
  73. }
  74. super.onLoad();
  75. }
  76. start() {
  77. if ((_crd && VMEnv === void 0 ? (_reportPossibleCrUseOfVMEnv({
  78. error: Error()
  79. }), VMEnv) : VMEnv).editor) return;
  80. this.onValueInit();
  81. }
  82. onValueInit() {
  83. let max = this.watchPathArr.length;
  84. for (let i = 0; i < max; i++) {
  85. this.templateValueArr[i] = this.VM.getValue(this.watchPathArr[i]);
  86. }
  87. let value = this.templateValueArr[0] / this.templateValueArr[1];
  88. this.setComponentValue(value);
  89. }
  90. setComponentValue(value) {
  91. if (this.stringFormat !== '') {
  92. let res = (_crd && StringFormatFunction === void 0 ? (_reportPossibleCrUseOfStringFormatFunction({
  93. error: Error()
  94. }), StringFormatFunction) : StringFormatFunction).deal(value, this.stringFormat);
  95. super.setComponentValue(res);
  96. } else {
  97. super.setComponentValue(value);
  98. }
  99. }
  100. onValueController(n, o) {
  101. let value = Math.round(n * this.templateValueArr[1]);
  102. if (Number.isNaN(value)) value = 0;
  103. this.VM.setValue(this.watchPathArr[0], value);
  104. }
  105. /** 初始化改变数据 */
  106. onValueChanged(n, o, pathArr) {
  107. if (this.templateMode === false) return;
  108. let path = pathArr.join('.'); // 寻找缓存位置
  109. let index = this.watchPathArr.findIndex(v => v === path);
  110. if (index >= 0) {
  111. // 如果是所属的路径,就可以替换文本了
  112. this.templateValueArr[index] = n; //缓存值
  113. }
  114. let value = this.templateValueArr[0] / this.templateValueArr[1];
  115. if (value > 1) value = 1;
  116. if (value < 0 || Number.isNaN(value)) value = 0;
  117. this.setComponentValue(value);
  118. }
  119. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "watchPath", [_dec3], {
  120. configurable: true,
  121. enumerable: true,
  122. writable: true,
  123. initializer: function () {
  124. return '';
  125. }
  126. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "watchPathArr", [_dec4], {
  127. configurable: true,
  128. enumerable: true,
  129. writable: true,
  130. initializer: function () {
  131. return ['[min]', '[max]'];
  132. }
  133. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "stringFormat", [_dec5], {
  134. configurable: true,
  135. enumerable: true,
  136. writable: true,
  137. initializer: function () {
  138. return '';
  139. }
  140. })), _class2)) || _class) || _class) || _class));
  141. _cclegacy._RF.pop();
  142. _crd = false;
  143. }
  144. };
  145. });
  146. //# sourceMappingURL=a09d98b4f81486ae56ffac23161a2c8c02812821.js.map