index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <PageWrapper title="水印示例">
  3. <CollapseContainer class="w-full h-32 bg-white rounded-md" title="Global WaterMark">
  4. <a-button type="primary" class="mr-2" @click="setWatermark('WaterMark Info1')">
  5. Create Watermark1
  6. </a-button>
  7. <a-button type="primary" class="mr-2" @click="setWatermark2('WaterMark Info2')">
  8. Create Watermark2
  9. </a-button>
  10. <a-button type="primary" class="mr-2" @click="setWatermark3('Custome Style WaterMark')">
  11. Create custom style Watermark
  12. </a-button>
  13. <a-button color="error" class="mr-2" @click="clear"> Clear Watermark1 </a-button>
  14. <a-button color="error" class="mr-2" @click="clearAll"> ClearAll </a-button>
  15. <a-button color="warning" class="mr-2" @click="setWatermark('WaterMark Info New')">
  16. Update Watermark1
  17. </a-button>
  18. </CollapseContainer>
  19. </PageWrapper>
  20. </template>
  21. <script lang="ts" setup>
  22. import { onUnmounted, ref } from 'vue';
  23. import { CollapseContainer } from '@/components/Container';
  24. import { useWatermark } from '@/hooks/web/useWatermark';
  25. import { PageWrapper } from '@/components/Page';
  26. const app = ref(document.body);
  27. const { setWatermark, clear, clearAll } = useWatermark();
  28. const { setWatermark: setWatermark2 } = useWatermark();
  29. const { setWatermark: setWatermark3 } = useWatermark(app, {
  30. fontColor: 'red',
  31. fontSize:12,
  32. rotate:30
  33. });
  34. onUnmounted(() => {
  35. clearAll();
  36. });
  37. </script>