accountService.js 904 Bytes
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
import { request, METHOD, removeAuthorization } from '@/utils/requestUtil';
import BASE_URL from '@/utils/baseUrlUtil';

/**
 * 登录服务,登录成功后 根据用户ID 获取用户 角色 + 菜单 + 功能权限 + 用户基本信息
 * @param name 账户名
 * @param password 账户密码
 * @returns {Promise<AxiosResponse<T>>}
 */
export async function login(name, password) {
  let loginApi = `${BASE_URL}/login`;
  return request(loginApi, METHOD.POST, {
    name: name,
    password: password
       });
}

/**
 * 退出登录
 */
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);
  removeAuthorization();
}

export default {
  login,
  logout,
}