Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
pro-layout
Commits
2c038ef5
Commit
2c038ef5
authored
Nov 18, 2021
by
章启成
Committed by
言肆
Nov 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(WaterMark): 使用 toRef 保留 props.content 的响应性
parent
f4b995c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
index.tsx
src/WaterMark/index.tsx
+4
-4
No files found.
src/WaterMark/index.tsx
View file @
2c038ef5
import
type
{
CSSProperties
,
PropType
,
ExtractPropTypes
}
from
'vue'
import
{
defineComponent
,
computed
,
ref
,
watchEffect
}
from
'vue'
import
{
defineComponent
,
computed
,
ref
,
watchEffect
,
toRef
}
from
'vue'
import
{
useRouteContext
}
from
'../RouteContext'
export
type
FontStyle
=
'none'
|
'normal'
|
'italic'
|
'oblique'
...
...
@@ -82,7 +82,6 @@ const WaterMark = defineComponent({
height
=
64
,
rotate
=
-
22
,
// 默认旋转 -22 度
image
,
content
,
offsetLeft
,
offsetTop
,
fontStyle
=
'normal'
,
...
...
@@ -93,6 +92,7 @@ const WaterMark = defineComponent({
prefixCls
:
customizePrefixCls
,
}
=
props
const
content
=
toRef
(
props
,
'content'
)
const
{
getPrefixCls
}
=
useRouteContext
()
const
prefixCls
=
getPrefixCls
(
'pro-layout-watermark'
,
customizePrefixCls
)
const
wrapperCls
=
computed
(()
=>
`
${
prefixCls
}
-wrapper`
)
...
...
@@ -133,11 +133,11 @@ const WaterMark = defineComponent({
ctx
.
drawImage
(
img
,
0
,
0
,
markWidth
,
markHeight
)
base64Url
.
value
=
canvas
.
toDataURL
()
}
}
else
if
(
content
)
{
}
else
if
(
content
.
value
)
{
const
markSize
=
Number
(
fontSize
)
*
ratio
ctx
.
font
=
`
${
fontStyle
}
normal
${
fontWeight
}
${
markSize
}
px/
${
markHeight
}
px
${
fontFamily
}
`
ctx
.
fillStyle
=
fontColor
ctx
.
fillText
(
content
,
0
,
0
)
ctx
.
fillText
(
content
.
value
,
0
,
0
)
base64Url
.
value
=
canvas
.
toDataURL
()
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment