import http from '@/utils/http'
import { AppDispatch } from '..'
/**
 * 字典管理-获取列表
 */
export const D1_APIgetlist = (back?: () => void): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.get('cms/dict/getTree')
    if (res.code === 0) {
      if (back) back()
      dispatch({ type: 'D1/getList', payload: res.data })
    }
  }
}

/**
 * 字典管理-删除字典
 */
export const D1_APIdel = (id: string) => {
  return http.get(`cms/dict/remove/${id}`)
}

/**
 * 字典管理-新增/修改
 */
export const D1_APIsave = (data: any) => {
  return http.post('cms/dict/save', data)
}
