feat: 替换mockjs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import config from '@/config/axios/config'
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
import { toAnyString } from '@/utils'
|
||||
import Mock from 'mockjs'
|
||||
|
||||
const { code } = config
|
||||
|
||||
@@ -18,9 +18,10 @@ interface ListProps {
|
||||
title: string
|
||||
content: string
|
||||
importance: number
|
||||
display_time: string
|
||||
display_time: any
|
||||
pageviews: number
|
||||
image_uri: string
|
||||
video_uri?: string
|
||||
}
|
||||
|
||||
interface TreeListProps {
|
||||
@@ -29,111 +30,154 @@ interface TreeListProps {
|
||||
title: string
|
||||
content: string
|
||||
importance: number
|
||||
display_time: string
|
||||
display_time: any
|
||||
image_uri: string
|
||||
pageviews: number
|
||||
children: TreeListProps[]
|
||||
video_uri?: string
|
||||
children?: TreeListProps[]
|
||||
}
|
||||
|
||||
let List: ListProps[] = []
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
List.push(
|
||||
Mock.mock({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(100, 500)',
|
||||
image_uri: Mock.Random.image('@integer(100, 500)x@integer(100, 500)'),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
})
|
||||
)
|
||||
List.push({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
})
|
||||
}
|
||||
|
||||
const treeList: TreeListProps[] = []
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
treeList.push(
|
||||
Mock.mock({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: '@first',
|
||||
title: '@title(5, 10)',
|
||||
content: baseContent,
|
||||
importance: '@integer(1, 3)',
|
||||
display_time: '@datetime',
|
||||
pageviews: '@integer(300, 5000)'
|
||||
}
|
||||
]
|
||||
// image_uri
|
||||
})
|
||||
)
|
||||
treeList.push({
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4',
|
||||
children: [
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
},
|
||||
{
|
||||
id: toAnyString(),
|
||||
// timestamp: +Mock.Random.date('T'),
|
||||
author: faker.person.firstName(),
|
||||
title: faker.lorem.sentence(),
|
||||
content: baseContent,
|
||||
importance: faker.number.int({ min: 1, max: 3 }),
|
||||
display_time: faker.date.anytime(),
|
||||
pageviews: faker.number.int({ min: 300, max: 5000 }),
|
||||
image_uri: faker.image.url({
|
||||
width: faker.number.int({ min: 200, max: 400 }),
|
||||
height: faker.number.int({ min: 200, max: 400 })
|
||||
}),
|
||||
video_uri:
|
||||
'//sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/mp4/xgplayer-demo-720p.mp4'
|
||||
}
|
||||
]
|
||||
// image_uri
|
||||
})
|
||||
}
|
||||
|
||||
export default [
|
||||
|
||||
Reference in New Issue
Block a user