From 019074d42c5dbdba5b9c073b0d8cc8471668e819 Mon Sep 17 00:00:00 2001
From: zuiidea
Date: Thu, 13 Oct 2016 01:12:44 +0800
Subject: [PATCH] remove ;
---
mock/users.js | 94 +++++++++++++++----------------
src/components/Example.js | 14 -----
src/components/Users/UserList.jsx | 12 ++--
src/services/example.js | 5 --
src/services/users.js | 12 ++--
src/utils/request.js | 14 ++---
6 files changed, 66 insertions(+), 85 deletions(-)
delete mode 100644 src/components/Example.js
delete mode 100644 src/services/example.js
diff --git a/mock/users.js b/mock/users.js
index e168aa1..eb7bf79 100644
--- a/mock/users.js
+++ b/mock/users.js
@@ -1,10 +1,10 @@
-'use strict';
+'use strict'
-const qs = require('qs');
-const mockjs = require('mockjs');
+const qs = require('qs')
+const mockjs = require('mockjs')
// 数据持久
-let tableListData = {};
+let tableListData = {}
if (!global.tableListData) {
const data = mockjs.mock({
'data|100': [{
@@ -17,43 +17,43 @@ if (!global.tableListData) {
total: 100,
current: 1
}
- });
- tableListData = data;
- global.tableListData = tableListData;
+ })
+ tableListData = data
+ global.tableListData = tableListData
} else {
- tableListData = global.tableListData;
+ tableListData = global.tableListData
}
module.exports = {
'GET /api/users' (req, res) {
- const page = qs.parse(req.query);
- const pageSize = page.pageSize || 10;
- const currentPage = page.page || 1;
+ const page = qs.parse(req.query)
+ const pageSize = page.pageSize || 10
+ const currentPage = page.page || 1
- let data;
- let newPage;
+ let data
+ let newPage
- let newData = tableListData.data.concat();
+ let newData = tableListData.data.concat()
if (page.field) {
const d = newData.filter(function (item) {
- return item[page.field].indexOf(page.keyword) > -1;
- });
+ return item[page.field].indexOf(page.keyword) > -1
+ })
- data = d.slice((currentPage - 1) * pageSize, currentPage * pageSize);
+ data = d.slice((currentPage - 1) * pageSize, currentPage * pageSize)
newPage = {
current: currentPage * 1,
total: d.length
- };
+ }
} else {
- data = tableListData.data.slice((currentPage - 1) * pageSize, currentPage * pageSize);
- tableListData.page.current = currentPage * 1;
+ data = tableListData.data.slice((currentPage - 1) * pageSize, currentPage * pageSize)
+ tableListData.page.current = currentPage * 1
newPage = {
current: tableListData.page.current,
total: tableListData.page.total
- };
+ }
}
@@ -62,69 +62,69 @@ module.exports = {
success: true,
data,
page: newPage
- });
- }, 500);
+ })
+ }, 500)
},
'POST /api/users' (req, res) {
setTimeout(function () {
- const newData = qs.parse(req.body);
+ const newData = qs.parse(req.body)
- newData.id = tableListData.data.length + 1;
- tableListData.data.unshift(newData);
+ newData.id = tableListData.data.length + 1
+ tableListData.data.unshift(newData)
- tableListData.page.total = tableListData.data.length;
- tableListData.page.current = 1;
+ tableListData.page.total = tableListData.data.length
+ tableListData.page.current = 1
- global.tableListData = tableListData;
+ global.tableListData = tableListData
res.json({
success: true,
data: tableListData.data,
page: tableListData.page
- });
- }, 500);
+ })
+ }, 500)
},
'DELETE /api/users' (req, res) {
setTimeout(function () {
- const deleteItem = qs.parse(req.body);
+ const deleteItem = qs.parse(req.body)
tableListData.data = tableListData.data.filter(function (item) {
if (item.id == deleteItem.id) {
- return false;
+ return false
}
- return true;
- });
+ return true
+ })
- tableListData.page.total = tableListData.data.length;
+ tableListData.page.total = tableListData.data.length
- global.tableListData = tableListData;
+ global.tableListData = tableListData
res.json({
success: true,
data: tableListData.data,
page: tableListData.page
- });
- }, 500);
+ })
+ }, 500)
},
'PUT /api/users' (req, res) {
setTimeout(function () {
- const editItem = qs.parse(req.body);
+ const editItem = qs.parse(req.body)
tableListData.data = tableListData.data.map(function (item) {
if (item.id == editItem.id) {
- return editItem;
+ return editItem
}
- return item;
- });
+ return item
+ })
- global.tableListData = tableListData;
+ global.tableListData = tableListData
res.json({
success: true,
data: tableListData.data,
page: tableListData.page
- });
- }, 500);
+ })
+ }, 500)
}
-};
+}
diff --git a/src/components/Example.js b/src/components/Example.js
deleted file mode 100644
index a9bc7a0..0000000
--- a/src/components/Example.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react';
-
-const Example = (props) => {
- return (
-
- Example
-
- );
-};
-
-Example.propTypes = {
-};
-
-export default Example;
diff --git a/src/components/Users/UserList.jsx b/src/components/Users/UserList.jsx
index 3f8a68f..7862673 100644
--- a/src/components/Users/UserList.jsx
+++ b/src/components/Users/UserList.jsx
@@ -1,5 +1,5 @@
-import React, { PropTypes } from 'react';
-import { Table, Popconfirm, Pagination } from 'antd';
+import React, { PropTypes } from 'react'
+import { Table, Popconfirm, Pagination } from 'antd'
function UserList({
total, current, loading, dataSource,
@@ -32,7 +32,7 @@ function UserList({
),
- }];
+ }]
return (
@@ -51,7 +51,7 @@ function UserList({
onChange={onPageChange}
/>
- );
+ )
}
UserList.propTypes = {
@@ -62,6 +62,6 @@ UserList.propTypes = {
loading: PropTypes.any,
total: PropTypes.any,
current: PropTypes.any,
-};
+}
-export default UserList;
+export default UserList
diff --git a/src/services/example.js b/src/services/example.js
deleted file mode 100644
index bbf54e3..0000000
--- a/src/services/example.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import request from '../utils/request';
-
-export async function query() {
- return request('/api/users');
-}
diff --git a/src/services/users.js b/src/services/users.js
index 47126d5..56b20bc 100644
--- a/src/services/users.js
+++ b/src/services/users.js
@@ -1,27 +1,27 @@
-import request from '../utils/request';
-import qs from 'qs';
+import request from '../utils/request'
+import qs from 'qs'
export async function query(params) {
- return request(`/api/users?${qs.stringify(params)}`);
+ return request(`/api/users?${qs.stringify(params)}`)
}
export async function create(params) {
return request('/api/users', {
method: 'post',
body: qs.stringify(params),
- });
+ })
}
export async function remove(params) {
return request('/api/users', {
method: 'delete',
body: qs.stringify(params),
- });
+ })
}
export async function update(params) {
return request('/api/users', {
method: 'put',
body: qs.stringify(params),
- });
+ })
}
diff --git a/src/utils/request.js b/src/utils/request.js
index c808422..242ff4a 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,17 +1,17 @@
-import fetch from 'dva/fetch';
+import fetch from 'dva/fetch'
function parseJSON(response) {
- return response.json();
+ return response.json()
}
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
- return response;
+ return response
}
- const error = new Error(response.statusText);
- error.response = response;
- throw error;
+ const error = new Error(response.statusText)
+ error.response = response
+ throw error
}
/**
@@ -26,5 +26,5 @@ export default function request(url, options) {
.then(checkStatus)
.then(parseJSON)
.then((data) => ({ data }))
- .catch((err) => ({ err }));
+ .catch((err) => ({ err }))
}