npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tmesoft/print-qrcode

v1.0.3

Published

a print-qrcode

Downloads

10

Readme

print-qrcode

如何使用

用于连接二维码打印设备打印二维码

  1. pnpm i @tmesoft/print-qrcode
  2. 需传入配置项,vendorId为设备供应商ID(必传),printCommand为自定义打印命令方法(可选)
  3. 可使用CommandApi打印类自定义打印命令

usePrintQrcode demo

<!--ts-->
import usePrintQrcode from '@tmesoft/print-qrcode'
const printQrcode = ref(usePrintQrcode({ vendorId: 1137 }))

const list = ref([{name:'名称001',code:'DEVICE001',type:'分类001',lab:'实验室001',url:'https://www.baidu.com'}]

// 连接设备
const connectDevice = () => {
 unref(printQrcode).choiceUsbDevice().catch(err=>{
 console.log(err)
 })
}

// 开始打印
const startPrint = () => {
unref(printQrcode).start(list.value,()=>{
console.log('打印完成')
})
}

// 停止打印
const stopPrint = () => {
unref(printQrcode).stop()
}

方法

| Name | params | Description | default | |-----------------|--------|-------------|---------| | initState | | 初始化打印状态 | | | choiceUsbDevice | | 选择USB设备 | | | start | {list:Array,callback:Function} | 开始打印 | | | stop | | 停止打印 | |

属性

| Name | type | Description | |------------|---------|---------------------------------------------------------------| | printProgress | number | 打印进度 | | isPrint | boolean | 打印中状态(true: 打印中,false: 空闲) | | printState | string | 打印状态(idle:空闲,printing:打印中,finished:打印结束,cancel:打印取消,error:打印错误) | | deviceName | string | 设备名称 | | connected | boolean | 设备连接状态(true: 已连接,false: 未连接) | | errorMsg | string | 错误信息 |

使用CommandApi类自定义打印命令 demo

<!--ts-->
import { CommandApi } from '@tmesoft/print-qrcode'

const command = new CommandApi()
// 设置标签尺寸(单位mm)
command.setSize(80, 50)
// 设置标签之间的间隔(单位mm)
command.setGap(2)
// 清除打印机缓存
command.setCls()
// 文本
command.setText(50, 10, 'TSS24.BF2', 0, 1, 1, '测试文本')
// 二维码
command.setQR(50, 50, 'L', 6, 'A', 0, 'http://www.baidu.com')
// 设置打印次数
command.setPagePrint()