From d3e7e177899f5db53d793e91ec528b009ba0921e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=96=8C?= <892728595@qq.com> Date: Fri, 8 Sep 2017 13:20:25 +0800 Subject: [PATCH] query-string --- src/models/app.js | 3 ++- src/models/post.js | 3 ++- src/models/user.js | 3 ++- src/routes/user/List.js | 3 +++ src/routes/user/index.js | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/models/app.js b/src/models/app.js index c5d0a34..5e2f7a0 100644 --- a/src/models/app.js +++ b/src/models/app.js @@ -7,6 +7,7 @@ import config from 'config' import { EnumRoleType } from 'enums' import { query, logout } from 'services/app' import * as menusService from 'services/menus' +import queryString from 'query-string' const { prefix } = config @@ -41,7 +42,7 @@ export default { type: 'updateState', payload: { locationPathname: location.pathname, - locationQuery: location.query, + locationQuery: queryString.parse(location.search), }, }) }) diff --git a/src/models/post.js b/src/models/post.js index 6ed99a8..1e3c7a1 100644 --- a/src/models/post.js +++ b/src/models/post.js @@ -1,6 +1,7 @@ import modelExtend from 'dva-model-extend' import { query } from 'services/posts' import { pageModel } from 'models/common' +import queryString from 'query-string' export default modelExtend(pageModel, { @@ -13,7 +14,7 @@ export default modelExtend(pageModel, { dispatch({ type: 'query', payload: { status: 2, - ...location.query, + ...queryString.parse(location.search), } }) } }) diff --git a/src/models/user.js b/src/models/user.js index 0a789e7..cfaf1fa 100644 --- a/src/models/user.js +++ b/src/models/user.js @@ -4,6 +4,7 @@ import { config } from 'utils' import { create, remove, update } from 'services/user' import * as usersService from 'services/users' import { pageModel } from './common' +import queryString from 'query-string' const { query } = usersService const { prefix } = config @@ -25,7 +26,7 @@ export default modelExtend(pageModel, { if (location.pathname === '/user') { dispatch({ type: 'query', - payload: location.query, + payload: queryString.parse(location.search), }) } }) diff --git a/src/routes/user/List.js b/src/routes/user/List.js index cd7543a..8f43f5d 100644 --- a/src/routes/user/List.js +++ b/src/routes/user/List.js @@ -5,11 +5,14 @@ import classnames from 'classnames' import { DropOption } from 'components' import { LinkWrapper } from 'components' import AnimTableBody from '../../components/DataTable/AnimTableBody' +import queryString from 'query-string' import styles from './List.less' const confirm = Modal.confirm const List = ({ onDeleteItem, onEditItem, isMotion, location, ...tableProps }) => { + location.query = queryString.parse(location.search) + const handleMenuClick = (record, e) => { if (e.key === '1') { onEditItem(record) diff --git a/src/routes/user/index.js b/src/routes/user/index.js index df64acd..258899d 100644 --- a/src/routes/user/index.js +++ b/src/routes/user/index.js @@ -6,8 +6,10 @@ import { Row, Col, Button, Popconfirm } from 'antd' import List from './List' import Filter from './Filter' import Modal from './Modal' +import queryString from 'query-string' const User = ({ location, dispatch, user, loading }) => { + location.query = queryString.parse(location.search) const { list, pagination, currentItem, modalVisible, modalType, isMotion, selectedRowKeys } = user const { pageSize } = pagination