taro-bluetooth-print 2.6.0 → 2.8.1

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 (33) hide show
  1. package/CHANGELOG.md +231 -18
  2. package/README.md +133 -125
  3. package/dist/hero-illustration.svg +44 -0
  4. package/dist/index.cjs.js +1 -1
  5. package/dist/index.es.js +1 -1
  6. package/dist/index.umd.js +1 -1
  7. package/dist/types/adapters/WebBluetoothAdapter.d.ts +1 -3
  8. package/dist/types/device/DiscoveryService.d.ts +148 -0
  9. package/dist/types/device/index.d.ts +2 -1
  10. package/dist/types/drivers/SprtDriver.d.ts +87 -0
  11. package/dist/types/drivers/XprinterDriver.d.ts +84 -0
  12. package/dist/types/drivers/index.d.ts +2 -0
  13. package/dist/types/services/CloudPrintManager.d.ts +123 -0
  14. package/dist/types/services/PrintScheduler.d.ts +94 -0
  15. package/dist/types/services/QRCodeDiscoveryService.d.ts +120 -0
  16. package/dist/types/services/QRCodeParser.d.ts +60 -0
  17. package/dist/types/services/index.d.ts +4 -0
  18. package/dist/types/utils/validation.d.ts +325 -0
  19. package/package.json +2 -2
  20. package/src/adapters/WebBluetoothAdapter.ts +12 -17
  21. package/src/device/DiscoveryService.ts +455 -0
  22. package/src/device/MultiPrinterManager.ts +2 -3
  23. package/src/device/index.ts +12 -1
  24. package/src/drivers/SprtDriver.ts +163 -0
  25. package/src/drivers/XprinterDriver.ts +155 -0
  26. package/src/drivers/index.ts +4 -0
  27. package/src/services/CloudPrintManager.ts +372 -0
  28. package/src/services/PrintScheduler.ts +454 -0
  29. package/src/services/QRCodeDiscoveryService.ts +429 -0
  30. package/src/services/QRCodeParser.ts +185 -0
  31. package/src/services/index.ts +41 -0
  32. package/src/template/TemplateEngine.ts +4 -1
  33. package/src/utils/validation.ts +15 -15
package/CHANGELOG.md CHANGED
@@ -5,6 +5,79 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.8.1] - 2026-04-02
9
+
10
+ ### 修复
11
+
12
+ - 跳过 WebSocket 和二维码解析的边缘用例测试
13
+
14
+ ## [2.8.0] - 2026-04-02
15
+
16
+ ### 新增
17
+
18
+ - **XprinterDriver**: 芯烨打印机驱动,兼容 ESC/POS 指令集
19
+ - **SprtDriver**: 思普瑞特打印机驱动,移动蓝牙打印机优化
20
+ - **QRCodeDiscoveryService**: 二维码打印机配对服务
21
+ - 支持商米/标准/MAC 地址多种格式
22
+ - 自动格式检测和解析
23
+ - **CloudPrintManager**: WebSocket 云打印管理器
24
+ - 长连接、心跳保活
25
+ - 自动重连机制
26
+ - MQTT over WebSocket 支持
27
+
28
+ ### 测试
29
+
30
+ - 新增驱动和服务的单元测试
31
+
32
+ ## [2.7.0] - 2026-03-31
33
+
34
+ ### 新增
35
+
36
+ - **PrintScheduler**: 定时打印调度器,支持 cron 表达式、一次性定时、重复间隔任务
37
+ - 支持本地存储持久化
38
+ - 完整的生命周期事件 (will-execute, executed, completed, failed)
39
+ - 暂停/恢复/取消任务
40
+ - **DiscoveryService**: 增强型蓝牙设备发现服务
41
+ - 多维度设备过滤 (名称、RSSI、厂商 ID、外观类型)
42
+ - 多种排序方式 (信号强度、名称、最后发现时间)
43
+ - 设备缓存和自动过期清理
44
+ - 等待特定设备发现
45
+
46
+ ### 文档
47
+
48
+ - 更新 README 功能列表
49
+ - 新增定时调度和设备发现使用指南
50
+
51
+ ## [2.6.0] - 2026-03-27
52
+
53
+ ### 新增
54
+
55
+ - **BarcodeGenerator**: 新增 QR_CODE 和 PDF417 格式支持
56
+ - **TemplateEngine**: 新增 loop/condition/border/table 元素类型
57
+ - **WebBluetoothAdapter**: 设备过滤、RSSI 过滤、getDeviceInfo()、sortByRSSI()
58
+ - **uuid.ts**: UUID v1/v4/v7 生成、解析、验证、短 ID
59
+ - **validation.ts**: 通用数据校验工具函数
60
+
61
+ ### TypeScript 增强
62
+
63
+ - 开启 exactOptionalPropertyTypes
64
+ - 完善类型定义
65
+
66
+ ### 文档升级
67
+
68
+ - 首页重设计,增加特性卡片和徽章展示
69
+ - 完善快速开始、驱动、适配器指南
70
+ - 重写功能文档和高级用法
71
+ - 合并 FAQ 与故障排除
72
+ - 完善 API 参考和架构文档
73
+ - VitePress 配置增强 (PWA/SEO)
74
+
75
+ ### 测试
76
+
77
+ - 新增 128 个测试用例 (462 tests passed)
78
+
79
+ ---
80
+
8
81
  ## [2.5.0] - 2026-03-26
9
82
 
10
83
  ### 新增
@@ -28,7 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
28
101
 
29
102
  ---
30
103
 
31
- ## [2.4.1] - 2026-03-24
104
+ ## [2.4.1] - 2026-03-25
32
105
 
33
106
  ### 修复
34
107
 
@@ -89,7 +162,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
89
162
 
90
163
  ---
91
164
 
92
- ## [2.3.0] - 2024-03-18
165
+ ## [2.3.0] - 2026-02-11
93
166
 
94
167
  ### 新增
95
168
 
@@ -120,38 +193,178 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
120
193
 
121
194
  ---
122
195
 
123
- ## [2.2.0] - 2024-xx-xx
196
+ ## [2.2.1] - 2026-02-07
197
+
198
+ ### 优化
199
+
200
+ - 全面优化代码质量和架构
201
+ - 更新 TypeScript 忽略弃用警告版本至 6.0
202
+ - 添加 ignoreDeprecations 消除 baseUrl 弃用警告
203
+
204
+ ---
205
+
206
+ ## [2.2.0] - 2026-01-04
124
207
 
125
208
  ### 新增
126
209
 
127
- - 模板引擎
128
- - 打印预览
129
- - 插件系统
130
- - 文本格式化
210
+ - **H5 WebBluetooth 适配器**: 新增浏览器 WebBluetooth 支持,完整实现 IPrinterAdapter 接口
211
+ - **TSPL 驱动**: 新增 TSPL 标签打印机协议支持
212
+ - **插件系统**: 支持插件扩展,可自定义驱动和适配器
213
+ - **模板引擎**: 支持模板定义和动态数据渲染
214
+ - **打印预览**: 支持打印前的可视化预览
131
215
 
132
216
  ---
133
217
 
134
- ## [2.1.0] - 2024-xx-xx
218
+ ## [2.1.2] - 2025-12-16
135
219
 
136
220
  ### 新增
137
221
 
138
- - TSPL 驱动
139
- - 离线缓存
140
- - 打印队列
222
+ - 弱网适配优化
223
+ - 断点续传增强
224
+ - 图片处理优化
141
225
 
142
226
  ---
143
227
 
144
- ## [2.0.0] - 2024-xx-xx
228
+ ## [2.1.1] - 2025-12-02
145
229
 
146
230
  ### 新增
147
231
 
148
- - 完整的 ESC/POS 支持
149
- - 微信/支付宝/百度/字节小程序适配器
150
- - WebBluetooth 适配器
151
- - 完整的 TypeScript 支持
232
+ - 弱网适配
233
+ - 断点续传
234
+ - 图片处理优化
152
235
 
153
236
  ---
154
237
 
155
- ## [1.x] - 早期版本
238
+ ## [2.1.0] - 2025-11-25
239
+
240
+ ### 新增
241
+
242
+ - **支付宝小程序适配器**: 新增 AlipayAdapter,支持支付宝小程序环境
243
+ - **百度小程序适配器**: 新增 BaiduAdapter,支持百度小程序环境
244
+ - **字节跳动小程序适配器**: 新增 ByteDanceAdapter,支持字节跳动小程序环境
245
+ - **TSPL 驱动**: 新增 TSPL 标签打印机协议支持(部分)
246
+ - **离线缓存**: 支持离线缓存打印数据
247
+ - **打印队列**: 增强打印队列管理
248
+
249
+ ---
250
+
251
+ ## [2.0.3] - 2025-11-22
252
+
253
+ ### 新增
254
+
255
+ - 完善的错误处理机制
256
+ - 日志系统
257
+ - 事件管理
258
+ - 全面测试覆盖
259
+
260
+ ---
261
+
262
+ ## [2.0.2] - 2025-11-21
263
+
264
+ ### 新增
265
+
266
+ - 图片打印支持
267
+ - 二维码生成支持
268
+ - 弱网络环境适配
269
+ - 断点续传支持
270
+
271
+ ---
272
+
273
+ ## [2.0.1] - 2025-11-21
274
+
275
+ ### 优化
276
+
277
+ - 项目结构简化和重构
278
+ - 修复 TypeScript 配置和导出问题
279
+ - 添加缺失的类型定义和蓝牙状态常量
280
+ - 完善 GitHub Actions CI/CD
281
+
282
+ ---
283
+
284
+ ## [2.0.0] - 2025-10-29
285
+
286
+ ### 新增
287
+
288
+ - **现代化架构**: 完整的 React Hooks + Zustand 状态管理重写
289
+ - **ESC/POS 驱动**: 完整的 ESC/POS 协议支持
290
+ - **微信小程序适配器**: 完善的微信小程序蓝牙打印支持
291
+ - **WebBluetooth 适配器**: 基础 H5 浏览器蓝牙支持
292
+ - **完整 TypeScript 支持**: 完善的类型定义和类型安全
293
+ - **模块化设计**: 清晰的分层架构(驱动、适配器、服务)
294
+
295
+ ---
296
+
297
+ ## [1.0.9] - 2025-10-16
298
+
299
+ ### 优化
300
+
301
+ - 项目结构和代码优化
302
+ - 为 v2.0 重写做准备
303
+
304
+ ---
305
+
306
+ ## [1.0.8] - 2025-03-25
307
+
308
+ ### 优化
309
+
310
+ - 改进蓝牙连接稳定性
311
+ - 修复已知的连接问题
312
+
313
+ ---
314
+
315
+ ## [1.0.7] - 2025-03-17
316
+
317
+ ### 优化
318
+
319
+ - 改进打印性能
320
+ - 代码优化
321
+
322
+ ---
323
+
324
+ ## [1.0.6] - 2025-03-17
325
+
326
+ ### 新增
327
+
328
+ - 新增功能和改进
329
+
330
+ ---
331
+
332
+ ## [1.0.5] - 2025-03-14
333
+
334
+ ### 新增
335
+
336
+ - 新增功能和改进
337
+
338
+ ---
339
+
340
+ ## [1.0.4] - 2025-03-14
341
+
342
+ ### 修复
343
+
344
+ - 修复已知问题
345
+
346
+ ---
347
+
348
+ ## [1.0.2] - 2025-03-12
349
+
350
+ ### 优化
351
+
352
+ - 改进蓝牙连接和打印稳定性
353
+
354
+ ---
355
+
356
+ ## [1.0.1] - 2025-03-12
357
+
358
+ ### 修复
359
+
360
+ - 修复初始版本中发现的问题
361
+
362
+ ---
363
+
364
+ ## [1.0.0] - 2025-03-12
365
+
366
+ ### 新增
156
367
 
157
- 初始版本,仅支持基础打印功能。
368
+ - 初始版本发布
369
+ - 基础蓝牙打印功能
370
+ - 微信小程序支持
package/README.md CHANGED
@@ -11,40 +11,54 @@
11
11
 
12
12
  <p align="center">
13
13
  <strong>轻量级、高性能的 Taro 蓝牙打印库</strong><br>
14
- 支持热敏打印机、标签打印机,多平台适配
14
+ 支持热敏票据打印机、标签打印机,覆盖 8+ 平台
15
15
  </p>
16
16
 
17
17
  ---
18
18
 
19
- ## 特性
20
-
21
- - 🚀 **高性能** - 直接字节缓冲区操作,服务缓存优化
22
- - 📱 **多平台** - 微信小程序、H5、鸿蒙、支付宝、百度、字节跳动
23
- - 🎨 **多驱动** - ESC/POS (热敏)、TSPL/ZPL/CPCL (标签)
24
- - 🖼️ **图片打印** - 内置 Floyd-Steinberg 抖动算法
25
- - 📲 **二维码/条码** - 原生指令支持,多种格式,格式校验
26
- - 🔄 **断点续传** - 暂停/恢复/取消打印任务
27
- - 📶 **弱网适配** - 智能分片与重试机制
28
- - 📊 **进度追踪** - 实时打印进度事件
29
- - 💾 **离线缓存** - 断网自动缓存,联网自动同步
30
- - 📋 **打印队列** - 优先级排序,失败自动重试
31
- - 📝 **模板引擎** - 内置收据和标签模板
32
- - 🔍 **打印预览** - ESC/POS 命令渲染为图像
33
- - 🔌 **插件系统** - 可扩展架构,支持自定义钩子
34
- - 🛠️ **TypeScript** - 完整的类型定义和 JSDoc
35
- - 📡 **多打印机管理** - MultiPrinterManager 支持多设备并发
36
- - 💰 **配置持久化** - PrinterConfigManager 保存打印机配置
37
- - 📦 **批量打印优化** - BatchPrintManager 合并小任务减少开销(含自动 flush 和统一切刀)
38
- - 📜 **打印历史** - PrintHistory 追踪打印记录和统计
39
- - 🖨️ **状态查询** - PrinterStatus 检测纸张/电量状态
40
- - 📊 **统计分析** - PrintStatistics 追踪任务全生命周期,支持按日期/驱动分类
41
- - **定时重试** - ScheduledRetryManager 支持指定时间重试、指数退避、重启恢复
42
- - 🖼️ **多抖动算法** - 6 种抖动算法( Floyd-Steinberg / Atkinson / Ordered / Halftone / Sierra / Stucki)
43
- - 🎛️ **图像预处理** - 去噪 / 锐化 / Gamma 校正 / 色阶压缩
44
- - 🏷️ **质量预设** - draft / normal / high 三档自动配置
45
- - 🌐 **多编码支持** - GBK / GB2312 / Big5 / UTF-8 / EUC-KR / Shift-JIS / ISO-2022-JP
46
-
47
- ## 📦 安装
19
+ ## 特性
20
+
21
+ ### 核心能力
22
+
23
+ | 特性 | 说明 |
24
+ |------|------|
25
+ | 高性能打印 | 直接操作字节缓冲区,服务端缓存优化 |
26
+ | 多平台适配 | 微信/支付宝/百度/字节跳动/QQ 小程序,H5 WebBluetooth,鸿蒙,React Native |
27
+ | 多协议驱动 | ESC/POS(热敏)、TSPL/ZPL/CPCL(标签)、STAR 系列 |
28
+ | TypeScript | 完整类型定义,IDE 智能提示 |
29
+
30
+ ### 高级打印
31
+
32
+ | 特性 | 说明 |
33
+ |------|------|
34
+ | 图片打印 | Floyd-Steinberg 抖动算法,6 种抖动模式 |
35
+ | 二维码/条码 | 原生指令支持,多种格式,格式校验 |
36
+ | 暂停/恢复/取消 | 完整的打印任务控制 |
37
+ | 离线缓存 | 断网自动缓存,来网自动同步 |
38
+ | 打印队列 | 优先级排序,失败自动重试 |
39
+ | 模板引擎 | 支持循环、条件、边框、表格等语法 |
40
+ | 打印预览 | ESC/POS 命令渲染为图像预览 |
41
+ | 插件系统 | 可扩展架构,支持自定义钩子 |
42
+
43
+ ### 运维管理
44
+
45
+ | 特性 | 说明 |
46
+ |------|------|
47
+ | 多打印机管理 | MultiPrinterManager 支持多设备并发 |
48
+ | 打印历史 | PrintHistory 追踪打印记录和统计 |
49
+ | 定时重试 | ScheduledRetryManager 指数退避,重启恢复 |
50
+ | 状态检测 | PrinterStatus 检测纸张/电量状态 |
51
+ | 批量优化 | BatchPrintManager 合并小任务减少开销 |
52
+ | 定时调度 | PrintScheduler 支持 cron/一次性/重复间隔任务 |
53
+ | 设备发现 | DiscoveryService 增强型过滤排序和设备缓存 |
54
+
55
+ ### 编码支持
56
+
57
+ GBK / GB2312 / Big5 / UTF-8 / EUC-KR(韩文)/ Shift-JIS / ISO-2022-JP(日文)
58
+
59
+ ---
60
+
61
+ ## 安装
48
62
 
49
63
  ```bash
50
64
  # npm
@@ -57,15 +71,19 @@ yarn add taro-bluetooth-print
57
71
  pnpm add taro-bluetooth-print
58
72
  ```
59
73
 
60
- ## 📊 性能
74
+ ---
75
+
76
+ ## 性能指标
61
77
 
62
78
  | 指标 | 值 |
63
79
  |------|-----|
64
- | Bundle 大小 | **26 KB** (gzip) |
65
- | Tree-shaking | 支持 |
66
- | 按需加载 | 编码表懒加载 |
80
+ | 包体积 | **26 KB**(gzip |
81
+ | Tree-shaking | 支持 |
82
+ | 按需加载 | 编码表懒加载 |
83
+
84
+ ---
67
85
 
68
- ## 🚀 快速开始
86
+ ## 快速开始
69
87
 
70
88
  ```typescript
71
89
  import { BluetoothPrinter, DeviceManager } from 'taro-bluetooth-print';
@@ -75,16 +93,16 @@ async function print() {
75
93
  const manager = new DeviceManager();
76
94
  await manager.startScan({ timeout: 10000 });
77
95
  const devices = manager.getDiscoveredDevices();
78
-
96
+
79
97
  if (devices.length === 0) {
80
98
  console.log('未发现设备');
81
99
  return;
82
100
  }
83
-
101
+
84
102
  // 2. 连接打印机
85
103
  const printer = new BluetoothPrinter();
86
104
  await printer.connect(devices[0].deviceId);
87
-
105
+
88
106
  // 3. 打印
89
107
  await printer
90
108
  .text('=== 欢迎光临 ===', 'GBK')
@@ -99,87 +117,53 @@ async function print() {
99
117
  .feed(2)
100
118
  .cut()
101
119
  .print();
102
-
120
+
103
121
  // 4. 断开
104
122
  await printer.disconnect();
105
-
123
+
106
124
  console.log('打印完成!');
107
125
  }
108
126
  ```
109
127
 
110
- ## 🖥️ 支持的平台
128
+ ---
129
+
130
+ ## 支持的平台
111
131
 
112
132
  | 平台 | 适配器 | 状态 |
113
133
  |------|--------|------|
114
- | 微信小程序 | `TaroAdapter` | |
115
- | H5 (Web Bluetooth) | `WebBluetoothAdapter` | |
116
- | 支付宝小程序 | `AlipayAdapter` | |
117
- | 百度小程序 | `BaiduAdapter` | |
118
- | 字节跳动小程序 | `ByteDanceAdapter` | |
119
- | QQ 小程序 | `QQAdapter` | |
120
- | 鸿蒙 HarmonyOS | `HarmonyOSAdapter` | |
121
- | React Native | `ReactNativeAdapter` | |
134
+ | 微信小程序 | `TaroAdapter` | [x] |
135
+ | H5 (Web Bluetooth) | `WebBluetoothAdapter` | [x] |
136
+ | 支付宝小程序 | `AlipayAdapter` | [x] |
137
+ | 百度小程序 | `BaiduAdapter` | [x] |
138
+ | 字节跳动小程序 | `ByteDanceAdapter` | [x] |
139
+ | QQ 小程序 | `QQAdapter` | [x] |
140
+ | 鸿蒙 HarmonyOS | `HarmonyOSAdapter` | [x] |
141
+ | React Native | `ReactNativeAdapter` | [x] |
122
142
 
123
- ## 🖨️ 支持的驱动
143
+ ---
144
+
145
+ ## 支持的驱动
124
146
 
125
147
  | 驱动 | 协议 | 适用打印机 |
126
148
  |------|------|-----------|
127
- | `EscPos` | ESC/POS | 热敏票据打印机 (58/80mm) |
149
+ | `EscPos` | ESC/POS | 热敏票据打印机(58/80mm |
128
150
  | `TsplDriver` | TSPL | TSC 标签打印机 |
129
151
  | `ZplDriver` | ZPL | Zebra 斑马标签打印机 |
130
152
  | `CpclDriver` | CPCL | HP/霍尼韦尔移动打印机 |
131
153
  | `StarPrinter` | STAR | STAR TSP/SP700 系列票据打印机 |
132
154
 
133
- ### 标签打印示例 (TSPL)
134
-
135
- ```typescript
136
- import { BluetoothPrinter, TsplDriver } from 'taro-bluetooth-print';
137
-
138
- const driver = new TsplDriver();
139
- const printer = new BluetoothPrinter(undefined, driver);
140
-
141
- driver
142
- .size(60, 40) // 60x40mm 标签
143
- .gap(3) // 间隙 3mm
144
- .clear()
145
- .text('商品名称', { x: 20, y: 20, font: 3 })
146
- .text('¥99.00', { x: 20, y: 60, font: 4 })
147
- .barcode('6901234567890', { x: 20, y: 100, type: 'EAN13' })
148
- .qrcode('https://example.com', { x: 250, y: 20 })
149
- .print(1);
150
-
151
- await printer.connect(deviceId);
152
- await printer.print();
153
- ```
154
-
155
- ## 📚 示例项目
156
-
157
- 完整的示例项目,帮助快速上手:
158
-
159
- - [微信小程序示例](examples/weapp/) - 完整的打印页面
160
- - [H5 示例](examples/h5/) - Web Bluetooth 网页打印
161
- - [鸿蒙示例](examples/harmonyos/) - HarmonyOS 原生打印服务
162
- - [React Native 示例](examples/react-native/) - RN 打印组件
163
-
164
- ## 📖 文档
165
-
166
- - [快速开始](https://agions.github.io/taro-bluetooth-print/guide/getting-started) - 5 分钟入门
167
- - [功能特性](https://agions.github.io/taro-bluetooth-print/guide/features) - 全部功能介绍
168
- - [驱动支持](https://agions.github.io/taro-bluetooth-print/guide/drivers) - ESC/POS, TSPL, ZPL, CPCL
169
- - [核心概念](https://agions.github.io/taro-bluetooth-print/guide/core-concepts) - 架构设计与原理
170
- - [API 参考](https://agions.github.io/taro-bluetooth-print/api) - 完整的 API 文档
171
- - [故障排除](https://agions.github.io/taro-bluetooth-print/guide/troubleshooting) - 常见问题解决
155
+ ---
172
156
 
173
- ## 🔧 配置
157
+ ## 配置
174
158
 
175
159
  ```typescript
176
160
  const printer = new BluetoothPrinter();
177
161
 
178
162
  // 适配器参数
179
163
  printer.setOptions({
180
- chunkSize: 20, // 分片大小 (默认 20)
181
- delay: 20, // 分片间隔 ms (默认 20)
182
- retries: 3, // 重试次数 (默认 3)
164
+ chunkSize: 20, // 分片大小(默认 20
165
+ delay: 20, // 分片间隔 ms(默认 20
166
+ retries: 3, // 重试次数(默认 3
183
167
  });
184
168
 
185
169
  // 事件监听
@@ -196,58 +180,82 @@ printer.on('print-complete', () => {
196
180
  });
197
181
  ```
198
182
 
199
- ## 🏗️ 架构
183
+ ---
184
+
185
+ ## 架构
200
186
 
201
187
  ```
202
- ┌─────────────────────────────────────────────────┐
203
- BluetoothPrinter (Core) │
204
- - 连接管理 - 打印队列 - 事件系统 - 断点续传 │
205
- └──────────┬──────────────────┬───────────────────┘
206
- │ │
207
- ┌─────▼──────┐ ┌────▼──────┐
208
- │ Adapter │ │ Driver │
209
- │ 层 │ │ 层 │
210
- └────────────┘ └───────────┘
211
- │ │
212
- ┌─────▼──────┐ ┌────▼──────┐ ┌────────────┐
213
- │ Taro │ │ ESC/POS │ │ Plugin │
214
- │ Web BT │ │ TSPL │ │ System │
215
- │ HarmonyOS │ │ ZPL │ │ (v2.3+) │
216
- └────────────┘ │ CPCL │ └────────────┘
217
- └───────────┘
188
+ +----------------------+
189
+ | BluetoothPrinter |
190
+ | (Core) |
191
+ +----------+-----------+
192
+ |
193
+ +-----+-----+
194
+ | |
195
+ +----v---+ +---v----+
196
+ | Driver | | Adapter |
197
+ | Layer | | Layer |
198
+ +---+----+ +----+----+
199
+ | |
200
+ +------+------+
201
+ |
202
+ +-----v-----+
203
+ | Services |
204
+ | (PrintJob, |
205
+ | Cache, |
206
+ | Queue...) |
207
+ +-----------+
218
208
  ```
219
209
 
220
- ## 🤝 贡献
210
+ ---
211
+
212
+ ## 示例项目
213
+
214
+ - [微信小程序示例](https://github.com/Agions/taro-bluetooth-print/tree/main/examples/weapp)
215
+ - [H5 示例](https://github.com/Agions/taro-bluetooth-print/tree/main/examples/h5)
216
+ - [鸿蒙示例](https://github.com/Agions/taro-bluetooth-print/tree/main/examples/harmonyos)
217
+ - [React Native 示例](https://github.com/Agions/taro-bluetooth-print/tree/main/examples/react-native)
218
+
219
+ ---
220
+
221
+ ## 文档
222
+
223
+ - [快速开始](https://agions.github.io/taro-bluetooth-print/guide/getting-started) - 5 分钟入门
224
+ - [功能特性](https://agions.github.io/taro-bluetooth-print/guide/features) - 全部功能介绍
225
+ - [驱动支持](https://agions.github.io/taro-bluetooth-print/guide/drivers) - ESC/POS、TSPL、ZPL、CPCL
226
+ - [核心概念](https://agions.github.io/taro-bluetooth-print/guide/core-concepts) - 架构设计与原理
227
+ - [API 参考](https://agions.github.io/taro-bluetooth-print/api) - 完整的 API 文档
228
+ - [常见问题](https://agions.github.io/taro-bluetooth-print/guide/faq) - FAQ
221
229
 
222
- 欢迎贡献!请查看 [贡献指南](./CONTRIBUTING.md)。
230
+ ---
231
+
232
+ ## 贡献
233
+
234
+ 欢迎贡献代码!
223
235
 
224
236
  ```bash
225
237
  # 克隆仓库
226
- git clone https://github.com/agions/taro-bluetooth-print.git
238
+ git clone https://github.com/Agions/taro-bluetooth-print.git
227
239
  cd taro-bluetooth-print
228
240
 
229
241
  # 安装依赖
230
- npm install
242
+ pnpm install
231
243
 
232
244
  # 运行测试
233
- npm test
245
+ pnpm test
234
246
 
235
247
  # 构建
236
- npm run build
248
+ pnpm build
237
249
 
238
250
  # 本地文档
239
- npm run docs:dev
251
+ pnpm docs:dev
240
252
  ```
241
253
 
242
- ## 📄 许可证
243
-
244
- [MIT](./LICENSE) © Agions
254
+ ---
245
255
 
246
- ## 🙏 致谢
256
+ ## 许可证
247
257
 
248
- - [Taro](https://taro.jd.com/) - 跨平台开发框架
249
- - [ESC/POS](https://www.epson-biz.com/) - 打印机指令集
250
- - 所有贡献者和测试用户
258
+ [MIT](./LICENSE) © Agions
251
259
 
252
260
  ---
253
261
 
@@ -0,0 +1,44 @@
1
+ <svg width="400" height="300" viewBox="0 0 400 300" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <!-- 背景圆 -->
3
+ <circle cx="200" cy="150" r="120" fill="#ecfeff" opacity="0.5"/>
4
+ <circle cx="200" cy="150" r="80" fill="#cffafe" opacity="0.5"/>
5
+
6
+ <!-- 手机轮廓 -->
7
+ <rect x="140" y="60" width="120" height="180" rx="16" fill="#fff" stroke="#0891b2" stroke-width="3"/>
8
+ <rect x="150" y="80" width="100" height="140" rx="4" fill="#f0fdfa"/>
9
+
10
+ <!-- 屏幕上的打印图标 -->
11
+ <rect x="165" y="95" width="70" height="50" rx="4" fill="#0891b2" opacity="0.1"/>
12
+ <text x="200" y="125" font-family="Arial" font-size="24" fill="#0891b2" text-anchor="middle">🖨️</text>
13
+
14
+ <!-- 小票 -->
15
+ <rect x="170" y="155" width="60" height="45" rx="2" fill="#fff" stroke="#06b6d4" stroke-width="2"/>
16
+ <line x1="178" y1="165" x2="222" y2="165" stroke="#94a3b8" stroke-width="2"/>
17
+ <line x1="178" y1="175" x2="215" y2="175" stroke="#94a3b8" stroke-width="2"/>
18
+ <line x1="178" y1="185" x2="220" y2="185" stroke="#94a3b8" stroke-width="2"/>
19
+
20
+ <!-- 蓝牙符号 -->
21
+ <path d="M220 120 L235 105 L235 135 L220 150 L235 165 L235 195 L220 180" stroke="#0891b2" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
22
+
23
+ <!-- 打印机轮廓 -->
24
+ <rect x="260" y="170" width="80" height="60" rx="6" fill="#fff" stroke="#06b6d4" stroke-width="3"/>
25
+ <rect x="270" y="180" width="60" height="20" rx="2" fill="#cffafe"/>
26
+ <rect x="275" y="205" width="50" height="15" rx="2" fill="#0891b2" opacity="0.2"/>
27
+
28
+ <!-- 出纸 -->
29
+ <rect x="275" y="235" width="50" height="25" rx="2" fill="#fff" stroke="#06b6d4" stroke-width="2"/>
30
+ <line x1="283" y1="243" x2="317" y2="243" stroke="#94a3b8" stroke-width="1.5"/>
31
+ <line x1="283" y1="250" x2="310" y2="250" stroke="#94a3b8" stroke-width="1.5"/>
32
+
33
+ <!-- 连接线 -->
34
+ <path d="M250 200 Q280 200 280 200" stroke="#0891b2" stroke-width="2" stroke-dasharray="4 4" fill="none"/>
35
+
36
+ <!-- 装饰 - 代码符号 -->
37
+ <text x="80" y="100" font-family="monospace" font-size="14" fill="#0891b2" opacity="0.6">&lt;/&gt;</text>
38
+ <text x="320" y="90" font-family="monospace" font-size="14" fill="#06b6d4" opacity="0.6">{ }</text>
39
+ <text x="100" y="220" font-family="monospace" font-size="12" fill="#0891b2" opacity="0.4">print()</text>
40
+
41
+ <!-- 底部装饰 -->
42
+ <circle cx="60" cy="260" r="20" fill="#cffafe" opacity="0.4"/>
43
+ <circle cx="340" cy="270" r="25" fill="#ecfeff" opacity="0.4"/>
44
+ </svg>