export default {
  bind(el, binding) {
    const debounce = (func, delay) => {
      let timer;
      return function (...args) {
        clearTimeout(timer);
        timer = setTimeout(() => func.apply(this, args), delay);
      };
    };

    el.addEventListener('click', debounce(() => {
      binding.value();
    }, binding.arg || 300)); // 默认延迟300ms
  },
  unbind(el) {
    el.removeEventListener('click', el._debounceClick);
  },
};
