优化代码

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

View File

@ -85,7 +85,7 @@ export default {
}, },
// 10token // 10token
refreshToken() { refreshToken() {
this.refreshTime = setInterval(() => { /*this.refreshTime = setInterval(() => {
const token = getStore({ const token = getStore({
name: "token", name: "token",
debug: true debug: true
@ -103,8 +103,8 @@ export default {
this.refreshLock = false; 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 请根据实际情况自行修改 config.headers['blade-auth'] = 'Bearer ' + getToken() // 让每个请求携带token--['Authorization']为自定义key 请根据实际情况自行修改
} }
//headers中配置serialize为true开启序列化 //headers中配置serialize为true开启序列化
if (config.methods === 'post' && meta.isSerialize === true) { if (config.method === 'post' && meta.isSerialize === true) {
config.data = serialize(config.data); config.data = serialize(config.data);
} }
return config return config
@ -65,4 +65,4 @@ axios.interceptors.response.use(res => {
return Promise.reject(new Error(error)); 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 baseUrl = './'
let url = 'https://sword.bladex.vip' let url = 'http://localhost'
module.exports = { module.exports = {
baseUrl: baseUrl, // 根据你的实际情况更改这里 baseUrl: baseUrl, // 根据你的实际情况更改这里
lintOnSave: true, lintOnSave: true,
@ -31,9 +31,9 @@ module.exports = {
target: url, target: url,
ws: true, ws: true,
pathRewrite: { pathRewrite: {
'^/api': '/api' '^/api': '/'
} }
} }
} }
} }
} }