// import { getAppList, addApp, delApp, getAppSet, setApp, resetSecret } from '../services/application'
import * as appService from '../services/application'
export default {
namespace: 'application',
state: {
appDetail: {
},
secret: '111',
},
reducers: {
saveList(state, { payload }) {
return { ...state, list: payload.list, totalCount: payload.totalCount }
},
save(state, appDetail) {
return { ...state, appDetail }
},
saveSecret(state, { payload }) {
return {
...state,
secret: payload
}
},
saveListDetail(state, { appDetail }) {
return {
...state,
ListDetail: appDetail
}
},
//新增or更改
isadd(state, payload) {
return { ...state, ...payload }
}
},
effects: {
// 获取应用列表
*fetchAppList({ payload }, { call, put, select }) {
const resp = yield call(appService.getAppList, payload)
const list = resp.items;
const totalCount = resp.totalCount;
yield put({ type: 'saveList', payload: { list, totalCount } })
},
//添加应用
*addApplication({ payload }, { call, put, select }) {
const addAppResp = yield call(appService.addApp, payload)
if (addAppResp) {
yield put({ type: 'fetchAppList' })
}
},
//删除应用
*delApplication({ payload }, { call, put, select }) {
const respdel = yield call(appService.delApp, payload)
if (respdel) {
yield put({ type: 'fetchAppList' })
}
},
//获取应用详情
*fetchAppDetail({ payload }, { call, put, select }) {
const appDetail = yield call(appService.getAppSet, payload)
yield put({ type: 'saveListDetail', appDetail })
},
//设置修改详情
*setAppDetail({ setpayload }, { call, put }) {
const setAppResp = yield call(appService.setApp, setpayload)
if (setAppResp) {
yield put({
type: 'fetchAppDetail',
payload: setpayload.id
})
}
},
//重置secret
*resetSecret({ payload }, { call, put }) {
const restSecretResp = yield call(appService.resetSecret, payload)
if (restSecretResp) {
yield put({
type: 'saveSecret',
payload: restSecretResp.data
})
}
},
// app开关
*appEnable({ payload }, { call, put, select }) {
const appEnableResp = yield call(appService.appEnable, payload)
if (appEnableResp) {
yield put({ type: 'fetchAppList' })
}
},
*appDisable({ payload }, { call, put, select }) {
const appDisableResp = yield call(appService.appDisable, payload)
if (appDisableResp) {
yield put({ type: 'fetchAppList' })
}
}
},
subscriptions: {
},
}
dva中model的使用
最新推荐文章于 2024-02-20 16:30:33 发布