From 9c9f3297e994b52a12a54df82c84f5c8ad50e520 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 15:46:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96http=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=93=8D=E5=BA=94=E6=8B=A6=E6=88=AA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-room-ui/packages/js/utils/httpParamsFormatting.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data-room-ui/packages/js/utils/httpParamsFormatting.js b/data-room-ui/packages/js/utils/httpParamsFormatting.js index 605f8267..a1f85154 100644 --- a/data-room-ui/packages/js/utils/httpParamsFormatting.js +++ b/data-room-ui/packages/js/utils/httpParamsFormatting.js @@ -35,8 +35,10 @@ export default function axiosFormatting (customConfig) { instance.interceptors.response.use(response => { if (response.data.code === 200) { // 执行响应脚本 - const resp = _.cloneDeep(response.data) - eval(newCustomConfig.responseScript) + // eslint-disable-next-line no-new-func + const getResp = new Function('response', newCustomConfig.responseScript) + const resp = getResp(response) + console.log(resp) return Promise.resolve(resp) } else { Message({ @@ -76,7 +78,7 @@ function replaceUrlParam (url, paramName, paramValue) { } // 将参数的值替换掉其他配置中对应属性的值 function replaceParams (customConfig) { - let newConfig = _.cloneDeep(customConfig) + const newConfig = _.cloneDeep(customConfig) newConfig.url = evalStrFunc(newConfig.paramsList, newConfig.url) newConfig.headers = evalArrFunc(newConfig.paramsList, newConfig.headers) newConfig.params = evalArrFunc(newConfig.paramsList, newConfig.params)