api.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. href: '',
  107. memberLink: '',
  108. },
  109. {
  110. id: 'xxx2',
  111. title: 'Angular',
  112. logo: imgMap.c,
  113. description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  114. updatedAt: new Date('2017-07-24 11:00:00'),
  115. member: '全组都是吴彦祖',
  116. href: '',
  117. memberLink: '',
  118. },
  119. {
  120. id: 'xxx3',
  121. title: 'React',
  122. logo: imgMap.a,
  123. description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  124. updatedAt: new Date(),
  125. member: '中二少女团',
  126. href: '',
  127. memberLink: '',
  128. },
  129. {
  130. id: 'xxx4',
  131. title: 'Ant Design',
  132. logo: imgMap.a,
  133. description: '那时候我只会想自己想要什么,从不想自己拥有什么',
  134. updatedAt: new Date('2017-07-23 06:23:00'),
  135. member: '程序员日常',
  136. href: '',
  137. memberLink: '',
  138. },
  139. {
  140. id: 'xxx5',
  141. title: 'Ant Design Mobile',
  142. logo: imgMap.b,
  143. description: '凛冬将至',
  144. updatedAt: new Date('2017-07-23 06:23:00'),
  145. member: '高逼格设计天团',
  146. href: '',
  147. memberLink: '',
  148. },
  149. {
  150. id: 'xxx6',
  151. title: 'Ant Motion',
  152. logo: imgMap.c,
  153. description: '生命就像一盒巧克力,结果往往出人意料',
  154. updatedAt: new Date('2017-07-23 06:23:00'),
  155. member: '骗你来学计算机',
  156. href: '',
  157. memberLink: '',
  158. },
  159. ];
  160. export const getActivities = [
  161. {
  162. id: 'trend-1',
  163. updatedAt: new Date(),
  164. user: {
  165. name: '林东东',
  166. avatar: imgMap.a,
  167. },
  168. group: {
  169. name: '高逼格设计天团',
  170. link: 'http://github.com/',
  171. },
  172. project: {
  173. name: '六月迭代',
  174. link: 'http://github.com/',
  175. },
  176. template: '在 @{group} 新建项目 @{project}',
  177. },
  178. {
  179. id: 'trend-2',
  180. updatedAt: new Date(),
  181. user: {
  182. name: '付小小',
  183. avatar: imgMap.c,
  184. },
  185. group: {
  186. name: '高逼格设计天团',
  187. link: 'http://github.com/',
  188. },
  189. project: {
  190. name: '六月迭代',
  191. link: 'http://github.com/',
  192. },
  193. template: '在 @{group} 新建项目 @{project}',
  194. },
  195. {
  196. id: 'trend-3',
  197. updatedAt: new Date(),
  198. user: {
  199. name: '曲丽丽',
  200. avatar: imgMap.b,
  201. },
  202. group: {
  203. name: '中二少女团',
  204. link: 'http://github.com/',
  205. },
  206. project: {
  207. name: '六月迭代',
  208. link: 'http://github.com/',
  209. },
  210. template: '在 @{group} 新建项目 @{project}',
  211. },
  212. {
  213. id: 'trend-4',
  214. updatedAt: new Date(),
  215. user: {
  216. name: '周星星',
  217. avatar: imgMap.c,
  218. },
  219. project: {
  220. name: '5 月日常迭代',
  221. link: 'http://github.com/',
  222. },
  223. template: '将 @{project} 更新至已发布状态',
  224. },
  225. {
  226. id: 'trend-5',
  227. updatedAt: new Date(),
  228. user: {
  229. name: '朱偏右',
  230. avatar: imgMap.a,
  231. },
  232. project: {
  233. name: '工程效能',
  234. link: 'http://github.com/',
  235. },
  236. comment: {
  237. name: '留言',
  238. link: 'http://github.com/',
  239. },
  240. template: '在 @{project} 发布了 @{comment}',
  241. },
  242. {
  243. id: 'trend-6',
  244. updatedAt: new Date(),
  245. user: {
  246. name: '乐哥',
  247. avatar: imgMap.d,
  248. },
  249. group: {
  250. name: '程序员日常',
  251. link: 'http://github.com/',
  252. },
  253. project: {
  254. name: '品牌迭代',
  255. link: 'http://github.com/',
  256. },
  257. template: '在 @{group} 新建项目 @{project}',
  258. },
  259. ];
  260. export default {
  261. getNotice,
  262. getActivities,
  263. getFakeList,
  264. };