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 +16 -21
- package/dist/style.css +1 -1
- package/dist/vg-print.es.js +36 -12
- package/dist/vg-print.umd.js +4 -4
- package/package.json +1 -1
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({
|
|
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
|
-
|
|
185
|
+
水印与授权行为说明:设计态与运行态分离。设计态始终显示默认水印;运行态由授权控制。
|
|
181
186
|
|
|
182
187
|
### 授权密钥(authKey)与默认水印
|
|
183
188
|
|
|
184
189
|
- 行为说明:
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
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: '
|
|
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
|
-
|
|
230
|
+
// 设计态不可关闭默认水印。
|
|
231
|
+
// 运行态的默认水印由授权控制,不建议通过传入空对象取消;如需取消,请注册有效 authKey。
|
|
232
|
+
const tpl3 = new hiprint.PrintTemplate({ template: {}, watermarkOptions: { content: 'your-brand', timestamp: true } })
|
|
238
233
|
```
|
|
239
234
|
|
|
240
235
|
- 插件注册(可选):
|