文件操作 - useRateLimitedCursor.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/extendify/src/AutoLaunch/hooks/useRateLimitedCursor.js
编辑文件内容
import { useEffect, useRef } from '@wordpress/element'; export const useRateLimitedCursor = (cb, intervalMs = 2000, deps = []) => { const lastAtRef = useRef(0); const timerRef = useRef(null); useEffect(() => { const schedule = () => { clearTimeout(timerRef.current); const now = Date.now(); const wait = Math.max(0, lastAtRef.current + intervalMs - now); const run = () => { lastAtRef.current = Date.now(); const hasMore = cb(); if (hasMore) schedule(); }; if (wait === 0) run(); else timerRef.current = setTimeout(run, wait); }; schedule(); return () => { clearTimeout(timerRef.current); timerRef.current = null; }; }, [cb, intervalMs, ...deps]); };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件