mine-h5-ui
Version:
一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍
74 lines (73 loc) • 1.78 kB
JavaScript
import { ref as w, computed as M, useTemplateRef as S, watch as R } from "vue";
import { useMoveHandle as T } from "../MeComposable/useMoveHandle/index.js";
/*!
* mine-h5-ui v2.15.0
* Copyright (c) 2025 biaov
* @license MIT
*/
const X = (r, v, { visible: b, statusCode: i }) => {
let f = 0;
const u = w(!1);
let o;
const c = M(() => {
if (!r.item) return null;
const { bgElem: e, elem: t } = r.item, [m] = e.size, [a, l] = t.size, [s, y] = t.initPos;
o = 310 / m;
const d = s * o;
return n.value = d, {
w: a * o,
h: l * o,
x: d,
y: y * o
};
}), n = w(0), k = S("captchaSlideMoveRef"), p = {
start({ x: e }) {
f = e;
},
move({ x: e }) {
if (!c.value) return;
let t = c.value.x + e - f;
t < 0 && (t = 0), t > 250 && (t = 250), n.value = t;
},
end(e) {
var a, l, s;
const t = (s = (l = (a = r.item) == null ? void 0 : a.elem) == null ? void 0 : l.initPos) == null ? void 0 : s[1];
if (!(o && t)) return;
this.move(e);
const m = Math.round(n.value / o);
v("check", [m, t]);
}
};
R(
k,
(e) => {
e && T(e, p);
},
{ immediate: !0 }
), R(i, async (e) => {
switch (e) {
case 1:
setTimeout(() => {
h(), i.value = 0;
}, 800);
break;
case 2:
u.value = !0, setTimeout(() => {
u.value = !1, n.value = c.value.x, i.value = 0;
}, 800);
break;
case 3:
x(), i.value = 0;
break;
}
});
const h = () => {
b.value = !1;
}, x = () => {
v("refresh"), i.value = 0;
};
return { moveX: n, imgRect: c, rectAni: u, onClose: h, onRefresh: x };
};
export {
X as useSlide
};