聊天平臺原始碼,登入時拼圖驗證
聊天平臺原始碼,登入時拼圖驗證實現的相關程式碼
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> body { display: flex; justify-content: center; align-items: center; min-height: 100vh; } #captcha { display: block; width: var(--width); height: var(--height); border-radius: 4px; background-image: url(https://dss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=2676921178,3792372773&fm=55&app=54&f=JPEG?w=1680&h=630); background-size: cover; background-position: center; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); position: relative; box-sizing: border-box; } #captcha::before, #captcha::after { position: absolute; content: ""; display: block; width: inherit; height: inherit; background-image: inherit; background-size: inherit; background-position: inherit; clip-path: var(--clip-path); --webkit-clip-path: var(--clip-path); } #captcha::after { transform: translateX(calc(var(--clip-offsetX) * -1 + var(--moved))); transition: .25s all ease-in-out; } #captcha::before { background-color: rgba(0, 0, 0, .5); background-blend-mode: multiply; } #captcha:active #handle span, #captcha:active::after { transition: none; } #captcha #handle { width: calc(var(--width) - (3px * 2)); height: 30px; border-radius: 18px; background-color: #eee; position: absolute; bottom: -50px; left: 0; box-shadow: inset 0 0 12px rgba(0, 0, 0, .2); border: 3px solid #ccc; } #handle span { display: block; width: var(--puzzle-width); height: inherit; border-radius: inherit; background-color: #fff; box-shadow: inset 0 0 6px rgba(0, 0, 0, .25), 0 2px 4px rgba(0, 0, 0, .3); position: absolute; cursor: move; transform: translateX(var(--moved)); transition: .25s all ease-in-out; } #captcha.passed #handle, #captcha.passed::after, #captcha.passed::before { opacity: 0; } </style> </head> <body> <div id="captcha"> <div id="handle"> <span></span> </div> </div> <script> let width = 400; // 寬度 let height = 260; // 高度 let puzzleWidth = 80; // 切圖寬 let puzzleHeight = 80; // 切圖高 let moved = 0; // 移動位置 let mpe = 5; // 允許最大誤差 let offsetX = 6; // 邊距值 let offsetY = 0; // 邊距值 let shouldMove = false; let clipRectX1 = randomRange(puzzleWidth + offsetX, width - puzzleWidth - offsetX); let clipRectX2 = clipRectX1 + puzzleWidth; let clipRectY1 = randomRange(puzzleHeight + offsetX, height - puzzleHeight - offsetY); let clipRectY2 = clipRectY1 + puzzleHeight; let captcha = document.querySelector('#captcha'); let handle = document.querySelector('#handle'); let button = document.querySelector('#handle span'); button.addEventListener("mousedown", (e) => { shouldMove = true; }) window.addEventListener("mousemove", (e) => { if (shouldMove) { const offsetLeft = handle.getBoundingClientRect().left; const buttonWidth = button.getBoundingClientRect().width; moved = e.clientX - offsetLeft - buttonWidth / 2; render(); } }) window.addEventListener("mouseup", (e) => { if (shouldMove) { const finalOffset = e.clientX - handle.getBoundingClientRect().left - puzzleWidth / 2; if (Math.abs(finalOffset - clipRectX1) < mpe) captcha.classList.add('passed') else moved = 0; render(); shouldMove = false; } }) /** * 超出省略 */ function clamp(num, a, b) { return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)) } /** * 隨機數字 */ function randomRange(min, max) { return Math.round(Math.random() * (max - min)) + min } /** * 渲染 */ function render() { let clipPath = `polygon( ${clipRectX1}px ${clipRectY1}px, ${clipRectX2}px ${clipRectY1}px, ${clipRectX2}px ${clipRectY2}px, ${clipRectX1}px ${clipRectY2}px )`; captcha.style = `--clip-offsetX:${clipRectX1}px;--moved:${clamp(moved, 0, width - puzzleWidth - offsetX)}px;--clip-path:${clipPath};--width:${width}px;--height:${height}px;--puzzle-width:${puzzleWidth}px;--puzzle-height:${puzzleHeight}px`; } render(); </script> </body> </html>
以上就是 聊天平臺原始碼,登入時拼圖驗證實現的相關程式碼,更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2839988/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- app直播原始碼,登入時輸入驗證碼、簡訊驗證身份APP原始碼
- 直播平臺軟體開發,前端實現登入拼圖驗證前端
- 登入驗證碼生成kaptcha(輸入驗證碼)APT
- node實現登入圖片驗證碼
- C# 滑動驗證碼|拼圖驗證|SlideCaptchaC#IDEAPT
- 聊天平臺原始碼,聊天平臺如何獲取到音訊流原始碼音訊
- 輸入驗證碼登入時,send_keys () 報錯
- 織夢CMS後臺登入驗證碼如何取消?
- uniapp 完成兩種方式登入 驗證碼登入 密碼登入APP密碼
- 滑動拼圖驗證碼水印Logo修改Go
- 【記錄】KgCaptcha滑動拼圖驗證碼GCAPT
- 聊天平臺原始碼,通過MediaStore獲取縮圖模糊原始碼AST
- 聊天平臺原始碼,啟動異常進入recovery模式原始碼模式
- 遊戲陪玩原始碼的登入方式,簡訊驗證碼登入的實現遊戲原始碼
- PbootCMS後臺關閉驗證碼,登入提示驗證碼不能空的解決方法boot
- 易優eyoucms網站後臺登入驗證碼是否不用,也可以登入?網站
- 織夢後臺登入成功又跳轉回登入介面與驗證碼
- PbootCMS後臺登入驗證碼看不清怎麼回事?boot
- Laravel-admin 登入新增驗證碼Laravel
- SpringBoot 整合 Shiro 密碼登入與郵件驗證碼登入(多 Realm 認證)Spring Boot密碼
- 直播系統程式碼,登入時常用驗證方式實現
- 手機直播原始碼,Android Studio使用者登入及驗證原始碼Android
- app直播原始碼,軟體登入時的背景圖更改APP原始碼
- Spring Security 如何新增登入驗證碼?鬆哥手把手教你給微人事新增登入驗證碼Spring
- 爬蟲模擬登入破解無原圖滑動驗證碼爬蟲
- thinkphp6後臺新增google登入驗證PHPGo
- vue實現簡訊驗證碼登入Vue
- springboot + shiro 驗證碼與記住登入Spring Boot
- uniapp 實現簡訊驗證碼登入APP
- C#滑動拼圖驗證碼實現筆記C#筆記
- 線上直播系統原始碼,使用者異地登入時對身份進行驗證原始碼
- 聊天平臺原始碼,TextView部分文字變色原始碼TextView
- 短視訊平臺原始碼,登入介面插入背景圖片原始碼
- Spring Security 一鍵接入驗證碼登入和小程式登入Spring
- 行為式驗證碼家族再添一員 網易易盾推出推理拼圖驗證碼
- pbootcms後臺登入驗證碼看不清的解決辦法boot
- 解決 PBootCMS 後臺登入不顯示驗證碼的問題boot
- JS登入驗證nullJSNull