From 26fba238a054217162964d42f05e68631112995e Mon Sep 17 00:00:00 2001 From: felixpan <1q2w3e4r> Date: Sat, 21 Jan 2017 00:13:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B5=8C=E5=A5=97?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=B3=A8=E9=94=80=E5=A4=B1=E8=B4=A5bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mock/app.js b/mock/app.js index 90d27cf..ce36fa3 100644 --- a/mock/app.js +++ b/mock/app.js @@ -26,8 +26,8 @@ module.exports = { if (d[0].password === userItem.password) { const now = new Date() now.setDate(now.getDate() + 1) - Cookie.set('user_session', now.getTime()) - Cookie.set('user_name', userItem.username) + Cookie.set('user_session', now.getTime(), { path: '/' }) + Cookie.set('user_name', userItem.username, { path: '/' }) response.message = '登录成功' response.success = true } else { @@ -49,8 +49,8 @@ module.exports = { }, 'POST /api/logout' (req, res) { - Cookie.remove('user_session', { path: '' }) - Cookie.remove('user_name', { path: '' }) + Cookie.remove('user_session', { path: '/' }) + Cookie.remove('user_name', { path: '/' }) res.json({ success: true, message: '退出成功' From 91b86a3b6cd1384d5400eb1059b5c115da1f5e44 Mon Sep 17 00:00:00 2001 From: felixpan <1q2w3e4r> Date: Sat, 21 Jan 2017 00:47:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=B8=A6?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E6=90=9C=E7=B4=A2=E6=97=B6=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E8=B7=B3=E8=BD=ACbug;=E6=96=B0=E5=A2=9E=E4=BA=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=E5=90=8E=EF=BC=8C=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E8=AF=B7=E6=B1=82=E6=95=B0=E6=8D=AE=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=B8=A6=E5=85=B3=E9=94=AE=E5=AD=97=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=B8=8E=E9=A1=B5=E7=A0=81=E8=BF=87=E6=BB=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ui/search.js | 4 ++-- src/components/users/search.js | 2 +- src/routes/users.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/ui/search.js b/src/components/ui/search.js index 235d56c..7e89ae2 100644 --- a/src/components/ui/search.js +++ b/src/components/ui/search.js @@ -37,14 +37,14 @@ class Search extends React.Component { this.handleSearch() } render () { - const {size, select, selectOptions, selectProps, style} = this.props + const {size, select, selectOptions, selectProps, style, keyword} = this.props const {clearVisible} = this.state return ( {select && } - + {clearVisible && } diff --git a/src/components/users/search.js b/src/components/users/search.js index aad9930..0d2d175 100644 --- a/src/components/users/search.js +++ b/src/components/users/search.js @@ -20,7 +20,7 @@ const search = ({ select: true, selectOptions: [{ value: 'name', name: '姓名' }, { value: 'address', name: '地址' }], selectProps: { - defaultValue: 'name' + defaultValue: field || 'name' }, onSearch: (value) => { onSearch(value) diff --git a/src/routes/users.js b/src/routes/users.js index b4be09b..3361e5a 100644 --- a/src/routes/users.js +++ b/src/routes/users.js @@ -31,9 +31,11 @@ function Users ({ location, dispatch, users }) { loading, pagination: pagination, onPageChange (page) { + const query = location.query dispatch(routerRedux.push({ pathname: '/users', query: { + ...query, page: page.current, pageSize: page.pageSize } @@ -60,6 +62,18 @@ function Users ({ location, dispatch, users }) { field, keyword, onSearch (fieldsValue) { + !!fieldsValue.keyword.length ? + dispatch(routerRedux.push({ + pathname: '/users', + query: { + field: fieldsValue.field, + keyword: fieldsValue.keyword + } + })) : + dispatch(routerRedux.push({ + pathname: '/users' + })) + dispatch({ type: 'users/query', payload: fieldsValue