2019-12-03 18:03:25 +00:00
|
|
|
import Mock from 'mockjs'
|
|
|
|
|
|
|
|
const List = []
|
2020-01-03 12:33:47 +00:00
|
|
|
const count = 10
|
2019-12-03 18:03:25 +00:00
|
|
|
|
|
|
|
const baseContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
|
|
|
|
const image_uri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
|
2020-01-03 12:33:47 +00:00
|
|
|
const titles = [
|
|
|
|
'Special Coffee ☕️☕️☕️',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei',
|
|
|
|
'VR Experience im Vrei'
|
|
|
|
]
|
2019-12-03 18:03:25 +00:00
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
List.push(Mock.mock({
|
2020-01-03 12:33:47 +00:00
|
|
|
id: i * 5 + 5,
|
2020-01-03 18:52:51 +00:00
|
|
|
timestamp: new Date().setDate(20),
|
2019-12-03 18:03:25 +00:00
|
|
|
author: '@first',
|
|
|
|
reviewer: '@first',
|
2020-01-03 12:33:47 +00:00
|
|
|
title: titles[i],
|
2019-12-03 18:03:25 +00:00
|
|
|
content_short: 'mock data',
|
|
|
|
content: baseContent,
|
|
|
|
forecast: '@float(0, 100, 2, 2)',
|
|
|
|
importance: '@integer(1, 3)',
|
|
|
|
'type|1': ['CN', 'US', 'JP', 'EU'],
|
2020-01-03 12:33:47 +00:00
|
|
|
'status|1': ['Aktiv', 'Entwurf', 'Gelöscht'],
|
2019-12-03 18:03:25 +00:00
|
|
|
display_time: '@datetime',
|
|
|
|
comment_disabled: true,
|
|
|
|
pageviews: '@integer(300, 5000)',
|
|
|
|
image_uri,
|
|
|
|
platforms: ['a-platform']
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
|
|
|
|
export default [
|
|
|
|
{
|
|
|
|
url: '/article/list',
|
|
|
|
type: 'get',
|
|
|
|
response: config => {
|
|
|
|
const { importance, type, title, page = 1, limit = 20, sort } = config.query
|
|
|
|
|
|
|
|
let mockList = List.filter(item => {
|
|
|
|
if (importance && item.importance !== +importance) return false
|
|
|
|
if (type && item.type !== type) return false
|
|
|
|
if (title && item.title.indexOf(title) < 0) return false
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
|
|
|
|
if (sort === '-id') {
|
|
|
|
mockList = mockList.reverse()
|
|
|
|
}
|
|
|
|
|
|
|
|
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
|
|
|
|
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: {
|
|
|
|
total: mockList.length,
|
|
|
|
items: pageList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
url: '/article/detail',
|
|
|
|
type: 'get',
|
|
|
|
response: config => {
|
|
|
|
const { id } = config.query
|
|
|
|
for (const article of List) {
|
|
|
|
if (article.id === +id) {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: article
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
url: '/article/pv',
|
|
|
|
type: 'get',
|
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: {
|
|
|
|
pvData: [
|
|
|
|
{ key: 'PC', pv: 1024 },
|
|
|
|
{ key: 'mobile', pv: 1024 },
|
|
|
|
{ key: 'ios', pv: 1024 },
|
|
|
|
{ key: 'android', pv: 1024 }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
url: '/article/create',
|
|
|
|
type: 'post',
|
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: 'success'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
url: '/article/update',
|
|
|
|
type: 'post',
|
|
|
|
response: _ => {
|
|
|
|
return {
|
|
|
|
code: 20000,
|
|
|
|
data: 'success'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|