@zhubangyun/lowcode-core 5.12.161 → 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.
- package/es/components/load-materials/index.js +38 -22
- package/es/components/page-loading/index.js +4 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +19 -2
- package/es/index.less +21 -0
- package/es/init/init.bar-height.d.ts +1 -0
- package/es/init/init.bar-height.js +37 -0
- package/es/init/init.mobile-class.d.ts +1 -0
- package/es/init/init.mobile-class.js +10 -0
- package/es/init/init.scroll-size.d.ts +5 -0
- package/es/init/init.scroll-size.js +26 -0
- package/es/style.js +3 -3
- package/es/utils/api/form-api.d.ts +2 -0
- package/es/utils/api/form-api.js +155 -34
- package/es/utils/api/index.d.ts +1 -1
- package/es/utils/api/index.js +4 -2
- package/es/utils/api/rest-api.d.ts +3 -1
- package/es/utils/api/rest-api.js +105 -23
- package/es/utils/api/schema.util.d.ts +3 -3
- package/es/utils/api/schema.util.js +17 -12
- package/es/utils/cache/index.js +57 -17
- package/es/utils/common/index.d.ts +3 -0
- package/es/utils/common/index.js +17 -3
- package/es/utils/page/index.js +10 -6
- package/es/utils/page/page-form-data-manager-group.js +10 -10
- package/es/utils/page/page-form-data-manager.d.ts +1 -0
- package/es/utils/page/page-form-data-manager.js +10 -10
- package/es/utils/page/page-form-group.d.ts +1 -0
- package/es/utils/page/page-form-group.js +2 -2
- package/es/utils/page/page-form.d.ts +1 -0
- package/es/utils/page/page-form.js +12 -4
- package/es/utils/page/page-layout.d.ts +3 -1
- package/es/utils/page/page-layout.js +44 -7
- package/es/utils/page/page-load-schema.js +20 -28
- package/es/utils/page/page-render.js +4 -5
- package/es/utils/page/page-show.d.ts +2 -0
- package/es/utils/page/page-show.js +9 -4
- package/es/utils/page/print-form.d.ts +3 -2
- package/es/utils/page/print-form.js +200 -61
- package/es/utils/uni-bridge.d.ts +20 -0
- package/es/utils/uni-bridge.js +172 -0
- package/es/utils/util.common.d.ts +1 -0
- package/es/utils/util.common.js +4 -0
- package/es/utils/utils.scrollbar-size.js +0 -0
- package/lib/components/load-materials/index.js +38 -22
- package/lib/components/page-loading/index.js +4 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +22 -4
- package/lib/index.less +21 -0
- package/lib/init/init.bar-height.d.ts +1 -0
- package/lib/init/init.bar-height.js +42 -0
- package/lib/init/init.mobile-class.d.ts +1 -0
- package/lib/init/init.mobile-class.js +14 -0
- package/lib/init/init.scroll-size.d.ts +5 -0
- package/lib/init/init.scroll-size.js +31 -0
- package/lib/style.js +3 -3
- package/lib/utils/api/form-api.d.ts +2 -0
- package/lib/utils/api/form-api.js +155 -34
- package/lib/utils/api/index.d.ts +1 -1
- package/lib/utils/api/index.js +4 -2
- package/lib/utils/api/rest-api.d.ts +3 -1
- package/lib/utils/api/rest-api.js +105 -23
- package/lib/utils/api/schema.util.d.ts +3 -3
- package/lib/utils/api/schema.util.js +19 -13
- package/lib/utils/cache/index.js +56 -16
- package/lib/utils/common/index.d.ts +3 -0
- package/lib/utils/common/index.js +19 -2
- package/lib/utils/page/index.js +10 -6
- package/lib/utils/page/page-form-data-manager-group.js +10 -10
- package/lib/utils/page/page-form-data-manager.d.ts +1 -0
- package/lib/utils/page/page-form-data-manager.js +10 -10
- package/lib/utils/page/page-form-group.d.ts +1 -0
- package/lib/utils/page/page-form-group.js +2 -2
- package/lib/utils/page/page-form.d.ts +1 -0
- package/lib/utils/page/page-form.js +12 -4
- package/lib/utils/page/page-layout.d.ts +3 -1
- package/lib/utils/page/page-layout.js +44 -7
- package/lib/utils/page/page-load-schema.js +19 -27
- package/lib/utils/page/page-render.js +4 -5
- package/lib/utils/page/page-show.d.ts +2 -0
- package/lib/utils/page/page-show.js +9 -4
- package/lib/utils/page/print-form.d.ts +3 -2
- package/lib/utils/page/print-form.js +200 -61
- package/lib/utils/uni-bridge.d.ts +20 -0
- package/lib/utils/uni-bridge.js +177 -0
- package/lib/utils/util.common.d.ts +1 -0
- package/lib/utils/util.common.js +8 -0
- package/lib/utils/utils.scrollbar-size.js +1 -0
- package/package.json +2 -2
|
@@ -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 = ["
|
|
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
|
|
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
|
-
|
|
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,
|
|
@@ -50,6 +50,7 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
50
50
|
}
|
|
51
51
|
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
52
52
|
_this.layoutRef = void 0;
|
|
53
|
+
_this.schema = void 0;
|
|
53
54
|
return _this;
|
|
54
55
|
}
|
|
55
56
|
(0, _inheritsLoose2["default"])(PageRender, _Component);
|
|
@@ -78,6 +79,10 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
78
79
|
}, /*#__PURE__*/_react["default"].createElement(_pageLoadSchema.PageLoadSchema, {
|
|
79
80
|
pageId: pageId
|
|
80
81
|
}, function (schema) {
|
|
82
|
+
_this2.schema = schema;
|
|
83
|
+
if (_this2.props.pageRef) {
|
|
84
|
+
_this2.props.pageRef(_this2);
|
|
85
|
+
}
|
|
81
86
|
return /*#__PURE__*/_react["default"].createElement(_reactRender.ReactRender, (0, _extends2["default"])({
|
|
82
87
|
schema: schema,
|
|
83
88
|
components: window._components || window.components || window.__components
|
|
@@ -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
|
|
18
|
+
_getFormPrintTemplates = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(formId) {
|
|
18
19
|
var res;
|
|
19
|
-
return _regenerator["default"].wrap(function (
|
|
20
|
-
while (1) switch (
|
|
20
|
+
return _regenerator["default"].wrap(function (_context2) {
|
|
21
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
21
22
|
case 0:
|
|
22
|
-
|
|
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
|
|
35
|
-
res =
|
|
41
|
+
case 2:
|
|
42
|
+
res = _context2.sent;
|
|
43
|
+
cache.set(formId, res.data || []);
|
|
36
44
|
if (!res.success) {
|
|
37
|
-
|
|
45
|
+
_context2.next = 3;
|
|
38
46
|
break;
|
|
39
47
|
}
|
|
40
|
-
return
|
|
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
|
|
53
|
+
return _context2.stop();
|
|
46
54
|
}
|
|
47
|
-
},
|
|
55
|
+
}, _callee2);
|
|
48
56
|
}));
|
|
49
57
|
return _getFormPrintTemplates.apply(this, arguments);
|
|
50
58
|
}
|
|
@@ -52,102 +60,233 @@ 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
|
|
63
|
+
_print = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(options) {
|
|
56
64
|
var templateId, iw, _t;
|
|
57
|
-
return _regenerator["default"].wrap(function (
|
|
58
|
-
while (1) switch (
|
|
65
|
+
return _regenerator["default"].wrap(function (_context3) {
|
|
66
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
59
67
|
case 0:
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
|
82
|
+
return _context3.abrupt("return");
|
|
71
83
|
case 2:
|
|
72
|
-
|
|
73
|
-
return openPrint(templateId);
|
|
84
|
+
_context3.next = 3;
|
|
85
|
+
return openPrint(templateId, options);
|
|
74
86
|
case 3:
|
|
75
|
-
iw =
|
|
87
|
+
iw = _context3.sent;
|
|
76
88
|
if (iw) {
|
|
77
|
-
|
|
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
|
|
93
|
+
return _context3.abrupt("return");
|
|
82
94
|
case 4:
|
|
83
|
-
|
|
84
|
-
iw.printOptions = options;
|
|
85
|
-
_context2.next = 6;
|
|
95
|
+
_context3.next = 6;
|
|
86
96
|
break;
|
|
87
97
|
case 5:
|
|
88
|
-
|
|
89
|
-
_t =
|
|
98
|
+
_context3.prev = 5;
|
|
99
|
+
_t = _context3["catch"](0);
|
|
90
100
|
console.log("打印失败", _t);
|
|
91
101
|
case 6:
|
|
92
|
-
|
|
93
|
-
return
|
|
102
|
+
_context3.prev = 6;
|
|
103
|
+
return _context3.finish(6);
|
|
94
104
|
case 7:
|
|
95
105
|
case "end":
|
|
96
|
-
return
|
|
106
|
+
return _context3.stop();
|
|
97
107
|
}
|
|
98
|
-
},
|
|
108
|
+
}, _callee3, null, [[0, 5, 6, 7]]);
|
|
99
109
|
}));
|
|
100
110
|
return _print.apply(this, arguments);
|
|
101
111
|
}
|
|
102
|
-
function openPrint(_x3) {
|
|
112
|
+
function openPrint(_x3, _x4) {
|
|
103
113
|
return _openPrint.apply(this, arguments);
|
|
104
114
|
}
|
|
105
115
|
function _openPrint() {
|
|
106
|
-
_openPrint = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
_openPrint = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(templateId, options) {
|
|
117
|
+
var url;
|
|
118
|
+
return _regenerator["default"].wrap(function (_context6) {
|
|
119
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
109
120
|
case 0:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
url = "/print/" + templateId;
|
|
122
|
+
return _context6.abrupt("return", new Promise(/*#__PURE__*/function () {
|
|
123
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(resolve, reject) {
|
|
124
|
+
var printWindow, iframe;
|
|
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
|
-
iframe.src =
|
|
118
|
-
iframe.
|
|
129
|
+
iframe.src = url;
|
|
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
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
136
|
+
printWindow = iframe.contentWindow;
|
|
137
|
+
if (printWindow) {
|
|
138
|
+
_context5.next = 1;
|
|
123
139
|
break;
|
|
124
140
|
}
|
|
125
141
|
reject("创建Iframe失败!");
|
|
126
|
-
return
|
|
142
|
+
return _context5.abrupt("return");
|
|
127
143
|
case 1:
|
|
128
|
-
|
|
129
|
-
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
window.printWindow = printWindow;
|
|
146
|
+
printWindow.onload = function () {
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
printWindow.printOptions = options;
|
|
130
149
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
150
|
+
printWindow.addEventListener("beforeprint", function () {});
|
|
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();
|
|
198
|
+
}
|
|
199
|
+
}, _callee4);
|
|
200
|
+
})));
|
|
136
201
|
case 2:
|
|
137
202
|
case "end":
|
|
138
|
-
return
|
|
203
|
+
return _context5.stop();
|
|
139
204
|
}
|
|
140
|
-
},
|
|
205
|
+
}, _callee5);
|
|
141
206
|
}));
|
|
142
|
-
return function (
|
|
207
|
+
return function (_x6, _x7) {
|
|
143
208
|
return _ref.apply(this, arguments);
|
|
144
209
|
};
|
|
145
210
|
}()));
|
|
146
211
|
case 1:
|
|
147
212
|
case "end":
|
|
148
|
-
return
|
|
213
|
+
return _context6.stop();
|
|
149
214
|
}
|
|
150
|
-
},
|
|
215
|
+
}, _callee6);
|
|
151
216
|
}));
|
|
152
217
|
return _openPrint.apply(this, arguments);
|
|
153
|
-
}
|
|
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
|
+
}();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface ScanCodeOptions {
|
|
2
|
+
onlyFromCamera?: boolean;
|
|
3
|
+
openUrl?: boolean;
|
|
4
|
+
scanType?: string[];
|
|
5
|
+
}
|
|
6
|
+
interface ScanCodeResult {
|
|
7
|
+
result: string;
|
|
8
|
+
}
|
|
9
|
+
declare class UniBridge {
|
|
10
|
+
private callbacks;
|
|
11
|
+
navigateTo(src: string): void;
|
|
12
|
+
scanCode(options: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
13
|
+
getBarHeight(): Promise<unknown>;
|
|
14
|
+
scanCodeResult(): Promise<string>;
|
|
15
|
+
getLocation(options: {}): Promise<unknown>;
|
|
16
|
+
private doAction;
|
|
17
|
+
private receiveMessage;
|
|
18
|
+
}
|
|
19
|
+
export declare const uniBridge: UniBridge;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.uniBridge = void 0;
|
|
6
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
var _message2 = _interopRequireDefault(require("antd/lib/message"));
|
|
8
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
|
+
var _uuid = require("uuid");
|
|
10
|
+
var UniBridge = /*#__PURE__*/function () {
|
|
11
|
+
function UniBridge() {
|
|
12
|
+
this.callbacks = {};
|
|
13
|
+
}
|
|
14
|
+
var _proto = UniBridge.prototype;
|
|
15
|
+
_proto.navigateTo = function navigateTo(src) {
|
|
16
|
+
var url = src;
|
|
17
|
+
if (!src.startsWith("http")) {
|
|
18
|
+
url = new URL(url, window.location.href).href;
|
|
19
|
+
}
|
|
20
|
+
if (window.plus) {
|
|
21
|
+
uni.navigateTo({
|
|
22
|
+
url: "/pages/web-page/index?url=" + encodeURIComponent(url)
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
window.open(url);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
_proto.scanCode = /*#__PURE__*/function () {
|
|
29
|
+
var _scanCode = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
|
|
30
|
+
var _t;
|
|
31
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
32
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33
|
+
case 0:
|
|
34
|
+
options.scanType = ['qrCode', 'barCode'];
|
|
35
|
+
_context.prev = 1;
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
return this.doAction("scanCode", options);
|
|
38
|
+
case 2:
|
|
39
|
+
return _context.abrupt("return", _context.sent);
|
|
40
|
+
case 3:
|
|
41
|
+
_context.prev = 3;
|
|
42
|
+
_t = _context["catch"](1);
|
|
43
|
+
throw _t;
|
|
44
|
+
case 4:
|
|
45
|
+
case "end":
|
|
46
|
+
return _context.stop();
|
|
47
|
+
}
|
|
48
|
+
}, _callee, this, [[1, 3]]);
|
|
49
|
+
}));
|
|
50
|
+
function scanCode(_x) {
|
|
51
|
+
return _scanCode.apply(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
return scanCode;
|
|
54
|
+
}();
|
|
55
|
+
_proto.getBarHeight = /*#__PURE__*/function () {
|
|
56
|
+
var _getBarHeight = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
57
|
+
return _regenerator["default"].wrap(function (_context2) {
|
|
58
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
return _context2.abrupt("return", this.doAction("getBarHeight", {}));
|
|
61
|
+
case 1:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context2.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee2, this);
|
|
66
|
+
}));
|
|
67
|
+
function getBarHeight() {
|
|
68
|
+
return _getBarHeight.apply(this, arguments);
|
|
69
|
+
}
|
|
70
|
+
return getBarHeight;
|
|
71
|
+
}();
|
|
72
|
+
_proto.scanCodeResult = /*#__PURE__*/function () {
|
|
73
|
+
var _scanCodeResult = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
74
|
+
var res;
|
|
75
|
+
return _regenerator["default"].wrap(function (_context3) {
|
|
76
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
77
|
+
case 0:
|
|
78
|
+
_context3.next = 1;
|
|
79
|
+
return this.scanCode({
|
|
80
|
+
onlyFromCamera: false,
|
|
81
|
+
openUrl: false
|
|
82
|
+
});
|
|
83
|
+
case 1:
|
|
84
|
+
res = _context3.sent;
|
|
85
|
+
return _context3.abrupt("return", res.result);
|
|
86
|
+
case 2:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context3.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee3, this);
|
|
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
|
+
}));
|
|
111
|
+
function getLocation(_x2) {
|
|
112
|
+
return _getLocation.apply(this, arguments);
|
|
113
|
+
}
|
|
114
|
+
return getLocation;
|
|
115
|
+
}();
|
|
116
|
+
_proto.doAction = /*#__PURE__*/function () {
|
|
117
|
+
var _doAction = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(action, options) {
|
|
118
|
+
var _this = this;
|
|
119
|
+
var messageId;
|
|
120
|
+
return _regenerator["default"].wrap(function (_context5) {
|
|
121
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
122
|
+
case 0:
|
|
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);
|
|
133
|
+
_this.callbacks[messageId] = {
|
|
134
|
+
resolve: resolve,
|
|
135
|
+
reject: reject
|
|
136
|
+
};
|
|
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
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
case 2:
|
|
152
|
+
case "end":
|
|
153
|
+
return _context5.stop();
|
|
154
|
+
}
|
|
155
|
+
}, _callee5);
|
|
156
|
+
}));
|
|
157
|
+
function doAction(_x3, _x4) {
|
|
158
|
+
return _doAction.apply(this, arguments);
|
|
159
|
+
}
|
|
160
|
+
return doAction;
|
|
161
|
+
}();
|
|
162
|
+
_proto.receiveMessage = function receiveMessage(message) {
|
|
163
|
+
var callback = this.callbacks[message.messageId];
|
|
164
|
+
console.log('客户端收到 UniApp 消息:', JSON.stringify(message));
|
|
165
|
+
console.log('客户端收到 UniApp 消息:callbacks', this.callbacks);
|
|
166
|
+
if (callback) {
|
|
167
|
+
if (message.success) {
|
|
168
|
+
callback.resolve(message.data);
|
|
169
|
+
} else {
|
|
170
|
+
callback.reject(message.error || new Error('操作失败'));
|
|
171
|
+
}
|
|
172
|
+
delete this.callbacks[message.messageId];
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return UniBridge;
|
|
176
|
+
}();
|
|
177
|
+
var uniBridge = exports.uniBridge = new UniBridge();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isTemplate(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhubangyun/lowcode-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.2.30",
|
|
4
4
|
"description": "低代码核心",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@alifd/next": "^1.24.18",
|
|
25
25
|
"axios": "^1.7.9",
|
|
26
26
|
"case": "^1.6.3",
|
|
27
|
-
"uuid": "^
|
|
27
|
+
"uuid": "^10.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@alib/build-scripts": "^0.1.18",
|