diff --git a/src/api/desk/notice.js b/src/api/desk/notice.js index 0f674f17..3c26a1f0 100644 --- a/src/api/desk/notice.js +++ b/src/api/desk/notice.js @@ -9,6 +9,7 @@ export const getList = (current, size, params) => { current, size, }, + cryptoToken: true, }); }; @@ -19,6 +20,7 @@ export const remove = ids => { params: { ids, }, + cryptoToken: true, }); }; @@ -27,6 +29,7 @@ export const add = row => { url: '/blade-desk/notice/submit', method: 'post', data: row, + cryptoToken: true, }); }; @@ -35,6 +38,7 @@ export const update = row => { url: '/blade-desk/notice/submit', method: 'post', data: row, + cryptoToken: true, }); }; @@ -45,5 +49,6 @@ export const getNotice = id => { params: { id, }, + cryptoToken: true, }); }; diff --git a/src/axios.js b/src/axios.js index 6b05cbf4..4c1ec2c3 100755 --- a/src/axios.js +++ b/src/axios.js @@ -17,6 +17,7 @@ import NProgress from 'nprogress'; // progress bar import 'nprogress/nprogress.css'; // progress bar style import { Base64 } from 'js-base64'; import { baseUrl } from '@/config/env'; +import crypto from '@/utils/crypto'; axios.defaults.timeout = 10000; //返回其他状态吗 @@ -45,11 +46,16 @@ axios.interceptors.request.use( `${website.clientId}:${website.clientSecret}` )}`; } - //让每个请求携带token + //headers判断请求是否携带token const meta = config.meta || {}; const isToken = meta.isToken === false; - if (getToken() && !isToken) { - config.headers[website.tokenHeader] = 'bearer ' + getToken(); + //headers传递token是否加密 + const cryptoToken = config.cryptoToken === true; + const token = getToken(); + if (token && !isToken) { + config.headers[website.tokenHeader] = cryptoToken + ? 'crypto ' + crypto.encrypt(token) + : 'bearer ' + token; } //headers中配置text请求 if (config.text === true) {