@lambo-design-mobile/lambo-js-bridge 1.0.0-beta.28 → 1.0.0-beta.29

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/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # Changelog
2
+ ## [1.0.0-beta.29](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.28...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.29) (2025-04-18)
3
+
2
4
  ## [1.0.0-beta.28](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.27...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.28) (2025-04-17)
3
5
 
4
6
  ## [1.0.0-beta.27](http://git.inspur.com/ecbh/lambo-design/lambo-design/-/compare/@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.26...@lambo-design-mobile/lambo-js-bridge@1.0.0-beta.27) (2025-03-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design-mobile/lambo-js-bridge",
3
- "version": "1.0.0-beta.28",
3
+ "version": "1.0.0-beta.29",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
package/src/sdk/LPAPI.js CHANGED
@@ -24,6 +24,9 @@
24
24
  });
25
25
  let lpapiModel = window.lpapiModel;
26
26
 
27
+ let defaultSuccess = (result) => {console.log("success result " + JSON.stringify(result));};
28
+ let defaultError = (err) => {console.log("err result " + JSON.stringify(err));};
29
+
27
30
  /***************************************************************************
28
31
  * 打印机的打开与断开操作。
29
32
  **************************************************************************/
@@ -60,6 +63,87 @@
60
63
  }, fail);
61
64
  }
62
65
  };
66
+ /**
67
+ * - JS 调用: window.printer.connectPrinter(success, error, options)
68
+ * - 描述: 连接到指定的打印机。
69
+ * - 参数 (options):
70
+ * - name (String, 必选): 要连接的打印机的名称或地址。具体是名称还是地址取决于原生实现。若为空字符串则选择第一台打印机
71
+ * - 成功回调数据 (result):
72
+ * - success (bool): true 表示连接成功,false 表示连接失败。
73
+ * - 示例: {"success": true}
74
+ * - 失败回调数据 (error): {"message": "错误描述"}
75
+ */
76
+ api.connectPrinter = function (success, error, options) {
77
+ if (Mobile.isAndroid()) {
78
+ LPAPIPlugin.connectPrinter(success, error, options);
79
+ }
80
+ }
81
+
82
+ /**
83
+ * #### getPrinterStatus
84
+ * - JS 调用: window.printer.getPrinterStatus(success, error)
85
+ * - 描述: 获取当前连接打印机的状态(如正常、缺纸、开盖等)。
86
+ * - 参数 (options): 无
87
+ * - 成功回调数据 (result):
88
+ * - status (String): 表示打印机状态的字符串。具体状态值取决于原生实现。
89
+ * - 示例: {"status": "NORMAL"} 或 {"status": "OUT_OF_PAPER"}
90
+ * - 失败回调数据 (error): {"message": "错误描述"}
91
+ */
92
+ api.getPrinterStatus = function (success, error) {
93
+ if (Mobile.isAndroid()) {
94
+ LPAPIPlugin.getPrinterStatus(success, error);
95
+ }
96
+ }
97
+
98
+ /**
99
+ *
100
+ * - JS 调用: window.printer.printText(success, error, options)
101
+ * - 描述: 快速打印文本,通常用于小票类打印机。会创建一个包含该文本的独立打印任务并提交。
102
+ * - 参数 (options): 类似于 drawText,但具体参数和行为(如是否自动换行、定位)可能与 drawText 不同,更侧重于流式打印。
103
+ * - text (String, 必选)
104
+ * - width, height, orientation, x, y, fontHeight (可选,默认值可能不同)。
105
+ * - 成功回调数据 (result): {"success": true}
106
+ * - 失败回调数据 (error): {"message": "错误描述"}
107
+ */
108
+ api.printText = function (success, error, options) {
109
+ if (Mobile.isAndroid()) {
110
+ LPAPIPlugin.printText(success, error, options);
111
+ }
112
+ }
113
+
114
+ /**
115
+ * - JS 调用: window.printer.printBarcode(success, error, options)
116
+ * - 描述: 快速打印一维条码。创建独立打印任务。
117
+ * - 参数 (options): 类似于 draw1DBarcode。
118
+ * - text (String, 必选)
119
+ * - type, width, height, x, y, textHeight (可选)。
120
+ * - 成功回调数据 (result): {"success": true}
121
+ * - 失败回调数据 (error): {"message": "错误描述"}
122
+ */
123
+
124
+ api.printBarcode = function (success, error, options) {
125
+ if (Mobile.isAndroid()) {
126
+ LPAPIPlugin.printBarcode(success, error, options);
127
+ }
128
+ }
129
+
130
+ /**
131
+ * - JS 调用: window.printer.printQRCode(success, error, options)
132
+ * - 描述: 快速打印二维码。创建独立打印任务。
133
+ * - 参数 (options): 类似于 draw2DQRCode。
134
+ * - text (String, 必选)
135
+ * - width, x, y (可选)。
136
+ * - 成功回调数据 (result): {"success": true}
137
+ * - 失败回调数据 (error): {"message": "错误描述"}
138
+ */
139
+
140
+ api.printQRCode = function (success, error, options) {
141
+ if (Mobile.isAndroid()) {
142
+ LPAPIPlugin.printQRCode(success, error, options);
143
+ }
144
+ }
145
+
146
+
63
147
 
64
148
  /**
65
149
  * 以数组的形式返货制定型号打印机的详细信息;
@@ -70,7 +154,7 @@
70
154
  * @param error 失败的结果回调函数;
71
155
  * 平台支持:Android;
72
156
  */
73
- api.getAllPrinterAddresses = function (names, success, error = () => {}) {
157
+ api.getAllPrinterAddresses = function (names, success, error = defaultError) {
74
158
  if (typeof names === "function") {
75
159
  success = names;
76
160
  names = "";
@@ -91,7 +175,7 @@
91
175
  // * @param error 失败的结果回调函数;
92
176
  // * 平台支持:Android;
93
177
  // */
94
- // api.getFirstPrinter = function (names, success, error = () => {}) {
178
+ // api.getFirstPrinter = function (names, success, error = defaultError) {
95
179
  // if (typeof names === "function"){
96
180
  // success = names;
97
181
  // names = "";
@@ -141,7 +225,7 @@
141
225
  * @param success 成功回调函数;
142
226
  * @param error 失败回调函数;
143
227
  */
144
- api.closePrinter = function (success = () => {}, error = () => {}) {
228
+ api.closePrinter = function (success = defaultSuccess, error = defaultError) {
145
229
  if (Mobile.isAndroid()) {
146
230
  LPAPIPlugin.closePrinter(success, error);
147
231
  } else if (Mobile.isIOS()) {
@@ -170,7 +254,7 @@
170
254
  * @param error 失败回调函数;
171
255
  * 平台支持:Android;
172
256
  */
173
- api.getPrinterState = function (success, error = () => {}) {
257
+ api.getPrinterState = function (success, error = defaultError) {
174
258
  if (Mobile.isAndroid()) {
175
259
  LPAPIPlugin.getPrinterState(success, error);
176
260
  }
@@ -183,7 +267,7 @@
183
267
  * @param success 结果回调函数;
184
268
  * 平台支持:Android;
185
269
  */
186
- api.getPrinterInfo = function (success, error = () => {}) {
270
+ api.getPrinterInfo = function (success, error = defaultError) {
187
271
  if (Mobile.isAndroid()) {
188
272
  LPAPIPlugin.getPrinterInfo(success, error);
189
273
  }
@@ -233,7 +317,7 @@
233
317
  * @return 成功与否?
234
318
  * 平台支持:Android+IOS;
235
319
  */
236
- api.startJob = function (width, height, orientation, success = () => {}, error = () => {}) {
320
+ api.startJob = function (width, height, orientation, success = defaultSuccess, error = defaultError) {
237
321
  if (Mobile.isAndroid()) {
238
322
  LPAPIPlugin.startJob(success, error,{
239
323
  width: width,
@@ -261,7 +345,7 @@
261
345
  * 结束一个打印页面。
262
346
  * 平台支持:Android;
263
347
  */
264
- api.endPage = function (success = () => {}, error = () => {}) {
348
+ api.endPage = function (success = defaultSuccess, error = defaultError) {
265
349
  if (Mobile.isAndroid()) {
266
350
  LPAPIPlugin.endPage(success, error);
267
351
  }
@@ -274,7 +358,7 @@
274
358
  * @param error 失败回调函数;
275
359
  * 平台支持:Android;
276
360
  */
277
- api.endJob = function (success = () => {}, error = () => {}) {
361
+ api.endJob = function (success = defaultSuccess, error = defaultError) {
278
362
  if (Mobile.isAndroid()) {
279
363
  LPAPIPlugin.endJob(success, error);
280
364
  }
@@ -286,7 +370,7 @@
286
370
  * @param error 失败回调函数;
287
371
  * 平台支持:Android
288
372
  */
289
- api.abortJob = function (success = () => {}, error = () => {}) {
373
+ api.abortJob = function (success = defaultSuccess, error = defaultError) {
290
374
  if (Mobile.isAndroid()) {
291
375
  LPAPIPlugin.abortJob(success, error);
292
376
  }
@@ -323,7 +407,7 @@
323
407
  * @param error 数据获取失败回调函数(返回值);
324
408
  * 平台支持:Android;
325
409
  */
326
- api.getJobPages = function (success, error = () => {}) {
410
+ api.getJobPages = function (success, error = defaultError) {
327
411
  if (Mobile.isAndroid()) {
328
412
  LPAPIPlugin.getJobPages(success, error);
329
413
  }
@@ -356,7 +440,7 @@
356
440
  * 当前打印动作的顺时针旋转角度(0,90,180,270)。
357
441
  * 平台支持:Android;
358
442
  */
359
- api.getItemOrientation = function (success, error = () => {}) {
443
+ api.getItemOrientation = function (success, error = defaultError) {
360
444
  if (Mobile.isAndroid()) {
361
445
  LPAPIPlugin.getItemOrientation(success, error);
362
446
  }
@@ -374,7 +458,7 @@
374
458
  * 270:逆时针旋转90度。
375
459
  * 平台支持:Android + IOS;
376
460
  */
377
- api.setItemOrientation = function (orientation, success = () => {}, error = () => {}) {
461
+ api.setItemOrientation = function (orientation, success = defaultSuccess, error = defaultError) {
378
462
  if (Mobile.isAndroid()) {
379
463
  LPAPIPlugin.setItemOrientation(success, error, {
380
464
  orientation: orientation || 0
@@ -395,7 +479,7 @@
395
479
  * 2:水平居右;
396
480
  * 平台支持:Android;
397
481
  */
398
- api.getItemHorizontalAlignment = function (success, error = () => {}) {
482
+ api.getItemHorizontalAlignment = function (success, error = defaultError) {
399
483
  if (Mobile.isAndroid()) {
400
484
  LPAPIPlugin.getItemHorizontalAlignment(success, error);
401
485
  }
@@ -411,7 +495,7 @@
411
495
  * 2:水平居右。
412
496
  * 平台支持:Android + IOS;
413
497
  */
414
- api.setItemHorizontalAlignment = function (alignment, success = () => {}, error = () => {}) {
498
+ api.setItemHorizontalAlignment = function (alignment, success = defaultSuccess, error = defaultError) {
415
499
  if (Mobile.isAndroid()) {
416
500
  LPAPIPlugin.setItemHorizontalAlignment(success, error,{
417
501
  alignment: alignment || 0
@@ -432,7 +516,7 @@
432
516
  * 2:垂直居下;
433
517
  * 平台支持:Android;
434
518
  */
435
- api.getItemVerticalAlignment = function (success, error = () => {}) {
519
+ api.getItemVerticalAlignment = function (success, error = defaultError) {
436
520
  if (Mobile.isAndroid()) {
437
521
  LPAPIPlugin.getItemVerticalAlignment(success, error);
438
522
  } else if (Mobile.isIOS()) {
@@ -451,7 +535,7 @@
451
535
  * 2:垂直居下。
452
536
  * 平台支持:Android + IOS;
453
537
  */
454
- api.setItemVerticalAlignment = function (alignment, success = () => {}, error = () => {}) {
538
+ api.setItemVerticalAlignment = function (alignment, success = defaultSuccess, error = defaultError) {
455
539
  if (Mobile.isAndroid()) {
456
540
  LPAPIPlugin.setItemVerticalAlignment(success, error, {
457
541
  alignment: alignment || 0
@@ -471,7 +555,7 @@
471
555
  * PenAlignment.INSET:绘制的线在指定的位置内侧。<br>
472
556
  * 平台支持:Android;
473
557
  */
474
- api.getItemPenAlignment = function (success, error = () => {}) {
558
+ api.getItemPenAlignment = function (success, error = defaultError) {
475
559
  if (Mobile.isAndroid()) {
476
560
  LPAPIPlugin.getItemPenAlignment(success, error);
477
561
  }
@@ -488,7 +572,7 @@
488
572
  * PenAlignment.INSET:绘制的线在指定的位置内侧。
489
573
  * 平台支持:Android;
490
574
  */
491
- api.setItemPenAlignment = function (penAlignment, success = () => {}, error = () => {}) {
575
+ api.setItemPenAlignment = function (penAlignment, success = defaultSuccess, error = defaultError) {
492
576
  if (Mobile.isAndroid()) {
493
577
  LPAPIPlugin.setItemPenAlignment(success, error,{
494
578
  alignment: penAlignment
@@ -523,7 +607,7 @@
523
607
  * 文本的字体风格(可按位组合),可以不指定,默认为0(正常)。0:正常;1:粗体;2:斜体;3:粗斜体 ;4:下划线;8:删除线。
524
608
  * @return 打印成功与否?
525
609
  */
526
- api.drawText = function (text, x, y, width, height, fontHeight, fontStyle, success = () => {}, error = () => {}) {
610
+ api.drawText = function (text, x, y, width, height, fontHeight, fontStyle, success = defaultSuccess, error = defaultError) {
527
611
  if (Mobile.isAndroid()) {
528
612
  LPAPIPlugin.drawText(success, error, {
529
613
  text: text,
@@ -555,7 +639,7 @@
555
639
  * 矩形框的线宽(单位mm)。矩形框的线宽是向矩形框内部延伸的。
556
640
  * @return 打印成功与否?
557
641
  */
558
- api.drawRectangle = function (x, y, width, height, lineWidth, success = () => {}, error = () => {}) {
642
+ api.drawRectangle = function (x, y, width, height, lineWidth, success = defaultSuccess, error = defaultError) {
559
643
  if (Mobile.isAndroid()) {
560
644
  LPAPIPlugin.drawRectangle(success, error,{
561
645
  x: x,
@@ -583,7 +667,7 @@
583
667
  * 绘制的填充矩形框的垂直高度(单位mm)。
584
668
  * @return 打印成功与否?
585
669
  */
586
- api.fillRectangle = function (x, y, width, height, success = () => {}, error = () => {}) {
670
+ api.fillRectangle = function (x, y, width, height, success = defaultSuccess, error = defaultError) {
587
671
  if (Mobile.isAndroid()) {
588
672
  LPAPIPlugin.fillRectangle(success, error,{
589
673
  x: x,
@@ -616,7 +700,7 @@
616
700
  * 圆角矩形框的线宽(单位mm)。圆角矩形框的线宽是向圆角矩形框内部延伸的。
617
701
  * @return 打印成功与否?
618
702
  */
619
- api.drawRoundRectangle = function (x, y, width, height, cornerWidth, cornerHeight, lineWidth, success = () => {}, error = () => {}) {
703
+ api.drawRoundRectangle = function (x, y, width, height, cornerWidth, cornerHeight, lineWidth, success = defaultSuccess, error = defaultError) {
620
704
  if (Mobile.isAndroid()) {
621
705
  LPAPIPlugin.drawRoundRectangle(success, error,{
622
706
  x: x,
@@ -650,7 +734,7 @@
650
734
  * 圆角高度(单位mm)。
651
735
  * @return 打印成功与否?
652
736
  */
653
- api.fillRoundRectangle = function (x, y, width, height, cornerWidth, cornerHeight, success = () => {}, error = () => {}) {
737
+ api.fillRoundRectangle = function (x, y, width, height, cornerWidth, cornerHeight, success = defaultSuccess, error = defaultError) {
654
738
  if (Mobile.isAndroid()) {
655
739
  LPAPIPlugin.fillRoundRectangle(success, error,{
656
740
  x: x,
@@ -681,7 +765,7 @@
681
765
  * 椭圆的线宽(单位mm)。椭圆的线宽是向椭圆内部延伸的。
682
766
  * @return 打印成功与否?
683
767
  */
684
- api.drawEllipse = function (x, y, width, height, lineWidth, success = () => {}, error = () => {}) {
768
+ api.drawEllipse = function (x, y, width, height, lineWidth, success = defaultSuccess, error = defaultError) {
685
769
  if (Mobile.isAndroid()) {
686
770
  LPAPIPlugin.drawEllipse(success, error,{
687
771
  x: x,
@@ -709,7 +793,7 @@
709
793
  * 绘制的填充椭圆的垂直高度(单位mm)。
710
794
  * @return 打印成功与否?
711
795
  */
712
- api.fillEllipse = function (x, y, width, height, success = () => {}, error = () => {}) {
796
+ api.fillEllipse = function (x, y, width, height, success = defaultSuccess, error = defaultError) {
713
797
  if (Mobile.isAndroid()) {
714
798
  LPAPIPlugin.fillEllipse(success, error,{
715
799
  x: x,
@@ -736,7 +820,7 @@
736
820
  * 圆的线宽(单位mm)。圆的线宽是向圆内部延伸的。
737
821
  * @return 打印成功与否?
738
822
  */
739
- api.drawCircle = function (x, y, radius, lineWidth, success = () => {}, error = () => {}) {
823
+ api.drawCircle = function (x, y, radius, lineWidth, success = defaultSuccess, error = defaultError) {
740
824
  x = x - radius;
741
825
  y = y - radius;
742
826
 
@@ -764,7 +848,7 @@
764
848
  * 绘制的填充圆的半径(单位mm)。
765
849
  * @return 打印成功与否?
766
850
  */
767
- api.fillCircle = function (x, y, radius, success = () => {}, error = () => {}) {
851
+ api.fillCircle = function (x, y, radius, success = defaultSuccess, error = defaultError) {
768
852
  x = x - radius;
769
853
  y = y - radius;
770
854
 
@@ -795,7 +879,7 @@
795
879
  * 线宽(单位mm)。线宽是向线的下方延伸的。
796
880
  * @return 打印成功与否?
797
881
  */
798
- api.drawLine = function (x1, y1, x2, y2, lineWidth, success = () => {}, error = () => {}) {
882
+ api.drawLine = function (x1, y1, x2, y2, lineWidth, success = defaultSuccess, error = defaultError) {
799
883
  if (Mobile.isAndroid()) {
800
884
  LPAPIPlugin.drawLine(success, error,{
801
885
  x1: x1,
@@ -829,7 +913,7 @@
829
913
  * 点划线线段长度数组的元素个数。
830
914
  * @return 打印成功与否。
831
915
  */
832
- api.drawDashLine = function (x1, y1, x2, y2, lineWidth, dashLen, dashCount, success = () => {}, error = () => {}) {
916
+ api.drawDashLine = function (x1, y1, x2, y2, lineWidth, dashLen, dashCount, success = defaultSuccess, error = defaultError) {
833
917
  if (Mobile.isAndroid()) {
834
918
  LPAPIPlugin.drawDashLine(success, error,{
835
919
  x1: x1,
@@ -941,7 +1025,7 @@
941
1025
  * 一维条码的编码类型参考文档。
942
1026
  * @return 打印成功与否?
943
1027
  */
944
- api.drawBarcode = function (text, x, y, width, height, textHeight, type, success = () => {}, error = () => {}) {
1028
+ api.drawBarcode = function (text, x, y, width, height, textHeight, type, success = defaultSuccess, error = defaultError) {
945
1029
  if (Mobile.isAndroid()) {
946
1030
  LPAPIPlugin.draw1DBarcode(success, error,{
947
1031
  text: text,
@@ -971,7 +1055,7 @@
971
1055
  * 绘制的QRCode二维码的水平宽度(单位mm)。
972
1056
  * @return 打印成功与否?
973
1057
  */
974
- api.drawQRCode = function (text, x, y, width, success = () => {}, error = () => {}) {
1058
+ api.drawQRCode = function (text, x, y, width, success = defaultSuccess, error = defaultError) {
975
1059
  if (Mobile.isAndroid()) {
976
1060
  LPAPIPlugin.draw2DQRCode(success, error, {
977
1061
  text: text,
@@ -1005,7 +1089,7 @@
1005
1089
  * 0~255表示绘制黑白图片,原图颜色>=灰度阀值的点会被认为是白色,而原图颜色<灰度阀值的点会被认为是黑色。默认值为192。
1006
1090
  * @return 打印成功与否?
1007
1091
  */
1008
- api.drawImage = function (image, x, y, width, height, threshold, success = () => {}, error = () => {}) {
1092
+ api.drawImage = function (image, x, y, width, height, threshold, success = defaultSuccess, error = defaultError) {
1009
1093
  if (Mobile.isAndroid()) {
1010
1094
  LPAPIPlugin.drawImage(success, error, {
1011
1095
  image: image || "",
@@ -92,9 +92,6 @@ class LamboJsBridge {
92
92
  return this.platform.downloadFile(options);
93
93
  }
94
94
 
95
- getPrinterApi(options={}){
96
- return this.platform.getPrinterApi(options);
97
- }
98
95
  // 创建一个 Vue 插件
99
96
  static install(Vue) {
100
97
  // 将 LamboJsBridge 实例挂载到 Vue 原型上,全局可用
@@ -1,5 +1,4 @@
1
1
  import './yuntu';
2
- import printerApi from './LPAPI';
3
2
 
4
3
  export const PRINTER_PLUGIN = "printerPlugin"
5
4
 
@@ -312,12 +311,6 @@ class YunTuAdapter {
312
311
  });
313
312
  }
314
313
 
315
- getPrinterApi(options) {
316
- console.log('YunTu: get printerApi with options', options);
317
- return printerApi;
318
- }
319
-
320
-
321
314
  }
322
315
 
323
316
  export default YunTuAdapter;