48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { Login } from "@/api/interface/index";
|
|
// import { BASEURL } from "@/api/config/servicePort";
|
|
import DynamicRouter from "@/assets/json/dynamicRouter.json";
|
|
import AuthButtons from "@/assets/json/authButtons.json";
|
|
import qs from "qs";
|
|
import http from "@/api";
|
|
import { GlobalStore } from "@/stores";
|
|
|
|
/**
|
|
* @name 登录模块
|
|
*/
|
|
// * 用户登录
|
|
|
|
const BASEURL = import.meta.env.VITE_API_URL;
|
|
|
|
export const loginApi = (params: Login.ReqLoginForm) => {
|
|
return http.post<Login.ResLogin>(BASEURL + `/xmgl/base/login`, params, { headers: { noLoading: true } }); // 正常 post json 请求 ==> application/json
|
|
// return http.get<Login.ResLogin>(BASEURL + `/xmgl/systemUser/login?${qs.stringify(params, { arrayFormat: "repeat" })}`); // 如果是 get 请求可以携带数组等复杂参数
|
|
};
|
|
|
|
// * 获取按钮权限
|
|
export const getAuthButtonListApi = () => {
|
|
// return http.get<Login.ResAuthButtons>(BASEURL + `/auth/buttons`, {}, { headers: { noLoading: true } });
|
|
// 如果想让按钮权限变为本地数据,注释上一行代码,并引入本地 authButtons.json 数据
|
|
return AuthButtons;
|
|
};
|
|
|
|
// * 获取菜单列表
|
|
export const getAuthMenuListApi = (params?: any) => {
|
|
const globalStore = GlobalStore();
|
|
if (!params && !globalStore.moduleId) return DynamicRouter;
|
|
return http.post<Menu.MenuOptions[]>(BASEURL + `/xmgl/baseMenu/queryBySelf`, params || { moduleId: globalStore.moduleId }, {
|
|
headers: { noLoading: true }
|
|
});
|
|
// 如果想让菜单变为本地数据,注释上一行代码,并引入本地 dynamicRouter.json 数据
|
|
// return DynamicRouter;
|
|
};
|
|
|
|
// * 用户退出登录
|
|
export const logoutApi = () => {
|
|
return http.post(BASEURL + `/xmgl/systemUser/logout`);
|
|
};
|
|
|
|
// * 页面跳转免登录
|
|
// export const jumpLoginApi = () => {
|
|
// return http.post(BASEURL + ``);
|
|
// };
|