feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
import { computed, onScopeDispose, ref } from 'vue'
/** 倒计时(验证码 60s、二维码失效 4:32 等通用) */
export function useCountDown(defaultSeconds = 60) {
const seconds = ref(0)
let timer: ReturnType<typeof setInterval> | null = null
const isCounting = computed(() => seconds.value > 0)
function start(total: number = defaultSeconds): void {
reset()
seconds.value = total
timer = setInterval(() => {
seconds.value -= 1
if (seconds.value <= 0) {
reset()
}
}, 1000)
}
function reset(): void {
if (timer !== null) {
clearInterval(timer)
timer = null
}
seconds.value = 0
}
onScopeDispose(reset)
return { seconds, isCounting, start, reset }
}