api.js 7.5 KB

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