84ffafa622d6d116336ccfdfdb2a1592352330d0.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCString, Enum, EventHandler, _decorator, VMBase, _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _crd, ccclass, property, executeInEditMode, menu, help, FILTER_MODE, VMEvent;
  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 _reportPossibleCrUseOfVMBase(extras) {
  8. _reporterNs.report("VMBase", "./VMBase", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. CCString = _cc.CCString;
  18. Enum = _cc.Enum;
  19. EventHandler = _cc.EventHandler;
  20. _decorator = _cc._decorator;
  21. }, function (_unresolved_2) {
  22. VMBase = _unresolved_2.VMBase;
  23. }],
  24. execute: function () {
  25. _crd = true;
  26. _cclegacy._RF.push({}, "a9ce7kf8XZJeLPlT2iWn2zD", "VMEvent", undefined);
  27. __checkObsolete__(['CCString', 'Enum', 'EventHandler', '_decorator']);
  28. // +普通 label 更新数据的情况,label.string = xxx;
  29. // +frameIndex 插件,通过number 数值设置 BhvFrameIndex 来切换当前贴图
  30. // +spriteFrame 直接替换贴图的情况 ,
  31. // 读取本地路径 data.spriteFrame = $res:/pic/com1
  32. // 读取网页路径 data.spriteFrame = $url:http:xxxxxxxxxx.png
  33. // +特殊条件控制
  34. // 比较条件:,如果传入值 > /< />= /<= /== 某值时,执行的action类型
  35. ({
  36. ccclass,
  37. property,
  38. executeInEditMode,
  39. menu,
  40. help
  41. } = _decorator);
  42. FILTER_MODE = /*#__PURE__*/function (FILTER_MODE) {
  43. FILTER_MODE[FILTER_MODE["none"] = 0] = "none";
  44. FILTER_MODE[FILTER_MODE["=="] = 1] = "==";
  45. FILTER_MODE[FILTER_MODE["!="] = 2] = "!=";
  46. FILTER_MODE[FILTER_MODE[">"] = 3] = ">";
  47. FILTER_MODE[FILTER_MODE[">="] = 4] = ">=";
  48. FILTER_MODE[FILTER_MODE["<"] = 5] = "<";
  49. FILTER_MODE[FILTER_MODE["<="] = 6] = "<=";
  50. return FILTER_MODE;
  51. }(FILTER_MODE || {});
  52. /**
  53. * [VM-Event]
  54. * 提供 ViewModel 的相关基础功能,
  55. * 如果值发生变化将会调用对应的函数方法
  56. */
  57. _export("default", VMEvent = (_dec = menu('OopsFramework/Mvvm/VM-EventCall (调用函数)'), _dec2 = help('https://gitee.com/dgflash/oops-framework/wikis/pages?sort_id=12037640&doc_id=2873565'), _dec3 = property({
  58. tooltip: '使用模板模式,可以使用多路径监听'
  59. }), _dec4 = property({
  60. tooltip: '监听获取值的路径',
  61. visible: function visible() {
  62. // @ts-ignore
  63. return this.templateMode === false;
  64. }
  65. }), _dec5 = property({
  66. tooltip: '触发一次后会自动关闭该事件'
  67. }), _dec6 = property({
  68. tooltip: '监听获取值的多条路径,这些值的改变都会通过这个函数回调,请使用 pathArr 区分获取的值 ',
  69. type: [CCString],
  70. visible: function visible() {
  71. // @ts-ignore
  72. return this.templateMode === true;
  73. }
  74. }), _dec7 = property({
  75. tooltip: '过滤模式,会根据条件过滤掉时间的触发',
  76. type: Enum(FILTER_MODE)
  77. }), _dec8 = property({
  78. visible: function visible() {
  79. // @ts-ignore
  80. return this.filterMode !== FILTER_MODE.none;
  81. }
  82. }), _dec9 = property([EventHandler]), ccclass(_class = executeInEditMode(_class = _dec(_class = _dec2(_class = (_class2 = class VMEvent extends (_crd && VMBase === void 0 ? (_reportPossibleCrUseOfVMBase({
  83. error: Error()
  84. }), VMBase) : VMBase) {
  85. constructor() {
  86. super(...arguments);
  87. _initializerDefineProperty(this, "templateMode", _descriptor, this);
  88. _initializerDefineProperty(this, "watchPath", _descriptor2, this);
  89. _initializerDefineProperty(this, "triggerOnce", _descriptor3, this);
  90. _initializerDefineProperty(this, "watchPathArr", _descriptor4, this);
  91. _initializerDefineProperty(this, "filterMode", _descriptor5, this);
  92. _initializerDefineProperty(this, "compareValue", _descriptor6, this);
  93. _initializerDefineProperty(this, "changeEvents", _descriptor7, this);
  94. }
  95. onValueInit() {}
  96. onValueChanged(newVar, oldVar, pathArr) {
  97. var res = this.conditionCheck(newVar, this.compareValue);
  98. if (!res) return;
  99. if (Array.isArray(this.changeEvents)) {
  100. this.changeEvents.forEach(v => {
  101. v.emit([newVar, oldVar, pathArr]);
  102. });
  103. } // 激活一次后,自动关闭组件
  104. if (this.triggerOnce === true) {
  105. this.enabled = false;
  106. }
  107. }
  108. /** 条件检查 */
  109. conditionCheck(a, b) {
  110. var cod = FILTER_MODE;
  111. switch (this.filterMode) {
  112. case cod.none:
  113. return true;
  114. case cod["=="]:
  115. if (a == b) return true;
  116. break;
  117. case cod["!="]:
  118. if (a != b) return true;
  119. break;
  120. case cod["<"]:
  121. if (a < b) return true;
  122. break;
  123. case cod[">"]:
  124. if (a > b) return true;
  125. break;
  126. case cod[">="]:
  127. if (a >= b) return true;
  128. break;
  129. case cod["<"]:
  130. if (a < b) return true;
  131. break;
  132. case cod["<="]:
  133. if (a <= b) return true;
  134. break;
  135. default:
  136. break;
  137. }
  138. return false;
  139. }
  140. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "templateMode", [_dec3], {
  141. configurable: true,
  142. enumerable: true,
  143. writable: true,
  144. initializer: function initializer() {
  145. return false;
  146. }
  147. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "watchPath", [_dec4], {
  148. configurable: true,
  149. enumerable: true,
  150. writable: true,
  151. initializer: function initializer() {
  152. return "";
  153. }
  154. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "triggerOnce", [_dec5], {
  155. configurable: true,
  156. enumerable: true,
  157. writable: true,
  158. initializer: function initializer() {
  159. return false;
  160. }
  161. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "watchPathArr", [_dec6], {
  162. configurable: true,
  163. enumerable: true,
  164. writable: true,
  165. initializer: function initializer() {
  166. return [];
  167. }
  168. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "filterMode", [_dec7], {
  169. configurable: true,
  170. enumerable: true,
  171. writable: true,
  172. initializer: function initializer() {
  173. return FILTER_MODE.none;
  174. }
  175. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "compareValue", [_dec8], {
  176. configurable: true,
  177. enumerable: true,
  178. writable: true,
  179. initializer: function initializer() {
  180. return '';
  181. }
  182. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "changeEvents", [_dec9], {
  183. configurable: true,
  184. enumerable: true,
  185. writable: true,
  186. initializer: function initializer() {
  187. return [];
  188. }
  189. })), _class2)) || _class) || _class) || _class) || _class));
  190. _cclegacy._RF.pop();
  191. _crd = false;
  192. }
  193. };
  194. });
  195. //# sourceMappingURL=84ffafa622d6d116336ccfdfdb2a1592352330d0.js.map