Spring774
2025-10-30 a972605e1cf8122330de5b6ff53857be130972be
assets/Script/Global.ts
@@ -163,4 +163,20 @@
        });
    }
    private static debounceStates: { [key: string]: boolean } = {};
    private static debounceTimer: { [key: string]: number } = {};
    //防快速点击函数
    static debounceClicks = (callback: () => void, identifier = 'default', delay = 1000) => {
        return () => {
            if (!Global.debounceStates[identifier]) {
                Global.debounceStates[identifier] = true;
                Global.debounceTimer[identifier] = setTimeout(() => {
                    Global.debounceStates[identifier] = false;
                    clearTimeout(Global.debounceTimer[identifier]);
                }, delay);
                callback();
            }
        };
    };
}