Przeglądaj źródła

remove .umirc.mock.js

愚道 7 lat temu
rodzic
commit
3b202a8a22
8 zmienionych plików z 37 dodań i 61 usunięć
  1. 0 0
      mock/.gitkeep
  2. 19 11
      mock/api.js
  3. 2 2
      mock/chart.js
  4. 4 4
      mock/geographic.js
  5. 3 2
      mock/notices.js
  6. 4 4
      mock/profile.js
  7. 4 4
      mock/rule.js
  8. 1 34
      .umirc.mock.js

+ 0 - 0
mock/.gitkeep


+ 19 - 11
mock/api.js

@@ -1,3 +1,5 @@
+import mockjs from 'mockjs';
+
 const titles = [
   'Alipay',
   'Angular',
@@ -59,7 +61,7 @@ const user = [
   '仲尼',
 ];
 
-export function fakeList(count) {
+function fakeList(count) {
   const list = [];
   for (let i = 0; i < count; i += 1) {
     list.push({
@@ -109,7 +111,7 @@ export function fakeList(count) {
 
 let sourceData;
 
-export function getFakeList(req, res) {
+function getFakeList(req, res) {
   const params = req.query;
 
   const count = params.count * 1 || 20;
@@ -124,7 +126,7 @@ export function getFakeList(req, res) {
   }
 }
 
-export function postFakeList(req, res) {
+function postFakeList(req, res) {
   const { /* url = '', */ body } = req;
   // const params = getUrlParams(url);
   const { method, id } = body;
@@ -160,7 +162,7 @@ export function postFakeList(req, res) {
   }
 }
 
-export const getNotice = [
+const getNotice = [
   {
     id: 'xxx1',
     title: titles[0],
@@ -223,7 +225,7 @@ export const getNotice = [
   },
 ];
 
-export const getActivities = [
+const getActivities = [
   {
     id: 'trend-1',
     updatedAt: new Date(),
@@ -324,7 +326,7 @@ export const getActivities = [
   },
 ];
 
-export function getFakeCaptcha(req, res) {
+function getFakeCaptcha(req, res) {
   if (res && res.json) {
     res.json('captcha-xxx');
   } else {
@@ -333,9 +335,15 @@ export function getFakeCaptcha(req, res) {
 }
 
 export default {
-  getNotice,
-  getActivities,
-  getFakeList,
-  postFakeList,
-  getFakeCaptcha,
+  'GET /api/project/notice': getNotice,
+  'GET /api/activities': getActivities,
+  'POST /api/forms': (req, res) => {
+    res.send({ message: 'Ok' });
+  },
+  'GET /api/tags': mockjs.mock({
+    'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }],
+  }),
+  'GET /api/fake_list': getFakeList,
+  'POST /api/fake_list': postFakeList,
+  'GET /api/captcha': getFakeCaptcha,
 };

+ 2 - 2
mock/chart.js

@@ -179,7 +179,7 @@ radarOriginData.forEach(item => {
   });
 });
 
-export const getFakeChartData = {
+const getFakeChartData = {
   visitData,
   visitData2,
   salesData,
@@ -193,5 +193,5 @@ export const getFakeChartData = {
 };
 
 export default {
-  getFakeChartData,
+  'GET /api/fake_chart_data': getFakeChartData,
 };

+ 4 - 4
mock/geographic.js

@@ -1,15 +1,15 @@
 import city from './geographic/city.json';
 import province from './geographic/province.json';
 
-export function getProvince(req, res) {
+function getProvince(req, res) {
   res.json(province);
 }
 
-export function getCity(req, res) {
+function getCity(req, res) {
   res.json(city[req.params.province]);
 }
 
 export default {
-  getProvince,
-  getCity,
+  'GET /api/geographic/province': getProvince,
+  'GET /api/geographic/city/:province': getCity,
 };

+ 3 - 2
mock/notices.js

@@ -1,4 +1,4 @@
-export const getNotices = (req, res) => {
+const getNotices = (req, res) => {
   res.json([
     {
       id: '000000001',
@@ -94,6 +94,7 @@ export const getNotices = (req, res) => {
     },
   ]);
 };
+
 export default {
-  getNotices,
+  'GET /api/notices': getNotices,
 };

+ 4 - 4
mock/profile.js

@@ -141,18 +141,18 @@ const advancedOperation3 = [
   },
 ];
 
-export const getProfileBasicData = {
+const getProfileBasicData = {
   basicGoods,
   basicProgress,
 };
 
-export const getProfileAdvancedData = {
+const getProfileAdvancedData = {
   advancedOperation1,
   advancedOperation2,
   advancedOperation3,
 };
 
 export default {
-  getProfileBasicData,
-  getProfileAdvancedData,
+  'GET /api/profile/advanced': getProfileAdvancedData,
+  'GET /api/profile/basic': getProfileBasicData,
 };

+ 4 - 4
mock/rule.js

@@ -23,7 +23,7 @@ for (let i = 0; i < 46; i += 1) {
   });
 }
 
-export function getRule(req, res, u) {
+function getRule(req, res, u) {
   let url = u;
   if (!url || Object.prototype.toString.call(url) !== '[object String]') {
     url = req.url; // eslint-disable-line
@@ -79,7 +79,7 @@ export function getRule(req, res, u) {
   }
 }
 
-export function postRule(req, res, u, b) {
+function postRule(req, res, u, b) {
   let url = u;
   if (!url || Object.prototype.toString.call(url) !== '[object String]') {
     url = req.url; // eslint-disable-line
@@ -141,6 +141,6 @@ export function postRule(req, res, u, b) {
 }
 
 export default {
-  getRule,
-  postRule,
+  'GET /api/rule': getRule,
+  'POST /api/rule': postRule,
 };

+ 1 - 34
.umirc.mock.js

@@ -1,17 +1,5 @@
-import mockjs from 'mockjs';
-import { getRule, postRule } from './mock/rule';
-import { getActivities, getNotice, getFakeList, postFakeList, getFakeCaptcha } from './mock/api';
-import { getFakeChartData } from './mock/chart';
-import { getProfileBasicData } from './mock/profile';
-import { getProfileAdvancedData } from './mock/profile';
-import { getNotices } from './mock/notices';
-import { getProvince, getCity } from './mock/geographic';
-
-// 是否禁用代理
-const noProxy = process.env.NO_PROXY === 'true';
-
 // 代码中会兼容本地 service mock 以及部署站点的静态数据
-const proxy = {
+export default {
   // 支持值为 Object 和 Array
   'GET /api/currentUser': {
     name: 'Serati Ma',
@@ -83,21 +71,6 @@ const proxy = {
       address: 'Sidney No. 1 Lake Park',
     },
   ],
-  'GET /api/project/notice': getNotice,
-  'GET /api/activities': getActivities,
-  'GET /api/rule': getRule,
-  'POST /api/rule': postRule,
-  'POST /api/forms': (req, res) => {
-    res.send({ message: 'Ok' });
-  },
-  'GET /api/tags': mockjs.mock({
-    'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }],
-  }),
-  'GET /api/fake_list': getFakeList,
-  'POST /api/fake_list': postFakeList,
-  'GET /api/fake_chart_data': getFakeChartData,
-  'GET /api/profile/basic': getProfileBasicData,
-  'GET /api/profile/advanced': getProfileAdvancedData,
   'POST /api/login/account': (req, res) => {
     const { password, userName, type } = req.body;
     if (password === '888888' && userName === 'admin') {
@@ -125,7 +98,6 @@ const proxy = {
   'POST /api/register': (req, res) => {
     res.send({ status: 'ok', currentAuthority: 'user' });
   },
-  'GET /api/notices': getNotices,
   'GET /api/500': (req, res) => {
     res.status(500).send({
       timestamp: 1513932555104,
@@ -162,9 +134,4 @@ const proxy = {
       path: '/base/category/list',
     });
   },
-  'GET /api/geographic/province': getProvince,
-  'GET /api/geographic/city/:province': getCity,
-  'GET /api/captcha': getFakeCaptcha,
 };
-
-export default (noProxy ? {} : proxy);