api.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import { imgMap, getUrlParams } from './utils';
  2. export function fakeList(count) {
  3. const titles = [
  4. 'Vue',
  5. 'AntDesignPro',
  6. 'DesignLab',
  7. 'Angular',
  8. 'AntDesign',
  9. 'React',
  10. 'Alipay',
  11. 'AntDesignMobile',
  12. ];
  13. const avatars = [
  14. 'https://gw.alipayobjects.com/zos/rmsportal/hYjIZrUoBfNxOAYBVDfc.png', // 凤蝶
  15. 'https://gw.alipayobjects.com/zos/rmsportal/HHWPIzPLCLYmVuPivyiA.png', // 云雀
  16. 'https://gw.alipayobjects.com/zos/rmsportal/irqByKtOdKfDojxIWTXF.png', // Basement
  17. 'https://gw.alipayobjects.com/zos/rmsportal/VcmdbCBcwPTGYgbYeMzX.png', // DesignLab
  18. ];
  19. const covers = [
  20. 'https://gw.alipayobjects.com/zos/rmsportal/nQIAJyTLNeVJfUpTskWk.png',
  21. 'https://gw.alipayobjects.com/zos/rmsportal/pnhtvpOTzypPvmHVrfKN.png',
  22. 'https://gw.alipayobjects.com/zos/rmsportal/SVrKVZEFDnhDTNpkplZj.png',
  23. 'https://gw.alipayobjects.com/zos/rmsportal/bUIOUkPTHgfGdDhgsAgE.png',
  24. ];
  25. const list = [];
  26. for (let i = 0; i < count; i += 1) {
  27. list.push({
  28. id: `fake-list-${i}`,
  29. owner: '曲丽丽',
  30. title: titles[i % 8],
  31. avatar: avatars[i % 4],
  32. cover: covers[i % 4],
  33. status: ['active', 'exception', 'normal'][i % 3],
  34. percent: Math.ceil(Math.random() * 50) + 50,
  35. logo: ['https://gw.alipayobjects.com/zos/rmsportal/KoJjkdbuTFxzJmmjuDVR.png', 'https://gw.alipayobjects.com/zos/rmsportal/UxGORCvEXJEsxOfEKZiA.png'][i % 2],
  36. href: 'https://ant.design',
  37. updatedAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
  38. createdAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
  39. subDescription: '一句话描述一句话描述',
  40. description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。',
  41. activeUser: Math.ceil(Math.random() * 100000) + 100000,
  42. newUser: Math.ceil(Math.random() * 1000) + 1000,
  43. star: Math.ceil(Math.random() * 100) + 100,
  44. like: Math.ceil(Math.random() * 100) + 100,
  45. message: Math.ceil(Math.random() * 10) + 10,
  46. content: '段落示意:蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
  47. members: [
  48. {
  49. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
  50. name: '曲丽丽',
  51. },
  52. {
  53. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
  54. name: '王昭君',
  55. },
  56. {
  57. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
  58. name: '董娜娜',
  59. },
  60. ],
  61. });
  62. }
  63. return list;
  64. }
  65. export function getFakeList(req, res, u) {
  66. let url = u;
  67. if (!url || Object.prototype.toString.call(url) !== '[object String]') {
  68. url = req.url; // eslint-disable-line
  69. }
  70. const params = getUrlParams(url);
  71. const count = (params.count * 1) || 20;
  72. const result = fakeList(count);
  73. if (res && res.json) {
  74. res.json(result);
  75. } else {
  76. return result;
  77. }
  78. }
  79. export const getNotice = [
  80. {
  81. id: 'xxx1',
  82. title: '消息列表体验优化',
  83. logo: imgMap.b,
  84. description: '这是一条描述信息这是一条描述信息',
  85. updatedAt: new Date(),
  86. member: '蜂鸟项目组',
  87. },
  88. {
  89. id: 'xxx2',
  90. title: 'XX 平台',
  91. logo: imgMap.c,
  92. description: '这是一条描述信息',
  93. updatedAt: new Date('2017-07-24 11:00:00'),
  94. member: '凤蝶精英小分队',
  95. },
  96. {
  97. id: 'xxx3',
  98. title: '消息列表体验优化',
  99. logo: imgMap.a,
  100. description: '这是一条描述信息这是一条描述信息',
  101. updatedAt: new Date(),
  102. member: '蜂鸟项目组',
  103. },
  104. {
  105. id: 'xxx4',
  106. title: '文档中心1',
  107. logo: imgMap.a,
  108. description: '这是一条描述信息这是一条描述信息',
  109. updatedAt: new Date('2017-07-23 06:23:00'),
  110. member: '成都超级小分队',
  111. },
  112. {
  113. id: 'xxx5',
  114. title: '文档中心2',
  115. logo: imgMap.b,
  116. description: '这是一条描述信息这是一条描述信息',
  117. updatedAt: new Date('2017-07-23 06:23:00'),
  118. member: '成都超级小分队',
  119. },
  120. {
  121. id: 'xxx6',
  122. title: '智能运营中心',
  123. logo: imgMap.c,
  124. description: '这是一条描述信息这是一条描述信息',
  125. updatedAt: new Date('2017-07-23 06:23:00'),
  126. member: '成都小分队',
  127. },
  128. ];
  129. export const getActivities = [
  130. {
  131. id: 'trend-1',
  132. updatedAt: new Date(),
  133. user: {
  134. name: '林东东',
  135. avatar: imgMap.a,
  136. },
  137. action: '在 [凤蝶精英小分队](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  138. },
  139. {
  140. id: 'trend-2',
  141. updatedAt: new Date(),
  142. user: {
  143. name: '林嘻嘻',
  144. avatar: imgMap.c,
  145. },
  146. action: '在 [凤蝶精英小分队](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  147. },
  148. {
  149. id: 'trend-3',
  150. updatedAt: new Date(),
  151. user: {
  152. name: '林囡囡',
  153. avatar: imgMap.b,
  154. },
  155. action: '在 [凤蝶精英小分队](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  156. },
  157. {
  158. id: 'trend-4',
  159. updatedAt: new Date(),
  160. user: {
  161. name: '林贝贝',
  162. avatar: imgMap.c,
  163. },
  164. action: '在 [5 月日常迭代](http://github.com/) 更新至已发布状态',
  165. },
  166. {
  167. id: 'trend-5',
  168. updatedAt: new Date(),
  169. user: {
  170. name: '林忠忠',
  171. avatar: imgMap.a,
  172. },
  173. action: '在 [工程效能](http://github.com/) 发布了 [留言](http://github.com/)',
  174. },
  175. {
  176. id: 'trend-6',
  177. updatedAt: new Date(),
  178. user: {
  179. name: '林呜呜',
  180. avatar: imgMap.d,
  181. },
  182. action: '在 [云雀](http://github.com/) 新建项目 [品牌迭代](http://github.com/)',
  183. },
  184. ];
  185. export default {
  186. getNotice,
  187. getActivities,
  188. getFakeList,
  189. };