From 635e362098c8ed251d09e5bef9d8c39a11c831fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 29 Jun 2018 10:38:36 +0800 Subject: [PATCH] Add compilation script --- .gitignore | 2 +- mock/api.js | 7 +++---- mock/rule.js | 7 ++++--- package.json | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index afd3e2c6..e7fefb84 100755 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ jsconfig.json .history *.log -funtction/mock \ No newline at end of file +functions/mock \ No newline at end of file diff --git a/mock/api.js b/mock/api.js index 49450556..a2017094 100644 --- a/mock/api.js +++ b/mock/api.js @@ -127,8 +127,7 @@ export function getFakeList(req, res) { export function postFakeList(req, res) { const { /* url = '', */ body } = req; // const params = getUrlParams(url); - const { method, id, ...restParams } = body; - + const { method, id } = body; // const count = (params.count * 1) || 20; let result = sourceData; @@ -139,13 +138,13 @@ export function postFakeList(req, res) { case 'update': result.forEach((item, i) => { if (item.id === id) { - result[i] = Object.assign(item, restParams); + result[i] = Object.assign(item, body); } }); break; case 'post': result.unshift({ - ...restParams, + body, id: `fake-list-${result.length}`, createdAt: new Date().getTime(), }); diff --git a/mock/rule.js b/mock/rule.js index ec3deeb9..6245b82c 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -31,7 +31,7 @@ export function getRule(req, res, u) { const params = parse(url, true).query; - let dataSource = [...tableListDataSource]; + let dataSource = tableListDataSource; if (params.sorter) { const s = params.sorter.split('_'); @@ -48,7 +48,7 @@ export function getRule(req, res, u) { let filterDataSource = []; status.forEach(s => { filterDataSource = filterDataSource.concat( - [...dataSource].filter(data => parseInt(data.status, 10) === parseInt(s[0], 10)) + dataSource.filter(data => parseInt(data.status, 10) === parseInt(s[0], 10)) ); }); dataSource = filterDataSource; @@ -116,7 +116,8 @@ export function postRule(req, res, u, b) { case 'update': tableListDataSource = tableListDataSource.map(item => { if (item.key === key) { - return { ...item, desc, name }; + Object.assign(item, { desc, name }); + return item; } return item; }); diff --git a/package.json b/package.json index cb2fa9a8..5bd0a6c6 100755 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "cross-env ESLINT=none roadhog dev", "start:no-proxy": "cross-env NO_PROXY=true ESLINT=none roadhog dev", "build": "cross-env ESLINT=none roadhog build", - "site": "npm run build && firebase deploy", + "site": "rollup -c && npm run build && firebase deploy", "analyze": "cross-env ANALYZE=1 roadhog build", "lint:style": "stylelint \"src/**/*.less\" --syntax less", "lint": "eslint --ext .js src mock tests && npm run lint:style", -- GitLab