细节优化

This commit is contained in:
kron
2025-06-22 15:04:10 +08:00
parent bd438e7b62
commit 1e681b46c7
11 changed files with 115 additions and 63 deletions

View File

@@ -1,5 +1,6 @@
<script setup>
import { ref } from "vue";
import { debounce } from "@/util";
const props = defineProps({
width: {
type: String,
@@ -28,15 +29,23 @@ const props = defineProps({
});
const loading = ref(false);
const onBtnClick = async () => {
const timer = ref(null);
const onBtnClick = debounce(async () => {
if (props.disabled || loading.value) return;
loading.value = true;
let loadingTimer = null;
loadingTimer = setTimeout(() => {
loading.value = true;
}, 300);
try {
await props.onClick();
} finally {
clearTimeout(loadingTimer);
loading.value = false;
}
};
});
</script>
<template>