2023-08-31 17:28:05 +08:00
|
|
|
|
<script lang="ts" setup>
|
2024-11-21 20:41:48 +08:00
|
|
|
|
import { useWatermark } from "@/composables/useWatermark"
|
2024-11-18 19:40:44 +08:00
|
|
|
|
import { ref } from "vue"
|
2023-08-30 18:26:49 +08:00
|
|
|
|
|
|
|
|
|
const localRef = ref<HTMLElement | null>(null)
|
2023-08-31 17:28:05 +08:00
|
|
|
|
const { setWatermark, clearWatermark } = useWatermark(localRef)
|
|
|
|
|
const { setWatermark: setGlobalWatermark, clearWatermark: clearGlobalWatermark } = useWatermark()
|
2023-08-30 18:26:49 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="app-container">
|
2023-08-31 17:28:05 +08:00
|
|
|
|
<h4>
|
2024-11-21 20:41:48 +08:00
|
|
|
|
该示例是演示:通过调用 composable 开启或关闭水印,
|
2023-09-01 00:43:44 +08:00
|
|
|
|
支持局部、全局、自定义样式(颜色、透明度、字体大小、字体、倾斜角度等),并自带防御(防删、防隐藏)和自适应功能
|
2023-08-31 17:28:05 +08:00
|
|
|
|
</h4>
|
2023-08-30 18:26:49 +08:00
|
|
|
|
<div ref="localRef" class="local" />
|
|
|
|
|
<el-button-group>
|
2024-11-18 19:40:44 +08:00
|
|
|
|
<el-button type="primary" @click="setWatermark('局部水印', { color: '#409eff' })">
|
|
|
|
|
创建局部水印
|
|
|
|
|
</el-button>
|
2023-09-01 11:52:57 +08:00
|
|
|
|
<el-button type="warning" @click="setWatermark('没有防御功能的局部水印', { color: '#e6a23c', defense: false })">
|
|
|
|
|
关闭防御功能
|
|
|
|
|
</el-button>
|
2024-11-18 19:40:44 +08:00
|
|
|
|
<el-button type="danger" @click="clearWatermark">
|
|
|
|
|
清除局部水印
|
|
|
|
|
</el-button>
|
2023-08-30 18:26:49 +08:00
|
|
|
|
</el-button-group>
|
|
|
|
|
<el-button-group>
|
2024-11-18 19:40:44 +08:00
|
|
|
|
<el-button type="primary" @click="setGlobalWatermark('全局水印', { color: '#409eff' })">
|
|
|
|
|
创建全局水印
|
|
|
|
|
</el-button>
|
2023-09-01 11:52:57 +08:00
|
|
|
|
<el-button
|
|
|
|
|
type="warning"
|
|
|
|
|
@click="setGlobalWatermark('没有防御功能的全局水印', { color: '#e6a23c', defense: false })"
|
|
|
|
|
>
|
|
|
|
|
关闭防御功能
|
2023-08-31 17:28:05 +08:00
|
|
|
|
</el-button>
|
2024-11-18 19:40:44 +08:00
|
|
|
|
<el-button type="danger" @click="clearGlobalWatermark">
|
|
|
|
|
清除全局水印
|
|
|
|
|
</el-button>
|
2023-08-30 18:26:49 +08:00
|
|
|
|
</el-button-group>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.local {
|
|
|
|
|
height: 30vh;
|
|
|
|
|
border: 2px dashed var(--el-color-primary);
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.el-button-group {
|
2023-08-31 17:28:05 +08:00
|
|
|
|
margin-right: 12px;
|
2023-08-30 18:26:49 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|