mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
build(deps): 更新依赖
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { ref, computed } from 'vue';
|
||||
import useBoolean from '../common/useBoolean';
|
||||
|
||||
/**
|
||||
* 倒计时
|
||||
@ -10,6 +11,8 @@ export default function useCountDown(second: number) {
|
||||
}
|
||||
const counts = ref(0);
|
||||
const isCounting = computed(() => Boolean(counts.value));
|
||||
// 完成一轮倒计时
|
||||
const { bool: isComplete, setTrue, setFalse } = useBoolean(false);
|
||||
|
||||
let intervalId: any;
|
||||
|
||||
@ -19,11 +22,13 @@ export default function useCountDown(second: number) {
|
||||
*/
|
||||
function start(updateSecond: number = second) {
|
||||
if (!counts.value) {
|
||||
setFalse();
|
||||
counts.value = updateSecond;
|
||||
intervalId = setInterval(() => {
|
||||
counts.value -= 1;
|
||||
if (counts.value <= 0) {
|
||||
clearInterval(intervalId);
|
||||
setTrue();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
@ -41,6 +46,7 @@ export default function useCountDown(second: number) {
|
||||
counts,
|
||||
isCounting,
|
||||
start,
|
||||
stop
|
||||
stop,
|
||||
isComplete
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user