commit | author | age
|
f9c38e
|
1 |
import Mock from 'mockjs2' |
I |
2 |
import { builder, getQueryParameters } from '../util' |
|
3 |
|
|
4 |
const titles = [ |
|
5 |
'Alipay', |
|
6 |
'Angular', |
|
7 |
'Ant Design', |
|
8 |
'XiaoNuo', |
|
9 |
'Bootstrap', |
|
10 |
'React', |
|
11 |
'Vue', |
|
12 |
'Webpack' |
|
13 |
] |
|
14 |
|
|
15 |
const avatar = ['https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', |
|
16 |
'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', |
|
17 |
'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', |
|
18 |
'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', |
|
19 |
'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png' |
|
20 |
] |
|
21 |
|
|
22 |
const covers = [ |
|
23 |
'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', |
|
24 |
'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', |
|
25 |
'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', |
|
26 |
'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png' |
|
27 |
] |
|
28 |
|
|
29 |
const owner = [ |
|
30 |
'付小小', |
|
31 |
'吴加好', |
|
32 |
'周星星', |
|
33 |
'林东东', |
|
34 |
'曲丽丽' |
|
35 |
] |
|
36 |
|
|
37 |
const content = '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。' |
|
38 |
const description = '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。' |
|
39 |
const href = 'https://ant.design' |
|
40 |
|
|
41 |
const article = (options) => { |
|
42 |
const queryParameters = getQueryParameters(options) |
|
43 |
console.log('queryParameters', queryParameters) |
|
44 |
if (queryParameters && !queryParameters.count) { |
|
45 |
queryParameters.count = 5 |
|
46 |
} |
|
47 |
const data = [] |
|
48 |
for (let i = 0; i < queryParameters.count; i++) { |
|
49 |
const tmpKey = i + 1 |
|
50 |
const num = parseInt(Math.random() * (4 + 1), 10) |
|
51 |
data.push({ |
|
52 |
id: tmpKey, |
|
53 |
avatar: avatar[num], |
|
54 |
owner: owner[num], |
|
55 |
content: content, |
|
56 |
star: Mock.mock('@integer(1, 999)'), |
|
57 |
percent: Mock.mock('@integer(1, 999)'), |
|
58 |
like: Mock.mock('@integer(1, 999)'), |
|
59 |
message: Mock.mock('@integer(1, 999)'), |
|
60 |
description: description, |
|
61 |
href: href, |
|
62 |
title: titles[ i % 8 ], |
|
63 |
updatedAt: Mock.mock('@datetime'), |
|
64 |
members: [ |
|
65 |
{ |
|
66 |
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', |
|
67 |
name: '曲丽丽', |
|
68 |
id: 'member1' |
|
69 |
}, |
|
70 |
{ |
|
71 |
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', |
|
72 |
name: '王昭君', |
|
73 |
id: 'member2' |
|
74 |
}, |
|
75 |
{ |
|
76 |
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', |
|
77 |
name: '董娜娜', |
|
78 |
id: 'member3' |
|
79 |
} |
|
80 |
], |
|
81 |
activeUser: Math.ceil(Math.random() * 100000) + 100000, |
|
82 |
newUser: Math.ceil(Math.random() * 1000) + 1000, |
|
83 |
cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)] |
|
84 |
}) |
|
85 |
} |
|
86 |
return builder(data) |
|
87 |
} |
|
88 |
|
|
89 |
Mock.mock(/\/list\/article/, 'get', article) |