|
@@ -8,22 +8,21 @@
|
|
|
</Button>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, ref, PropType } from 'vue';
|
|
|
+ import { defineComponent, ref, PropType, watchEffect } from 'vue';
|
|
|
|
|
|
import { Button } from 'ant-design-vue';
|
|
|
|
|
|
import { useCountdown } from './useCountdown';
|
|
|
import { isFunction } from '/@/utils/is';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import { propTypes } from '/@/utils/propTypes';
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'CountButton',
|
|
|
components: { Button },
|
|
|
props: {
|
|
|
- count: {
|
|
|
- type: Number,
|
|
|
- default: 60,
|
|
|
- },
|
|
|
+ value: propTypes.string,
|
|
|
+ count: propTypes.number.def(60),
|
|
|
beforeStartFunc: {
|
|
|
type: Function as PropType<() => boolean>,
|
|
|
default: null,
|
|
@@ -32,8 +31,12 @@
|
|
|
setup(props) {
|
|
|
const loading = ref(false);
|
|
|
|
|
|
- const { currentCount, isStart, start } = useCountdown(props.count);
|
|
|
+ const { currentCount, isStart, start, reset } = useCountdown(props.count);
|
|
|
const { t } = useI18n();
|
|
|
+
|
|
|
+ watchEffect(() => {
|
|
|
+ props.value === undefined && reset();
|
|
|
+ });
|
|
|
/**
|
|
|
* @description: Judge whether there is an external function before execution, and decide whether to start after execution
|
|
|
*/
|