@wfrog/vc-ui 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/es/chunk/{BMzd-IS6.mjs → 09Ec85_u.mjs} +13 -13
- package/dist/es/chunk/{su2Zrql0.mjs → 4eyJqDa9.mjs} +1 -1
- package/dist/es/chunk/{Dqz1zvKN.mjs → 73YgKz3H.mjs} +1 -1
- package/dist/es/chunk/{Dh4jaUSg.mjs → B5UQmWXg.mjs} +5 -5
- package/dist/es/chunk/{CVlj9F0I.mjs → BHsNc7jl.mjs} +4 -3
- package/dist/es/chunk/{CEm0brzD.mjs → BI0vrXwX.mjs} +2 -1
- package/dist/es/chunk/{BJS5Pdfp.mjs → BTpNRPQW.mjs} +1 -1
- package/dist/es/chunk/{De_EXLIy.mjs → BUEEWLrd.mjs} +1 -1
- package/dist/es/chunk/{C5hWsUfD.mjs → BcTuAX8r.mjs} +2 -2
- package/dist/es/chunk/{DyDMGLoF.mjs → Bl2KlMdP.mjs} +3 -2
- package/dist/es/chunk/{ViP2SEY4.mjs → Bp9jXKX0.mjs} +2 -3
- package/dist/es/chunk/{C2LgraHx.mjs → BpqBBo4z.mjs} +2 -3
- package/dist/es/chunk/{CS4VKsqy.mjs → BsGCX4td.mjs} +1 -1
- package/dist/es/chunk/{-EkpfdcW.mjs → BsLJxiSC.mjs} +46 -8
- package/dist/es/chunk/{zfg5SOj1.mjs → BtTIs3tG.mjs} +3 -3
- package/dist/es/chunk/{B_tU9Nax.mjs → BzedaLtg.mjs} +1 -1
- package/dist/es/chunk/{Dvi7RsXg.mjs → C7wQNvSS.mjs} +10 -9
- package/dist/es/chunk/{8rLUmOVR.mjs → CBSopeeE.mjs} +3 -2
- package/dist/es/chunk/{Coex0GxM.mjs → CLCfXfvv.mjs} +10 -10
- package/dist/es/chunk/{DqUIKX7f.mjs → CLMc8GzD.mjs} +8 -7
- package/dist/es/chunk/{D3uV7vm-.mjs → CLbj8G-F.mjs} +3 -3
- package/dist/es/chunk/{C7iSSBUr.mjs → CPERtDRX.mjs} +5 -5
- package/dist/es/chunk/{VAdRxe-1.mjs → Cbhe4I9Z.mjs} +1 -1
- package/dist/es/chunk/{D5259bwd.mjs → CizMbf5K.mjs} +2 -1
- package/dist/es/chunk/CsLIbnzG.mjs +64 -0
- package/dist/es/chunk/{Ce9ApjrT.mjs → Cu6erWl4.mjs} +4 -4
- package/dist/es/chunk/{VCrtRnxt.mjs → D0LB3gF-.mjs} +7 -7
- package/dist/es/chunk/{D3DXeVfC.mjs → DFOLES4O.mjs} +60 -16
- package/dist/es/chunk/{E_WRn0OP.mjs → DRoyW749.mjs} +58 -264
- package/dist/es/chunk/{D389hx_T.mjs → DTLPXrjb.mjs} +1 -1
- package/dist/es/chunk/{DZACQ9LT.mjs → DXPWe_a5.mjs} +2 -2
- package/dist/es/chunk/{BWcCXRRK.mjs → DZD-YnCt.mjs} +4 -4
- package/dist/es/chunk/{BdDihk0t.mjs → DaCDeO95.mjs} +591 -562
- package/dist/es/chunk/{CZ4ggqDE.mjs → DihosKp1.mjs} +6 -6
- package/dist/es/chunk/{aibQ9WSZ.mjs → Dk6Bx0KT.mjs} +1 -1
- package/dist/es/chunk/{CyxEcbcy.mjs → DouIsSPi.mjs} +1 -1
- package/dist/es/chunk/{HSv8BL8o.mjs → DrgvuOYH.mjs} +2 -1
- package/dist/es/chunk/{DhhdKtyu.mjs → DwKWIlzw.mjs} +9 -8
- package/dist/es/chunk/{BX-Ogf7p.mjs → FHvLvzEB.mjs} +23 -23
- package/dist/es/chunk/{CMABHk8B.mjs → HAog8AWU.mjs} +22 -22
- package/dist/es/chunk/{Spa-JKB4.mjs → NQBKROII.mjs} +127 -2
- package/dist/es/chunk/{BAtns-Mc.mjs → OEa4tYPF.mjs} +1 -1
- package/dist/es/chunk/{JCIyOUEY.mjs → XwSiBVsA.mjs} +3 -2
- package/dist/es/chunk/{CaTfZePA.mjs → axpwSky6.mjs} +5 -5
- package/dist/es/chunk/{DMHNh_tw.mjs → cPBw23yt.mjs} +3 -3
- package/dist/es/chunk/{nWBcrYxV.mjs → f0-vIQGp.mjs} +3 -5
- package/dist/es/components/awesome-icon/awesome-icon.mjs +4 -6
- package/dist/es/components/backbottom/backbottom.mjs +2 -2
- package/dist/es/components/button/button.mjs +8 -8
- package/dist/es/components/choice/choice.mjs +2 -2
- package/dist/es/components/choice-boolean/choice-boolean.mjs +1 -1
- package/dist/es/components/config-provider/config-provider.mjs +1 -1
- package/dist/es/components/config-provider/config-provider2.mjs +1 -1
- package/dist/es/components/cropper/cropper.mjs +150 -15
- package/dist/es/components/currency/currency.mjs +6 -6
- package/dist/es/components/daterange-picker/daterange-picker.mjs +25 -23
- package/dist/es/components/dialog/dialog.mjs +11 -12
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.mjs +20 -23
- package/dist/es/components/dialog-map-point/dialog-map-point.mjs +8 -13
- package/dist/es/components/dialog-upload-images/dialog-upload-images.mjs +12 -16
- package/dist/es/components/drag-verify/components/image.vue.d.ts +54 -0
- package/dist/es/components/drag-verify/components/text.vue.d.ts +22 -0
- package/dist/es/components/drag-verify/drag-verify.d.ts +22 -0
- package/dist/es/components/drag-verify/drag-verify.mjs +475 -0
- package/dist/es/components/drag-verify/drag-verify.vue.d.ts +123 -0
- package/dist/es/components/drag-verify/helper.d.ts +2 -0
- package/dist/es/components/drag-verify/index.css +117 -0
- package/dist/es/components/drag-verify/index.d.ts +4 -0
- package/dist/es/components/drag-verify/index.mjs +6 -0
- package/dist/es/components/drawer/drawer.mjs +12 -13
- package/dist/es/components/easy-pagination/easy-pagination.mjs +4 -4
- package/dist/es/components/el-icon/el-icon.mjs +2 -2
- package/dist/es/components/flag/flag.mjs +1 -1
- package/dist/es/components/icon/icon.mjs +2 -2
- package/dist/es/components/icon/icon2.mjs +1 -1
- package/dist/es/components/image/image.mjs +5 -5
- package/dist/es/components/input/input.mjs +4 -4
- package/dist/es/components/input-number/input-number.mjs +5 -5
- package/dist/es/components/pca-picker/pca-picker.mjs +21 -23
- package/dist/es/components/qr-code/qr-code.mjs +1 -1
- package/dist/es/components/screenfull/screenfull.mjs +5 -5
- package/dist/es/components/select/select.mjs +7 -7
- package/dist/es/components/single-player/single-player.mjs +16 -16
- package/dist/es/components/svg-icon/svg-icon.mjs +2 -2
- package/dist/es/components/switch/switch.mjs +2 -2
- package/dist/es/components/sync-scroll-container/sync-scroll-container.mjs +3 -3
- package/dist/es/components/tags/tags.mjs +9 -9
- package/dist/es/components/text-ellipsis/text-ellipsis.mjs +4 -4
- package/dist/es/components/thousand-input/thousand-input.mjs +4 -4
- package/dist/es/components/tinymce/index.css +1 -1
- package/dist/es/components/tinymce/tinymce.mjs +7 -10
- package/dist/es/components/tree-picker/tree-picker.mjs +11 -12
- package/dist/es/components/upload-file/upload-file.mjs +6 -9
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.mjs +26 -24
- package/dist/es/use/useSmallScreen/index.mjs +1 -1
- package/dist/global.d.ts +1 -0
- package/dist/index.css +118 -1
- package/package.json +3 -6
- package/dist/es/chunk/BAGoDD49.mjs +0 -36
- package/dist/es/chunk/CD98REcR.mjs +0 -666
- package/dist/es/chunk/CEClY-_T.mjs +0 -445
- package/dist/es/chunk/Fo0dZYnz.mjs +0 -128
- package/dist/es/chunk/O-uhUKF4.mjs +0 -43
- package/dist/es/chunk/qY9OvNHY.mjs +0 -283
- package/dist/es/components/cdn-tag.vue.d.ts +0 -5
- package/dist/es/components/document.vue.d.ts +0 -14
- package/dist/es/components/example-wrapper.vue.d.ts +0 -19
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import './index.css'
|
|
2
|
+
import { defineComponent, useCssVars, unref, computed, ref, createElementBlock, openBlock, normalizeClass, createElementVNode, toDisplayString, withModifiers, createVNode, withCtx, createBlock, useTemplateRef, onBeforeMount, createCommentVNode, mergeProps, isRef, Fragment } from 'vue';
|
|
3
|
+
import { useVModel } from '@vueuse/core';
|
|
4
|
+
import '../../chunk/DRoyW749.mjs';
|
|
5
|
+
import { CircleCheck, DArrowRight, Refresh } from '@element-plus/icons-vue';
|
|
6
|
+
import '../../chunk/DaCDeO95.mjs';
|
|
7
|
+
import { E as ElIcon } from '../../chunk/cPBw23yt.mjs';
|
|
8
|
+
import { _ as _export_sfc } from '../../chunk/pcqpp-6-.mjs';
|
|
9
|
+
|
|
10
|
+
function inRange(target, range) {
|
|
11
|
+
return target >= range[0] && target <= range[1];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function draw(ctx, x, y, l, r, operation) {
|
|
15
|
+
const PI = Math.PI;
|
|
16
|
+
ctx.beginPath();
|
|
17
|
+
ctx.moveTo(x, y);
|
|
18
|
+
ctx.arc(x + l / 2, y - r + 2, r, 0.72 * PI, 2.26 * PI);
|
|
19
|
+
ctx.lineTo(x + l, y);
|
|
20
|
+
ctx.arc(x + l + r - 2, y + l / 2, r, 1.21 * PI, 2.78 * PI);
|
|
21
|
+
ctx.lineTo(x + l, y + l);
|
|
22
|
+
ctx.lineTo(x, y + l);
|
|
23
|
+
ctx.arc(x + r - 2, y + l / 2, r + 0.4, 2.76 * PI, 1.24 * PI, true);
|
|
24
|
+
ctx.lineTo(x, y);
|
|
25
|
+
ctx.lineWidth = 2;
|
|
26
|
+
ctx.fillStyle = "rgba(255, 255, 255, 0.8)";
|
|
27
|
+
ctx.strokeStyle = "rgba(255, 255, 255, 0.8)";
|
|
28
|
+
ctx.stroke();
|
|
29
|
+
ctx[operation]();
|
|
30
|
+
ctx.globalCompositeOperation = "destination-over";
|
|
31
|
+
}
|
|
32
|
+
function getContext(width, height, canvas) {
|
|
33
|
+
const myCanvas = canvas || document.createElement("canvas");
|
|
34
|
+
myCanvas.width = width;
|
|
35
|
+
myCanvas.height = height;
|
|
36
|
+
const ctx = myCanvas.getContext("2d");
|
|
37
|
+
return ctx;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
41
|
+
__name: "text",
|
|
42
|
+
props: {
|
|
43
|
+
successRange: {},
|
|
44
|
+
type: {},
|
|
45
|
+
diffWidth: {},
|
|
46
|
+
imgs: {},
|
|
47
|
+
success: { type: Boolean },
|
|
48
|
+
width: {},
|
|
49
|
+
height: {},
|
|
50
|
+
background: {},
|
|
51
|
+
circle: { type: Boolean },
|
|
52
|
+
radius: {},
|
|
53
|
+
text: {},
|
|
54
|
+
successText: {},
|
|
55
|
+
textColor: {},
|
|
56
|
+
stopToCheck: { type: Boolean },
|
|
57
|
+
tips: { type: Boolean },
|
|
58
|
+
refresh: { type: Boolean },
|
|
59
|
+
successTips: {},
|
|
60
|
+
failedTips: {}
|
|
61
|
+
},
|
|
62
|
+
emits: ["success", "failed", "update:success", "dragStart", "dragMoving", "dragFinished", "dragEnd"],
|
|
63
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
64
|
+
useCssVars((_ctx) => ({
|
|
65
|
+
"v891781fa": `${-unref(halfWidth)}px`,
|
|
66
|
+
"v13fb2ccc": `${unref(halfWidth)}px`,
|
|
67
|
+
"v4a80da82": `${_ctx.width}px`,
|
|
68
|
+
"v330f40e4": `${_ctx.height}px`,
|
|
69
|
+
"v67c15c9b": `${_ctx.background[0]}`,
|
|
70
|
+
"v9f6c5848": `${_ctx.circle ? _ctx.height / 2 : _ctx.radius}px`,
|
|
71
|
+
"v5bbe29b5": unref(myTextColor),
|
|
72
|
+
"v15190af8": `${(unref(sliderLeft) - _ctx.width) / 2}px`,
|
|
73
|
+
"v477e15dc": `${unref(progressWidth)}px`,
|
|
74
|
+
"v67c1d0fa": `${_ctx.background[1]}`,
|
|
75
|
+
"add22124": `${_ctx.circle ? `${_ctx.height / 2}px 0 0 ${_ctx.height / 2}px` : _ctx.radius}px`,
|
|
76
|
+
"v67c24559": `${_ctx.background[2]}`,
|
|
77
|
+
"v52b68a76": `${unref(sliderLeft)}px`
|
|
78
|
+
}));
|
|
79
|
+
const props = __props;
|
|
80
|
+
const emits = __emit;
|
|
81
|
+
const isMoving = ref(false);
|
|
82
|
+
const startX = ref(0);
|
|
83
|
+
const currentX = ref(0);
|
|
84
|
+
const isSuccess = ref(false);
|
|
85
|
+
const isSwiped = ref(false);
|
|
86
|
+
const mySuccess = useVModel(props, "success", emits);
|
|
87
|
+
const myText = computed(() => isSuccess.value ? props.successText : props.text);
|
|
88
|
+
const moveX = computed(() => currentX.value - startX.value);
|
|
89
|
+
const halfWidth = computed(() => props.width / 2);
|
|
90
|
+
const swipeWidth = computed(() => props.width - props.height);
|
|
91
|
+
const mySuccessRange = computed(() => props.successRange || [swipeWidth.value, 9999]);
|
|
92
|
+
const sliderLeft = computed(() => {
|
|
93
|
+
if (moveX.value < 0) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
if (moveX.value > swipeWidth.value) {
|
|
97
|
+
return swipeWidth.value;
|
|
98
|
+
}
|
|
99
|
+
return moveX.value;
|
|
100
|
+
});
|
|
101
|
+
const progressWidth = computed(() => {
|
|
102
|
+
if (moveX.value < 0) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
if (moveX.value > swipeWidth.value) {
|
|
106
|
+
return props.width - props.height / 2;
|
|
107
|
+
}
|
|
108
|
+
return moveX.value + props.height / 2;
|
|
109
|
+
});
|
|
110
|
+
const myTextColor = computed(() => isSuccess.value ? "#fff" : props.textColor);
|
|
111
|
+
function verify(result) {
|
|
112
|
+
mySuccess.value = result;
|
|
113
|
+
result ? emits("success") : emits("failed");
|
|
114
|
+
}
|
|
115
|
+
function dragMoving(e) {
|
|
116
|
+
if (!isMoving.value || isSuccess.value) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
currentX.value = e.pageX || e.touches[0].pageX;
|
|
120
|
+
emits("dragMoving", moveX.value);
|
|
121
|
+
if (inRange(moveX.value, mySuccessRange.value) && !props.stopToCheck) {
|
|
122
|
+
isSuccess.value = true;
|
|
123
|
+
isMoving.value = false;
|
|
124
|
+
verify(true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function dragFinished(e) {
|
|
128
|
+
if (!isMoving.value || isSuccess.value) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
currentX.value = e.pageX || e.touches[0].pageX;
|
|
132
|
+
isMoving.value = false;
|
|
133
|
+
if (!inRange(moveX.value, mySuccessRange.value)) {
|
|
134
|
+
currentX.value = startX.value;
|
|
135
|
+
isSwiped.value = true;
|
|
136
|
+
setTimeout(() => {
|
|
137
|
+
isSwiped.value = false;
|
|
138
|
+
emits("dragFinished", currentX.value);
|
|
139
|
+
}, 500);
|
|
140
|
+
verify(false);
|
|
141
|
+
} else {
|
|
142
|
+
isSuccess.value = true;
|
|
143
|
+
verify(true);
|
|
144
|
+
}
|
|
145
|
+
emits("dragEnd", currentX.value);
|
|
146
|
+
}
|
|
147
|
+
function dragStart(e) {
|
|
148
|
+
if (isSuccess.value) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
isMoving.value = true;
|
|
152
|
+
startX.value = e.pageX || e.touches[0].pageX;
|
|
153
|
+
emits("dragStart", startX.value);
|
|
154
|
+
}
|
|
155
|
+
function reset() {
|
|
156
|
+
isMoving.value = false;
|
|
157
|
+
startX.value = 0;
|
|
158
|
+
currentX.value = 0;
|
|
159
|
+
isSuccess.value = false;
|
|
160
|
+
isSwiped.value = false;
|
|
161
|
+
mySuccess.value = false;
|
|
162
|
+
}
|
|
163
|
+
__expose({ reset });
|
|
164
|
+
return (_ctx, _cache) => {
|
|
165
|
+
const _component_el_icon = ElIcon;
|
|
166
|
+
return openBlock(), createElementBlock("div", {
|
|
167
|
+
class: normalizeClass(_ctx.$style.wrapper),
|
|
168
|
+
onMousemove: dragMoving,
|
|
169
|
+
onMouseup: dragFinished,
|
|
170
|
+
onMouseleave: dragFinished
|
|
171
|
+
}, [
|
|
172
|
+
createElementVNode("div", {
|
|
173
|
+
class: normalizeClass([_ctx.$style.progress, { [_ctx.$style.animate]: unref(isSwiped), [_ctx.$style.success]: unref(isSuccess) }])
|
|
174
|
+
}, null, 2),
|
|
175
|
+
createElementVNode("div", {
|
|
176
|
+
class: normalizeClass([_ctx.$style.text, { [_ctx.$style.animate]: !unref(isSuccess) }])
|
|
177
|
+
}, [
|
|
178
|
+
createElementVNode("span", {
|
|
179
|
+
class: normalizeClass({ [_ctx.$style["text-transform"]]: __props.stopToCheck && unref(isSuccess), [_ctx.$style.success]: unref(isSuccess) })
|
|
180
|
+
}, toDisplayString(unref(myText)), 3)
|
|
181
|
+
], 2),
|
|
182
|
+
createElementVNode("div", {
|
|
183
|
+
class: normalizeClass([_ctx.$style.slider, { [_ctx.$style.animate]: unref(isSwiped) }]),
|
|
184
|
+
onMousedown: withModifiers(dragStart, ["prevent"])
|
|
185
|
+
}, [
|
|
186
|
+
createVNode(_component_el_icon, {
|
|
187
|
+
size: 20,
|
|
188
|
+
color: unref(isSuccess) ? __props.background[2] : __props.textColor
|
|
189
|
+
}, {
|
|
190
|
+
default: withCtx(() => [
|
|
191
|
+
unref(isSuccess) ? (openBlock(), createBlock(unref(CircleCheck), { key: 0 })) : (openBlock(), createBlock(unref(DArrowRight), { key: 1 }))
|
|
192
|
+
]),
|
|
193
|
+
_: 1
|
|
194
|
+
}, 8, ["color"])
|
|
195
|
+
], 34)
|
|
196
|
+
], 34);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
/* unplugin-vue-components disabled */const wrapper$2 = "_wrapper_12cgr_9";
|
|
202
|
+
const text = "_text_12cgr_23";
|
|
203
|
+
const animate$1 = "_animate_12cgr_34";
|
|
204
|
+
const slidetounlock = "_slidetounlock_12cgr_1";
|
|
205
|
+
const success$1 = "_success_12cgr_37";
|
|
206
|
+
const progress = "_progress_12cgr_47";
|
|
207
|
+
const slider = "_slider_12cgr_61";
|
|
208
|
+
const style0$2 = {
|
|
209
|
+
wrapper: wrapper$2,
|
|
210
|
+
text: text,
|
|
211
|
+
animate: animate$1,
|
|
212
|
+
slidetounlock: slidetounlock,
|
|
213
|
+
success: success$1,
|
|
214
|
+
"text-transform": "_text-transform_12cgr_42",
|
|
215
|
+
progress: progress,
|
|
216
|
+
slider: slider
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const cssModules$2 = {
|
|
220
|
+
"$style": style0$2
|
|
221
|
+
};
|
|
222
|
+
const Text = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__cssModules", cssModules$2]]);
|
|
223
|
+
|
|
224
|
+
const _hoisted_1 = ["src"];
|
|
225
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
226
|
+
__name: "image",
|
|
227
|
+
props: {
|
|
228
|
+
type: {},
|
|
229
|
+
diffWidth: {},
|
|
230
|
+
imgs: {},
|
|
231
|
+
success: { type: Boolean },
|
|
232
|
+
width: {},
|
|
233
|
+
height: {},
|
|
234
|
+
background: {},
|
|
235
|
+
circle: { type: Boolean },
|
|
236
|
+
radius: {},
|
|
237
|
+
text: {},
|
|
238
|
+
successText: {},
|
|
239
|
+
textColor: {},
|
|
240
|
+
stopToCheck: { type: Boolean },
|
|
241
|
+
tips: { type: Boolean },
|
|
242
|
+
refresh: { type: Boolean },
|
|
243
|
+
successTips: {},
|
|
244
|
+
failedTips: {}
|
|
245
|
+
},
|
|
246
|
+
emits: ["success", "failed", "update:success"],
|
|
247
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
248
|
+
useCssVars((_ctx) => ({
|
|
249
|
+
"c713fcfc": `${_ctx.width}px`,
|
|
250
|
+
"afb2aafe": `${_ctx.height}px`
|
|
251
|
+
}));
|
|
252
|
+
const props = __props;
|
|
253
|
+
const emits = __emit;
|
|
254
|
+
const mainRef = useTemplateRef("mainRef");
|
|
255
|
+
const moveRef = useTemplateRef("moveRef");
|
|
256
|
+
const imgRef = useTemplateRef("imgRef");
|
|
257
|
+
const textRef = useTemplateRef("textRef");
|
|
258
|
+
const mySuccess = useVModel(props, "success", emits);
|
|
259
|
+
const isSwiped = ref(false);
|
|
260
|
+
const clipBarX = ref(0);
|
|
261
|
+
const isSuccess = ref(false);
|
|
262
|
+
const imgSrc = ref("");
|
|
263
|
+
const isHandled = ref(false);
|
|
264
|
+
const successRange = computed(() => [clipBarX.value - props.diffWidth, clipBarX.value + props.diffWidth]);
|
|
265
|
+
function setImage() {
|
|
266
|
+
if (props.imgs.length <= 1) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const lastImg = imgSrc.value;
|
|
270
|
+
do {
|
|
271
|
+
imgSrc.value = props.imgs[Math.floor(Math.random() * props.imgs.length)];
|
|
272
|
+
} while (lastImg === imgSrc.value);
|
|
273
|
+
}
|
|
274
|
+
function render() {
|
|
275
|
+
const img = imgRef.value;
|
|
276
|
+
const imgWidth = img.width;
|
|
277
|
+
const imgHeight = img.height;
|
|
278
|
+
const l = props.height;
|
|
279
|
+
const r = props.radius;
|
|
280
|
+
const halfWidth = Math.floor(props.width / 2);
|
|
281
|
+
const refreshHeight = 25;
|
|
282
|
+
const tipHeight = 20;
|
|
283
|
+
const maxX = Math.max(0, halfWidth - l - r - 5);
|
|
284
|
+
const x = halfWidth + Math.ceil(Math.random() * maxX);
|
|
285
|
+
const y = refreshHeight + Math.floor(Math.random() * Math.max(0, imgHeight - l - refreshHeight - tipHeight));
|
|
286
|
+
const mainCtx = getContext(imgWidth, imgHeight, mainRef.value);
|
|
287
|
+
draw(mainCtx, x, y, l, r, "fill");
|
|
288
|
+
clipBarX.value = x;
|
|
289
|
+
const tmpCtx = getContext(imgWidth, imgHeight);
|
|
290
|
+
draw(tmpCtx, x, y, l, r, "clip");
|
|
291
|
+
tmpCtx.drawImage(img, 0, 0, imgWidth, imgHeight);
|
|
292
|
+
const pieceSize = l + r * 2 + 3;
|
|
293
|
+
const pieceX = Math.max(0, x - r - 1);
|
|
294
|
+
const pieceY = Math.max(0, y - r - 1);
|
|
295
|
+
const sx = Math.min(pieceX, imgWidth - pieceSize);
|
|
296
|
+
const sy = Math.min(pieceY, imgHeight - pieceSize);
|
|
297
|
+
const imageData = tmpCtx.getImageData(sx, sy, pieceSize, pieceSize);
|
|
298
|
+
const moveCtx = getContext(pieceSize, pieceSize, moveRef.value);
|
|
299
|
+
moveRef.value.style.top = `${y - 5}px`;
|
|
300
|
+
moveCtx.putImageData(imageData, 0, 0);
|
|
301
|
+
}
|
|
302
|
+
function handleDragMoving(moveX) {
|
|
303
|
+
moveRef.value.style.left = `${moveX}px`;
|
|
304
|
+
}
|
|
305
|
+
function handleFailed() {
|
|
306
|
+
isSwiped.value = true;
|
|
307
|
+
isHandled.value = true;
|
|
308
|
+
moveRef.value.style.left = "0px";
|
|
309
|
+
emits("failed");
|
|
310
|
+
}
|
|
311
|
+
function handleSuccess() {
|
|
312
|
+
isSuccess.value = true;
|
|
313
|
+
isHandled.value = true;
|
|
314
|
+
emits("success");
|
|
315
|
+
}
|
|
316
|
+
function reset() {
|
|
317
|
+
isHandled.value = false;
|
|
318
|
+
isSuccess.value = false;
|
|
319
|
+
textRef.value?.reset();
|
|
320
|
+
moveRef.value.style.left = "0px";
|
|
321
|
+
render();
|
|
322
|
+
}
|
|
323
|
+
__expose({ reset: setImage });
|
|
324
|
+
onBeforeMount(() => setImage());
|
|
325
|
+
return (_ctx, _cache) => {
|
|
326
|
+
const _component_el_icon = ElIcon;
|
|
327
|
+
return openBlock(), createElementBlock("div", {
|
|
328
|
+
class: normalizeClass(_ctx.$style.wrapper)
|
|
329
|
+
}, [
|
|
330
|
+
createElementVNode("div", {
|
|
331
|
+
class: normalizeClass(_ctx.$style.container)
|
|
332
|
+
}, [
|
|
333
|
+
createElementVNode("img", {
|
|
334
|
+
ref_key: "imgRef",
|
|
335
|
+
ref: imgRef,
|
|
336
|
+
crossOrigin: "anonymous",
|
|
337
|
+
src: unref(imgSrc),
|
|
338
|
+
style: { "width": "100%" },
|
|
339
|
+
onLoad: reset
|
|
340
|
+
}, null, 40, _hoisted_1),
|
|
341
|
+
createElementVNode("canvas", {
|
|
342
|
+
ref_key: "mainRef",
|
|
343
|
+
ref: mainRef,
|
|
344
|
+
class: "main-canvas"
|
|
345
|
+
}, null, 512),
|
|
346
|
+
createElementVNode("canvas", {
|
|
347
|
+
ref_key: "moveRef",
|
|
348
|
+
ref: moveRef,
|
|
349
|
+
class: normalizeClass([_ctx.$style["move-canvas"], { [_ctx.$style.animate]: unref(isSwiped) }])
|
|
350
|
+
}, null, 2),
|
|
351
|
+
__props.refresh && !unref(isSuccess) ? (openBlock(), createElementBlock("div", {
|
|
352
|
+
key: 0,
|
|
353
|
+
class: normalizeClass(_ctx.$style.refresh),
|
|
354
|
+
onClick: setImage
|
|
355
|
+
}, [
|
|
356
|
+
createVNode(_component_el_icon, { size: 26 }, {
|
|
357
|
+
default: withCtx(() => [
|
|
358
|
+
createVNode(unref(Refresh))
|
|
359
|
+
]),
|
|
360
|
+
_: 1
|
|
361
|
+
})
|
|
362
|
+
], 2)) : createCommentVNode("", true),
|
|
363
|
+
__props.tips && unref(isHandled) ? (openBlock(), createElementBlock("div", {
|
|
364
|
+
key: 1,
|
|
365
|
+
class: normalizeClass([_ctx.$style.tips, { [_ctx.$style.success]: unref(isSuccess), [_ctx.$style.danger]: !unref(isSuccess) }])
|
|
366
|
+
}, toDisplayString(unref(isSuccess) ? __props.successTips : __props.failedTips), 3)) : createCommentVNode("", true)
|
|
367
|
+
], 2),
|
|
368
|
+
createVNode(Text, mergeProps({
|
|
369
|
+
ref_key: "textRef",
|
|
370
|
+
ref: textRef
|
|
371
|
+
}, props, {
|
|
372
|
+
success: unref(mySuccess),
|
|
373
|
+
"onUpdate:success": _cache[0] || (_cache[0] = ($event) => isRef(mySuccess) ? mySuccess.value = $event : null),
|
|
374
|
+
"success-range": unref(successRange),
|
|
375
|
+
"stop-to-check": "",
|
|
376
|
+
onDragMoving: handleDragMoving,
|
|
377
|
+
onDragFinished: _cache[1] || (_cache[1] = ($event) => isSwiped.value = false),
|
|
378
|
+
onFailed: handleFailed,
|
|
379
|
+
onSuccess: handleSuccess
|
|
380
|
+
}), null, 16, ["success", "success-range"])
|
|
381
|
+
], 2);
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
/* unplugin-vue-components disabled */const wrapper$1 = "_wrapper_1jbqv_1";
|
|
387
|
+
const container = "_container_1jbqv_8";
|
|
388
|
+
const refresh = "_refresh_1jbqv_19";
|
|
389
|
+
const animate = "_animate_1jbqv_28";
|
|
390
|
+
const tips = "_tips_1jbqv_32";
|
|
391
|
+
const success = "_success_1jbqv_42";
|
|
392
|
+
const danger = "_danger_1jbqv_46";
|
|
393
|
+
const style0$1 = {
|
|
394
|
+
wrapper: wrapper$1,
|
|
395
|
+
container: container,
|
|
396
|
+
refresh: refresh,
|
|
397
|
+
"move-canvas": "_move-canvas_1jbqv_28",
|
|
398
|
+
animate: animate,
|
|
399
|
+
tips: tips,
|
|
400
|
+
success: success,
|
|
401
|
+
danger: danger
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
const cssModules$1 = {
|
|
405
|
+
"$style": style0$1
|
|
406
|
+
};
|
|
407
|
+
const Image = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__cssModules", cssModules$1]]);
|
|
408
|
+
|
|
409
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
410
|
+
__name: "drag-verify",
|
|
411
|
+
props: {
|
|
412
|
+
type: { default: "text" },
|
|
413
|
+
diffWidth: { default: 20 },
|
|
414
|
+
imgs: { default: () => [] },
|
|
415
|
+
success: { type: Boolean },
|
|
416
|
+
width: { default: 300 },
|
|
417
|
+
height: { default: 40 },
|
|
418
|
+
background: { default: () => ["#f5f5f5", "#d9d9d9", "#76c61d"] },
|
|
419
|
+
circle: { type: Boolean, default: false },
|
|
420
|
+
radius: { default: 4 },
|
|
421
|
+
text: { default: "拖动滑块完成验证" },
|
|
422
|
+
successText: { default: "验证成功" },
|
|
423
|
+
textColor: { default: "#333" },
|
|
424
|
+
stopToCheck: { type: Boolean, default: false },
|
|
425
|
+
tips: { type: Boolean, default: true },
|
|
426
|
+
refresh: { type: Boolean, default: true },
|
|
427
|
+
successTips: { default: "验证通过,超过89.7%用户" },
|
|
428
|
+
failedTips: { default: "验证未通过,拖动滑块将悬浮图像正确合并" }
|
|
429
|
+
},
|
|
430
|
+
setup(__props, { expose: __expose }) {
|
|
431
|
+
const props = __props;
|
|
432
|
+
const mySuccess = useVModel(props, "success");
|
|
433
|
+
const textRef = useTemplateRef("textRef");
|
|
434
|
+
const imageRef = useTemplateRef("imageRef");
|
|
435
|
+
__expose({
|
|
436
|
+
reset: () => {
|
|
437
|
+
textRef.value?.reset();
|
|
438
|
+
imageRef.value?.reset();
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
return (_ctx, _cache) => {
|
|
442
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
443
|
+
__props.type === "text" ? (openBlock(), createBlock(Text, mergeProps({ key: 0 }, props, {
|
|
444
|
+
ref_key: "textRef",
|
|
445
|
+
ref: textRef,
|
|
446
|
+
success: unref(mySuccess),
|
|
447
|
+
"onUpdate:success": _cache[0] || (_cache[0] = ($event) => isRef(mySuccess) ? mySuccess.value = $event : null)
|
|
448
|
+
}), null, 16, ["success"])) : createCommentVNode("", true),
|
|
449
|
+
__props.type === "image" ? (openBlock(), createBlock(Image, mergeProps({ key: 1 }, props, {
|
|
450
|
+
ref_key: "imageRef",
|
|
451
|
+
ref: imageRef,
|
|
452
|
+
success: unref(mySuccess),
|
|
453
|
+
"onUpdate:success": _cache[1] || (_cache[1] = ($event) => isRef(mySuccess) ? mySuccess.value = $event : null)
|
|
454
|
+
}), null, 16, ["success"])) : createCommentVNode("", true)
|
|
455
|
+
], 64);
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
/* unplugin-vue-components disabled */const wrapper = "_wrapper_72jdw_1";
|
|
461
|
+
const style0 = {
|
|
462
|
+
wrapper: wrapper
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
const cssModules = {
|
|
466
|
+
"$style": style0
|
|
467
|
+
};
|
|
468
|
+
const Component = /* @__PURE__ */ _export_sfc(_sfc_main, [["__cssModules", cssModules]]);
|
|
469
|
+
|
|
470
|
+
const __vite_glob_0_14 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
471
|
+
__proto__: null,
|
|
472
|
+
default: Component
|
|
473
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
474
|
+
|
|
475
|
+
export { Component as C, __vite_glob_0_14 as _ };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { IDragVerifyProps } from './drag-verify';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<IDragVerifyProps, {
|
|
3
|
+
reset: () => void;
|
|
4
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<IDragVerifyProps> & Readonly<{}>, {
|
|
5
|
+
type: "text" | "image";
|
|
6
|
+
circle: boolean;
|
|
7
|
+
text: string;
|
|
8
|
+
width: number;
|
|
9
|
+
textColor: string;
|
|
10
|
+
height: number;
|
|
11
|
+
background: [string, string, string];
|
|
12
|
+
diffWidth: number;
|
|
13
|
+
imgs: string[];
|
|
14
|
+
radius: number;
|
|
15
|
+
successText: string;
|
|
16
|
+
stopToCheck: boolean;
|
|
17
|
+
tips: boolean;
|
|
18
|
+
refresh: boolean;
|
|
19
|
+
successTips: string;
|
|
20
|
+
failedTips: string;
|
|
21
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
22
|
+
textRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./drag-verify').IDragVerifyTextProps> & Readonly<{
|
|
23
|
+
onSuccess?: (() => any) | undefined;
|
|
24
|
+
onFailed?: (() => any) | undefined;
|
|
25
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
26
|
+
onDragStart?: ((startX: number) => any) | undefined;
|
|
27
|
+
onDragMoving?: ((moveX: number) => any) | undefined;
|
|
28
|
+
onDragFinished?: ((moveX: number) => any) | undefined;
|
|
29
|
+
onDragEnd?: ((currentX: number) => any) | undefined;
|
|
30
|
+
}>, {
|
|
31
|
+
reset: () => void;
|
|
32
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
33
|
+
success: () => any;
|
|
34
|
+
failed: () => any;
|
|
35
|
+
"update:success": (success: boolean) => any;
|
|
36
|
+
dragStart: (startX: number) => any;
|
|
37
|
+
dragMoving: (moveX: number) => any;
|
|
38
|
+
dragFinished: (moveX: number) => any;
|
|
39
|
+
dragEnd: (currentX: number) => any;
|
|
40
|
+
}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
|
41
|
+
P: {};
|
|
42
|
+
B: {};
|
|
43
|
+
D: {};
|
|
44
|
+
C: {};
|
|
45
|
+
M: {};
|
|
46
|
+
Defaults: {};
|
|
47
|
+
}, Readonly<import('./drag-verify').IDragVerifyTextProps> & Readonly<{
|
|
48
|
+
onSuccess?: (() => any) | undefined;
|
|
49
|
+
onFailed?: (() => any) | undefined;
|
|
50
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
51
|
+
onDragStart?: ((startX: number) => any) | undefined;
|
|
52
|
+
onDragMoving?: ((moveX: number) => any) | undefined;
|
|
53
|
+
onDragFinished?: ((moveX: number) => any) | undefined;
|
|
54
|
+
onDragEnd?: ((currentX: number) => any) | undefined;
|
|
55
|
+
}>, {
|
|
56
|
+
reset: () => void;
|
|
57
|
+
}, {}, {}, {}, {}> | null;
|
|
58
|
+
imageRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<Required<IDragVerifyProps>> & Readonly<{
|
|
59
|
+
onSuccess?: (() => any) | undefined;
|
|
60
|
+
onFailed?: (() => any) | undefined;
|
|
61
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
62
|
+
}>, {
|
|
63
|
+
reset: () => void;
|
|
64
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
65
|
+
success: () => any;
|
|
66
|
+
failed: () => any;
|
|
67
|
+
"update:success": (success: boolean) => any;
|
|
68
|
+
}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
69
|
+
imgRef: HTMLImageElement;
|
|
70
|
+
mainRef: HTMLCanvasElement;
|
|
71
|
+
moveRef: HTMLCanvasElement;
|
|
72
|
+
textRef: import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('./drag-verify').IDragVerifyTextProps> & Readonly<{
|
|
73
|
+
onSuccess?: (() => any) | undefined;
|
|
74
|
+
onFailed?: (() => any) | undefined;
|
|
75
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
76
|
+
onDragStart?: ((startX: number) => any) | undefined;
|
|
77
|
+
onDragMoving?: ((moveX: number) => any) | undefined;
|
|
78
|
+
onDragFinished?: ((moveX: number) => any) | undefined;
|
|
79
|
+
onDragEnd?: ((currentX: number) => any) | undefined;
|
|
80
|
+
}>, {
|
|
81
|
+
reset: () => void;
|
|
82
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
83
|
+
success: () => any;
|
|
84
|
+
failed: () => any;
|
|
85
|
+
"update:success": (success: boolean) => any;
|
|
86
|
+
dragStart: (startX: number) => any;
|
|
87
|
+
dragMoving: (moveX: number) => any;
|
|
88
|
+
dragFinished: (moveX: number) => any;
|
|
89
|
+
dragEnd: (currentX: number) => any;
|
|
90
|
+
}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
|
91
|
+
P: {};
|
|
92
|
+
B: {};
|
|
93
|
+
D: {};
|
|
94
|
+
C: {};
|
|
95
|
+
M: {};
|
|
96
|
+
Defaults: {};
|
|
97
|
+
}, Readonly<import('./drag-verify').IDragVerifyTextProps> & Readonly<{
|
|
98
|
+
onSuccess?: (() => any) | undefined;
|
|
99
|
+
onFailed?: (() => any) | undefined;
|
|
100
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
101
|
+
onDragStart?: ((startX: number) => any) | undefined;
|
|
102
|
+
onDragMoving?: ((moveX: number) => any) | undefined;
|
|
103
|
+
onDragFinished?: ((moveX: number) => any) | undefined;
|
|
104
|
+
onDragEnd?: ((currentX: number) => any) | undefined;
|
|
105
|
+
}>, {
|
|
106
|
+
reset: () => void;
|
|
107
|
+
}, {}, {}, {}, {}> | null;
|
|
108
|
+
}, HTMLDivElement, import('vue').ComponentProvideOptions, {
|
|
109
|
+
P: {};
|
|
110
|
+
B: {};
|
|
111
|
+
D: {};
|
|
112
|
+
C: {};
|
|
113
|
+
M: {};
|
|
114
|
+
Defaults: {};
|
|
115
|
+
}, Readonly<Required<IDragVerifyProps>> & Readonly<{
|
|
116
|
+
onSuccess?: (() => any) | undefined;
|
|
117
|
+
onFailed?: (() => any) | undefined;
|
|
118
|
+
"onUpdate:success"?: ((success: boolean) => any) | undefined;
|
|
119
|
+
}>, {
|
|
120
|
+
reset: () => void;
|
|
121
|
+
}, {}, {}, {}, {}> | null;
|
|
122
|
+
}, any>;
|
|
123
|
+
export default _default;
|