2024-07-28 14:29:05 +08:00
|
|
|
|
<script lang="ts" setup>
|
2024-08-11 20:05:52 +08:00
|
|
|
|
import { Page } from '@vben/common-ui';
|
2024-07-28 14:29:05 +08:00
|
|
|
|
import { useWatermark } from '@vben/hooks';
|
|
|
|
|
|
2024-08-11 20:05:52 +08:00
|
|
|
|
import { Button, Card } from 'ant-design-vue';
|
2024-07-28 14:29:05 +08:00
|
|
|
|
|
2024-11-15 14:06:13 +08:00
|
|
|
|
const { destroyWatermark, updateWatermark, watermark } = useWatermark();
|
|
|
|
|
|
|
|
|
|
async function recreateWaterMark() {
|
|
|
|
|
destroyWatermark();
|
|
|
|
|
await updateWatermark({});
|
|
|
|
|
}
|
2024-07-28 14:29:05 +08:00
|
|
|
|
|
|
|
|
|
async function createWaterMark() {
|
|
|
|
|
await updateWatermark({
|
|
|
|
|
advancedStyle: {
|
|
|
|
|
colorStops: [
|
|
|
|
|
{
|
|
|
|
|
color: 'red',
|
|
|
|
|
offset: 0,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
color: 'blue',
|
|
|
|
|
offset: 1,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
type: 'linear',
|
|
|
|
|
},
|
2024-11-15 14:06:13 +08:00
|
|
|
|
content: `hello my watermark\n${new Date().toLocaleString()}`,
|
2024-07-28 14:29:05 +08:00
|
|
|
|
globalAlpha: 0.5,
|
|
|
|
|
gridLayoutOptions: {
|
|
|
|
|
cols: 2,
|
|
|
|
|
gap: [20, 20],
|
|
|
|
|
matrix: [
|
|
|
|
|
[1, 0],
|
|
|
|
|
[0, 1],
|
|
|
|
|
],
|
|
|
|
|
rows: 2,
|
|
|
|
|
},
|
|
|
|
|
height: 200,
|
|
|
|
|
layout: 'grid',
|
|
|
|
|
rotate: 22,
|
|
|
|
|
width: 200,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-08-11 20:05:52 +08:00
|
|
|
|
<Page title="水印">
|
|
|
|
|
<template #description>
|
2024-07-28 14:29:05 +08:00
|
|
|
|
<div class="text-foreground/80 mt-2">
|
|
|
|
|
水印使用了
|
|
|
|
|
<a
|
|
|
|
|
class="text-primary"
|
|
|
|
|
href="https://zhensherlock.github.io/watermark-js-plus/"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
watermark-js-plus
|
|
|
|
|
</a>
|
|
|
|
|
开源插件,详细配置可见插件配置。
|
|
|
|
|
</div>
|
2024-08-11 20:05:52 +08:00
|
|
|
|
</template>
|
2024-07-28 14:29:05 +08:00
|
|
|
|
|
2024-08-11 20:05:52 +08:00
|
|
|
|
<Card title="使用">
|
2024-11-15 14:06:13 +08:00
|
|
|
|
<Button
|
|
|
|
|
:disabled="!!watermark"
|
|
|
|
|
class="mr-2"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="recreateWaterMark"
|
|
|
|
|
>
|
2024-08-11 20:05:52 +08:00
|
|
|
|
创建水印
|
|
|
|
|
</Button>
|
2024-11-15 14:06:13 +08:00
|
|
|
|
<Button
|
|
|
|
|
:disabled="!watermark"
|
|
|
|
|
class="mr-2"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="createWaterMark"
|
|
|
|
|
>
|
|
|
|
|
更新水印
|
|
|
|
|
</Button>
|
|
|
|
|
<Button :disabled="!watermark" danger @click="destroyWatermark">
|
|
|
|
|
移除水印
|
|
|
|
|
</Button>
|
2024-08-11 20:05:52 +08:00
|
|
|
|
</Card>
|
|
|
|
|
</Page>
|
2024-07-28 14:29:05 +08:00
|
|
|
|
</template>
|