vg-print 1.0.232 → 1.0.302

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 CcSimple
3
+ Copyright (c) 2021 gmcSimple
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -155,7 +155,7 @@ const onSave = ({ template, data, templateId }) => {
155
155
 
156
156
  本库导出 `hiprint`,可直接创建与操作模板对象(`hiprint.PrintTemplate`):
157
157
 
158
- ```js
158
+ ```
159
159
  import { hiprint, defaultElementTypeProvider } from 'vg-print'
160
160
  // 全局配置
161
161
  hiprint.setConfig({ showAdsorbLine: true, showPosition: true, showSizeBox: true })
@@ -177,6 +177,90 @@ tpl.toPdf({ name: '示例' }, '打印预览pdf', { paperWidth: 210, paperHeight:
177
177
  tpl.toImage({ name: '示例' }, { isDownload: true, name: '图片', limit: 1, type: 'image/jpeg', pixelRatio: 2 })
178
178
  ```
179
179
 
180
+ 在任何场景(完整设计器、轻量 API、直接 `new`)只要在应用初始化阶段先调用这行注册,默认水印就会自动移除。
181
+
182
+ ### 授权密钥(authKey)与默认水印
183
+
184
+ - 行为说明:
185
+ - 未配置`authKey`时,库会为每个模板默认注入水印:`{ content: 'vg-print', timestamp: true }`。
186
+ - 配置了`authKey`时,库不再注入默认水印;如需自定义,可自行传入`watermarkOptions`。
187
+ - 适用于所有入口:完整设计器组件、直接`new hiprint.PrintTemplate(...)`、以及轻量运行时 API(`createTemplate`)。
188
+
189
+ - 全局注册授权密钥:
190
+
191
+ ```js
192
+ import { hiprint } from 'vg-print'
193
+
194
+ // 注册授权 key(建议在应用启动时调用)
195
+ hiprint.register({ authKey: 'YOUR_AUTH_KEY' })
196
+
197
+ // 有授权 key → 默认水印移除
198
+ const tpl = new hiprint.PrintTemplate({ template: {} })
199
+ ```
200
+
201
+ - 加密用法(可选):
202
+
203
+ - Base64 轻度加密(无需 AES 参数;库端自动 Base64 解码):
204
+
205
+ ```js
206
+ import { hiprint } from 'vg-print'
207
+
208
+ await hiprint.register({ authKey: '你的key' })
209
+ // 解密成功 → 默认水印移除
210
+ ```
211
+
212
+ - 轻量运行时 API 使用授权:
213
+
214
+ ```js
215
+ import { hiprint, createTemplate, printBrowser } from 'vg-print'
216
+
217
+ hiprint.register({ authKey: 'YOUR_AUTH_KEY' })
218
+ const tpl = createTemplate(tmplJson) // 不再自动注入默认水印
219
+ printBrowser(tpl, data)
220
+ ```
221
+
222
+ - 自定义或显式控制水印:
223
+
224
+ ```js
225
+ // 无授权时,库会注入默认水印;如需自定义水印样式/内容
226
+ const tpl = new hiprint.PrintTemplate({
227
+ template: {},
228
+ watermarkOptions: { content: 'your-brand', timestamp: true, rotate: 20 }
229
+ })
230
+
231
+ // 有授权时,库不会注入默认水印;若仍需水印,请显式传入
232
+ const tpl2 = createTemplate(tmplJson, {
233
+ watermarkOptions: { content: 'your-brand', timestamp: true }
234
+ })
235
+
236
+ // 注意:若想在无授权时也不显示默认水印,可显式传入空对象
237
+ const tpl3 = new hiprint.PrintTemplate({ template: {}, watermarkOptions: {} })
238
+ ```
239
+
240
+ - 插件注册(可选):
241
+
242
+ ```js
243
+ import { hiprint } from 'vg-print'
244
+
245
+ // 两种形式的插件均支持
246
+ function pluginFn(h) { /* 扩展逻辑 */ }
247
+ const pluginObj = { install(h) { /* 扩展逻辑 */ } }
248
+
249
+ hiprint.register({
250
+ authKey: 'YOUR_AUTH_KEY',
251
+ plugins: [pluginFn, pluginObj]
252
+ })
253
+ ```
254
+
255
+ 默认水印参数参考:
256
+
257
+ ```js
258
+ { content: 'vg-print', timestamp: true }
259
+ }
260
+
261
+
262
+
263
+
180
264
  ## 轻量运行时 API(无需设计器 UI)
181
265
 
182
266
  当你只想“拿模板 + 数据”直接做预览、浏览器打印、导出 PDF/图片或进行客户端直连打印,而不引入页面设计器时,使用以下 API: