mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-31 22:53:47 +00:00
🐛 Fixing dva history.listen multiple triggers.
This commit is contained in:
+2
-1
@@ -12,6 +12,7 @@
|
||||
"d3-shape": "^1.3.0",
|
||||
"draftjs-to-html": "^0.8.4",
|
||||
"draftjs-to-markdown": "^0.5.1",
|
||||
"dva": "2.4.1",
|
||||
"dva-model-extend": "^0.1.2",
|
||||
"echarts": "^4.2.0",
|
||||
"echarts-for-react": "^2.0.15-beta.0",
|
||||
@@ -63,7 +64,7 @@
|
||||
"stylelint": "^10.0.0",
|
||||
"stylelint-config-prettier": "^5.2.0",
|
||||
"stylelint-config-standard": "^18.3.0",
|
||||
"umi": "^2.8.7",
|
||||
"umi": "^2.8.9",
|
||||
"umi-plugin-react": "^1.9.6"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
+9
-14
@@ -13,24 +13,19 @@ import Modal from './components/Modal'
|
||||
@withI18n()
|
||||
@connect(({ user, loading }) => ({ user, loading }))
|
||||
class User extends PureComponent {
|
||||
componentDidMount() {
|
||||
this.handleRefresh({ page: 1, pageSize: 10 })
|
||||
}
|
||||
|
||||
handleRefresh = newQuery => {
|
||||
const { location, dispatch } = this.props
|
||||
const { location } = this.props
|
||||
const { query, pathname } = location
|
||||
const payload = {
|
||||
...query,
|
||||
...newQuery,
|
||||
}
|
||||
dispatch({
|
||||
type: 'user/query',
|
||||
payload,
|
||||
})
|
||||
|
||||
router.push({
|
||||
pathname,
|
||||
search: stringify(payload, { arrayFormat: 'repeat' }),
|
||||
search: stringify(
|
||||
{
|
||||
...query,
|
||||
...newQuery,
|
||||
},
|
||||
{ arrayFormat: 'repeat' }
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -1,4 +1,3 @@
|
||||
/* global window */
|
||||
import modelExtend from 'dva-model-extend'
|
||||
import { pathMatchRegexp } from 'utils'
|
||||
import api from 'api'
|
||||
@@ -22,6 +21,20 @@ export default modelExtend(pageModel, {
|
||||
selectedRowKeys: [],
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (pathMatchRegexp('/user', location.pathname)) {
|
||||
const payload = location.query || { page: 1, pageSize: 10 }
|
||||
dispatch({
|
||||
type: 'query',
|
||||
payload,
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query({ payload = {} }, { call, put }) {
|
||||
const data = yield call(queryUserList, payload)
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { message } from 'antd'
|
||||
|
||||
export default {
|
||||
onError(e) {
|
||||
onError(e, a) {
|
||||
e.preventDefault()
|
||||
message.error(e.message)
|
||||
if (e.message) {
|
||||
message.error(e.message)
|
||||
} else {
|
||||
/* eslint-disable */
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user