fes.js/docs/reference/plugin/plugins/watermark.md
harrywan 98bae6d141
feat: watermark (#112)
* feat: 基础功能

* feat: 支持时间戳

* refactor(plugin-watermark): 优化实现

* feat(plugin-watermark): 提供开关

* docs: 添加文档

* docs: 优化文档
2022-04-18 13:31:47 +08:00

1.1 KiB
Raw Blame History

@fesjs/plugin-watermark

介绍

给页面添加水印效果

启用方式

package.json 中引入依赖:

{
    "dependencies": {
        "@fesjs/fes": "^2.0.0",
        "@fesjs/plugin-watermark": "^2.0.0"
    }
}

编译时配置

export default {
    watermark: {
        disabled: false
    },
}

disabled

是否禁用水印,默认是false

可以在开发环境关闭水印:

export default {
    watermark: {
        disabled: true
    },
}

API

createWatermark

创建水印功能,通过 @fesjs/fes 导入 API

import { createWatermark } from '@fesjs/fes'

createWatermark({ content: '我是水印' });

默认参数是:

{
    container = document.body,
    width = '300px',
    height = '300px',
    textAlign = 'center',
    textBaseline = 'middle',
    font = '16px Microsoft Yahei',
    fillStyle = 'rgba(184, 184, 184, 0.2)',
    content = '请勿外传',
    rotate = '45',
    zIndex = 99999,
    timestamp = 'YYYY-MM-DD hh:mm'
}

如果不需要时间戳,则可以设置timestampfalse