UNPKG

mine-h5-ui

Version:

一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍

45 lines (44 loc) 909 B
import { ref as l, watch as u } from "vue"; import { CountDown as m } from "../MeAPI/function.js"; /*! * mine-h5-ui v2.16.0 * Copyright (c) 2025 biaov * @license MIT */ const w = (t, a) => { const r = l({}); let e; const s = t.format.includes("ms") ? 10 : 1e3; let n = 0; const d = () => { e || (e = setInterval(() => { n <= 0 ? (clearInterval(e), e = void 0, a("end")) : (n -= s, r.value = m(n, t.format), a("progress", n)); }, s)); }, c = () => { clearInterval(e), e = void 0; }, i = () => { n = t.time, r.value = m(n, t.format); }; return u( () => t.isStart, (o) => { o && d(); }, { immediate: !0 } ), u( () => t.isSuspend, (o) => { o && c(); } ), u( () => t.isReset, (o) => { o && i(); } ), i(), { formatAfter: r }; }; export { w as useCountdown };