优化代码

This commit is contained in:
smallchill 2019-02-14 17:36:47 +08:00
parent 52dc1da5e2
commit fe1a5fff08
5 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,6 @@
import request from '@/router/axios';
import { baseUrl } from '@/config/env';
import {baseUrl} from '@/config/env';
export const loginByUsername = (account, password, type) => request({
url: 'api/blade-auth/token',
method: 'post',
@ -7,6 +8,9 @@ export const loginByUsername = (account, password, type) => request({
account,
password,
type
},
meta:{
isSerialize:true,
}
})
@ -39,4 +43,4 @@ export const sendLogs = (list) => request({
export const logout = () => request({
url: baseUrl + '/user/logout',
method: 'get'
})
})

View File

@ -85,7 +85,7 @@ export default {
},
// 10token
refreshToken() {
this.refreshTime = setInterval(() => {
/*this.refreshTime = setInterval(() => {
const token = getStore({
name: "token",
debug: true
@ -103,8 +103,8 @@ export default {
this.refreshLock = false;
});
}
}, 10000);
}, 10000);*/
}
}
};
</script>
</script>

View File

@ -34,7 +34,7 @@ axios.interceptors.request.use(config => {
config.headers['blade-auth'] = 'Bearer ' + getToken() // 让每个请求携带token--['Authorization']为自定义key 请根据实际情况自行修改
}
//headers中配置serialize为true开启序列化
if (config.methods === 'post' && meta.isSerialize === true) {
if (config.method === 'post' && meta.isSerialize === true) {
config.data = serialize(config.data);
}
return config
@ -65,4 +65,4 @@ axios.interceptors.response.use(res => {
return Promise.reject(new Error(error));
})
export default axios;
export default axios;

View File

@ -165,4 +165,4 @@ const user = {
}
}
export default user
export default user

View File

@ -1,6 +1,6 @@
// 基础路径 注意发布之前要先修改这里
let baseUrl = './'
let url = 'https://sword.bladex.vip'
let url = 'http://localhost'
module.exports = {
baseUrl: baseUrl, // 根据你的实际情况更改这里
lintOnSave: true,
@ -31,9 +31,9 @@ module.exports = {
target: url,
ws: true,
pathRewrite: {
'^/api': '/api'
'^/api': '/'
}
}
}
}
}
}