@jcyao/print-sdk 1.1.1 → 1.1.2

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
@@ -2,6 +2,41 @@
2
2
 
3
3
  所有版本的变更记录都列在这里,遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/) 规范。
4
4
 
5
+ ## [1.1.2] - 2026-05-07
6
+
7
+ ### 🐛 问题修复
8
+
9
+ | 问题 | 修复内容 |
10
+ |------|----------|
11
+ | 打印内容偏左 | `@media print` 中 `.print-page` 的 `margin` 未完全覆盖,导致 `auto` margin 在打印时产生偏移 |
12
+ | 批量打印无边距 | `generateBatchPrintStyles` 未设置 `.print-page` 的 `padding`,导致边距功能失效 |
13
+
14
+ ### 🔧 修复详情
15
+
16
+ #### 1. 打印样式 `@media print` 增强
17
+
18
+ - `body` 样式增加 `!important` 标记,确保打印时完全重置 `margin`、`padding`、`background`
19
+ - `.print-page` 的 `margin-bottom: 0 !important` 改为 `margin: 0 !important`,完全覆盖所有方向的 `auto` margin
20
+ - `.print-page` 的 `box-shadow` 增加 `!important` 标记
21
+
22
+ **影响范围**:`generatePrintPageStyles`、`generateBatchPrintStyles`
23
+
24
+ #### 2. 批量打印边距修复
25
+
26
+ - `generateBatchPrintStyles` 的 `.print-page` 基础样式增加 `padding: ${marginTop}mm ${marginRight}mm ${marginBottom}mm ${marginLeft}mm`
27
+ - 确保批量打印时页面边距功能正常生效
28
+
29
+ ---
30
+
31
+ ## [1.1.1] - 2026-01-22
32
+
33
+ ### ✨ 新增功能
34
+
35
+ - **表格嵌套对象数据支持**:表格打印支持嵌套对象格式的数据源(如 `{ a: { b: 1 } }`),数据绑定时可通过路径(如 `a.b`)正确解析
36
+ - **服务架构简化**:移除独立 server 服务,改用 Vite mock 集成,降低开发和部署复杂度
37
+
38
+ ---
39
+
5
40
  ## [1.1.0] - 2026-04-15
6
41
 
7
42
  ### 🎯 重大改进
package/README.md CHANGED
@@ -5,7 +5,17 @@
5
5
 
6
6
  通用打印 SDK - 客户端打印解决方案
7
7
 
8
- **当前版本**: v1.1.0
8
+ **当前版本**: v1.1.2
9
+
10
+ ## 🆕 v1.1.2 问题修复
11
+
12
+ - 🐛 **打印内容偏移修复**:`@media print` 中 `.print-page` 的 `margin` 完全覆盖,解决打印内容偏左问题
13
+ - 🐛 **批量打印边距修复**:`generateBatchPrintStyles` 增加 `padding` 设置,批量打印边距功能正常生效
14
+
15
+ ## 🆕 v1.1.1 新增功能
16
+
17
+ - ✨ **表格嵌套对象数据支持**:表格打印支持嵌套对象格式的数据源
18
+ - 🔧 **服务架构简化**:移除独立 server 服务,改用 Vite mock 集成
9
19
 
10
20
  ## 🆕 v1.1.0 重大改进
11
21
 
package/dist/index.esm.js CHANGED
@@ -209,8 +209,9 @@ function generatePrintPageStyles(config) {
209
209
 
210
210
  @media print {
211
211
  body {
212
- background: white;
213
- padding: 0;
212
+ margin: 0 !important;
213
+ padding: 0 !important;
214
+ background: white !important;
214
215
  }
215
216
 
216
217
  @page {
@@ -219,9 +220,9 @@ function generatePrintPageStyles(config) {
219
220
  }
220
221
 
221
222
  .print-page {
223
+ margin: 0 !important;
224
+ box-shadow: none !important;
222
225
  page-break-after: always;
223
- margin-bottom: 0 !important;
224
- box-shadow: none; /* 移除阴影 */
225
226
  }
226
227
 
227
228
  .print-page:last-child {
@@ -248,7 +249,7 @@ function generatePrintPageStyles(config) {
248
249
  * 用于 PrintSDK 的 printMultiple
249
250
  */
250
251
  function generateBatchPrintStyles(config) {
251
- const { pageWidthMm, pageHeightMm, isContinuous = false, minHeightMm = 100, } = config;
252
+ const { pageWidthMm, pageHeightMm, marginTop = 0, marginRight = 0, marginBottom = 0, marginLeft = 0, isContinuous = false, minHeightMm = 100, } = config;
252
253
  return `
253
254
  * { margin: 0; padding: 0; box-sizing: border-box; }
254
255
  body { margin: 0; padding: 0; background: #f5f5f5; }
@@ -259,8 +260,8 @@ function generateBatchPrintStyles(config) {
259
260
  }
260
261
 
261
262
  @media print {
262
- body { margin: 0; padding: 0; background: white; }
263
- .print-page { margin: 0; page-break-after: always; box-shadow: none !important; }
263
+ body { margin: 0 !important; padding: 0 !important; background: white !important; }
264
+ .print-page { margin: 0 !important; page-break-after: always; box-shadow: none !important; }
264
265
  .print-page:last-child { page-break-after: auto; }
265
266
  }
266
267
 
@@ -271,7 +272,7 @@ function generateBatchPrintStyles(config) {
271
272
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
272
273
  }
273
274
  }
274
-
275
+
275
276
  .print-page {
276
277
  width: ${pageWidthMm}mm;
277
278
  height: ${isContinuous ? 'auto' : pageHeightMm + 'mm'};
@@ -279,6 +280,7 @@ function generateBatchPrintStyles(config) {
279
280
  background: white;
280
281
  position: relative;
281
282
  box-sizing: border-box;
283
+ padding: ${marginTop}mm ${marginRight}mm ${marginBottom}mm ${marginLeft}mm;
282
284
  }
283
285
 
284
286
  ${generateComponentStyles()}