update 迁移table和modal-form组件,迁移app管理
This commit is contained in:
@@ -2,16 +2,16 @@ import { createStore } from 'redux'
|
||||
import { cloneDeep, result, isEqual } from 'lodash'
|
||||
import reducer from './reducer'
|
||||
|
||||
const store = createStore(reducer)
|
||||
const _store = createStore(reducer)
|
||||
|
||||
const exStore = cloneDeep(store)
|
||||
const store = cloneDeep(_store)
|
||||
|
||||
/**
|
||||
* 允许传入第一个参数path,只监听指定属性路径的对象
|
||||
* @param {...any} args
|
||||
* @returns
|
||||
*/
|
||||
exStore.subscribe = (...args) => {
|
||||
store.subscribe = (...args) => {
|
||||
let path,
|
||||
listener,
|
||||
snapshot
|
||||
@@ -19,13 +19,13 @@ exStore.subscribe = (...args) => {
|
||||
if (typeof args[0] === 'string' && typeof args[1] === 'function') {
|
||||
path = args[0]
|
||||
listener = args[1]
|
||||
snapshot = cloneDeep(result(store.getState(), path))
|
||||
snapshot = cloneDeep(result(_store.getState(), path))
|
||||
} else {
|
||||
listener = args[0]
|
||||
}
|
||||
|
||||
return store.subscribe((...args) => {
|
||||
const state = store.getState()
|
||||
return _store.subscribe((...args) => {
|
||||
const state = _store.getState()
|
||||
if (path) {
|
||||
const resultState = cloneDeep(result(state, path))
|
||||
if (!isEqual(snapshot, resultState)) {
|
||||
@@ -43,12 +43,12 @@ exStore.subscribe = (...args) => {
|
||||
* @param {*} path
|
||||
* @returns
|
||||
*/
|
||||
exStore.getState = (path) => {
|
||||
store.getState = (path) => {
|
||||
if (path) {
|
||||
return result(store.getState(), path)
|
||||
return result(_store.getState(), path)
|
||||
}
|
||||
|
||||
return store.getState()
|
||||
return _store.getState()
|
||||
}
|
||||
|
||||
export default exStore
|
||||
export default store
|
||||
@@ -14,7 +14,8 @@ const user = (state = {}, action) => {
|
||||
const dicData = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case 'ADD_DIC_DATA':
|
||||
return state
|
||||
const _state = { ...state, ...action.value }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user