文件操作 - useUnsplashImages.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/extendify/src/Draft/hooks/useUnsplashImages.js
编辑文件内容
import { fetchImages } from '@shared/lib/unsplash'; import { useUnsplashCacheStore } from '@shared/state/unsplash-cache'; import useSWRImmutable from 'swr/immutable'; const searchImages = async (search, source = null) => { const cache = useUnsplashCacheStore.getState(); if (search === 'unsplash' && !cache.isEmpty() && !cache.hasExpired()) { return cache.images; } return await fetchImages(search, source); }; export const useUnsplashImages = (search, source = null) => { const key = search || 'unsplash'; const { data, error } = useSWRImmutable(key, () => searchImages(key, source)); return { data, error, loading: !data && !error }; };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件