vg-print 1.0.302 → 1.0.303

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/README.md CHANGED
@@ -162,7 +162,12 @@ hiprint.setConfig({ showAdsorbLine: true, showPosition: true, showSizeBox: true
162
162
  // 注册插件
163
163
  hiprint.register({ authKey: '', plugins: [] })
164
164
  // 初始化元素提供器 (默认元素提供器)
165
- hiprint.init({ providers: [new defaultElementTypeProvider()] })
165
+ hiprint.init({
166
+ providers: [new defaultElementTypeProvider()],
167
+ host: 'http://localhost:17521',
168
+ token: '',
169
+ lang: 'en'
170
+ })
166
171
  // 创建模板对象
167
172
  const tpl = new hiprint.PrintTemplate({ template: {} })
168
173
  // 设计模板
@@ -177,14 +182,14 @@ tpl.toPdf({ name: '示例' }, '打印预览pdf', { paperWidth: 210, paperHeight:
177
182
  tpl.toImage({ name: '示例' }, { isDownload: true, name: '图片', limit: 1, type: 'image/jpeg', pixelRatio: 2 })
178
183
  ```
179
184
 
180
- 在任何场景(完整设计器、轻量 API、直接 `new`)只要在应用初始化阶段先调用这行注册,默认水印就会自动移除。
185
+ 水印与授权行为说明:设计态与运行态分离。设计态始终显示默认水印;运行态由授权控制。
181
186
 
182
187
  ### 授权密钥(authKey)与默认水印
183
188
 
184
189
  - 行为说明:
185
- - 未配置`authKey`时,库会为每个模板默认注入水印:`{ content: 'vg-print', timestamp: true }`。
186
- - 配置了`authKey`时,库不再注入默认水印;如需自定义,可自行传入`watermarkOptions`。
187
- - 适用于所有入口:完整设计器组件、直接`new hiprint.PrintTemplate(...)`、以及轻量运行时 API(`createTemplate`)。
190
+ - 设计态(FullDesigner 设计界面):始终显示默认水印 `{ content: 'vg-print', timestamp: true }`,不受 `authKey` 控制。
191
+ - 运行态(预览、浏览器打印、导出 PDF/图片、直连打印):未注册 `authKey` 时显示默认水印;注册有效 `authKey` 后默认水印移除。
192
+ - 适用于所有入口:完整设计器组件、直接 `new hiprint.PrintTemplate(...)`、以及轻量运行时 API(`createTemplate`)。
188
193
 
189
194
  - 全局注册授权密钥:
190
195
 
@@ -192,23 +197,12 @@ tpl.toImage({ name: '示例' }, { isDownload: true, name: '图片', limit: 1, ty
192
197
  import { hiprint } from 'vg-print'
193
198
 
194
199
  // 注册授权 key(建议在应用启动时调用)
195
- hiprint.register({ authKey: 'YOUR_AUTH_KEY' })
200
+ hiprint.register({ authKey: '你的key' })
196
201
 
197
- // 有授权 key → 默认水印移除
202
+ // 有授权 key → 运行态默认水印移除(设计态仍显示)
198
203
  const tpl = new hiprint.PrintTemplate({ template: {} })
199
204
  ```
200
205
 
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
206
  - 轻量运行时 API 使用授权:
213
207
 
214
208
  ```js
@@ -228,13 +222,14 @@ const tpl = new hiprint.PrintTemplate({
228
222
  watermarkOptions: { content: 'your-brand', timestamp: true, rotate: 20 }
229
223
  })
230
224
 
231
- // 有授权时,库不会注入默认水印;若仍需水印,请显式传入
225
+ // 有授权时,运行态不会注入默认水印;若仍需水印,请显式传入
232
226
  const tpl2 = createTemplate(tmplJson, {
233
227
  watermarkOptions: { content: 'your-brand', timestamp: true }
234
228
  })
235
229
 
236
- // 注意:若想在无授权时也不显示默认水印,可显式传入空对象
237
- const tpl3 = new hiprint.PrintTemplate({ template: {}, watermarkOptions: {} })
230
+ // 设计态不可关闭默认水印。
231
+ // 运行态的默认水印由授权控制,不建议通过传入空对象取消;如需取消,请注册有效 authKey。
232
+ const tpl3 = new hiprint.PrintTemplate({ template: {}, watermarkOptions: { content: 'your-brand', timestamp: true } })
238
233
  ```
239
234
 
240
235
  - 插件注册(可选):