notices.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. const fakeNotices = [
  2. {
  3. id: '000000001',
  4. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
  5. title: '你收到了 14 份新周报',
  6. datetime: '2017-08-09',
  7. type: 'notification',
  8. },
  9. {
  10. id: '000000002',
  11. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
  12. title: '你推荐的 曲妮妮 已通过第三轮面试',
  13. datetime: '2017-08-08',
  14. type: 'notification',
  15. },
  16. {
  17. id: '000000003',
  18. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
  19. title: '这种模板可以区分多种通知类型',
  20. datetime: '2017-08-07',
  21. read: true,
  22. type: 'notification',
  23. },
  24. {
  25. id: '000000004',
  26. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
  27. title: '左侧图标用于区分不同的类型',
  28. datetime: '2017-08-07',
  29. type: 'notification',
  30. },
  31. {
  32. id: '000000005',
  33. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
  34. title: '内容不要超过两行字,超出时自动截断',
  35. datetime: '2017-08-07',
  36. type: 'notification',
  37. },
  38. {
  39. id: '000000006',
  40. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  41. title: '曲丽丽 评论了你',
  42. description: '描述信息描述信息描述信息',
  43. datetime: '2017-08-07',
  44. type: 'message',
  45. clickClose: true,
  46. },
  47. {
  48. id: '000000007',
  49. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  50. title: '朱偏右 回复了你',
  51. description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
  52. datetime: '2017-08-07',
  53. type: 'message',
  54. clickClose: true,
  55. },
  56. {
  57. id: '000000008',
  58. avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
  59. title: '标题',
  60. description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
  61. datetime: '2017-08-07',
  62. type: 'message',
  63. clickClose: true,
  64. },
  65. {
  66. id: '000000009',
  67. title: '任务名称',
  68. description: '任务需要在 2017-01-12 20:00 前启动',
  69. extra: '未开始',
  70. status: 'todo',
  71. type: 'event',
  72. },
  73. {
  74. id: '000000010',
  75. title: '第三方紧急代码变更',
  76. description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
  77. extra: '马上到期',
  78. status: 'urgent',
  79. type: 'event',
  80. },
  81. {
  82. id: '000000011',
  83. title: '信息安全考试',
  84. description: '指派竹尔于 2017-01-09 前完成更新并发布',
  85. extra: '已耗时 8 天',
  86. status: 'doing',
  87. type: 'event',
  88. },
  89. {
  90. id: '000000012',
  91. title: 'ABCD 版本发布',
  92. description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
  93. extra: '进行中',
  94. status: 'processing',
  95. type: 'event',
  96. },
  97. ];
  98. const getNotices = (req, res) => {
  99. if (req.query && req.query.type) {
  100. const startFrom = parseInt(req.query.lastItemId, 10) + 1;
  101. const result = fakeNotices
  102. .filter(({ type }) => type === req.query.type)
  103. .map((notice, index) => ({
  104. ...notice,
  105. id: `0000000${startFrom + index}`,
  106. }));
  107. return res.json(startFrom > 24 ? result.concat(null) : result);
  108. }
  109. return res.json(fakeNotices);
  110. };
  111. export default {
  112. 'GET /api/notices': getNotices,
  113. };