vue-admin-template 登录、获取用户信息、退出登录说明

说明

登录、获取用户信息、退出登录,封装在 src/api/user.js 文件中

注意: 返回格式中的 code 必须是 20000,在 utils/request.js 49行上下修改值

登录

post 请求

返回数据格式

如下:

{"code":20000,"data":{"token":"admin-token"}}

获取用户信息

get 请求

返回数据格式

{
    "code":20000,
    "data":{
        "roles":[
            "admin"
        ],
        "introduction":"I am a super administrator",
        "avatar":"https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
        "name":"Super Admin"
    }
}

退出登录

post 请求

返回数据格式

{"code":20000,"data":"success"}

原文出处:https://www.malaoshi.top/show_1IX2psURKEYW.html