chore: refactor countdown logic and update utils4u auto imports
This commit is contained in:
@ -9,7 +9,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<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 isSending = ref(false);
|
||||||
const sendSms = async () => {
|
const sendSms = async () => {
|
||||||
@ -17,7 +17,7 @@ const sendSms = async () => {
|
|||||||
isSending.value = true;
|
isSending.value = true;
|
||||||
try {
|
try {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
triggerCountdown();
|
startCountdown();
|
||||||
ToastService.add({ severity: 'info', summary: '提示', life: 3000, detail: '验证码发送成功' });
|
ToastService.add({ severity: 'info', summary: '提示', life: 3000, detail: '验证码发送成功' });
|
||||||
} finally {
|
} finally {
|
||||||
isSending.value = false;
|
isSending.value = false;
|
||||||
|
@ -77,7 +77,16 @@ export function Plugins() {
|
|||||||
'@vueuse/core',
|
'@vueuse/core',
|
||||||
VueRouterAutoImports,
|
VueRouterAutoImports,
|
||||||
unheadVueComposablesImports,
|
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
|
// add any other imports you were relying on
|
||||||
'vue-router/auto': ['useLink'],
|
'vue-router/auto': ['useLink'],
|
||||||
|
Reference in New Issue
Block a user