2 lines
6.5 KiB
Java
2 lines
6.5 KiB
Java
|
|
var J=Object.defineProperty,K=Object.defineProperties;var Q=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var k=(e,r,d)=>r in e?J(e,r,{enumerable:!0,configurable:!0,writable:!0,value:d}):e[r]=d,v=(e,r)=>{for(var d in r||(r={}))U.call(r,d)&&k(e,d,r[d]);if(C)for(var d of C(r))tt.call(r,d)&&k(e,d,r[d]);return e},X=(e,r)=>K(e,Q(r));import{Y as V,N as et,ag as j,bs as W,x as A}from"./index-BI6CMai0.js";import{d as Z,r as G,f as E,e as b,w as H,h as nt,u,k as h,aG as st}from"./vue-vendor-C7Zq48Yl.js";import{useTimeoutFn as Y}from"./useTimeout-DDl4l82I.js";import{aA as it,b9 as at}from"./antd-vue-vendor-BPnV8VqP.js";const{t:F}=V(),q={value:{type:Boolean,default:!1},isSlot:{type:Boolean,default:!1},text:{type:[String],default:F("component.verify.dragText")},successText:{type:[String],default:F("component.verify.successText")},height:{type:[Number,String],default:40},width:{type:[Number,String],default:220},circle:{type:Boolean,default:!1},wrapStyle:{type:Object,default:{}},contentStyle:{type:Object,default:{}},barStyle:{type:Object,default:{}},actionStyle:{type:Object,default:{}}},ot=X(v({},q),{src:{type:String},imgWidth:{type:Number,default:260},imgWrapStyle:{type:Object,default:{}},minDegree:{type:Number,default:90},maxDegree:{type:Number,default:270},diffDegree:{type:Number,default:20}}),z=Z({name:"BaseDargVerify",props:q,emits:["success","update:value","change","start","move","end"],setup(e,{emit:r,slots:d,expose:_}){const n=G({isMoving:!1,isPassing:!1,moveDistance:0,toLeft:!1,startTime:0,endTime:0}),s=E(null),w=E(null),D=E(null),T=E(null);et({el:document,name:"mouseup",listener:()=>{n.isMoving&&y()}});const O=b(()=>{const{height:t,actionStyle:a}=e,c=`${parseInt(t)}px`;return v({left:0,width:c,height:c},a)}),N=b(()=>{const{height:t,width:a,circle:c,wrapStyle:i}=e,l=parseInt(t),m=`${parseInt(a)}px`;return v({width:m,height:`${l}px`,lineHeight:`${l}px`,borderRadius:c?l/2+"px":0},i)}),I=b(()=>{const{height:t,circle:a,barStyle:c}=e,i=parseInt(t);return v({height:`${i}px`,borderRadius:a?i/2+"px 0 0 "+i/2+"px":0},c)}),P=b(()=>{const{height:t,width:a,contentStyle:c}=e,i=`${parseInt(t)}px`,l=`${parseInt(a)}px`;return v({height:i,width:l},c)});H(()=>n.isPassing,t=>{if(t){const{startTime:a,endTime:c}=n,i=(c-a)/1e3;r("success",{isPassing:t,time:i.toFixed(1)}),r("update:value",t),r("change",t)}}),nt(()=>{n.isPassing=!!e.value});function R(t){return t.pageX||t.touches[0].pageX}function M(t){if(n.isPassing)return;const a=u(T);a&&(r("start",t),n.moveDistance=R(t)-parseInt(a.style.left.replace("px",""),10),n.startTime=new Date().getTime(),n.isMoving=!0)}function o(t){const a=parseInt(t.style.width),{width:c}=e,i=parseInt(c);return{offset:i-a-6,widthNum:i,actionWidth:a}}function f(t){const{isMoving:a,moveDistance:c}=n;if(a){const i=u(T),l=u(w);if(!i||!l)return;const{offset:m,widthNum:S,actionWidth:$}=o(i),p=R(t)-c;r("move",{event:t,moveDistance:c,moveX:p}),p>0&&p<=m?(i.style.left=`${p}px`,l.style.width=`${p+$/2}px`):p>m&&(i.style.left=`${S-$}px`,l.style.width=`${S-$/2}px`,e.isSlot||x())}}function g(t){const{isMoving:a,isPassing:c,moveDistance:i}=n;if(a&&!c){r("end",t);const l=u(T),m=u(w);if(!l||!m)return;const S=R(t)-i,{offset:$,widthNum:p,actionWidth:B}=o(l);S<$?e.isSlot?setTimeout(()=>{if(!e.value)y();else{const L=u(D);L&&(L.style.width=`${parseInt(m.style.width)}px`)}},0):y():(l.style.left=`${p-B}px`,m.style.width=`${p-B/2}px`,x()),n.isMoving=!1}}function x(){if(e.isSlot){y();return}n.endTime=new Date().getTime(),n.isPassing=!0,n.isMoving=!1}function y(){n.isMoving=!1,n.isPassing=!1,n.moveDistance=0,n.toLeft=!1,n.startTime=0,n.endTime=0;const t=u(T),a=u(w),c=u(D);!t||!a||!c||(n.toLeft=!0,Y(()=>{n.toLeft=!1,t.style.left="0",a.style.width="0"},300),c.style.width=u(P).width)}return _({resume:y}),()=>{const t=()=>{const i=["darg-verify-bar"];return n.toLeft&&i.push("to-left"),h("div",{class:i,ref:w,style:u(I)},null)},a=()=>{const i=["darg-verify-content"],{isPassing:l}=n,{text:m,successText:S}=e;return l&&i.push("success"),h("div",{class:i,re
|