Files
XuJiacheng 9a387f3eec feat: 初始化项目结构并添加基础配置
添加前后端基础项目结构,包括.gitignore、package.json等配置文件
实现前端基础功能模块,包括路由、状态管理、API请求封装等
添加前端UI组件库和样式体系
配置开发环境Mock系统和构建工具链
2026-03-18 14:03:35 +08:00

40 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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,
}