细节优化

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,3 +1,20 @@
export const debounce = (fn, delay = 300) => {
let timer = null;
return async (...args) => {
if (timer) clearTimeout(timer);
return new Promise((resolve) => {
timer = setTimeout(async () => {
try {
const result = await fn(...args);
resolve(result);
} finally {
timer = null;
}
}, delay);
});
};
};
export function renderScores(ctx, arrows = []) {
let rowIndex = 0;
arrows.forEach((item, i) => {