From 4fefaff0857365b6d87d8ddd428848289af4d3e9 Mon Sep 17 00:00:00 2001 From: Tyh2001 <1469442737@qq.com> Date: Thu, 28 Sep 2023 15:59:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_hooks/use-watermark/index.ts | 4 +- .../fighting-design/watermark/src/props.ts | 18 ++- .../watermark/src/watermark.vue | 109 ++++++++++++++---- packages/fighting-theme/src/watermark.scss | 6 +- start/src/App.vue | 17 +-- 5 files changed, 98 insertions(+), 56 deletions(-) diff --git a/packages/fighting-design/_hooks/use-watermark/index.ts b/packages/fighting-design/_hooks/use-watermark/index.ts index 85c5ebb410..b877f09553 100644 --- a/packages/fighting-design/_hooks/use-watermark/index.ts +++ b/packages/fighting-design/_hooks/use-watermark/index.ts @@ -45,14 +45,14 @@ export const useWatermark = (prop: WatermarkProps): UseWatermarkReturn => { const { width } = ctx.measureText(prop.content) - const cavasSize = Math.max(100, width) * prop.gap * devicePixeRatio + const cavasSize = Math.max(100, width) * devicePixeRatio + prop.gap canvas.width = cavasSize canvas.height = cavasSize ctx.translate(canvas.width / 2, canvas.height / 2) ctx.rotate((Math.PI / 190) * -45) - ctx.fillStyle = '#111' + ctx.fillStyle = prop.fontColor ctx.font = font ctx.textAlign = 'center' ctx.textBaseline = 'middle' diff --git a/packages/fighting-design/watermark/src/props.ts b/packages/fighting-design/watermark/src/props.ts index 5df60ce849..d2a324b360 100644 --- a/packages/fighting-design/watermark/src/props.ts +++ b/packages/fighting-design/watermark/src/props.ts @@ -1,24 +1,20 @@ import { setBooleanProp, setStringProp, - setNumberProp + setNumberProp, + setStringNumberProp } from '../../_utils' import type { ExtractPropTypes } from 'vue' export const Props = { /** 水印内容 */ content: setStringProp(), - /** 水印的宽度 */ - width: setNumberProp(280), - /** 水印的高度 */ - height: setNumberProp(200), - gap: setNumberProp(20), /** 文字大小 */ - fontSize: setNumberProp(24), + fontSize: setNumberProp(40), + /** 间距 */ + gap: setNumberProp(40), /** 文字颜色 */ - fontColor: setStringProp('#333'), - /** 自定义图片水印 */ - image: setStringProp(), + fontColor: setStringProp('#111'), /** 是否为块级元素 */ block: setBooleanProp(), /** @@ -26,7 +22,7 @@ export const Props = { * * @see z-index https://developer.mozilla.org/zh-CN/docs/Web/CSS/z-index */ - zIndex: setNumberProp(100) + zIndex: setStringNumberProp(9999) } as const /** watermark 组件 props 类型 */ diff --git a/packages/fighting-design/watermark/src/watermark.vue b/packages/fighting-design/watermark/src/watermark.vue index 3307ee8857..e8dfe51fd4 100644 --- a/packages/fighting-design/watermark/src/watermark.vue +++ b/packages/fighting-design/watermark/src/watermark.vue @@ -1,44 +1,107 @@ diff --git a/packages/fighting-theme/src/watermark.scss b/packages/fighting-theme/src/watermark.scss index 0a0b9a69a6..55acfba34e 100644 --- a/packages/fighting-theme/src/watermark.scss +++ b/packages/fighting-theme/src/watermark.scss @@ -1,7 +1,3 @@ .f-watermark { - display: inline-block; - - &.f-watermark__block { - display: block; - } + position: relative; } diff --git a/start/src/App.vue b/start/src/App.vue index d2261e5d20..1c772edac4 100644 --- a/start/src/App.vue +++ b/start/src/App.vue @@ -1,16 +1,3 @@ - + - +