MCPcopy Create free account
hub / github.com/baiwumm/react-admin / getRandomImg

Function getRandomImg

Xmw_web/src/utils/index.ts:253–265  ·  view source on GitHub ↗
(size = 1)

Source from the content-addressed store, hash-verified

251 * @description: 获取 /assets/img 路径下随机图片
252 */
253export const getRandomImg = (size = 1) => {
254 if (!isInteger(size) || size < 1) {
255 return message.warning('参数必须是一个正整数!');
256 }
257 // 匹配该目录下所有的图片
258 const images: string[] = [];
259 for (let i = 1; i <= 20; i += 1) {
260 images.push(`/images/${i}.jpg`);
261 }
262 // 获取图片集合
263 const result = sampleSize(images, size);
264 return result.length === 1 ? result[0] : result;
265};
266
267
268/**

Callers 13

CaptchaFunction · 0.90
resetRotateCaptchaRefFunction · 0.90
getRandomImgSrcFunction · 0.90
LazyloadFunction · 0.90
ColorthiefFunction · 0.90
ThumbnailSwiperFunction · 0.90
CardsSwiperFunction · 0.90
CoverflowSwiperFunction · 0.90
FlipSwiperFunction · 0.90
CubeSwiperFunction · 0.90
VisualSwiperFunction · 0.90
CreativeSwiperFunction · 0.90

Calls 1

warningMethod · 0.80

Tested by

no test coverage detected