@zhubangyun/lowcode-core 5.12.92 → 6.1.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/es/components/load-materials/index.js +44 -28
  2. package/es/components/page-loading/index.js +4 -1
  3. package/es/demo/index.js +8 -8
  4. package/es/index.d.ts +1 -1
  5. package/es/index.js +41 -2
  6. package/es/index.less +10 -0
  7. package/es/style.js +2 -2
  8. package/es/utils/api/file-api.js +21 -21
  9. package/es/utils/api/form-api.d.ts +2 -1
  10. package/es/utils/api/form-api.js +90 -51
  11. package/es/utils/api/form-api.utils.js +5 -4
  12. package/es/utils/api/index.d.ts +2 -2
  13. package/es/utils/api/index.js +1 -0
  14. package/es/utils/api/rest-api.d.ts +3 -1
  15. package/es/utils/api/rest-api.js +207 -125
  16. package/es/utils/api/schema-api.js +5 -5
  17. package/es/utils/api/schema.util.d.ts +3 -3
  18. package/es/utils/api/schema.util.js +17 -12
  19. package/es/utils/api/script-api.js +12 -12
  20. package/es/utils/api/user-info.js +7 -7
  21. package/es/utils/cache/index.js +66 -26
  22. package/es/utils/common/LoadPlugins.js +33 -33
  23. package/es/utils/common/SingletonInstanceMap.js +21 -21
  24. package/es/utils/common/index.d.ts +3 -0
  25. package/es/utils/common/index.js +13 -3
  26. package/es/utils/designer/assets/assets.parse.js +15 -15
  27. package/es/utils/designer/assets/assets.typing.js +6 -0
  28. package/es/utils/designer/engine/index.js +23 -23
  29. package/es/utils/designer/index.js +7 -7
  30. package/es/utils/page/index.js +18 -18
  31. package/es/utils/page/page-form-data-manager-group.js +9 -6
  32. package/es/utils/page/page-form-data-manager.d.ts +1 -0
  33. package/es/utils/page/page-form-data-manager.js +9 -6
  34. package/es/utils/page/page-form-group.d.ts +1 -0
  35. package/es/utils/page/page-form-group.js +8 -7
  36. package/es/utils/page/page-form.d.ts +1 -0
  37. package/es/utils/page/page-form.js +23 -12
  38. package/es/utils/page/page-layout.d.ts +3 -0
  39. package/es/utils/page/page-layout.js +33 -9
  40. package/es/utils/page/page-load-schema.js +20 -28
  41. package/es/utils/page/page-render.js +4 -4
  42. package/es/utils/page/page-show.d.ts +2 -0
  43. package/es/utils/page/page-show.js +8 -3
  44. package/es/utils/page/print-form.js +60 -51
  45. package/es/utils/uni-bridge.d.ts +18 -0
  46. package/es/utils/uni-bridge.js +130 -0
  47. package/es/utils/util.common.d.ts +1 -0
  48. package/es/utils/util.common.js +4 -0
  49. package/lib/components/load-materials/index.js +45 -30
  50. package/lib/components/page-loading/index.js +4 -1
  51. package/lib/demo/index.js +9 -10
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.js +45 -6
  54. package/lib/index.less +10 -0
  55. package/lib/style.js +2 -2
  56. package/lib/utils/api/file-api.js +21 -21
  57. package/lib/utils/api/form-api.d.ts +2 -1
  58. package/lib/utils/api/form-api.js +90 -51
  59. package/lib/utils/api/form-api.utils.js +5 -4
  60. package/lib/utils/api/index.d.ts +2 -2
  61. package/lib/utils/api/index.js +2 -2
  62. package/lib/utils/api/rest-api.d.ts +3 -1
  63. package/lib/utils/api/rest-api.js +207 -125
  64. package/lib/utils/api/schema-api.js +5 -5
  65. package/lib/utils/api/schema.util.d.ts +3 -3
  66. package/lib/utils/api/schema.util.js +19 -13
  67. package/lib/utils/api/script-api.js +12 -12
  68. package/lib/utils/api/user-info.js +7 -7
  69. package/lib/utils/cache/index.js +65 -25
  70. package/lib/utils/common/LoadPlugins.js +33 -33
  71. package/lib/utils/common/SingletonInstanceMap.js +21 -21
  72. package/lib/utils/common/index.d.ts +3 -0
  73. package/lib/utils/common/index.js +15 -2
  74. package/lib/utils/designer/assets/assets.parse.js +16 -17
  75. package/lib/utils/designer/assets/assets.typing.js +6 -0
  76. package/lib/utils/designer/engine/index.js +23 -23
  77. package/lib/utils/designer/index.js +7 -7
  78. package/lib/utils/index.js +1 -2
  79. package/lib/utils/page/index.js +18 -18
  80. package/lib/utils/page/page-form-data-manager-group.js +10 -8
  81. package/lib/utils/page/page-form-data-manager.d.ts +1 -0
  82. package/lib/utils/page/page-form-data-manager.js +10 -8
  83. package/lib/utils/page/page-form-group.d.ts +1 -0
  84. package/lib/utils/page/page-form-group.js +9 -9
  85. package/lib/utils/page/page-form.d.ts +1 -0
  86. package/lib/utils/page/page-form.js +24 -14
  87. package/lib/utils/page/page-layout.d.ts +3 -0
  88. package/lib/utils/page/page-layout.js +34 -11
  89. package/lib/utils/page/page-load-schema.js +19 -27
  90. package/lib/utils/page/page-render.js +4 -4
  91. package/lib/utils/page/page-show.d.ts +2 -0
  92. package/lib/utils/page/page-show.js +9 -5
  93. package/lib/utils/page/print-form.js +60 -51
  94. package/lib/utils/uni-bridge.d.ts +18 -0
  95. package/lib/utils/uni-bridge.js +135 -0
  96. package/lib/utils/util.common.d.ts +1 -0
  97. package/lib/utils/util.common.js +8 -0
  98. package/package.json +2 -2
@@ -1,56 +1,48 @@
1
1
  import _Result from "antd/es/result";
2
2
  import _message from "antd/es/message";
3
- import { useEffect, useState } from "react";
3
+ import { Fragment, useEffect, useState } from "react";
4
4
  import { getSchema } from "../api";
5
- import { PageLoading } from "../../components/page-loading";
6
5
  import { getSchemaFromCache } from "../api/schema-api";
6
+ import { hideLoading, showLoading } from "./index";
7
7
  export function PageLoadSchema(props) {
8
8
  var pageId = props.pageId,
9
9
  children = props.children;
10
10
  var cache = getSchemaFromCache(pageId);
11
- var _useState = useState(!cache),
12
- loading = _useState[0],
13
- setLoading = _useState[1];
14
- var _useState2 = useState(cache === null || cache === void 0 ? void 0 : cache.data),
15
- schema = _useState2[0],
16
- setSchema = _useState2[1];
17
- var _useState3 = useState(),
18
- errorMsg = _useState3[0],
19
- setErrorMsg = _useState3[1];
11
+ var _useState = useState(cache === null || cache === void 0 ? void 0 : cache.data),
12
+ schema = _useState[0],
13
+ setSchema = _useState[1];
14
+ var _useState2 = useState(),
15
+ errorMsg = _useState2[0],
16
+ setErrorMsg = _useState2[1];
20
17
  useEffect(function () {
21
- if (cache) {
18
+ if (cache !== null && cache !== void 0 && cache.success) {
22
19
  return;
23
20
  }
24
21
  if (pageId) {
22
+ showLoading().then();
25
23
  getSchema(pageId).then(function (res) {
26
24
  if (res.success) {
27
- setLoading(false);
28
- setSchema(res.data);
25
+ setSchema(res === null || res === void 0 ? void 0 : res.data);
29
26
  } else {
30
- setErrorMsg(res.message);
27
+ setErrorMsg(res === null || res === void 0 ? void 0 : res.message);
31
28
  }
29
+ })["finally"](function () {
30
+ hideLoading().then();
32
31
  });
33
32
  } else {
34
- setLoading(false);
35
- setErrorMsg("页面id不可为空!");
36
- console.error("页面id不可为空!");
37
- _message.error("页面id不可为空!").then();
33
+ hideLoading().then();
34
+ setErrorMsg("参数错误:页面id不可为空!");
35
+ _message.error("参数错误:页面id不可为空!").then();
38
36
  }
39
37
  }, []);
40
- if (cache) {
38
+ if (schema) {
41
39
  return children(schema);
42
40
  }
43
- if (loading) {
44
- return /*#__PURE__*/React.createElement(PageLoading, {
45
- loading: true,
46
- background: "rgba(255, 255, 255, 0)"
47
- });
48
- }
49
- if (!schema) {
41
+ if (errorMsg) {
50
42
  return /*#__PURE__*/React.createElement(_Result, {
51
43
  status: 500,
52
44
  title: errorMsg
53
45
  });
54
46
  }
55
- return children(schema);
47
+ return /*#__PURE__*/React.createElement(Fragment, null);
56
48
  }
@@ -4,10 +4,10 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { createElement } from "react";
5
5
  import { createRoot } from "react-dom/client";
6
6
  export function renderElement(options) {
7
- return new Promise( /*#__PURE__*/function () {
8
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
7
+ return new Promise(/*#__PURE__*/function () {
8
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
9
9
  var container, _onClose, _options$element, component, props, unmount, root, element;
10
- return _regeneratorRuntime.wrap(function _callee$(_context) {
10
+ return _regeneratorRuntime.wrap(function (_context) {
11
11
  while (1) switch (_context.prev = _context.next) {
12
12
  case 0:
13
13
  container = options.container, _onClose = options.onClose;
@@ -37,7 +37,7 @@ export function renderElement(options) {
37
37
  }
38
38
  }));
39
39
  root.render(element);
40
- case 7:
40
+ case 1:
41
41
  case "end":
42
42
  return _context.stop();
43
43
  }
@@ -4,6 +4,8 @@ export interface ShowPageProps {
4
4
  pageId: string;
5
5
  layout?: PageLayoutType;
6
6
  onClose?: () => void | Promise<void>;
7
+ extraProps?: any;
8
+ afterLoadSchema?: (schema: any) => void;
7
9
  pageRef?: (page: any) => void;
8
10
  }
9
11
  export declare function show(options: ShowPageProps): Promise<any | any[]>;
@@ -14,9 +14,9 @@ export function show(_x) {
14
14
  return _show.apply(this, arguments);
15
15
  }
16
16
  function _show() {
17
- _show = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
17
+ _show = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
18
18
  var container, onClose, props;
19
- return _regeneratorRuntime.wrap(function _callee$(_context) {
19
+ return _regeneratorRuntime.wrap(function (_context) {
20
20
  while (1) switch (_context.prev = _context.next) {
21
21
  case 0:
22
22
  container = options.container, onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
@@ -28,7 +28,7 @@ function _show() {
28
28
  props: props
29
29
  }
30
30
  }));
31
- case 2:
31
+ case 1:
32
32
  case "end":
33
33
  return _context.stop();
34
34
  }
@@ -44,6 +44,7 @@ var PageRender = /*#__PURE__*/function (_Component) {
44
44
  }
45
45
  _this = _Component.call.apply(_Component, [this].concat(args)) || this;
46
46
  _this.layoutRef = void 0;
47
+ _this.schema = void 0;
47
48
  return _this;
48
49
  }
49
50
  _inheritsLoose(PageRender, _Component);
@@ -72,6 +73,10 @@ var PageRender = /*#__PURE__*/function (_Component) {
72
73
  }, /*#__PURE__*/React.createElement(PageLoadSchema, {
73
74
  pageId: pageId
74
75
  }, function (schema) {
76
+ _this2.schema = schema;
77
+ if (_this2.props.pageRef) {
78
+ _this2.props.pageRef(_this2);
79
+ }
75
80
  return /*#__PURE__*/React.createElement(ReactRender, _extends({
76
81
  schema: schema,
77
82
  components: window._components || window.components || window.__components
@@ -8,12 +8,12 @@ export function getFormPrintTemplates(_x) {
8
8
  return _getFormPrintTemplates.apply(this, arguments);
9
9
  }
10
10
  function _getFormPrintTemplates() {
11
- _getFormPrintTemplates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formId) {
11
+ _getFormPrintTemplates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(formId) {
12
12
  var res;
13
- return _regeneratorRuntime.wrap(function _callee$(_context) {
13
+ return _regeneratorRuntime.wrap(function (_context) {
14
14
  while (1) switch (_context.prev = _context.next) {
15
15
  case 0:
16
- _context.next = 2;
16
+ _context.next = 1;
17
17
  return apiRequest.get("forms/search", {
18
18
  params: {
19
19
  formId: FormIds.printTemplate,
@@ -25,16 +25,16 @@ function _getFormPrintTemplates() {
25
25
  pageSize: 1000
26
26
  }
27
27
  });
28
- case 2:
28
+ case 1:
29
29
  res = _context.sent;
30
30
  if (!res.success) {
31
- _context.next = 7;
31
+ _context.next = 2;
32
32
  break;
33
33
  }
34
34
  return _context.abrupt("return", res.data);
35
- case 7:
35
+ case 2:
36
36
  return _context.abrupt("return", []);
37
- case 8:
37
+ case 3:
38
38
  case "end":
39
39
  return _context.stop();
40
40
  }
@@ -46,94 +46,103 @@ export function print(_x2) {
46
46
  return _print.apply(this, arguments);
47
47
  }
48
48
  function _print() {
49
- _print = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
50
- var templateId, iw;
51
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
49
+ _print = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
50
+ var templateId, iw, _t;
51
+ return _regeneratorRuntime.wrap(function (_context2) {
52
52
  while (1) switch (_context2.prev = _context2.next) {
53
53
  case 0:
54
54
  _context2.prev = 0;
55
- _context2.next = 3;
55
+ _context2.next = 1;
56
56
  return showLoading();
57
- case 3:
57
+ case 1:
58
58
  templateId = options === null || options === void 0 ? void 0 : options.templateId;
59
59
  if (templateId) {
60
- _context2.next = 7;
60
+ _context2.next = 2;
61
61
  break;
62
62
  }
63
63
  _message.error("\u6253\u5370\u5931\u8D25!\u6A21\u677Fid\u4E0D\u53EF\u4E3A\u7A7A!");
64
64
  return _context2.abrupt("return");
65
- case 7:
66
- _context2.next = 9;
67
- return openPrint(templateId);
68
- case 9:
65
+ case 2:
66
+ _context2.next = 3;
67
+ return openPrint(templateId, options);
68
+ case 3:
69
69
  iw = _context2.sent;
70
70
  if (iw) {
71
- _context2.next = 13;
71
+ _context2.next = 4;
72
72
  break;
73
73
  }
74
74
  _message.error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
75
75
  return _context2.abrupt("return");
76
- case 13:
77
- // @ts-ignore
78
- iw.printOptions = options;
79
- _context2.next = 19;
76
+ case 4:
77
+ _context2.next = 6;
80
78
  break;
81
- case 16:
82
- _context2.prev = 16;
83
- _context2.t0 = _context2["catch"](0);
84
- console.log("打印失败", _context2.t0);
85
- case 19:
86
- _context2.prev = 19;
87
- return _context2.finish(19);
88
- case 21:
79
+ case 5:
80
+ _context2.prev = 5;
81
+ _t = _context2["catch"](0);
82
+ console.log("打印失败", _t);
83
+ case 6:
84
+ _context2.prev = 6;
85
+ return _context2.finish(6);
86
+ case 7:
89
87
  case "end":
90
88
  return _context2.stop();
91
89
  }
92
- }, _callee2, null, [[0, 16, 19, 21]]);
90
+ }, _callee2, null, [[0, 5, 6, 7]]);
93
91
  }));
94
92
  return _print.apply(this, arguments);
95
93
  }
96
- function openPrint(_x3) {
94
+ function openPrint(_x3, _x4) {
97
95
  return _openPrint.apply(this, arguments);
98
96
  }
99
97
  function _openPrint() {
100
- _openPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId) {
101
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
98
+ _openPrint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId, options) {
99
+ var url;
100
+ return _regeneratorRuntime.wrap(function (_context4) {
102
101
  while (1) switch (_context4.prev = _context4.next) {
103
102
  case 0:
104
- return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
105
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolve, reject) {
106
- var iframe, iframeWindow;
107
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
103
+ url = "/print/" + templateId;
104
+ return _context4.abrupt("return", new Promise(/*#__PURE__*/function () {
105
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolve, reject) {
106
+ var printWindow, iframe;
107
+ return _regeneratorRuntime.wrap(function (_context3) {
108
108
  while (1) switch (_context3.prev = _context3.next) {
109
109
  case 0:
110
110
  iframe = document.createElement("iframe");
111
- iframe.src = "/print/" + templateId;
112
- iframe.style.display = "none";
111
+ iframe.src = url;
112
+ iframe.className = "print-iframe";
113
113
  document.body.appendChild(iframe);
114
- iframeWindow = iframe.contentWindow;
115
- if (iframeWindow) {
116
- _context3.next = 8;
114
+ printWindow = iframe.contentWindow;
115
+ if (printWindow) {
116
+ _context3.next = 1;
117
117
  break;
118
118
  }
119
119
  reject("创建Iframe失败!");
120
120
  return _context3.abrupt("return");
121
- case 8:
122
- iframeWindow.onload = function () {
123
- resolve(iframeWindow);
121
+ case 1:
122
+ // @ts-ignore
123
+ window.printWindow = printWindow;
124
+ printWindow.onload = function () {
125
+ // @ts-ignore
126
+ printWindow.printOptions = options;
124
127
  };
125
- iframeWindow.addEventListener("beforeprint", function () {});
126
- iframeWindow.addEventListener("afterprint", function () {
128
+ printWindow.addEventListener("beforeprint", function () {});
129
+ printWindow.addEventListener("afterprint", function () {
127
130
  hideLoading();
128
- iframe.remove();
131
+ setTimeout(function () {
132
+ resolve(printWindow);
133
+ if (window.__debug) {
134
+ return;
135
+ }
136
+ iframe.remove();
137
+ }, 100);
129
138
  });
130
- case 11:
139
+ case 2:
131
140
  case "end":
132
141
  return _context3.stop();
133
142
  }
134
143
  }, _callee3);
135
144
  }));
136
- return function (_x4, _x5) {
145
+ return function (_x5, _x6) {
137
146
  return _ref.apply(this, arguments);
138
147
  };
139
148
  }()));
@@ -0,0 +1,18 @@
1
+ interface ScanCodeOptions {
2
+ onlyFromCamera?: boolean;
3
+ openUrl?: boolean;
4
+ }
5
+ interface ScanCodeResult {
6
+ result: string;
7
+ }
8
+ declare class UniBridge {
9
+ private callbacks;
10
+ navigateTo(src: string): void;
11
+ scanCode(options: ScanCodeOptions): Promise<ScanCodeResult>;
12
+ getBarHeight(): Promise<unknown>;
13
+ getLocation(options: {}): Promise<unknown>;
14
+ private doAction;
15
+ private receiveMessage;
16
+ }
17
+ export declare const uniBridge: UniBridge;
18
+ export {};
@@ -0,0 +1,130 @@
1
+ import _message from "antd/es/message";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ var uniqueId = 0;
5
+ var UniBridge = /*#__PURE__*/function () {
6
+ function UniBridge() {
7
+ this.callbacks = {};
8
+ }
9
+ var _proto = UniBridge.prototype;
10
+ _proto.navigateTo = function navigateTo(src) {
11
+ var url = src;
12
+ if (!src.startsWith("http")) {
13
+ url = new URL(url, window.location.href).href;
14
+ }
15
+ uni.navigateTo({
16
+ url: "/pages/web-page/index?url=" + url
17
+ });
18
+ };
19
+ _proto.scanCode = /*#__PURE__*/function () {
20
+ var _scanCode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
21
+ var _t;
22
+ return _regeneratorRuntime.wrap(function (_context) {
23
+ while (1) switch (_context.prev = _context.next) {
24
+ case 0:
25
+ _context.prev = 0;
26
+ _context.next = 1;
27
+ return this.doAction("scanCode", options);
28
+ case 1:
29
+ return _context.abrupt("return", _context.sent);
30
+ case 2:
31
+ _context.prev = 2;
32
+ _t = _context["catch"](0);
33
+ _message.error("");
34
+ throw _t;
35
+ case 3:
36
+ case "end":
37
+ return _context.stop();
38
+ }
39
+ }, _callee, this, [[0, 2]]);
40
+ }));
41
+ function scanCode(_x) {
42
+ return _scanCode.apply(this, arguments);
43
+ }
44
+ return scanCode;
45
+ }();
46
+ _proto.getBarHeight = /*#__PURE__*/function () {
47
+ var _getBarHeight = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
48
+ return _regeneratorRuntime.wrap(function (_context2) {
49
+ while (1) switch (_context2.prev = _context2.next) {
50
+ case 0:
51
+ return _context2.abrupt("return", this.doAction("getBarHeight", {}));
52
+ case 1:
53
+ case "end":
54
+ return _context2.stop();
55
+ }
56
+ }, _callee2, this);
57
+ }));
58
+ function getBarHeight() {
59
+ return _getBarHeight.apply(this, arguments);
60
+ }
61
+ return getBarHeight;
62
+ }();
63
+ _proto.getLocation = /*#__PURE__*/function () {
64
+ var _getLocation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
65
+ return _regeneratorRuntime.wrap(function (_context3) {
66
+ while (1) switch (_context3.prev = _context3.next) {
67
+ case 0:
68
+ return _context3.abrupt("return", this.doAction("getLocation", {
69
+ type: 'wgs84'
70
+ }));
71
+ case 1:
72
+ case "end":
73
+ return _context3.stop();
74
+ }
75
+ }, _callee3, this);
76
+ }));
77
+ function getLocation(_x2) {
78
+ return _getLocation.apply(this, arguments);
79
+ }
80
+ return getLocation;
81
+ }();
82
+ _proto.doAction = /*#__PURE__*/function () {
83
+ var _doAction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(action, options) {
84
+ var _this = this;
85
+ var messageId;
86
+ return _regeneratorRuntime.wrap(function (_context4) {
87
+ while (1) switch (_context4.prev = _context4.next) {
88
+ case 0:
89
+ uniqueId++;
90
+ messageId = "msg_" + uniqueId + Date.now().toString(36);
91
+ return _context4.abrupt("return", new Promise(function (resolve, reject) {
92
+ _this.callbacks[messageId] = {
93
+ resolve: resolve,
94
+ reject: reject
95
+ };
96
+ console.log("postMessage", action, options);
97
+ uni.postMessage({
98
+ data: {
99
+ action: action,
100
+ messageId: messageId,
101
+ options: options
102
+ }
103
+ });
104
+ }));
105
+ case 1:
106
+ case "end":
107
+ return _context4.stop();
108
+ }
109
+ }, _callee4);
110
+ }));
111
+ function doAction(_x3, _x4) {
112
+ return _doAction.apply(this, arguments);
113
+ }
114
+ return doAction;
115
+ }();
116
+ _proto.receiveMessage = function receiveMessage(message) {
117
+ console.log('收到 UniApp 消息:', message);
118
+ var callback = this.callbacks[message.messageId];
119
+ if (callback) {
120
+ if (message.success) {
121
+ callback.resolve(message.data);
122
+ } else {
123
+ callback.reject(message.error || new Error('操作失败'));
124
+ }
125
+ delete this.callbacks[message.messageId];
126
+ }
127
+ };
128
+ return UniBridge;
129
+ }();
130
+ export var uniBridge = new UniBridge();
@@ -0,0 +1 @@
1
+ export declare function isTemplate(): boolean;
@@ -0,0 +1,4 @@
1
+ export function isTemplate() {
2
+ return false;
3
+ return location.host == "templates.zhiyunhe.com";
4
+ }
@@ -8,26 +8,38 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _pageLoading = require("../page-loading");
10
10
  var _common = require("../../utils/common");
11
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
12
+ function getInit() {
13
+ if (window._components) {
14
+ return true;
15
+ }
16
+ if (window.AntdProMaterial) {
17
+ setComponents();
18
+ return true;
19
+ }
20
+ return false;
21
+ }
13
22
  function LoadMaterials(props) {
14
- var _useState = (0, _react.useState)(false),
23
+ var _useState = (0, _react.useState)(getInit()),
15
24
  init = _useState[0],
16
25
  setInit = _useState[1];
17
26
  (0, _react.useEffect)(function () {
18
27
  initialize().then();
19
28
  }, []);
20
- if (window._components) {
21
- return props.children;
22
- }
23
29
  function initialize() {
24
30
  return _initialize.apply(this, arguments);
25
31
  }
26
32
  function _initialize() {
27
- _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
28
- return _regenerator["default"].wrap(function _callee$(_context) {
33
+ _initialize = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
34
+ return _regenerator["default"].wrap(function (_context) {
29
35
  while (1) switch (_context.prev = _context.next) {
30
36
  case 0:
37
+ if (!init) {
38
+ _context.next = 1;
39
+ break;
40
+ }
41
+ return _context.abrupt("return");
42
+ case 1:
31
43
  _context.next = 2;
32
44
  return loadMaterials();
33
45
  case 2:
@@ -52,41 +64,44 @@ function loadMaterials() {
52
64
  return _loadMaterials.apply(this, arguments);
53
65
  }
54
66
  function _loadMaterials() {
55
- _loadMaterials = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
56
- var components, urls;
57
- return _regenerator["default"].wrap(function _callee2$(_context2) {
67
+ _loadMaterials = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
68
+ var urls;
69
+ return _regenerator["default"].wrap(function (_context2) {
58
70
  while (1) switch (_context2.prev = _context2.next) {
59
71
  case 0:
60
- components = {};
61
72
  if (!window._components) {
62
- _context2.next = 3;
73
+ _context2.next = 1;
63
74
  break;
64
75
  }
65
76
  return _context2.abrupt("return");
66
- case 3:
67
- urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antd/latest/reset.css", "antd/latest/antd.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
68
- _context2.next = 6;
77
+ case 1:
78
+ urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
79
+ _context2.next = 2;
69
80
  return (0, _common.loadPlugins)(urls.map(function (url) {
70
81
  return "https://cdn.zhiyunhe.com/plugin/" + url;
71
82
  }));
72
- case 6:
73
- ["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
74
- var data = window[lib];
75
- if (data) {
76
- Object.entries(data).forEach(function (_ref) {
77
- var key = _ref[0],
78
- value = _ref[1];
79
- // @ts-ignore
80
- components[key] = value;
81
- });
82
- }
83
- });
84
- window._components = components;
85
- case 8:
83
+ case 2:
84
+ setComponents();
85
+ case 3:
86
86
  case "end":
87
87
  return _context2.stop();
88
88
  }
89
89
  }, _callee2);
90
90
  }));
91
91
  return _loadMaterials.apply(this, arguments);
92
+ }
93
+ function setComponents() {
94
+ var components = {};
95
+ ["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
96
+ var data = window[lib];
97
+ if (data) {
98
+ Object.entries(data).forEach(function (_ref) {
99
+ var key = _ref[0],
100
+ value = _ref[1];
101
+ // @ts-ignore
102
+ components[key] = value;
103
+ });
104
+ }
105
+ });
106
+ window._components = components;
92
107
  }
@@ -3,16 +3,19 @@
3
3
  exports.__esModule = true;
4
4
  exports.PageLoading = PageLoading;
5
5
  require("./index.less");
6
+ var _react = require("react");
6
7
  function PageLoading(props) {
7
8
  var loading = props.loading,
8
9
  _props$background = props.background,
9
10
  background = _props$background === void 0 ? "#f1f1f1" : _props$background,
10
11
  children = props.children;
12
+ (0, _react.useEffect)(function () {}, [loading]);
11
13
  return /*#__PURE__*/React.createElement("div", {
12
14
  className: "page-loading-wrapper",
13
15
  style: {
14
16
  width: "100%",
15
- height: "100%"
17
+ height: "100%",
18
+ background: "rgba(0,0,0,0)"
16
19
  }
17
20
  }, children, loading && /*#__PURE__*/React.createElement("div", {
18
21
  className: "page-loading",