山西督察-superintend-distribute-web react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
3.5 KiB

  1. const waitTime = (time = 100) =>
  2. new Promise(resolve => {
  3. setTimeout(() => {
  4. resolve(true);
  5. }, time);
  6. });
  7. async function getFakeCaptcha(req, res) {
  8. await waitTime(2000);
  9. return res.json('captcha-xxx');
  10. } // 代码中会兼容本地 service mock 以及部署站点的静态数据
  11. export default {
  12. // 支持值为 Object 和 Array
  13. 'GET /api/currentUser': {
  14. name: 'Serati Ma',
  15. avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
  16. userid: '00000001',
  17. email: 'antdesign@alipay.com',
  18. signature: '海纳百川,有容乃大',
  19. title: '交互专家',
  20. group: '蚂蚁集团-某某某事业群-某某平台部-某某技术部-UED',
  21. tags: [
  22. {
  23. key: '0',
  24. label: '很有想法的',
  25. },
  26. {
  27. key: '1',
  28. label: '专注设计',
  29. },
  30. {
  31. key: '2',
  32. label: '辣~',
  33. },
  34. {
  35. key: '3',
  36. label: '大长腿',
  37. },
  38. {
  39. key: '4',
  40. label: '川妹子',
  41. },
  42. {
  43. key: '5',
  44. label: '海纳百川',
  45. },
  46. ],
  47. notifyCount: 12,
  48. unreadCount: 11,
  49. country: 'China',
  50. geographic: {
  51. province: {
  52. label: '浙江省',
  53. key: '330000',
  54. },
  55. city: {
  56. label: '杭州市',
  57. key: '330100',
  58. },
  59. },
  60. address: '西湖区工专路 77 号',
  61. phone: '0752-268888888',
  62. },
  63. // GET POST 可省略
  64. 'GET /api/users': [
  65. {
  66. key: '1',
  67. name: 'John Brown',
  68. age: 32,
  69. address: 'New York No. 1 Lake Park',
  70. },
  71. {
  72. key: '2',
  73. name: 'Jim Green',
  74. age: 42,
  75. address: 'London No. 1 Lake Park',
  76. },
  77. {
  78. key: '3',
  79. name: 'Joe Black',
  80. age: 32,
  81. address: 'Sidney No. 1 Lake Park',
  82. },
  83. ],
  84. 'POST /api/login/account': async (req, res) => {
  85. const { password, userName, type } = req.body;
  86. await waitTime(2000);
  87. if (password === 'ant.design' && userName === 'admin') {
  88. res.send({
  89. status: 'ok',
  90. type,
  91. currentAuthority: 'admin',
  92. });
  93. return;
  94. }
  95. if (password === 'ant.design' && userName === 'user') {
  96. res.send({
  97. status: 'ok',
  98. type,
  99. currentAuthority: 'user',
  100. });
  101. return;
  102. }
  103. if (type === 'mobile') {
  104. res.send({
  105. status: 'ok',
  106. type,
  107. currentAuthority: 'admin',
  108. });
  109. return;
  110. }
  111. res.send({
  112. status: 'error',
  113. type,
  114. currentAuthority: 'guest',
  115. });
  116. },
  117. 'POST /api/register': (req, res) => {
  118. res.send({
  119. status: 'ok',
  120. currentAuthority: 'user',
  121. });
  122. },
  123. 'GET /api/500': (req, res) => {
  124. res.status(500).send({
  125. timestamp: 1513932555104,
  126. status: 500,
  127. error: 'error',
  128. message: 'error',
  129. path: '/base/category/list',
  130. });
  131. },
  132. 'GET /api/404': (req, res) => {
  133. res.status(404).send({
  134. timestamp: 1513932643431,
  135. status: 404,
  136. error: 'Not Found',
  137. message: 'No message available',
  138. path: '/base/category/list/2121212',
  139. });
  140. },
  141. 'GET /api/403': (req, res) => {
  142. res.status(403).send({
  143. timestamp: 1513932555104,
  144. status: 403,
  145. error: 'Unauthorized',
  146. message: 'Unauthorized',
  147. path: '/base/category/list',
  148. });
  149. },
  150. 'GET /api/401': (req, res) => {
  151. res.status(401).send({
  152. timestamp: 1513932555104,
  153. status: 401,
  154. error: 'Unauthorized',
  155. message: 'Unauthorized',
  156. path: '/base/category/list',
  157. });
  158. },
  159. 'GET /api/login/captcha': getFakeCaptcha,
  160. };