watermark-js-plus 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -1
- package/package.json +22 -10
- package/.editorconfig +0 -16
- package/.eslintignore +0 -7
- package/.eslintrc.cjs +0 -46
- package/.github/workflows/deploy.yml +0 -29
- package/.github/workflows/npm-publish.yml +0 -32
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.prettierrc +0 -10
- package/CHANGELOG.md +0 -18
- package/babel.config.cjs +0 -23
- package/changelog-option.cjs +0 -87
- package/commitlint.config.cjs +0 -26
- package/docs/.vitepress/config.ts +0 -103
- package/docs/.vitepress/locales/zh-CN.ts +0 -51
- package/docs/.vitepress/theme/index.ts +0 -12
- package/docs/config/blind-decode.md +0 -33
- package/docs/config/blind.md +0 -19
- package/docs/config/index.md +0 -178
- package/docs/guide/blind-watermark.md +0 -267
- package/docs/guide/getting-started.md +0 -73
- package/docs/guide/watermark.md +0 -213
- package/docs/guide/what-is-this.md +0 -19
- package/docs/index.md +0 -33
- package/docs/public/favicons/apple-touch-icon.png +0 -0
- package/docs/public/favicons/favicon-64x64.png +0 -0
- package/docs/public/hero-image.png +0 -0
- package/docs/public/logo.png +0 -0
- package/docs/zh/config/blind-decode.md +0 -33
- package/docs/zh/config/blind.md +0 -19
- package/docs/zh/config/index.md +0 -178
- package/docs/zh/guide/blink-watermark.md +0 -288
- package/docs/zh/guide/getting-started.md +0 -48
- package/docs/zh/guide/watermark.md +0 -213
- package/docs/zh/guide/what-is-this.md +0 -19
- package/docs/zh/index.md +0 -33
- package/rollup.config.mjs +0 -40
- package/src/blind.ts +0 -43
- package/src/index.ts +0 -7
- package/src/types/index.ts +0 -69
- package/src/utils/index.ts +0 -63
- package/src/watermark.ts +0 -300
- package/tools/terser.js +0 -19
- package/tsconfig.json +0 -15
package/docs/config/blind.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: doc
|
|
3
|
-
---
|
|
4
|
-
# Blind Watermark Config
|
|
5
|
-
|
|
6
|
-
## globalAlpha
|
|
7
|
-
|
|
8
|
-
- **Type:** `number`
|
|
9
|
-
- **Default:** `0.005`
|
|
10
|
-
|
|
11
|
-
Transparency of watermark.
|
|
12
|
-
|
|
13
|
-
## mode
|
|
14
|
-
|
|
15
|
-
- **Type:** `string`
|
|
16
|
-
- **Default:** `'blind'`
|
|
17
|
-
- **available values**: `'default' | 'blind'`
|
|
18
|
-
|
|
19
|
-
Watermark mode
|
package/docs/config/index.md
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: doc
|
|
3
|
-
---
|
|
4
|
-
# Basic Config
|
|
5
|
-
|
|
6
|
-
## width
|
|
7
|
-
|
|
8
|
-
- **Type:** `number`
|
|
9
|
-
- **Default:** `300`
|
|
10
|
-
|
|
11
|
-
A unit of width for a single watermark.
|
|
12
|
-
|
|
13
|
-
## height
|
|
14
|
-
|
|
15
|
-
- **Type:** `number`
|
|
16
|
-
- **Default:** `300`
|
|
17
|
-
|
|
18
|
-
A unit of height for a single watermark.
|
|
19
|
-
|
|
20
|
-
## rotate
|
|
21
|
-
|
|
22
|
-
- **Type:** `number`
|
|
23
|
-
- **Default:** `45`
|
|
24
|
-
|
|
25
|
-
Watermark rotation Angle.
|
|
26
|
-
|
|
27
|
-
Rotate with the center of the text as the origin.
|
|
28
|
-
|
|
29
|
-
## contentType
|
|
30
|
-
|
|
31
|
-
- **Type:** `string`
|
|
32
|
-
- **Default:** `'text'`
|
|
33
|
-
- **available values**: `'text' | 'image' | 'multi-line-text' | 'rich-text'`
|
|
34
|
-
|
|
35
|
-
Type of watermark content.
|
|
36
|
-
|
|
37
|
-
## content
|
|
38
|
-
|
|
39
|
-
- **Type:** `string`
|
|
40
|
-
- **Default:** `'hello watermark-js-plus'`
|
|
41
|
-
|
|
42
|
-
Watermark content.
|
|
43
|
-
|
|
44
|
-
## imageWidth
|
|
45
|
-
|
|
46
|
-
- **Type:** `number`
|
|
47
|
-
- **Default:** `0`
|
|
48
|
-
|
|
49
|
-
Watermark image width.
|
|
50
|
-
|
|
51
|
-
## imageHeight
|
|
52
|
-
|
|
53
|
-
- **Type:** `number`
|
|
54
|
-
- **Default:** `0`
|
|
55
|
-
|
|
56
|
-
Watermark image height.
|
|
57
|
-
|
|
58
|
-
## lineHeight
|
|
59
|
-
|
|
60
|
-
- **Type:** `number`
|
|
61
|
-
- **Default:** `30`
|
|
62
|
-
|
|
63
|
-
Watermark content line high.
|
|
64
|
-
|
|
65
|
-
## zIndex
|
|
66
|
-
|
|
67
|
-
- **Type:** `number`
|
|
68
|
-
- **Default:** `10000`
|
|
69
|
-
|
|
70
|
-
z-index
|
|
71
|
-
|
|
72
|
-
## backgroundPosition
|
|
73
|
-
|
|
74
|
-
- **Type:** `string`
|
|
75
|
-
- **Default:** `'0 0, 0 0'`
|
|
76
|
-
|
|
77
|
-
background-position
|
|
78
|
-
|
|
79
|
-
## fontSize
|
|
80
|
-
|
|
81
|
-
- **Type:** `number`
|
|
82
|
-
- **Default:** `20`
|
|
83
|
-
|
|
84
|
-
The font size of the watermark content.
|
|
85
|
-
|
|
86
|
-
## fontFamily
|
|
87
|
-
|
|
88
|
-
- **Type:** `string`
|
|
89
|
-
- **Default:** `'sans-serif'`
|
|
90
|
-
|
|
91
|
-
The font family of the watermark content.
|
|
92
|
-
|
|
93
|
-
## textAlign
|
|
94
|
-
|
|
95
|
-
- **Type:** `string`
|
|
96
|
-
- **Default:** `'center'`
|
|
97
|
-
- **available values**: `'center' | 'left' | 'right'`
|
|
98
|
-
|
|
99
|
-
Watermark content horizontal alignment.
|
|
100
|
-
|
|
101
|
-
## textBaseline
|
|
102
|
-
|
|
103
|
-
- **Type:** `string`
|
|
104
|
-
- **Default:** `'middle'`
|
|
105
|
-
- **available values**: `'top' | 'bottom' | 'middle'`
|
|
106
|
-
|
|
107
|
-
Watermark content baseline.
|
|
108
|
-
|
|
109
|
-
## fontColor
|
|
110
|
-
|
|
111
|
-
- **Type:** `string`
|
|
112
|
-
- **Default:** `'#000'`
|
|
113
|
-
|
|
114
|
-
Watermark content font color.
|
|
115
|
-
|
|
116
|
-
## globalAlpha
|
|
117
|
-
|
|
118
|
-
- **Type:** `number`
|
|
119
|
-
- **Default:** `0.5`
|
|
120
|
-
|
|
121
|
-
Transparency of watermark.
|
|
122
|
-
|
|
123
|
-
## fontWeight
|
|
124
|
-
|
|
125
|
-
- **Type:** `string`
|
|
126
|
-
- **Default:** `'normal'`
|
|
127
|
-
|
|
128
|
-
Watermark content font weight.
|
|
129
|
-
|
|
130
|
-
## mode
|
|
131
|
-
|
|
132
|
-
- **Type:** `string`
|
|
133
|
-
- **Default:** `'default'`
|
|
134
|
-
- **available values**: `'default' | 'blind'`
|
|
135
|
-
|
|
136
|
-
Watermark mode
|
|
137
|
-
|
|
138
|
-
## mutationObserve
|
|
139
|
-
|
|
140
|
-
- **Type:** `boolean`
|
|
141
|
-
- **Default:** `true`
|
|
142
|
-
|
|
143
|
-
Enable listening for watermark dom changes.
|
|
144
|
-
|
|
145
|
-
## unique
|
|
146
|
-
|
|
147
|
-
- **Type:** `boolean`
|
|
148
|
-
- **Default:** `true`
|
|
149
|
-
|
|
150
|
-
The watermark cannot be added repeatedly.
|
|
151
|
-
|
|
152
|
-
## parent
|
|
153
|
-
|
|
154
|
-
- **Type:** `Element | string`
|
|
155
|
-
- **Default:** `'body'`
|
|
156
|
-
|
|
157
|
-
Watermarking container.
|
|
158
|
-
|
|
159
|
-
## onSuccess
|
|
160
|
-
|
|
161
|
-
- **Type:** `Function`
|
|
162
|
-
- **Default:** `() => {}`
|
|
163
|
-
|
|
164
|
-
Watermark added successful callback event.
|
|
165
|
-
|
|
166
|
-
## onBeforeDestroy
|
|
167
|
-
|
|
168
|
-
- **Type:** `Function`
|
|
169
|
-
- **Default:** `() => {}`
|
|
170
|
-
|
|
171
|
-
Watermark delete before callback event.
|
|
172
|
-
|
|
173
|
-
## onDestroyed
|
|
174
|
-
|
|
175
|
-
- **Type:** `Function`
|
|
176
|
-
- **Default:** `() => {}`
|
|
177
|
-
|
|
178
|
-
Watermark deleted after callback event.
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: doc
|
|
3
|
-
---
|
|
4
|
-
# Blind watermark
|
|
5
|
-
|
|
6
|
-
<script setup lang="ts">
|
|
7
|
-
import VPButton from 'vitepress/dist/client/theme-default/components/VPButton.vue';
|
|
8
|
-
import { ref, getCurrentInstance } from 'vue';
|
|
9
|
-
import { Plus } from '@element-plus/icons-vue';
|
|
10
|
-
import wm from '../../src';
|
|
11
|
-
import { useData } from 'vitepress';
|
|
12
|
-
|
|
13
|
-
const { isDark } = useData();
|
|
14
|
-
const app = getCurrentInstance();
|
|
15
|
-
const decodeBlindImage = ref('');
|
|
16
|
-
|
|
17
|
-
// text blind watermark
|
|
18
|
-
const textBlindWatermark = new wm.BlindWatermark({
|
|
19
|
-
content: 'hello my watermark',
|
|
20
|
-
width: 200,
|
|
21
|
-
height: 200,
|
|
22
|
-
onSuccess: () => {
|
|
23
|
-
app.appContext.config.globalProperties.$message({
|
|
24
|
-
message: 'The text blind watermark added successfully!',
|
|
25
|
-
type: 'success'
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
const handleAddTextBlindWatermark = () => {
|
|
30
|
-
if (isDark.value) {
|
|
31
|
-
textBlindWatermark.options.fontColor = '#fff'
|
|
32
|
-
}
|
|
33
|
-
textBlindWatermark.create();
|
|
34
|
-
};
|
|
35
|
-
const handleRemoveTextBlindWatermark = () => {
|
|
36
|
-
textBlindWatermark.destroy();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// multiline blind text watermark
|
|
40
|
-
const multiLineTextBlindWatermark = new wm.BlindWatermark({
|
|
41
|
-
contentType: 'multi-line-text',
|
|
42
|
-
content: 'hello my multiline blind watermark',
|
|
43
|
-
fontSize: 30,
|
|
44
|
-
width: 200,
|
|
45
|
-
height: 200,
|
|
46
|
-
onSuccess: () => {
|
|
47
|
-
app.appContext.config.globalProperties.$message({
|
|
48
|
-
message: 'The multiline text blind watermark added successfully!',
|
|
49
|
-
type: 'success'
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
const handleAddMultiLineTextBlindWatermark = () => {
|
|
54
|
-
if (isDark.value) {
|
|
55
|
-
multiLineTextBlindWatermark.options.fontColor = '#fff'
|
|
56
|
-
}
|
|
57
|
-
multiLineTextBlindWatermark.create();
|
|
58
|
-
};
|
|
59
|
-
const handleRemoveMultiLineTextBlindWatermark = () => {
|
|
60
|
-
multiLineTextBlindWatermark.destroy();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// image blind watermark
|
|
64
|
-
const imageBlindWatermark = new wm.BlindWatermark({
|
|
65
|
-
contentType: 'image',
|
|
66
|
-
image: 'https://cdn.jsdelivr.net/gh/zhensherlock/oss@main/uPic/github-mkWBiK.png',
|
|
67
|
-
imageWidth: 200,
|
|
68
|
-
// imageHeight: 20,
|
|
69
|
-
width: 300,
|
|
70
|
-
height: 300,
|
|
71
|
-
onSuccess: () => {
|
|
72
|
-
app.appContext.config.globalProperties.$message({
|
|
73
|
-
message: '!The image blind watermark added successfully',
|
|
74
|
-
type: 'success'
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const handleAddImageBlindWatermark = () => {
|
|
79
|
-
imageBlindWatermark.create();
|
|
80
|
-
};
|
|
81
|
-
const handleRemoveImageBlindWatermark = () => {
|
|
82
|
-
imageBlindWatermark.destroy();
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// rich text blind watermark
|
|
86
|
-
const richTextBlindWatermark = new wm.BlindWatermark({
|
|
87
|
-
contentType: 'rich-text',
|
|
88
|
-
content: '<div style="background: #ccc;">The watermark is so <span style="color: #f00">good</span>.</div>',
|
|
89
|
-
width: 300,
|
|
90
|
-
height: 300,
|
|
91
|
-
onSuccess: () => {
|
|
92
|
-
app.appContext.config.globalProperties.$message({
|
|
93
|
-
message: 'The rich text blind watermark added successfully!',
|
|
94
|
-
type: 'success'
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
const handleAddRichTextBlindWatermark = () => {
|
|
99
|
-
richTextBlindWatermark.create();
|
|
100
|
-
};
|
|
101
|
-
const handleRemoveRichTextBlindWatermark = () => {
|
|
102
|
-
richTextBlindWatermark.destroy();
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// decode blind watermark
|
|
106
|
-
const handleSuccess = (uploadFile) => {
|
|
107
|
-
wm.BlindWatermark.decode({
|
|
108
|
-
...(isDark.value ? {
|
|
109
|
-
compositeOperation: 'overlay',
|
|
110
|
-
fillColor: '#fff',
|
|
111
|
-
} : {}),
|
|
112
|
-
url: uploadFile.url,
|
|
113
|
-
onSuccess: (imageBase64) => {
|
|
114
|
-
decodeBlindImage.value = imageBase64
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
</script>
|
|
119
|
-
|
|
120
|
-
## Text Blind Watermark
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
import wm from 'watermark-js-plus' // import watermark plugin
|
|
124
|
-
|
|
125
|
-
const watermark = new wm.BlindWatermark({
|
|
126
|
-
content: 'hello my watermark',
|
|
127
|
-
width: 200,
|
|
128
|
-
height: 200,
|
|
129
|
-
onSuccess: () => {
|
|
130
|
-
app.appContext.config.globalProperties.$message({
|
|
131
|
-
message: 'The text blind watermark added successfully!',
|
|
132
|
-
type: 'success'
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
watermark.create() // add watermark
|
|
138
|
-
|
|
139
|
-
watermark.destroy() // remove watermark
|
|
140
|
-
```
|
|
141
|
-
<el-space>
|
|
142
|
-
<VPButton text="Add Text Blind Watermark" @click="handleAddTextBlindWatermark"></VPButton>
|
|
143
|
-
<VPButton text="Remove Text Blind Watermark" @click="handleRemoveTextBlindWatermark"></VPButton>
|
|
144
|
-
</el-space>
|
|
145
|
-
|
|
146
|
-
## Multiline Text Blind Watermark
|
|
147
|
-
|
|
148
|
-
```js
|
|
149
|
-
import wm from 'watermark-js-plus' // import watermark plugin
|
|
150
|
-
|
|
151
|
-
const watermark = new wm.BlindWatermark({
|
|
152
|
-
contentType: 'multi-line-text',
|
|
153
|
-
content: 'hello my multiline blind watermark',
|
|
154
|
-
fontSize: 30,
|
|
155
|
-
width: 200,
|
|
156
|
-
height: 200,
|
|
157
|
-
onSuccess: () => {
|
|
158
|
-
app.appContext.config.globalProperties.$message({
|
|
159
|
-
message: 'The multiline text blind watermark added successfully!',
|
|
160
|
-
type: 'success'
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
watermark.create() // add watermark
|
|
166
|
-
|
|
167
|
-
watermark.destroy() // remove watermark
|
|
168
|
-
```
|
|
169
|
-
<el-space>
|
|
170
|
-
<VPButton text="Add Multiline Text Blind Watermark" @click="handleAddMultiLineTextBlindWatermark"></VPButton>
|
|
171
|
-
<VPButton text="Remove Multiline Text Blind Watermark" @click="handleRemoveMultiLineTextBlindWatermark"></VPButton>
|
|
172
|
-
</el-space>
|
|
173
|
-
|
|
174
|
-
## Image Blind Watermark
|
|
175
|
-
|
|
176
|
-
```js
|
|
177
|
-
import wm from 'watermark-js-plus' // import watermark plugin
|
|
178
|
-
|
|
179
|
-
const watermark = new wm.BlindWatermark({
|
|
180
|
-
contentType: 'image',
|
|
181
|
-
content: 'http://upic-service.test.upcdn.net/uPic/github-JxMIKf.png',
|
|
182
|
-
width: 300,
|
|
183
|
-
height: 300,
|
|
184
|
-
imageWidth: 100, // image width
|
|
185
|
-
// imageHeight: 20, // image height
|
|
186
|
-
onSuccess: () => {
|
|
187
|
-
app.appContext.config.globalProperties.$message({
|
|
188
|
-
message: 'The image blind watermark added successfully!',
|
|
189
|
-
type: 'success'
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
watermark.create() // add watermark
|
|
195
|
-
|
|
196
|
-
watermark.destroy() // remove watermark
|
|
197
|
-
```
|
|
198
|
-
<el-space>
|
|
199
|
-
<VPButton text="Add Image Blind Watermark" @click="handleAddImageBlindWatermark"></VPButton>
|
|
200
|
-
<VPButton text="Remove Image Blind Watermark" @click="handleRemoveImageBlindWatermark"></VPButton>
|
|
201
|
-
</el-space>
|
|
202
|
-
|
|
203
|
-
## Rich Text Blind Watermark
|
|
204
|
-
|
|
205
|
-
```js
|
|
206
|
-
import wm from 'watermark-js-plus' // import watermark plugin
|
|
207
|
-
|
|
208
|
-
const watermark = new wm.BlindWatermark({
|
|
209
|
-
contentType: 'rich-text',
|
|
210
|
-
content: '<div style="background: #ccc;">The watermark is so <span style="color: #f00">good</span>.</div>',
|
|
211
|
-
width: 300,
|
|
212
|
-
height: 300,
|
|
213
|
-
onSuccess: () => {
|
|
214
|
-
app.appContext.config.globalProperties.$message({
|
|
215
|
-
message: 'The rich text blind watermark added successfully!',
|
|
216
|
-
type: 'success'
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
watermark.create() // add watermark
|
|
222
|
-
|
|
223
|
-
watermark.destroy() // remove watermark
|
|
224
|
-
```
|
|
225
|
-
<el-space>
|
|
226
|
-
<VPButton text="Add RichText Blind Watermark" @click="handleAddRichTextBlindWatermark"></VPButton>
|
|
227
|
-
<VPButton text="Remove Rich Text Blind Watermark" @click="handleRemoveRichTextBlindWatermark"></VPButton>
|
|
228
|
-
</el-space>
|
|
229
|
-
|
|
230
|
-
## Decode Blind Watermark
|
|
231
|
-
|
|
232
|
-
```js
|
|
233
|
-
import wm from 'watermark-js-plus' // import watermark plugin
|
|
234
|
-
|
|
235
|
-
wm.BlindWatermark.decode({
|
|
236
|
-
url: uploadFile.url, // image url
|
|
237
|
-
onSuccess: (imageBase64) => { // success callback
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
<div>
|
|
243
|
-
<el-upload
|
|
244
|
-
list-type="picture-card"
|
|
245
|
-
accept="image/*"
|
|
246
|
-
:auto-upload="false"
|
|
247
|
-
:show-file-list="false"
|
|
248
|
-
:on-change="handleSuccess"
|
|
249
|
-
>
|
|
250
|
-
<el-icon><Plus /></el-icon>
|
|
251
|
-
</el-upload>
|
|
252
|
-
<el-image
|
|
253
|
-
v-if="decodeBlindImage"
|
|
254
|
-
style="width: 400px; height: 400px;margin-top: 20px;"
|
|
255
|
-
:src="decodeBlindImage"
|
|
256
|
-
:preview-src-list="[decodeBlindImage]"
|
|
257
|
-
fit="cover"
|
|
258
|
-
/>
|
|
259
|
-
</div>
|
|
260
|
-
|
|
261
|
-
[//]: # (<div style="position: relative;">)
|
|
262
|
-
|
|
263
|
-
[//]: # ( <div style="position: absolute;top:0;bottom: 0;left: 0;right: 0;mix-blend-mode: color-burn;background: #000;"></div>)
|
|
264
|
-
|
|
265
|
-
[//]: # ( <img width="200" src="http://upic-service.test.upcdn.net/uPic/iShot_2022-11-28_10.35.29-RP6dBG.png" alt="">)
|
|
266
|
-
|
|
267
|
-
[//]: # (</div>)
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
layout: doc
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Getting Started
|
|
6
|
-
|
|
7
|
-
## Installing
|
|
8
|
-
|
|
9
|
-
Using npm:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
$ npm install watermark-js-plus
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
[//]: # (Using bower:)
|
|
16
|
-
|
|
17
|
-
[//]: # ()
|
|
18
|
-
[//]: # (```bash)
|
|
19
|
-
|
|
20
|
-
[//]: # ($ bower install watermark-js-plus)
|
|
21
|
-
|
|
22
|
-
[//]: # (```)
|
|
23
|
-
|
|
24
|
-
Using yarn:
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
$ yarn add watermark-js-plus
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
[//]: # ()
|
|
31
|
-
[//]: # (Using jsDelivr CDN:)
|
|
32
|
-
|
|
33
|
-
[//]: # ()
|
|
34
|
-
[//]: # (```html)
|
|
35
|
-
|
|
36
|
-
[//]: # (<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>)
|
|
37
|
-
|
|
38
|
-
[//]: # (```)
|
|
39
|
-
|
|
40
|
-
[//]: # ()
|
|
41
|
-
[//]: # (Using unpkg CDN:)
|
|
42
|
-
|
|
43
|
-
[//]: # ()
|
|
44
|
-
[//]: # (```html)
|
|
45
|
-
|
|
46
|
-
[//]: # (<script src="https://unpkg.com/axios/dist/axios.min.js"></script>)
|
|
47
|
-
|
|
48
|
-
[//]: # (```)
|
|
49
|
-
|
|
50
|
-
## Usage
|
|
51
|
-
|
|
52
|
-
1. Import watermark plugin
|
|
53
|
-
```ts
|
|
54
|
-
import wm from 'watermark-js-plus' // 引入水印插件
|
|
55
|
-
```
|
|
56
|
-
2. instantiation
|
|
57
|
-
```ts
|
|
58
|
-
const watermark = new wm.Watermark({
|
|
59
|
-
content: 'hello my watermark',
|
|
60
|
-
width: 200,
|
|
61
|
-
height: 200,
|
|
62
|
-
onSuccess: () => {
|
|
63
|
-
app.appContext.config.globalProperties.$message({
|
|
64
|
-
message: 'text watermark added successfully!',
|
|
65
|
-
type: 'success'
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
```
|
|
70
|
-
3. Add a watermark to the web page
|
|
71
|
-
```ts
|
|
72
|
-
watermark.create()
|
|
73
|
-
```
|