1
- # Go Captcha Vue Package
1
+ <div align =" center " >
2
+ <img width =" 120 " style =" padding-top : 50px ; margin : 0 ;" src =" http://47.104.180.148/go-captcha/gocaptcha_logo.svg?v=1 " />
3
+ <h1 style =" margin : 0 ; padding : 0 " >Go Captcha</h1 >
4
+ <p >Behavior Captcha For Vue</p >
5
+
6
+ </div >
7
+
8
+ <br />
9
+
10
+ > English | [ 中文] ( README_zh.md )
2
11
3
12
<br />
4
13
14
+ <p > ⭐️ If it helps you, please give a star.</p >
15
+
16
+ <img src =" http://47.104.180.148/go-captcha/go-captcha-v2.jpg " alt =" Poster " >
17
+
18
+
5
19
| Vue Version | Go Captcha Version |
6
20
| :-----------------------| :------------------:|
7
21
| vue >= 2.7.14 && < 3.0 | go-captcha-vue@^1 |
8
22
| vue >= 3.0 | go-captcha-vue@^2 |
9
23
10
24
## Install
25
+ Greater than or equal to vue2.7.14 and less than vue3.0
11
26
``` shell
12
- # Greater than or equal to vue2.7.14 and less than vue3.0
13
27
yarn add go-captcha-vue@^1
14
28
# or
15
29
npm install go-captcha-vue@^1
16
30
# or
17
31
pnpm install go-captcha-vue@^1
32
+ ```
18
33
19
- # ###########################################
20
- # Greater than vue3.0
34
+ Greater than vue3.0
35
+ ``` shell
21
36
yarn add go-captcha-vue@^2
22
37
# or
23
38
npm install go-captcha-vue@^2
24
39
# or
25
40
pnpm install go-captcha-vue@^2
26
41
```
27
42
28
- Use Go Captcha
43
+ ## Use Go Captcha
29
44
``` ts
30
45
import " go-captcha-vue/dist/style.css"
31
46
import GoCaptcha from " go-captcha-vue"
32
47
33
48
Vue .use (GoCaptcha )
49
+
50
+ // OR
51
+ import {Click , Rotate , Slide , SlideRegion , Button } from " go-captcha-vue" ;
52
+ Vue .component (' gocaptcha-click' , Click )
53
+ Vue .component (' gocaptcha-rotate' , Rotate )
54
+ Vue .component (' gocaptcha-slide' , Slide )
55
+ Vue .component (' gocaptcha-slide-region' , SlideRegion )
56
+ Vue .component (' gocaptcha-button' , Button )
34
57
```
35
58
36
- ## 🖖 Click Mode Captcha
59
+
60
+ ## Click Mode
37
61
``` vue
38
62
<gocaptcha-click
39
63
:config="{}"
40
64
:data="{}"
41
65
:events="{}"
66
+ ref="domRef"
42
67
/>
68
+
69
+ <script>
70
+ // call methods
71
+ const domRef = ref(null)
72
+ domRef.value.clear()
73
+ domRef.value.refresh()
74
+ </script>
43
75
```
44
76
45
- ### Parameter Reference
77
+
46
78
``` ts
47
79
// config = {}
48
- interface ClickConfig {
80
+ interface Config {
49
81
width? : number ;
50
82
height? : number ;
51
83
thumbWidth? : number ;
@@ -60,43 +92,46 @@ interface ClickConfig {
60
92
}
61
93
62
94
// data = {}
63
- interface ClickData {
95
+ interface Data {
64
96
image: string ;
65
97
thumb: string ;
66
98
}
67
99
68
100
// events = {}
69
- interface ClickEvents {
101
+ interface Events {
70
102
click? : (x : number , y : number ) => void ;
71
103
refresh? : () => void ;
72
104
close? : () => void ;
73
105
confirm? : (dots : Array <ClickDot >, reset : () => void ) => boolean ;
74
106
}
75
107
76
- // component method
77
- interface ClickExpose {
108
+ // export component method
109
+ interface ExportMethods {
78
110
reset: () => void ,
79
111
clear: () => void ,
80
112
refresh: () => void ,
81
113
close: () => void ,
82
114
}
83
115
```
84
116
85
- ## 🖖 Slide Mode Captcha
117
+ ## Slide Mode
86
118
``` vue
87
119
<gocaptcha-slide
88
120
:config="{}"
89
121
:data="{}"
90
122
:events="{}"
123
+ ref="domRef"
91
124
/>
92
125
93
- <gocaptcha-slide-region
94
- :config="{}"
95
- :data="{}"
96
- :events="{}"
97
- />
126
+ <script>
127
+ // call methods
128
+ const domRef = ref(null)
129
+ domRef.value.clear()
130
+ domRef.value.refresh()
131
+ </script>
98
132
```
99
- ### Parameter Reference
133
+
134
+
100
135
``` ts
101
136
// config = {}
102
137
interface SlideConfig {
@@ -130,14 +165,33 @@ interface SlideEvents {
130
165
confirm? : (point : SlidePoint , reset : () => void ) => boolean ;
131
166
}
132
167
133
- // component method
134
- interface SlideExpose {
168
+ // export component method
169
+ interface ExportMethods {
135
170
reset: () => void ,
136
171
clear: () => void ,
137
172
refresh: () => void ,
138
173
close: () => void ,
139
174
}
140
175
```
176
+
177
+ ## Drag-And-Drop Mode
178
+ ``` vue
179
+ <gocaptcha-slide-region
180
+ :config="{}"
181
+ :data="{}"
182
+ :events="{}"
183
+ ref="domRef"
184
+ />
185
+
186
+ <script>
187
+ // call methods
188
+ const domRef = ref(null)
189
+ domRef.value.clear()
190
+ domRef.value.refresh()
191
+ </script>
192
+ ```
193
+
194
+
141
195
``` ts
142
196
// config = {}
143
197
interface SlideRegionConfig {
@@ -171,29 +225,36 @@ interface SlideRegionEvents {
171
225
confirm? : (point : SlideRegionPoint , reset : () => void ) => boolean ;
172
226
}
173
227
174
-
175
- // component method
176
- interface SlideRegionExpose {
228
+ // export component method
229
+ interface ExportMethods {
177
230
reset: () => void ,
178
231
clear: () => void ,
179
232
refresh: () => void ,
180
233
close: () => void ,
181
234
}
182
235
```
183
236
184
- ## 🖖 Rotate Mode Captcha
237
+ ## Rotation Mode
185
238
``` vue
186
239
<gocaptcha-rotate
187
240
:config="{}"
188
241
:data="{}"
189
242
:events="{}"
243
+ ref="domRef"
190
244
/>
245
+
246
+ <script>
247
+ // call methods
248
+ const domRef = ref(null)
249
+ domRef.value.clear()
250
+ domRef.value.refresh()
251
+ </script>
191
252
```
192
253
193
- ### Parameter Reference
254
+
194
255
``` ts
195
256
// config = {}
196
- interface RotateConfig {
257
+ interface Config {
197
258
width? : number ;
198
259
height? : number ;
199
260
thumbWidth? : number ;
@@ -207,22 +268,22 @@ interface RotateConfig {
207
268
}
208
269
209
270
// data = {}
210
- interface RotateData {
271
+ interface Data {
211
272
angle: number ;
212
273
image: string ;
213
274
thumb: string ;
214
275
}
215
276
216
277
// events = {}
217
- interface RotateEvents {
278
+ interface Events {
218
279
rotate? : (angle : number ) => void ;
219
280
refresh? : () => void ;
220
281
close? : () => void ;
221
282
confirm? : (angle : number , reset : () => void ) => boolean ;
222
283
}
223
284
224
- // component method
225
- interface RotateExpose {
285
+ // export component method
286
+ interface ExportMethods {
226
287
reset: () => void ,
227
288
clear: () => void ,
228
289
refresh: () => void ,
@@ -231,12 +292,13 @@ interface RotateExpose {
231
292
```
232
293
233
294
295
+
234
296
## Button
235
297
``` vue
236
298
<gocaptcha-button @clickEvent="() => console.log('hello')"/>
237
299
```
238
300
239
- ### params
301
+
240
302
``` ts
241
303
interface $Attr {
242
304
config? : CaptchaConfig ;
@@ -249,19 +311,10 @@ interface $Event {
249
311
clickEvent? : ()=> void ; // event -> @clickEvent=""
250
312
}
251
313
252
- export interface ButtonConfig {
314
+ export interface CaptchaConfig {
253
315
width? : number ;
254
316
height? : number ;
255
317
verticalPadding? : number ;
256
318
horizontalPadding? : number ;
257
319
}
258
-
259
320
```
260
-
261
- <br />
262
-
263
- ## 👍 Sponsor
264
- <div >
265
- <a href =" http://gocaptcha.wencodes.com/sponsor/ " target =" _blank " >http://gocaptcha.wencodes.com/sponsor/ </a >
266
- </div >
267
- <br />
0 commit comments