正在显示
9 个修改的文件
包含
13 行增加
和
112 行删除
@@ -15,11 +15,7 @@ | @@ -15,11 +15,7 @@ | ||
15 | "antd": "^3.10.9", | 15 | "antd": "^3.10.9", |
16 | "classnames": "^2.2.6", | 16 | "classnames": "^2.2.6", |
17 | "dva": "^2.4.0", | 17 | "dva": "^2.4.0", |
18 | - "hash.js": "^1.1.5", | ||
19 | - "mockjs": "*", | ||
20 | "moment": "^2.22.2", | 18 | "moment": "^2.22.2", |
21 | - "nzh": "^1.0.3", | ||
22 | - "qs": "^6.6.0", | ||
23 | "react": "^16.6.3", | 19 | "react": "^16.6.3", |
24 | "umi-request": "^1.0.0" | 20 | "umi-request": "^1.0.0" |
25 | }, | 21 | }, |
1 | -let sourceData; | ||
2 | - | ||
3 | const titles = [ | 1 | const titles = [ |
4 | 'Alipay', | 2 | 'Alipay', |
5 | 'Angular', | 3 | 'Angular', |
@@ -21,19 +19,6 @@ const avatars = [ | @@ -21,19 +19,6 @@ const avatars = [ | ||
21 | 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack | 19 | 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack |
22 | ]; | 20 | ]; |
23 | 21 | ||
24 | -const avatars2 = [ | ||
25 | - 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', | ||
26 | - 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png', | ||
27 | - 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png', | ||
28 | - 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png', | ||
29 | - 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png', | ||
30 | - 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png', | ||
31 | - 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png', | ||
32 | - 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png', | ||
33 | - 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png', | ||
34 | - 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png', | ||
35 | -]; | ||
36 | - | ||
37 | const covers = [ | 22 | const covers = [ |
38 | 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', | 23 | 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', |
39 | 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', | 24 | 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', |
@@ -114,43 +99,9 @@ function getFakeList(req, res) { | @@ -114,43 +99,9 @@ function getFakeList(req, res) { | ||
114 | const count = params.count * 1 || 20; | 99 | const count = params.count * 1 || 20; |
115 | 100 | ||
116 | const result = fakeList(count); | 101 | const result = fakeList(count); |
117 | - sourceData = result; | ||
118 | - return res.json(result); | ||
119 | -} | ||
120 | - | ||
121 | -function postFakeList(req, res) { | ||
122 | - const { /* url = '', */ body } = req; | ||
123 | - // const params = getUrlParams(url); | ||
124 | - const { method, id } = body; | ||
125 | - // const count = (params.count * 1) || 20; | ||
126 | - let result = sourceData; | ||
127 | - | ||
128 | - switch (method) { | ||
129 | - case 'delete': | ||
130 | - result = result.filter(item => item.id !== id); | ||
131 | - break; | ||
132 | - case 'update': | ||
133 | - result.forEach((item, i) => { | ||
134 | - if (item.id === id) { | ||
135 | - result[i] = Object.assign(item, body); | ||
136 | - } | ||
137 | - }); | ||
138 | - break; | ||
139 | - case 'post': | ||
140 | - result.unshift({ | ||
141 | - body, | ||
142 | - id: `fake-list-${result.length}`, | ||
143 | - createdAt: new Date().getTime(), | ||
144 | - }); | ||
145 | - break; | ||
146 | - default: | ||
147 | - break; | ||
148 | - } | ||
149 | - | ||
150 | return res.json(result); | 102 | return res.json(result); |
151 | } | 103 | } |
152 | 104 | ||
153 | export default { | 105 | export default { |
154 | - 'GET /api/fake_list': getFakeList, | ||
155 | - 'POST /api/fake_list': postFakeList, | 106 | + 'GET /api/BLOCK_NAME/fake_list': getFakeList, |
156 | }; | 107 | }; |
@@ -3,8 +3,8 @@ import { connect } from 'dva'; | @@ -3,8 +3,8 @@ import { connect } from 'dva'; | ||
3 | import { Form, Card, Select, List, Tag, Icon, Row, Col, Button } from 'antd'; | 3 | import { Form, Card, Select, List, Tag, Icon, Row, Col, Button } from 'antd'; |
4 | 4 | ||
5 | import TagSelect from 'ant-design-pro/lib/TagSelect'; | 5 | import TagSelect from 'ant-design-pro/lib/TagSelect'; |
6 | -import StandardFormRow from '@/components/StandardFormRow'; | ||
7 | -import ArticleListContent from '@/components/ArticleListContent'; | 6 | +import StandardFormRow from './components/StandardFormRow'; |
7 | +import ArticleListContent from './components/ArticleListContent'; | ||
8 | import styles from './style.less'; | 8 | import styles from './style.less'; |
9 | 9 | ||
10 | const { Option } = Select; | 10 | const { Option } = Select; |
@@ -12,9 +12,9 @@ const FormItem = Form.Item; | @@ -12,9 +12,9 @@ const FormItem = Form.Item; | ||
12 | 12 | ||
13 | const pageSize = 5; | 13 | const pageSize = 5; |
14 | 14 | ||
15 | -@connect(({ list, loading }) => ({ | ||
16 | - list, | ||
17 | - loading: loading.models.list, | 15 | +@connect(({ BLOCK_NAME, loading }) => ({ |
16 | + BLOCK_NAME, | ||
17 | + loading: loading.models.BLOCK_NAME, | ||
18 | })) | 18 | })) |
19 | @Form.create({ | 19 | @Form.create({ |
20 | onValuesChange({ dispatch }, changedValues, allValues) { | 20 | onValuesChange({ dispatch }, changedValues, allValues) { |
@@ -23,7 +23,7 @@ const pageSize = 5; | @@ -23,7 +23,7 @@ const pageSize = 5; | ||
23 | console.log(changedValues, allValues); | 23 | console.log(changedValues, allValues); |
24 | // 模拟查询表单生效 | 24 | // 模拟查询表单生效 |
25 | dispatch({ | 25 | dispatch({ |
26 | - type: 'list/fetch', | 26 | + type: 'BLOCK_NAME/fetch', |
27 | payload: { | 27 | payload: { |
28 | count: 5, | 28 | count: 5, |
29 | }, | 29 | }, |
@@ -34,7 +34,7 @@ class SearchList extends Component { | @@ -34,7 +34,7 @@ class SearchList extends Component { | ||
34 | componentDidMount() { | 34 | componentDidMount() { |
35 | const { dispatch } = this.props; | 35 | const { dispatch } = this.props; |
36 | dispatch({ | 36 | dispatch({ |
37 | - type: 'list/fetch', | 37 | + type: 'BLOCK_NAME/fetch', |
38 | payload: { | 38 | payload: { |
39 | count: 5, | 39 | count: 5, |
40 | }, | 40 | }, |
@@ -51,7 +51,7 @@ class SearchList extends Component { | @@ -51,7 +51,7 @@ class SearchList extends Component { | ||
51 | fetchMore = () => { | 51 | fetchMore = () => { |
52 | const { dispatch } = this.props; | 52 | const { dispatch } = this.props; |
53 | dispatch({ | 53 | dispatch({ |
54 | - type: 'list/appendFetch', | 54 | + type: 'BLOCK_NAME/appendFetch', |
55 | payload: { | 55 | payload: { |
56 | count: pageSize, | 56 | count: pageSize, |
57 | }, | 57 | }, |
@@ -61,7 +61,7 @@ class SearchList extends Component { | @@ -61,7 +61,7 @@ class SearchList extends Component { | ||
61 | render() { | 61 | render() { |
62 | const { | 62 | const { |
63 | form, | 63 | form, |
64 | - list: { list }, | 64 | + BLOCK_NAME: { list }, |
65 | loading, | 65 | loading, |
66 | } = this.props; | 66 | } = this.props; |
67 | const { getFieldDecorator } = form; | 67 | const { getFieldDecorator } = form; |
1 | -import { queryFakeList, removeFakeList, addFakeList, updateFakeList } from './service'; | 1 | +import { queryFakeList } from './service'; |
2 | 2 | ||
3 | export default { | 3 | export default { |
4 | - namespace: 'list', | 4 | + namespace: 'BLOCK_NAME', |
5 | 5 | ||
6 | state: { | 6 | state: { |
7 | list: [], | 7 | list: [], |
@@ -22,19 +22,6 @@ export default { | @@ -22,19 +22,6 @@ export default { | ||
22 | payload: Array.isArray(response) ? response : [], | 22 | payload: Array.isArray(response) ? response : [], |
23 | }); | 23 | }); |
24 | }, | 24 | }, |
25 | - *submit({ payload }, { call, put }) { | ||
26 | - let callback; | ||
27 | - if (payload.id) { | ||
28 | - callback = Object.keys(payload).length === 1 ? removeFakeList : updateFakeList; | ||
29 | - } else { | ||
30 | - callback = addFakeList; | ||
31 | - } | ||
32 | - const response = yield call(callback, payload); // post | ||
33 | - yield put({ | ||
34 | - type: 'queryList', | ||
35 | - payload: response, | ||
36 | - }); | ||
37 | - }, | ||
38 | }, | 25 | }, |
39 | 26 | ||
40 | reducers: { | 27 | reducers: { |
1 | import request from 'umi-request'; | 1 | import request from 'umi-request'; |
2 | 2 | ||
3 | export async function queryFakeList(params) { | 3 | export async function queryFakeList(params) { |
4 | - return request(`/api/fake_list`, { | 4 | + return request(`/api/BLOCK_NAME/fake_list`, { |
5 | params, | 5 | params, |
6 | }); | 6 | }); |
7 | } | 7 | } |
8 | - | ||
9 | -export async function removeFakeList(params) { | ||
10 | - const { count = 5, ...restParams } = params; | ||
11 | - return request(`/api/fake_list?count=${count}`, { | ||
12 | - method: 'POST', | ||
13 | - body: { | ||
14 | - ...restParams, | ||
15 | - method: 'delete', | ||
16 | - }, | ||
17 | - }); | ||
18 | -} | ||
19 | - | ||
20 | -export async function addFakeList(params) { | ||
21 | - const { count = 5, ...restParams } = params; | ||
22 | - return request(`/api/fake_list?count=${count}`, { | ||
23 | - method: 'POST', | ||
24 | - body: { | ||
25 | - ...restParams, | ||
26 | - method: 'post', | ||
27 | - }, | ||
28 | - }); | ||
29 | -} | ||
30 | - | ||
31 | -export async function updateFakeList(params) { | ||
32 | - const { count = 5, ...restParams } = params; | ||
33 | - return request(`/api/fake_list?count=${count}`, { | ||
34 | - method: 'POST', | ||
35 | - body: { | ||
36 | - ...restParams, | ||
37 | - method: 'update', | ||
38 | - }, | ||
39 | - }); | ||
40 | -} |
请
注册
或
登录
后发表评论