chore: refactor countdown logic and update utils4u auto imports
Some checks failed
/ build-and-deploy-to-vercel (push) Has been cancelled
/ depcheck (push) Successful in 1m42s
/ surge (push) Successful in 39s
/ playwright (push) Successful in 2m34s

This commit is contained in:
严浩
2025-02-08 10:39:36 +08:00
parent 1d5a387ae0
commit c465fd6fec
2 changed files with 12 additions and 3 deletions

View File

@ -9,7 +9,7 @@
</template>
<script setup lang="ts">
const { countdownTime, triggerCountdown, isCounting } = useCountdown($__DEV__ ? 5 : 60);
const { remaining: countdownTime, start: startCountdown, isActive: isCounting } = useCountdown($__DEV__ ? 3 : 60);
const isSending = ref(false);
const sendSms = async () => {
@ -17,7 +17,7 @@ const sendSms = async () => {
isSending.value = true;
try {
await new Promise((resolve) => setTimeout(resolve, 1000));
triggerCountdown();
startCountdown();
ToastService.add({ severity: 'info', summary: '提示', life: 3000, detail: '验证码发送成功' });
} finally {
isSending.value = false;

View File

@ -77,7 +77,16 @@ export function Plugins() {
'@vueuse/core',
VueRouterAutoImports,
unheadVueComposablesImports,
createUtils4uAutoImports(['primevue']),
Object.assign(
createUtils4uAutoImports([
'primevue', // 参考重写 utils4u 的 createUtils4uAutoImports 的逻辑 https://github.com/unplugin/unplugin-auto-import/blob/main/src/presets/vueuse-core.ts
]),
{
'utils4u/vue-use': createUtils4uAutoImports(['primevue'])['utils4u/vue-use'].filter(
(item) => !['useCountdown'].includes(item.toString()), // FIXME: Duplicated imports "useCountdown", the one from "@vueuse/core" has been ignored and "utils4u/vue-use" is used
),
},
),
{
// add any other imports you were relying on
'vue-router/auto': ['useLink'],