// 导入总仓库和自己声明的 AppDispatch // import store, { AppDispatch } from ".." import { DictListTypeAPI, DictListTypeObj } from "@/types"; import http from "@/utils/http"; import { AppDispatch } from ".."; /** * 用户登录接口 */ export const userLoginAPI = (data: any) => { return http.post("admin/login", { ...data }); }; /** * 修改密码接口 */ export const passWordEditAPI = (data: any) => { return http.post("sys/user/updatePwd", { ...data }); }; /** * 获取下拉框数据 */ export const getDictListAPI = () => { return async (dispatch: AppDispatch) => { const res = await http.get("cms/dict/getList"); const list: DictListTypeAPI[] = res.data; const obj = { age: [{ label: "全部", value: "", type: "age" }], texture: [{ label: "全部", value: "", type: "texture" }], level: [{ label: "全部", value: "", type: "level" }], source: [{ label: "全部", value: "", type: "source" }], } as DictListTypeObj; list.forEach((v) => { obj[v.type].push({ label: v.name, value: v.name, type: v.type }); }); dispatch({ type: "login/getDictList", payload: obj }); }; };