fix(captcha): 修复滑块验证码在桌面端无法使用的问题

- 兼容触摸事件和鼠标事件,支持移动端和桌面端
- 添加鼠标移动、鼠标抬起和鼠标离开事件处理
- 修复坐标获取逻辑,统一处理触摸和鼠标坐标
- 移除调试日志,优化控制台输出
- 添加环境判断,生产环境不加载vConsole
This commit is contained in:
shenyifei 2025-12-24 15:14:57 +08:00
parent eaddca0d83
commit ddf2fe3751
2 changed files with 11 additions and 5 deletions

View File

@ -69,8 +69,10 @@ function App({ children }: PropsWithChildren<any>) {
root.render(<TabBar />);
// 初始化vConsole调试工具
const VConsole = require("vconsole");
new VConsole();
if (process.env.NODE_ENV === "development") {
const VConsole = require("vconsole");
new VConsole();
}
}
});

View File

@ -164,12 +164,13 @@ class Captcha extends Component {
}
};
//
// /
move = (e) => {
console.log(e, "滑动滑动");
if (this.state.status && !this.state.isEnd) {
console.log(e.touches[0].pageX);
let x = e.touches[0].pageX; // /X
//
let x = e.touches ? e.touches[0].pageX : e.pageX; // /X
console.log(x);
let bar_area_left = this.state.barAreaLeft; //
let move_block_left = x - bar_area_left; //
console.log(
@ -355,7 +356,10 @@ class Captcha extends Component {
onTouchStart={this.start}
onMouseDown={this.start}
onTouchMove={this.move}
onMouseMove={this.move}
onTouchEnd={this.end}
onMouseUp={this.end}
onMouseLeave={this.end}
style={{
width: barSize.height,
height: barSize.height,