secure-action
Version:
Secure Action 是一个基于行为的验证码组件,适用于 Vue 3。
31 lines (30 loc) • 689 B
JavaScript
const withInstall = (comp, name) => {
comp.install = function(app) {
app.component(comp.name, comp);
};
comp.name = name;
return comp;
};
function addPoint(points, newPoint, r = 5) {
let flag = false;
const newPoints = [];
for (let i = 0; i < points.length; i++) {
if (flag)
continue;
const [x1, y1] = points[i];
const [x2, y2] = newPoint;
const distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
if (distance < r) {
flag = true;
continue;
}
newPoints.push(points[i]);
}
if (!flag)
newPoints.push(newPoint);
return points.length < 1 ? [newPoint] : newPoints;
}
export {
addPoint,
withInstall
};