api.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { imgMap, getUrlParams } from './utils';
  2. export function fakeList(count) {
  3. const titles = [
  4. 'Vue',
  5. 'Ant Design Pro',
  6. 'Bootstrap',
  7. 'Angular',
  8. 'Ant Design',
  9. 'React',
  10. 'Alipay',
  11. 'Ant Design Mobile',
  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/HrxcVbrKnCJOZvtzSqjN.png',
  21. 'https://gw.alipayobjects.com/zos/rmsportal/alaPpKWajEbIYEUvvVNf.png',
  22. 'https://gw.alipayobjects.com/zos/rmsportal/RLwlKSYGSXGHuWSojyvp.png',
  23. 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png',
  24. ];
  25. const desc = [
  26. '那是一种内在的东西, 他们到达不了,也无法触及的',
  27. '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  28. '生命就像一盒巧克力,结果往往出人意料',
  29. '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  30. '那时候我只会想自己想要什么,从不想自己拥有什么',
  31. ];
  32. const user = [
  33. '付小小',
  34. '曲丽丽',
  35. '林东东',
  36. '周星星',
  37. '吴加好',
  38. '朱偏右',
  39. '鱼酱',
  40. '乐哥',
  41. '谭小仪',
  42. '仲尼',
  43. ];
  44. const list = [];
  45. for (let i = 0; i < count; i += 1) {
  46. list.push({
  47. id: `fake-list-${i}`,
  48. owner: user[i % 10],
  49. title: titles[i % 8],
  50. avatar: avatars[i % 4],
  51. cover: (i / 4) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)],
  52. status: ['active', 'exception', 'normal'][i % 3],
  53. percent: Math.ceil(Math.random() * 50) + 50,
  54. logo: ['https://gw.alipayobjects.com/zos/rmsportal/KoJjkdbuTFxzJmmjuDVR.png', 'https://gw.alipayobjects.com/zos/rmsportal/UxGORCvEXJEsxOfEKZiA.png'][i % 2],
  55. href: 'https://ant.design',
  56. updatedAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
  57. createdAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)),
  58. subDescription: desc[i % 5],
  59. description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。',
  60. activeUser: Math.ceil(Math.random() * 100000) + 100000,
  61. newUser: Math.ceil(Math.random() * 1000) + 1000,
  62. star: Math.ceil(Math.random() * 100) + 100,
  63. like: Math.ceil(Math.random() * 100) + 100,
  64. message: Math.ceil(Math.random() * 10) + 10,
  65. content: '段落示意:蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
  66. members: [
  67. {
  68. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
  69. name: '曲丽丽',
  70. },
  71. {
  72. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
  73. name: '王昭君',
  74. },
  75. {
  76. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
  77. name: '董娜娜',
  78. },
  79. ],
  80. });
  81. }
  82. return list;
  83. }
  84. export function getFakeList(req, res, u) {
  85. let url = u;
  86. if (!url || Object.prototype.toString.call(url) !== '[object String]') {
  87. url = req.url; // eslint-disable-line
  88. }
  89. const params = getUrlParams(url);
  90. const count = (params.count * 1) || 20;
  91. const result = fakeList(count);
  92. if (res && res.json) {
  93. res.json(result);
  94. } else {
  95. return result;
  96. }
  97. }
  98. export const getNotice = [
  99. {
  100. id: 'xxx1',
  101. title: 'Vue',
  102. logo: imgMap.b,
  103. description: '那是一种内在的东西, 他们到达不了,也无法触及的',
  104. updatedAt: new Date(),
  105. member: '科学搬砖组',
  106. },
  107. {
  108. id: 'xxx2',
  109. title: 'Angular',
  110. logo: imgMap.c,
  111. description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  112. updatedAt: new Date('2017-07-24 11:00:00'),
  113. member: '全组都是吴彦祖',
  114. },
  115. {
  116. id: 'xxx3',
  117. title: 'React',
  118. logo: imgMap.a,
  119. description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  120. updatedAt: new Date(),
  121. member: '中二少女团',
  122. },
  123. {
  124. id: 'xxx4',
  125. title: 'Ant Design',
  126. logo: imgMap.a,
  127. description: '那时候我只会想自己想要什么,从不想自己拥有什么',
  128. updatedAt: new Date('2017-07-23 06:23:00'),
  129. member: '程序员日常',
  130. },
  131. {
  132. id: 'xxx5',
  133. title: 'Ant Design Mobile',
  134. logo: imgMap.b,
  135. description: '凛冬将至',
  136. updatedAt: new Date('2017-07-23 06:23:00'),
  137. member: '高逼格设计天团',
  138. },
  139. {
  140. id: 'xxx6',
  141. title: 'Ant Motion',
  142. logo: imgMap.c,
  143. description: '生命就像一盒巧克力,结果往往出人意料',
  144. updatedAt: new Date('2017-07-23 06:23:00'),
  145. member: '骗你来学计算机',
  146. },
  147. ];
  148. export const getActivities = [
  149. {
  150. id: 'trend-1',
  151. updatedAt: new Date(),
  152. user: {
  153. name: '林东东',
  154. avatar: imgMap.a,
  155. },
  156. action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  157. },
  158. {
  159. id: 'trend-2',
  160. updatedAt: new Date(),
  161. user: {
  162. name: '付小小',
  163. avatar: imgMap.c,
  164. },
  165. action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  166. },
  167. {
  168. id: 'trend-3',
  169. updatedAt: new Date(),
  170. user: {
  171. name: '曲丽丽',
  172. avatar: imgMap.b,
  173. },
  174. action: '在 [中二少女团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
  175. },
  176. {
  177. id: 'trend-4',
  178. updatedAt: new Date(),
  179. user: {
  180. name: '周星星',
  181. avatar: imgMap.c,
  182. },
  183. action: '在 [5 月日常迭代](http://github.com/) 更新至已发布状态',
  184. },
  185. {
  186. id: 'trend-5',
  187. updatedAt: new Date(),
  188. user: {
  189. name: '朱偏右',
  190. avatar: imgMap.a,
  191. },
  192. action: '在 [工程效能](http://github.com/) 发布了 [留言](http://github.com/)',
  193. },
  194. {
  195. id: 'trend-6',
  196. updatedAt: new Date(),
  197. user: {
  198. name: '乐哥',
  199. avatar: imgMap.d,
  200. },
  201. action: '在 [程序员日常](http://github.com/) 新建项目 [品牌迭代](http://github.com/)',
  202. },
  203. ];
  204. export default {
  205. getNotice,
  206. getActivities,
  207. getFakeList,
  208. };