| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // 单例控制器
- export default {
- namespace: 'single',
- state: {
- drawer: {
- visible: false,
- config: {}
- },
- modal: {
- visible: false,
- // search: null,
- config: {}
- }
- },
- effects: {
- *toggleDrawer({ payload }, { put }) {
- yield put({
- type: 'changeDrawer',
- payload
- })
- },
- *toggleModal({ payload }, { put }) {
- yield put({
- type: 'changeModal',
- payload
- })
- },
- *setProps({ payload }, { put }) {
- yield put({
- type: 'changeState',
- payload
- })
- }
- // *setModalSearchVal({ payload }, { put }) {
- // yield put({
- // type: 'changeState',
- // payload
- // })
- // }
- },
- reducers: {
- // 改变state对应type的config
- changeState(state, action) {
- return {
- ...state,
- [action.payload.type]: { ...state[action.payload.type], config: action.payload.config }
- }
- },
- changeDrawer(state) {
- return {
- ...state,
- drawer: { ...state.drawer, visible: !state.drawer.visible }
- }
- },
- changeModal(state) {
- return {
- ...state,
- modal: { ...state.modal, visible: !state.modal.visible }
- }
- }
- // changeModalSearch(state, action) {
- // return {
- // ...state,
- // modal: { ...state.modal, search: action.payload }
- // }
- // }
- }
- }
|