?
?
const Mock = require('mockjs')
const moment = require('moment')
const getImage = () => {
const urlArr = [
'http://images.gongzuoshouji.cn/teacher/2021-08-09/84751fbcf153487f868a21a77048d19c.jpg',
'http://images.gongzuoshouji.cn/teacher/20210804/196b0fa5d1726432492ad5edae6a565b.jpg',
'http://images.gongzuoshouji.cn/teacher/20210730/a8e65bfaf7575a051a45b8dedd528af4.jpg',
]
const index = Mock.Random.integer(0, urlArr.length - 1)
return urlArr[index]
}
//初始化好友列表、群列表數(shù)據(jù)
const initFriendsList = () => {
const friendsList = []
const getList = ({type}) => {
let arr = []
for (let i = 0; i < 100; i++) {
const temp = Mock.mock({
name: '@cname',
msg: '@ctitle',
type,
img: getImage() ,
date: moment().subtract(i, 'day').format()
})
arr.push({ ...temp, id: i + 1 })
}
return arr
}
for (let i = 0; i < 4; i++) {
friendsList.push({
type: i + 1 + '',
friends: getList({type: i + 1 + ''})
})
}
return friendsList
}
const friendsList = initFriendsList()
?
?
?
?
?
本文摘自 :https://blog.51cto.com/x