Skip to content

Commit 6c63b2d

Browse files
committed
fix rotate captcha
1 parent 0c86a7c commit 6c63b2d

File tree

12 files changed

+42
-12
lines changed

12 files changed

+42
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div align="center">
22
<img width="120" style="padding-top: 50px; margin: 0;" src="http://47.104.180.148/go-captcha/gocaptcha_logo.svg?v=1"/>
33
<h1 style="margin: 0; padding: 0">Go Captcha</h1>
4-
<p>Behavior Captcha For React</p>
4+
<p>The Behavior Captcha For The React</p>
55

66
</div>
77

@@ -249,6 +249,7 @@ interface Data {
249249
angle: number;
250250
image: string;
251251
thumb: string;
252+
thumbSize: number;
252253
}
253254

254255
// events = {}

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ interface Data {
251251
angle: number;
252252
image: string;
253253
thumb: string;
254+
thumbSize: number;
254255
}
255256

256257
// events = {}

example/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import * as ReactDOM from 'react-dom';
55
import GoCaptcha from '../.';
66
// import GoCaptcha from '../src';
77
import {useEffect, useRef, useState} from "react";
8+
// @ts-ignore
89
import {ClickRef} from "../dist/components/Click";
10+
// @ts-ignore
911
import {SlideRef} from "../dist/components/Slide";
12+
// @ts-ignore
1013
import {SlideRegionRef} from "../src/components/SlideRegion";
14+
// @ts-ignore
1115
import {RotateRef} from "../src/components/Rotate";
1216

1317
const App = () => {
@@ -114,9 +118,9 @@ const App = () => {
114118
///////////////////////////////////
115119

116120
const [rotateData, setRotateData] = useState({
117-
angle: 20,
118121
image: rotateImage,
119122
thumb: rotateThumb,
123+
thumbSize: 195
120124
})
121125

122126
const [rotateConfig, setRotateConfig] = useState({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "go-captcha-react",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"license": "MIT",
55
"private": false,
66
"email": "[email protected]",

src/components/Click/Index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const Index:FC<Props> = forwardRef<ClickRef, Props>((props: Props, ref) => {
5555
const vPadding = localConfig.verticalPadding || 0
5656
const width = (localConfig.width || 0) + ( hPadding * 2) + (localConfig.showTheme ? 2 : 0)
5757
const hasDisplayWrapperState = (localConfig.width || 0) > 0 || (localConfig.height || 0) > 0
58-
const hasDisplayImageState = localData.image != '' || localData.thumb != ''
58+
const hasDisplayImageState = (localData.image && localData.image.length > 0) && (localData.thumb && localData.thumb.length > 0)
5959

6060
useImperativeHandle(ref, () => ({
6161
reset: handler.resetData,

src/components/Click/index.module.less

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
z-index: 2;
2121
width: 22px;
2222
height: 22px;
23-
color: #cedffe;
24-
background: #3e7cff;
23+
color: var(--go-captcha-theme-dot-color);
24+
background: var(--go-captcha-theme-dot-bg-color);
2525
border: 3px solid #f7f9fb;
26+
border-color: var(--go-captcha-theme-dot-border-color);
2627
display:-webkit-box;
2728
display:-webkit-flex;
2829
display:-ms-flexbox;

src/components/Rotate/Index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const Index:FC<Props> = forwardRef<RotateRef, Props>((props: Props, ref) => {
6969
const width = (localConfig.width || 0) + ( hPadding * 2) + (localConfig.showTheme ? 2 : 0)
7070
const size = (localConfig.size || 0) > 0 ? localConfig.size : defaultConfig().size
7171
const hasDisplayWrapperState = (localConfig.width || 0) > 0 || (localConfig.height || 0) > 0
72-
const hasDisplayImageState = localData.image != '' && localData.thumb != ''
72+
const hasDisplayImageState = (localData.image && localData.image.length > 0) && (localData.thumb && localData.thumb.length > 0)
7373

7474
useImperativeHandle(ref, () => ({
7575
reset: handler.resetData,
@@ -145,7 +145,13 @@ const Index:FC<Props> = forwardRef<RotateRef, Props>((props: Props, ref) => {
145145
<div className={cstyles.thumb}>
146146
<div
147147
className={cstyles.thumbBlock}
148-
style={{ transform: `rotate(${handler.getState().thumbAngle}deg)`}}
148+
style={{
149+
transform: `rotate(${handler.getState().thumbAngle}deg)`,
150+
...(localData.thumbSize > 0 ? {
151+
width: localData.thumbSize + "px",
152+
height: localData.thumbSize + "px"
153+
} : {})
154+
}}
149155
>
150156
<img
151157
className={localData.thumb == '' ? styles.hide : ''}

src/components/Rotate/index.module.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
left: 0;
6363
right: 0;
6464
bottom: 0;
65+
display: -webkit-box;
66+
display: -moz-box;
67+
display: -ms-flexbox;
68+
display: -webkit-flex;
69+
display: flex;
70+
justify-content: center;
71+
align-items: center;
72+
6573
:global{
6674
img{
6775
max-width: 100%;

src/components/Rotate/meta/data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ export interface RotateData {
88
angle: number;
99
image: string;
1010
thumb: string;
11+
thumbSize: number;
1112
}
1213

1314
export const defaultRotateData = () :RotateData => ({
1415
angle: 0,
1516
image: '',
16-
thumb: ''
17+
thumb: '',
18+
thumbSize: 0
1719
})

src/components/Slide/Index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const Index:FC<Props> = forwardRef<SlideRef, Props>((props: Props, ref) => {
7272
const vPadding = localConfig.verticalPadding || 0
7373
const width = (localConfig.width || 0) + ( hPadding * 2) + (localConfig.showTheme ? 2 : 0)
7474
const hasDisplayWrapperState = (localConfig.width || 0) > 0 || (localConfig.height || 0) > 0
75-
const hasDisplayImageState = localData.image != '' && localData.thumb != ''
75+
const hasDisplayImageState = (localData.image && localData.image.length > 0) && (localData.thumb && localData.thumb.length > 0)
7676

7777
useImperativeHandle(ref, () => ({
7878
reset: handler.resetData,

0 commit comments

Comments
 (0)