正在显示
5 个修改的文件
包含
9 行增加
和
99 行删除
... | ... | @@ -84,7 +84,7 @@ const getNotice = [ |
84 | 84 | |
85 | 85 | export default { |
86 | 86 | // 支持值为 Object 和 Array |
87 | - 'GET /api/currentUser': { | |
87 | + 'GET /api/BLOCK_NAME/currentUser': { | |
88 | 88 | name: 'Serati Ma', |
89 | 89 | avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', |
90 | 90 | userid: '00000001', |
... | ... | @@ -135,88 +135,4 @@ export default { |
135 | 135 | address: '西湖区工专路 77 号', |
136 | 136 | phone: '0752-268888888', |
137 | 137 | }, |
138 | - // GET POST 可省略 | |
139 | - 'GET /api/users': [ | |
140 | - { | |
141 | - key: '1', | |
142 | - name: 'John Brown', | |
143 | - age: 32, | |
144 | - address: 'New York No. 1 Lake Park', | |
145 | - }, | |
146 | - { | |
147 | - key: '2', | |
148 | - name: 'Jim Green', | |
149 | - age: 42, | |
150 | - address: 'London No. 1 Lake Park', | |
151 | - }, | |
152 | - { | |
153 | - key: '3', | |
154 | - name: 'Joe Black', | |
155 | - age: 32, | |
156 | - address: 'Sidney No. 1 Lake Park', | |
157 | - }, | |
158 | - ], | |
159 | - 'POST /api/login/account': (req, res) => { | |
160 | - const { password, userName, type } = req.body; | |
161 | - if (password === 'ant.design' && userName === 'admin') { | |
162 | - res.send({ | |
163 | - status: 'ok', | |
164 | - type, | |
165 | - currentAuthority: 'admin', | |
166 | - }); | |
167 | - return; | |
168 | - } | |
169 | - if (password === 'ant.design' && userName === 'user') { | |
170 | - res.send({ | |
171 | - status: 'ok', | |
172 | - type, | |
173 | - currentAuthority: 'user', | |
174 | - }); | |
175 | - return; | |
176 | - } | |
177 | - res.send({ | |
178 | - status: 'error', | |
179 | - type, | |
180 | - currentAuthority: 'guest', | |
181 | - }); | |
182 | - }, | |
183 | - 'POST /api/register': (req, res) => { | |
184 | - res.send({ status: 'ok', currentAuthority: 'user' }); | |
185 | - }, | |
186 | - 'GET /api/500': (req, res) => { | |
187 | - res.status(500).send({ | |
188 | - timestamp: 1513932555104, | |
189 | - status: 500, | |
190 | - error: 'error', | |
191 | - message: 'error', | |
192 | - path: '/base/category/list', | |
193 | - }); | |
194 | - }, | |
195 | - 'GET /api/404': (req, res) => { | |
196 | - res.status(404).send({ | |
197 | - timestamp: 1513932643431, | |
198 | - status: 404, | |
199 | - error: 'Not Found', | |
200 | - message: 'No message available', | |
201 | - path: '/base/category/list/2121212', | |
202 | - }); | |
203 | - }, | |
204 | - 'GET /api/403': (req, res) => { | |
205 | - res.status(403).send({ | |
206 | - timestamp: 1513932555104, | |
207 | - status: 403, | |
208 | - error: 'Unauthorized', | |
209 | - message: 'Unauthorized', | |
210 | - path: '/base/category/list', | |
211 | - }); | |
212 | - }, | |
213 | - 'GET /api/401': (req, res) => { | |
214 | - res.status(401).send({ | |
215 | - timestamp: 1513932555104, | |
216 | - status: 401, | |
217 | - error: 'Unauthorized', | |
218 | - message: 'Unauthorized', | |
219 | - path: '/base/category/list', | |
220 | - }); | |
221 | - }, | |
222 | 138 | }; |
... | ... |
... | ... | @@ -3,7 +3,6 @@ import { connect } from 'dva'; |
3 | 3 | import Link from 'umi/link'; |
4 | 4 | import { Card, Row, Col, Icon, Avatar, Tag, Divider, Input } from 'antd'; |
5 | 5 | import styles from './Center.less'; |
6 | -// import router from 'umi/router'; | |
7 | 6 | |
8 | 7 | const operationTabList = [ |
9 | 8 | { |
... | ... | @@ -32,9 +31,9 @@ const operationTabList = [ |
32 | 31 | }, |
33 | 32 | ]; |
34 | 33 | |
35 | -@connect(({ loading, user }) => ({ | |
36 | - currentUser: user.currentUser, | |
37 | - currentUserLoading: loading.effects['user/fetchCurrent'], | |
34 | +@connect(({ loading, BLOCK_NAME }) => ({ | |
35 | + currentUser: BLOCK_NAME.currentUser, | |
36 | + currentUserLoading: loading.effects['BLOCK_NAME/fetchCurrent'], | |
38 | 37 | })) |
39 | 38 | class Center extends PureComponent { |
40 | 39 | static getDerivedStateFromProps(props, state) { |
... | ... | @@ -59,7 +58,7 @@ class Center extends PureComponent { |
59 | 58 | componentDidMount() { |
60 | 59 | const { dispatch } = this.props; |
61 | 60 | dispatch({ |
62 | - type: 'user/fetchCurrent', | |
61 | + type: 'BLOCK_NAME/fetchCurrent', | |
63 | 62 | }); |
64 | 63 | } |
65 | 64 | |
... | ... |
1 | 1 | import request from 'umi-request'; |
2 | 2 | |
3 | 3 | export async function query() { |
4 | - return request('/api/users'); | |
4 | + return request('/api/BLOCK_NAME/users'); | |
5 | 5 | } |
6 | 6 | |
7 | 7 | export async function queryCurrent() { |
8 | - return request('/api/currentUser'); | |
8 | + return request('/api/BLOCK_NAME/currentUser'); | |
9 | 9 | } |
... | ... |
请
注册
或
登录
后发表评论