jdcProject_front/src/views/hook-demo/use-watermark.vue
2024-11-18 19:40:44 +08:00

56 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script lang="ts" setup>
import { useWatermark } from "@/hooks/useWatermark"
import { ref } from "vue"
const localRef = ref<HTMLElement | null>(null)
const { setWatermark, clearWatermark } = useWatermark(localRef)
const { setWatermark: setGlobalWatermark, clearWatermark: clearGlobalWatermark } = useWatermark()
</script>
<template>
<div class="app-container">
<h4>
该示例是演示通过调用 hook开启或关闭水印
支持局部全局自定义样式颜色透明度字体大小字体倾斜角度等并自带防御防删防隐藏和自适应功能
</h4>
<div ref="localRef" class="local" />
<el-button-group>
<el-button type="primary" @click="setWatermark('局部水印', { color: '#409eff' })">
创建局部水印
</el-button>
<el-button type="warning" @click="setWatermark('没有防御功能的局部水印', { color: '#e6a23c', defense: false })">
关闭防御功能
</el-button>
<el-button type="danger" @click="clearWatermark">
清除局部水印
</el-button>
</el-button-group>
<el-button-group>
<el-button type="primary" @click="setGlobalWatermark('全局水印', { color: '#409eff' })">
创建全局水印
</el-button>
<el-button
type="warning"
@click="setGlobalWatermark('没有防御功能的全局水印', { color: '#e6a23c', defense: false })"
>
关闭防御功能
</el-button>
<el-button type="danger" @click="clearGlobalWatermark">
清除全局水印
</el-button>
</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 {
margin-right: 12px;
}
</style>