标签:header 状态码 src eve cafe avatar http role trim
{"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"}}
{"code":20000,"data":{"total":20,"items":[{"order_no":"E0C88E0f-C2f4-CCA9-9D56-14f5ccbC983c","timestamp":56933083649,"username":"Steven Hall","price":5465,"status":"pending"}]}}
这里选择了i18n分支,可以做语言切换
VUE_APP_BASE_API = ‘http://localhost:8000/‘
// 修改url和method
export function login(data) {
return request({
url: ‘/api/v1/auth/‘,
method: ‘post‘,
data
})
}
// 超时时间
timeout: 50000
// 如果修改了token的header,这里修改为自己对应的header
config.headers[‘X-Token‘] = getToken()
// res.code修改为自己对应的code
这里感觉类似于http的状态码,做个分类判断,看自己需求改了。
// 不对用户名做判断
export function validUsername(str) {
// const valid_map = [‘admin‘, ‘editor‘]
// return valid_map.indexOf(str.trim()) >= 0
return true
}
标签:header 状态码 src eve cafe avatar http role trim
原文地址:https://www.cnblogs.com/wangruixing/p/13359751.html