@zhubangyun/lowcode-core 6.1.90 → 6.2.30

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 (55) hide show
  1. package/es/index.js +12 -34
  2. package/es/index.less +11 -0
  3. package/es/init/init.bar-height.d.ts +1 -0
  4. package/es/init/init.bar-height.js +37 -0
  5. package/es/init/init.mobile-class.d.ts +1 -0
  6. package/es/init/init.mobile-class.js +10 -0
  7. package/es/init/init.scroll-size.d.ts +5 -0
  8. package/es/init/init.scroll-size.js +26 -0
  9. package/es/style.js +1 -1
  10. package/es/utils/api/form-api.d.ts +1 -0
  11. package/es/utils/api/form-api.js +101 -19
  12. package/es/utils/api/index.js +3 -2
  13. package/es/utils/common/index.d.ts +1 -1
  14. package/es/utils/common/index.js +5 -1
  15. package/es/utils/page/index.js +10 -6
  16. package/es/utils/page/page-form-data-manager-group.js +8 -8
  17. package/es/utils/page/page-form-data-manager.js +8 -8
  18. package/es/utils/page/page-form.js +4 -6
  19. package/es/utils/page/page-layout.d.ts +2 -1
  20. package/es/utils/page/page-layout.js +23 -3
  21. package/es/utils/page/page-render.js +4 -5
  22. package/es/utils/page/page-show.js +4 -4
  23. package/es/utils/page/print-form.d.ts +3 -2
  24. package/es/utils/page/print-form.js +184 -54
  25. package/es/utils/uni-bridge.d.ts +2 -0
  26. package/es/utils/uni-bridge.js +78 -36
  27. package/es/utils/utils.scrollbar-size.js +0 -0
  28. package/lib/index.js +12 -34
  29. package/lib/index.less +11 -0
  30. package/lib/init/init.bar-height.d.ts +1 -0
  31. package/lib/init/init.bar-height.js +42 -0
  32. package/lib/init/init.mobile-class.d.ts +1 -0
  33. package/lib/init/init.mobile-class.js +14 -0
  34. package/lib/init/init.scroll-size.d.ts +5 -0
  35. package/lib/init/init.scroll-size.js +31 -0
  36. package/lib/style.js +1 -1
  37. package/lib/utils/api/form-api.d.ts +1 -0
  38. package/lib/utils/api/form-api.js +100 -18
  39. package/lib/utils/api/index.js +3 -2
  40. package/lib/utils/common/index.d.ts +1 -1
  41. package/lib/utils/common/index.js +5 -1
  42. package/lib/utils/page/index.js +10 -6
  43. package/lib/utils/page/page-form-data-manager-group.js +8 -8
  44. package/lib/utils/page/page-form-data-manager.js +8 -8
  45. package/lib/utils/page/page-form.js +4 -6
  46. package/lib/utils/page/page-layout.d.ts +2 -1
  47. package/lib/utils/page/page-layout.js +23 -3
  48. package/lib/utils/page/page-render.js +4 -5
  49. package/lib/utils/page/page-show.js +4 -4
  50. package/lib/utils/page/print-form.d.ts +3 -2
  51. package/lib/utils/page/print-form.js +184 -54
  52. package/lib/utils/uni-bridge.d.ts +2 -0
  53. package/lib/utils/uni-bridge.js +78 -36
  54. package/lib/utils/utils.scrollbar-size.js +1 -0
  55. package/package.json +1 -1
@@ -14,20 +14,20 @@ var _pageLayout = require("./page-layout");
14
14
  var _pageLoadSchema = require("./page-load-schema");
15
15
  var _reactRender = require("../../components/react-render");
16
16
  var _excluded = ["layout", "pageId", "onClose"],
17
- _excluded2 = ["container", "onClose"];
17
+ _excluded2 = ["onClose"];
18
18
  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); }
19
19
  function show(_x) {
20
20
  return _show.apply(this, arguments);
21
21
  }
22
22
  function _show() {
23
23
  _show = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
24
- var container, onClose, props;
24
+ var onClose, props;
25
25
  return _regenerator["default"].wrap(function (_context) {
26
26
  while (1) switch (_context.prev = _context.next) {
27
27
  case 0:
28
- container = options.container, onClose = options.onClose, props = (0, _objectWithoutPropertiesLoose2["default"])(options, _excluded2);
28
+ onClose = options.onClose, props = (0, _objectWithoutPropertiesLoose2["default"])(options, _excluded2);
29
29
  return _context.abrupt("return", (0, _pageRender.renderElement)({
30
- container: container,
30
+ container: props.container,
31
31
  onClose: onClose,
32
32
  element: {
33
33
  component: PageRender,
@@ -1,8 +1,9 @@
1
1
  interface PrintOptions {
2
+ showLoading?: boolean;
2
3
  templateId: string;
3
- mode?: "print" | "export";
4
+ mode?: "print" | "export" | "cloud_print";
4
5
  data: any;
5
6
  }
6
- export declare function getFormPrintTemplates(formId: string): Promise<any[]>;
7
+ export declare function getFormPrintTemplates(formId: string): Promise<any>;
7
8
  export declare function print(options: PrintOptions): Promise<void>;
8
9
  export {};
@@ -10,16 +10,23 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _api = require("../api");
11
11
  var _formIds = require("../formIds");
12
12
  var _index = require("./index");
13
+ var cache = new Map();
13
14
  function getFormPrintTemplates(_x) {
14
15
  return _getFormPrintTemplates.apply(this, arguments);
15
16
  }
16
17
  function _getFormPrintTemplates() {
17
- _getFormPrintTemplates = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(formId) {
18
+ _getFormPrintTemplates = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(formId) {
18
19
  var res;
19
- return _regenerator["default"].wrap(function (_context) {
20
- while (1) switch (_context.prev = _context.next) {
20
+ return _regenerator["default"].wrap(function (_context2) {
21
+ while (1) switch (_context2.prev = _context2.next) {
21
22
  case 0:
22
- _context.next = 1;
23
+ if (!cache.has(formId)) {
24
+ _context2.next = 1;
25
+ break;
26
+ }
27
+ return _context2.abrupt("return", cache.get(formId));
28
+ case 1:
29
+ _context2.next = 2;
23
30
  return _api.apiRequest.get("forms/search", {
24
31
  params: {
25
32
  formId: _formIds.FormIds.printTemplate,
@@ -31,20 +38,21 @@ function _getFormPrintTemplates() {
31
38
  pageSize: 1000
32
39
  }
33
40
  });
34
- case 1:
35
- res = _context.sent;
41
+ case 2:
42
+ res = _context2.sent;
43
+ cache.set(formId, res.data || []);
36
44
  if (!res.success) {
37
- _context.next = 2;
45
+ _context2.next = 3;
38
46
  break;
39
47
  }
40
- return _context.abrupt("return", res.data);
41
- case 2:
42
- return _context.abrupt("return", []);
48
+ return _context2.abrupt("return", res.data);
43
49
  case 3:
50
+ return _context2.abrupt("return", []);
51
+ case 4:
44
52
  case "end":
45
- return _context.stop();
53
+ return _context2.stop();
46
54
  }
47
- }, _callee);
55
+ }, _callee2);
48
56
  }));
49
57
  return _getFormPrintTemplates.apply(this, arguments);
50
58
  }
@@ -52,48 +60,52 @@ function print(_x2) {
52
60
  return _print.apply(this, arguments);
53
61
  }
54
62
  function _print() {
55
- _print = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
63
+ _print = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(options) {
56
64
  var templateId, iw, _t;
57
- return _regenerator["default"].wrap(function (_context2) {
58
- while (1) switch (_context2.prev = _context2.next) {
65
+ return _regenerator["default"].wrap(function (_context3) {
66
+ while (1) switch (_context3.prev = _context3.next) {
59
67
  case 0:
60
- _context2.prev = 0;
61
- _context2.next = 1;
68
+ _context3.prev = 0;
69
+ if (!(options.showLoading != false)) {
70
+ _context3.next = 1;
71
+ break;
72
+ }
73
+ _context3.next = 1;
62
74
  return (0, _index.showLoading)();
63
75
  case 1:
64
76
  templateId = options === null || options === void 0 ? void 0 : options.templateId;
65
77
  if (templateId) {
66
- _context2.next = 2;
78
+ _context3.next = 2;
67
79
  break;
68
80
  }
69
81
  _message2["default"].error("\u6253\u5370\u5931\u8D25!\u6A21\u677Fid\u4E0D\u53EF\u4E3A\u7A7A!");
70
- return _context2.abrupt("return");
82
+ return _context3.abrupt("return");
71
83
  case 2:
72
- _context2.next = 3;
84
+ _context3.next = 3;
73
85
  return openPrint(templateId, options);
74
86
  case 3:
75
- iw = _context2.sent;
87
+ iw = _context3.sent;
76
88
  if (iw) {
77
- _context2.next = 4;
89
+ _context3.next = 4;
78
90
  break;
79
91
  }
80
92
  _message2["default"].error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
81
- return _context2.abrupt("return");
93
+ return _context3.abrupt("return");
82
94
  case 4:
83
- _context2.next = 6;
95
+ _context3.next = 6;
84
96
  break;
85
97
  case 5:
86
- _context2.prev = 5;
87
- _t = _context2["catch"](0);
98
+ _context3.prev = 5;
99
+ _t = _context3["catch"](0);
88
100
  console.log("打印失败", _t);
89
101
  case 6:
90
- _context2.prev = 6;
91
- return _context2.finish(6);
102
+ _context3.prev = 6;
103
+ return _context3.finish(6);
92
104
  case 7:
93
105
  case "end":
94
- return _context2.stop();
106
+ return _context3.stop();
95
107
  }
96
- }, _callee2, null, [[0, 5, 6, 7]]);
108
+ }, _callee3, null, [[0, 5, 6, 7]]);
97
109
  }));
98
110
  return _print.apply(this, arguments);
99
111
  }
@@ -101,29 +113,33 @@ function openPrint(_x3, _x4) {
101
113
  return _openPrint.apply(this, arguments);
102
114
  }
103
115
  function _openPrint() {
104
- _openPrint = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(templateId, options) {
116
+ _openPrint = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(templateId, options) {
105
117
  var url;
106
- return _regenerator["default"].wrap(function (_context4) {
107
- while (1) switch (_context4.prev = _context4.next) {
118
+ return _regenerator["default"].wrap(function (_context6) {
119
+ while (1) switch (_context6.prev = _context6.next) {
108
120
  case 0:
109
121
  url = "/print/" + templateId;
110
- return _context4.abrupt("return", new Promise(/*#__PURE__*/function () {
111
- var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(resolve, reject) {
122
+ return _context6.abrupt("return", new Promise(/*#__PURE__*/function () {
123
+ var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(resolve, reject) {
112
124
  var printWindow, iframe;
113
- return _regenerator["default"].wrap(function (_context3) {
114
- while (1) switch (_context3.prev = _context3.next) {
125
+ return _regenerator["default"].wrap(function (_context5) {
126
+ while (1) switch (_context5.prev = _context5.next) {
115
127
  case 0:
116
128
  iframe = document.createElement("iframe");
117
129
  iframe.src = url;
118
130
  iframe.className = "print-iframe";
131
+ iframe.onload = function () {
132
+ // @ts-ignore
133
+ iframe.contentWindow.printOptions = options;
134
+ };
119
135
  document.body.appendChild(iframe);
120
136
  printWindow = iframe.contentWindow;
121
137
  if (printWindow) {
122
- _context3.next = 1;
138
+ _context5.next = 1;
123
139
  break;
124
140
  }
125
141
  reject("创建Iframe失败!");
126
- return _context3.abrupt("return");
142
+ return _context5.abrupt("return");
127
143
  case 1:
128
144
  // @ts-ignore
129
145
  window.printWindow = printWindow;
@@ -132,31 +148,145 @@ function _openPrint() {
132
148
  printWindow.printOptions = options;
133
149
  };
134
150
  printWindow.addEventListener("beforeprint", function () {});
135
- printWindow.addEventListener("afterprint", function () {
136
- (0, _index.hideLoading)();
137
- setTimeout(function () {
138
- resolve(printWindow);
139
- if (window.__debug) {
140
- return;
151
+ printWindow.addEventListener("afterprint", /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
152
+ var _printWindow, printer, _printWindow2, doc, html;
153
+ return _regenerator["default"].wrap(function (_context4) {
154
+ while (1) switch (_context4.prev = _context4.next) {
155
+ case 0:
156
+ if (window.__debug) {
157
+ console.debug((_printWindow = printWindow) === null || _printWindow === void 0 ? void 0 : _printWindow.document.documentElement.outerHTML);
158
+ }
159
+ _context4.next = 1;
160
+ return (0, _index.hideLoading)();
161
+ case 1:
162
+ if (!(options.mode == "cloud_print")) {
163
+ _context4.next = 5;
164
+ break;
165
+ }
166
+ _context4.next = 2;
167
+ return getCloudPrinter();
168
+ case 2:
169
+ printer = _context4.sent;
170
+ if (!printer) {
171
+ _context4.next = 4;
172
+ break;
173
+ }
174
+ doc = (_printWindow2 = printWindow) === null || _printWindow2 === void 0 ? void 0 : _printWindow2.document;
175
+ if (!doc) {
176
+ _context4.next = 3;
177
+ break;
178
+ }
179
+ doc.querySelectorAll("script").forEach(function (item) {
180
+ return item.remove();
181
+ });
182
+ html = doc.documentElement.outerHTML;
183
+ _context4.next = 3;
184
+ return printer.post("<!doctype html>" + html);
185
+ case 3:
186
+ _context4.next = 5;
187
+ break;
188
+ case 4:
189
+ _message2["default"].error("\u6253\u5370\u5931\u8D25\uFF01\u8BF7\u5148\u7ED1\u5B9A\u4E91\u6253\u5370\u673A");
190
+ case 5:
191
+ resolve(printWindow);
192
+ setTimeout(function () {
193
+ return iframe.remove();
194
+ }, 100);
195
+ case 6:
196
+ case "end":
197
+ return _context4.stop();
141
198
  }
142
- iframe.remove();
143
- }, 100);
144
- });
199
+ }, _callee4);
200
+ })));
145
201
  case 2:
146
202
  case "end":
147
- return _context3.stop();
203
+ return _context5.stop();
148
204
  }
149
- }, _callee3);
205
+ }, _callee5);
150
206
  }));
151
- return function (_x5, _x6) {
207
+ return function (_x6, _x7) {
152
208
  return _ref.apply(this, arguments);
153
209
  };
154
210
  }()));
155
211
  case 1:
156
212
  case "end":
157
- return _context4.stop();
213
+ return _context6.stop();
158
214
  }
159
- }, _callee4);
215
+ }, _callee6);
160
216
  }));
161
217
  return _openPrint.apply(this, arguments);
162
- }
218
+ }
219
+ function getCloudPrinter() {
220
+ return _getCloudPrinter.apply(this, arguments);
221
+ }
222
+ function _getCloudPrinter() {
223
+ _getCloudPrinter = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
224
+ var itemValue;
225
+ return _regenerator["default"].wrap(function (_context7) {
226
+ while (1) switch (_context7.prev = _context7.next) {
227
+ case 0:
228
+ itemValue = localStorage.getItem("default:cloud-printer");
229
+ if (!(itemValue == null)) {
230
+ _context7.next = 1;
231
+ break;
232
+ }
233
+ return _context7.abrupt("return", null);
234
+ case 1:
235
+ return _context7.abrupt("return", new CloudPrinter(JSON.parse(itemValue)));
236
+ case 2:
237
+ case "end":
238
+ return _context7.stop();
239
+ }
240
+ }, _callee7);
241
+ }));
242
+ return _getCloudPrinter.apply(this, arguments);
243
+ }
244
+ var CloudPrinter = /*#__PURE__*/function () {
245
+ function CloudPrinter(options) {
246
+ this.deviceName = void 0;
247
+ this.serverIp = void 0;
248
+ this.port = void 0;
249
+ Object.assign(this, options);
250
+ }
251
+ var _proto = CloudPrinter.prototype;
252
+ _proto.post = /*#__PURE__*/function () {
253
+ var _post = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(html) {
254
+ var baseUrl, baseRes, res;
255
+ return _regenerator["default"].wrap(function (_context) {
256
+ while (1) switch (_context.prev = _context.next) {
257
+ case 0:
258
+ baseUrl = "http://" + this.serverIp + ":" + this.port;
259
+ _context.next = 1;
260
+ return _api.apiRequest.get(baseUrl);
261
+ case 1:
262
+ baseRes = _context.sent;
263
+ if (baseRes !== null && baseRes !== void 0 && baseRes.success) {
264
+ _context.next = 2;
265
+ break;
266
+ }
267
+ _message2["default"].error("云打印服务不可用");
268
+ return _context.abrupt("return");
269
+ case 2:
270
+ _context.next = 3;
271
+ return _api.apiRequest.post(baseUrl + "/print", {
272
+ deviceName: this.deviceName,
273
+ data: html
274
+ });
275
+ case 3:
276
+ res = _context.sent;
277
+ if (!res.success) {
278
+ _message2["default"].error(res.message);
279
+ }
280
+ case 4:
281
+ case "end":
282
+ return _context.stop();
283
+ }
284
+ }, _callee, this);
285
+ }));
286
+ function post(_x5) {
287
+ return _post.apply(this, arguments);
288
+ }
289
+ return post;
290
+ }();
291
+ return CloudPrinter;
292
+ }();
@@ -1,6 +1,7 @@
1
1
  interface ScanCodeOptions {
2
2
  onlyFromCamera?: boolean;
3
3
  openUrl?: boolean;
4
+ scanType?: string[];
4
5
  }
5
6
  interface ScanCodeResult {
6
7
  result: string;
@@ -10,6 +11,7 @@ declare class UniBridge {
10
11
  navigateTo(src: string): void;
11
12
  scanCode(options: ScanCodeOptions): Promise<ScanCodeResult>;
12
13
  getBarHeight(): Promise<unknown>;
14
+ scanCodeResult(): Promise<string>;
13
15
  getLocation(options: {}): Promise<unknown>;
14
16
  private doAction;
15
17
  private receiveMessage;
@@ -6,7 +6,7 @@ exports.uniBridge = void 0;
6
6
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
7
  var _message2 = _interopRequireDefault(require("antd/lib/message"));
8
8
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
- var uniqueId = 0;
9
+ var _uuid = require("uuid");
10
10
  var UniBridge = /*#__PURE__*/function () {
11
11
  function UniBridge() {
12
12
  this.callbacks = {};
@@ -17,9 +17,13 @@ var UniBridge = /*#__PURE__*/function () {
17
17
  if (!src.startsWith("http")) {
18
18
  url = new URL(url, window.location.href).href;
19
19
  }
20
- uni.navigateTo({
21
- url: "/pages/web-page/index?url=" + url
22
- });
20
+ if (window.plus) {
21
+ uni.navigateTo({
22
+ url: "/pages/web-page/index?url=" + encodeURIComponent(url)
23
+ });
24
+ } else {
25
+ window.open(url);
26
+ }
23
27
  };
24
28
  _proto.scanCode = /*#__PURE__*/function () {
25
29
  var _scanCode = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
@@ -27,21 +31,21 @@ var UniBridge = /*#__PURE__*/function () {
27
31
  return _regenerator["default"].wrap(function (_context) {
28
32
  while (1) switch (_context.prev = _context.next) {
29
33
  case 0:
30
- _context.prev = 0;
31
- _context.next = 1;
34
+ options.scanType = ['qrCode', 'barCode'];
35
+ _context.prev = 1;
36
+ _context.next = 2;
32
37
  return this.doAction("scanCode", options);
33
- case 1:
34
- return _context.abrupt("return", _context.sent);
35
38
  case 2:
36
- _context.prev = 2;
37
- _t = _context["catch"](0);
38
- _message2["default"].error("");
39
- throw _t;
39
+ return _context.abrupt("return", _context.sent);
40
40
  case 3:
41
+ _context.prev = 3;
42
+ _t = _context["catch"](1);
43
+ throw _t;
44
+ case 4:
41
45
  case "end":
42
46
  return _context.stop();
43
47
  }
44
- }, _callee, this, [[0, 2]]);
48
+ }, _callee, this, [[1, 3]]);
45
49
  }));
46
50
  function scanCode(_x) {
47
51
  return _scanCode.apply(this, arguments);
@@ -65,53 +69,90 @@ var UniBridge = /*#__PURE__*/function () {
65
69
  }
66
70
  return getBarHeight;
67
71
  }();
68
- _proto.getLocation = /*#__PURE__*/function () {
69
- var _getLocation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(options) {
72
+ _proto.scanCodeResult = /*#__PURE__*/function () {
73
+ var _scanCodeResult = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
74
+ var res;
70
75
  return _regenerator["default"].wrap(function (_context3) {
71
76
  while (1) switch (_context3.prev = _context3.next) {
72
77
  case 0:
73
- return _context3.abrupt("return", this.doAction("getLocation", {
74
- type: 'wgs84'
75
- }));
78
+ _context3.next = 1;
79
+ return this.scanCode({
80
+ onlyFromCamera: false,
81
+ openUrl: false
82
+ });
76
83
  case 1:
84
+ res = _context3.sent;
85
+ return _context3.abrupt("return", res.result);
86
+ case 2:
77
87
  case "end":
78
88
  return _context3.stop();
79
89
  }
80
90
  }, _callee3, this);
81
91
  }));
92
+ function scanCodeResult() {
93
+ return _scanCodeResult.apply(this, arguments);
94
+ }
95
+ return scanCodeResult;
96
+ }();
97
+ _proto.getLocation = /*#__PURE__*/function () {
98
+ var _getLocation = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(options) {
99
+ return _regenerator["default"].wrap(function (_context4) {
100
+ while (1) switch (_context4.prev = _context4.next) {
101
+ case 0:
102
+ return _context4.abrupt("return", this.doAction("getLocation", {
103
+ type: 'wgs84'
104
+ }));
105
+ case 1:
106
+ case "end":
107
+ return _context4.stop();
108
+ }
109
+ }, _callee4, this);
110
+ }));
82
111
  function getLocation(_x2) {
83
112
  return _getLocation.apply(this, arguments);
84
113
  }
85
114
  return getLocation;
86
115
  }();
87
116
  _proto.doAction = /*#__PURE__*/function () {
88
- var _doAction = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(action, options) {
117
+ var _doAction = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(action, options) {
89
118
  var _this = this;
90
119
  var messageId;
91
- return _regenerator["default"].wrap(function (_context4) {
92
- while (1) switch (_context4.prev = _context4.next) {
120
+ return _regenerator["default"].wrap(function (_context5) {
121
+ while (1) switch (_context5.prev = _context5.next) {
93
122
  case 0:
94
- uniqueId++;
95
- messageId = "msg_" + uniqueId + Date.now().toString(36);
96
- return _context4.abrupt("return", new Promise(function (resolve, reject) {
123
+ if (window.uni) {
124
+ _context5.next = 1;
125
+ break;
126
+ }
127
+ _message2["default"].error("\u6267\u884C\u5931\u8D25\uFF01\u7F3A\u5C11uni\u63D2\u4EF6");
128
+ return _context5.abrupt("return");
129
+ case 1:
130
+ messageId = (0, _uuid.v7)();
131
+ return _context5.abrupt("return", new Promise(function (resolve, reject) {
132
+ console.log("UniBridge.doAction", messageId, action, options);
97
133
  _this.callbacks[messageId] = {
98
134
  resolve: resolve,
99
135
  reject: reject
100
136
  };
101
- console.log("postMessage", action, options);
102
- uni.postMessage({
103
- data: {
104
- action: action,
105
- messageId: messageId,
106
- options: options
107
- }
108
- });
137
+ try {
138
+ console.log("postMessage", messageId, action, options);
139
+ uni.postMessage({
140
+ data: {
141
+ action: action,
142
+ messageId: messageId,
143
+ options: options
144
+ }
145
+ });
146
+ } catch (e) {
147
+ console.log("UniBridge.doAction 异常", e);
148
+ delete _this.callbacks[messageId];
149
+ }
109
150
  }));
110
- case 1:
151
+ case 2:
111
152
  case "end":
112
- return _context4.stop();
153
+ return _context5.stop();
113
154
  }
114
- }, _callee4);
155
+ }, _callee5);
115
156
  }));
116
157
  function doAction(_x3, _x4) {
117
158
  return _doAction.apply(this, arguments);
@@ -119,8 +160,9 @@ var UniBridge = /*#__PURE__*/function () {
119
160
  return doAction;
120
161
  }();
121
162
  _proto.receiveMessage = function receiveMessage(message) {
122
- console.log('收到 UniApp 消息:', message);
123
163
  var callback = this.callbacks[message.messageId];
164
+ console.log('客户端收到 UniApp 消息:', JSON.stringify(message));
165
+ console.log('客户端收到 UniApp 消息:callbacks', this.callbacks);
124
166
  if (callback) {
125
167
  if (message.success) {
126
168
  callback.resolve(message.data);
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhubangyun/lowcode-core",
3
- "version": "6.1.90",
3
+ "version": "6.2.30",
4
4
  "description": "低代码核心",
5
5
  "files": [
6
6
  "lib",