f493614a84bde9a825731834174b0b6063b74d70.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, BlockInputEvents, Layers, Node, Widget, instantiate, ViewUtil, Notify, LayerNotify, _crd, ToastPrefabPath, WaitPrefabPath;
  4. function _reportPossibleCrUseOfViewUtil(extras) {
  5. _reporterNs.report("ViewUtil", "../../utils/ViewUtil", _context.meta, extras);
  6. }
  7. function _reportPossibleCrUseOfNotify(extras) {
  8. _reporterNs.report("Notify", "../prompt/Notify", _context.meta, extras);
  9. }
  10. _export("LayerNotify", void 0);
  11. return {
  12. setters: [function (_unresolved_) {
  13. _reporterNs = _unresolved_;
  14. }, function (_cc) {
  15. _cclegacy = _cc.cclegacy;
  16. __checkObsolete__ = _cc.__checkObsolete__;
  17. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  18. BlockInputEvents = _cc.BlockInputEvents;
  19. Layers = _cc.Layers;
  20. Node = _cc.Node;
  21. Widget = _cc.Widget;
  22. instantiate = _cc.instantiate;
  23. }, function (_unresolved_2) {
  24. ViewUtil = _unresolved_2.ViewUtil;
  25. }, function (_unresolved_3) {
  26. Notify = _unresolved_3.Notify;
  27. }],
  28. execute: function () {
  29. _crd = true;
  30. _cclegacy._RF.push({}, "da14ax+B2xNsL2taQFOh7we", "LayerNotify", undefined);
  31. /*
  32. * @Author: dgflash
  33. * @Date: 2022-08-15 10:06:47
  34. * @LastEditors: dgflash
  35. * @LastEditTime: 2022-09-02 13:44:12
  36. */
  37. __checkObsolete__(['BlockInputEvents', 'Layers', 'Node', 'Widget', 'instantiate']);
  38. ToastPrefabPath = 'common/prefab/notify';
  39. WaitPrefabPath = 'common/prefab/wait';
  40. /*
  41. * 滚动消息提示层
  42. */
  43. _export("LayerNotify", LayerNotify = class LayerNotify extends Node {
  44. constructor(name) {
  45. super(name);
  46. this.black = void 0;
  47. /** 等待提示资源 */
  48. this.wait = null;
  49. /** 自定义弹出提示资源 */
  50. this.notify = null;
  51. /** 自定义弹出提示内容资源 */
  52. this.notifyItem = null;
  53. var widget = this.addComponent(Widget);
  54. widget.isAlignLeft = widget.isAlignRight = widget.isAlignTop = widget.isAlignBottom = true;
  55. widget.left = widget.right = widget.top = widget.bottom = 0;
  56. widget.alignMode = 2;
  57. widget.enabled = true;
  58. this.init();
  59. }
  60. init() {
  61. this.layer = Layers.Enum.UI_2D;
  62. this.black = this.addComponent(BlockInputEvents);
  63. this.black.enabled = false;
  64. }
  65. /** 打开等待提示 */
  66. waitOpen() {
  67. if (this.wait == null) this.wait = (_crd && ViewUtil === void 0 ? (_reportPossibleCrUseOfViewUtil({
  68. error: Error()
  69. }), ViewUtil) : ViewUtil).createPrefabNode(WaitPrefabPath);
  70. if (this.wait.parent == null) {
  71. this.wait.parent = this;
  72. this.black.enabled = true;
  73. }
  74. }
  75. /** 关闭等待提示 */
  76. waitClose() {
  77. if (this.wait && this.wait.parent) {
  78. this.wait.parent = null;
  79. this.black.enabled = false;
  80. }
  81. }
  82. /**
  83. * 渐隐飘过提示
  84. * @param content 文本表示
  85. * @param useI18n 是否使用多语言
  86. */
  87. toast(content, useI18n) {
  88. if (this.notify == null) {
  89. this.notify = (_crd && ViewUtil === void 0 ? (_reportPossibleCrUseOfViewUtil({
  90. error: Error()
  91. }), ViewUtil) : ViewUtil).createPrefabNode(ToastPrefabPath);
  92. this.notifyItem = this.notify.children[0];
  93. this.notifyItem.parent = null;
  94. }
  95. this.notify.parent = this;
  96. var childNode = instantiate(this.notifyItem);
  97. var prompt = childNode.getChildByName("prompt");
  98. var toastCom = prompt.getComponent(_crd && Notify === void 0 ? (_reportPossibleCrUseOfNotify({
  99. error: Error()
  100. }), Notify) : Notify);
  101. childNode.parent = this.notify;
  102. toastCom.onComplete = () => {
  103. if (this.notify.children.length == 0) {
  104. this.notify.parent = null;
  105. }
  106. };
  107. toastCom.toast(content, useI18n); // 超过3个提示,就施放第一个提示
  108. if (this.notify.children.length > 3) {
  109. this.notify.children[0].destroy();
  110. }
  111. }
  112. });
  113. _cclegacy._RF.pop();
  114. _crd = false;
  115. }
  116. };
  117. });
  118. //# sourceMappingURL=f493614a84bde9a825731834174b0b6063b74d70.js.map