vg-print 1.0.232 → 1.0.301
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 +1 -1
- package/README.md +86 -1
- package/dist/style.css +1 -1
- package/dist/vg-print.es.js +208 -129
- package/dist/vg-print.umd.js +6 -6
- package/package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ const onSave = ({ template, data, templateId }) => {
|
|
|
155
155
|
|
|
156
156
|
本库导出 `hiprint`,可直接创建与操作模板对象(`hiprint.PrintTemplate`):
|
|
157
157
|
|
|
158
|
-
```
|
|
158
|
+
```
|
|
159
159
|
import { hiprint, defaultElementTypeProvider } from 'vg-print'
|
|
160
160
|
// 全局配置
|
|
161
161
|
hiprint.setConfig({ showAdsorbLine: true, showPosition: true, showSizeBox: true })
|
|
@@ -177,6 +177,91 @@ 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
|
+
// 明文:gmc5760337 → Base64:Z21jNTc2MDMzNw==
|
|
209
|
+
await hiprint.register({ authKey: '你的key' })
|
|
210
|
+
// 解密成功 → 默认水印移除
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
- 轻量运行时 API 使用授权:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
import { hiprint, createTemplate, printBrowser } from 'vg-print'
|
|
217
|
+
|
|
218
|
+
hiprint.register({ authKey: 'YOUR_AUTH_KEY' })
|
|
219
|
+
const tpl = createTemplate(tmplJson) // 不再自动注入默认水印
|
|
220
|
+
printBrowser(tpl, data)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
- 自定义或显式控制水印:
|
|
224
|
+
|
|
225
|
+
```js
|
|
226
|
+
// 无授权时,库会注入默认水印;如需自定义水印样式/内容
|
|
227
|
+
const tpl = new hiprint.PrintTemplate({
|
|
228
|
+
template: {},
|
|
229
|
+
watermarkOptions: { content: 'your-brand', timestamp: true, rotate: 20 }
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
// 有授权时,库不会注入默认水印;若仍需水印,请显式传入
|
|
233
|
+
const tpl2 = createTemplate(tmplJson, {
|
|
234
|
+
watermarkOptions: { content: 'your-brand', timestamp: true }
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// 注意:若想在无授权时也不显示默认水印,可显式传入空对象
|
|
238
|
+
const tpl3 = new hiprint.PrintTemplate({ template: {}, watermarkOptions: {} })
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- 插件注册(可选):
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import { hiprint } from 'vg-print'
|
|
245
|
+
|
|
246
|
+
// 两种形式的插件均支持
|
|
247
|
+
function pluginFn(h) { /* 扩展逻辑 */ }
|
|
248
|
+
const pluginObj = { install(h) { /* 扩展逻辑 */ } }
|
|
249
|
+
|
|
250
|
+
hiprint.register({
|
|
251
|
+
authKey: 'YOUR_AUTH_KEY',
|
|
252
|
+
plugins: [pluginFn, pluginObj]
|
|
253
|
+
})
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
默认水印参数参考:
|
|
257
|
+
|
|
258
|
+
```js
|
|
259
|
+
{ content: 'vg-print', timestamp: true }
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
180
265
|
## 轻量运行时 API(无需设计器 UI)
|
|
181
266
|
|
|
182
267
|
当你只想“拿模板 + 数据”直接做预览、浏览器打印、导出 PDF/图片或进行客户端直连打印,而不引入页面设计器时,使用以下 API:
|