import { request, METHOD } from '@/utils/requestUtil'; import md5 from 'crypto-js/md5'; import { clearToken, clearUserId, clearUserInfo } from '@/utils'; import { logoutApi } from '@/api'; /** * 登录服务,登录成功后 根据用户ID 获取用户 角色 + 菜单 + 功能权限 + 用户基本信息 * @param name 账户名 * @param password 账户密码 * @returns {Promise>} */ export async function login(userName, password) { return request('/api/v1/login', METHOD.POST, { userName, password: md5(password).toString(), }); } /** * 退出登录 */ export function logout() { // //清除所有保存的信息 // localStorage.removeItem(process.env.VUE_APP_ROUTES_KEY); // localStorage.removeItem(process.env.VUE_APP_PERMISSIONS_KEY); // localStorage.removeItem(process.env.VUE_APP_ROLES_KEY); // localStorage.removeItem(process.env.VUE_APP_USER_KEY); return logoutApi().then(res => { clearToken(); clearUserId(); clearUserInfo(); return res; }); } export default { login, logout, };