初始化拉取,原文件名:admin-plus-webpack5
Some checks failed
Call HTTPS API / build (push) Has been cancelled

This commit is contained in:
2025-12-26 20:43:10 +08:00
parent 7c68ec3a42
commit 3e2da1115e
420 changed files with 75413 additions and 2 deletions

39
mock/utils/index.js Normal file
View File

@@ -0,0 +1,39 @@
const fs = require('fs')
const { Random } = require('mockjs')
/**
* @description 随机生成图片url。
* @returns {string}
*/
function handleRandomImage(/* width = 50, height = 50 */) {
//return `https://picsum.photos/${width}/${height}?random=${Random.guid()}`
return (
'https://gcore.jsdelivr.net/gh/' +
'chuzh' +
'ixin/image' +
`/table/vab-image-${Random.integer(1, 38)}.jpg`
)
}
/**
* @description 处理所有 controller 模块npm run serve时在node环境中自动输出controller文件夹下Mock接口请勿修改。
* @returns {[]}
*/
function handleMockArray() {
const getFiles = (path, baseUrl = './controller') => {
const files = fs.readdirSync(path)
return files.flatMap((file) => {
const fPath = `${path}/${file}`
const stat = fs.statSync(fPath)
return stat.isDirectory()
? getFiles(fPath, `${baseUrl}/${file}`)
: `${baseUrl}/${file}`
})
}
return getFiles('mock/controller')
}
module.exports = {
handleRandomImage,
handleMockArray,
}