yimu-urovo-sdk
v1.0.7
Published
YIMU UROVO SDK
Downloads
28
Readme
森冕 web 调用 Flutter 的 API 介绍
通过 npm 安装
npm install yimu-urovo-sdk
扫描二维码
import { scanBarcode } from 'yimu-urovo-sdk'
try {
const res = await scanBarcode();
// 返回数据处理
} catch (error) {
// 异常
}
优博迅打印机相关
连接
import { connectToPrinter } from 'yimu-urovo-sdk'
try {
// 传入打印机包含id地址(必填)+端口(选填,默认9100)的对象
const res = await connectToPrinter({ip, port});
if (res.status == "success") {
// 成功
} else {
// 失败
}
} catch (error) {
// 其他异常
}
返回格式
{
status: 'success', // success成功,failed失败
};
断开连接
import { disconnect } from 'yimu-urovo-sdk'
try {
const res = await disconnect();
if (res.status == "success") {
// 成功
} else {
// 失败
}
} catch (error) {
// 其他异常
}
返回格式
{
status: 'success', // success成功,failed失败
};
打印
import { urovoPrint } from 'yimu-urovo-sdk'
try {
// 传入zpl指令
const res = await urovoPrint(zplStr);
} catch (error) {
// 异常
}
返回格式
{
status: 'success', // 因为优博迅打印机打印完成没有回调,默认为success成功
};
image 转 zpl 指令相关
image 转 zpl
import { convertImage } from 'yimu-urovo-sdk'
try {
// 传入图片base64地址(必填),options为可配置对象
const res = await convertImage(base64, options);
// 返回zpl指令
} catch (error) {
// 异常
}
options 详解
| 参数 | 默认 | 描述 | 是否选填 | | ------ | ---- | --------------------------------------------------------------------------------------------------------------------------------------- | -------- | | black | 50 | 浓度(1 ~ 99) | 是 | | rot | 'N' | 旋转角度'N':不旋转'L':逆时针旋转 90 度'R':顺时针旋转 90 度'I':旋转 180 度'B':同'L',逆时针旋转 90 度 | 是 | | notrim | true | 不去边缘空白 | 是 |
斑马扫码枪相关
扫码枪初始化(即连接)
import { initToPairing } from 'yimu-urovo-sdk'
try {
const res = await initToPairing();
// 返回数据处理
} catch (error) {
// 异常
}
返回格式
{
scannerName: '', // 仅success时有该字段
status: 'success', // success成功,failed失败
};
扫码枪扫码
import { callBackScannerData } from 'yimu-urovo-sdk'
callBackScannerData((res) => {
// 获取扫描内容,推荐在onMounted(以vue3为例)等生命周期里监听,防止重复监听
})
返回格式
{
text: '123123', // 内容
type: 'code128', // 码类型
};
扫码枪断开连接
import { disconnectScanner } from 'yimu-urovo-sdk'
try {
const res = await disconnectScanner();
// 返回数据处理
} catch (error) {
// 异常
}
返回格式
{
status: 'success', // success成功,failed失败
};
扫码枪补充说明
注: 1:因扫码枪断开连接后 sdk 无法获取其返回状态,故扫码枪是否已连接状态要开发本地存储,sdk 无法提供方法查询当前状态。在遇到场景需要重连时由开发自行判断。 2:app 关闭时会自动断开扫码枪连接,且每次连接必须扫码匹配,无法直接无感连接,产品设计时需注意此项。