article.js 3.1 KB

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