提交 c3acc056 authored 作者: 钟是志's avatar 钟是志

解决北电科防火墙问题 把接口数据转成文件

上级 03382e2d
...@@ -36,7 +36,6 @@ const giveKey = (key, datas) => { ...@@ -36,7 +36,6 @@ const giveKey = (key, datas) => {
return datas; return datas;
}; };
const encryptApiList = [ const encryptApiList = [
{ {
api: 'DataColumnApi/getOptions', api: 'DataColumnApi/getOptions',
...@@ -146,11 +145,13 @@ const countAllValues = async (datas, item) => { ...@@ -146,11 +145,13 @@ const countAllValues = async (datas, item) => {
} else { } else {
if (item.query) { if (item.query) {
if (datas?.sqlKey.length < 13) { if (datas?.sqlKey.length < 13) {
const response = await apiRequest('/SqlManageEntityApi/findParamsKey', { sqlKey: datas.sqlKey }); const response = await apiRequest('/SqlManageEntityApi/findParamsKey', {
sqlKey: datas.sqlKey,
});
if (!response || (Array.isArray(response) && response.length === 0)) { if (!response || (Array.isArray(response) && response.length === 0)) {
datas.allValues = JSON.stringify({}); datas.allValues = JSON.stringify({});
} else { } else {
const x = isJSON(datas.allValues) && JSON.parse(datas.allValues) || {}; const x = (isJSON(datas.allValues) && JSON.parse(datas.allValues)) || {};
const y = {}; const y = {};
for (let i of response) { for (let i of response) {
if (x[i]) { if (x[i]) {
...@@ -167,13 +168,12 @@ const countAllValues = async (datas, item) => { ...@@ -167,13 +168,12 @@ const countAllValues = async (datas, item) => {
return datas; return datas;
}; };
export function requestFileInfo(url, datas) {
export function requestFileInfo(url, datas){
const formData = new FormData(); const formData = new FormData();
if(getToken()){ if (getToken()) {
datas.token = getToken(); datas.token = getToken();
} }
for(let key in datas){ for (let key in datas) {
formData.append(key, datas[key]); formData.append(key, datas[key]);
} }
return fetch(queryApiActionPath() + url, { return fetch(queryApiActionPath() + url, {
...@@ -185,17 +185,18 @@ export function requestFileInfo(url, datas){ ...@@ -185,17 +185,18 @@ export function requestFileInfo(url, datas){
credentials: 'omit', credentials: 'omit',
mode: 'cors', mode: 'cors',
body: formData, body: formData,
}).then((res) => { })
return res.json(); .then(res => {
}).then((res) => { return res.json();
// console.log(res); })
return res; .then(res => {
}); // console.log(res);
return res;
});
} }
function giveFilePostData(datas, url) {
function giveFilePostData(datas, url){ url = url.replaceAll('//', '/');
url = url.replaceAll('\/\/', '\/');
if (url && typeof url === 'string') { if (url && typeof url === 'string') {
// const roleGroup = getUserInfo().groupsId; // const roleGroup = getUserInfo().groupsId;
// url = url.replace(url, `/safe/${roleGroup}/` + url); // url = url.replace(url, `/safe/${roleGroup}/` + url);
...@@ -219,21 +220,23 @@ function giveFilePostData(datas, url){ ...@@ -219,21 +220,23 @@ function giveFilePostData(datas, url){
url = url.replace(url, `/safe/${roleGroup}/` + url); url = url.replace(url, `/safe/${roleGroup}/` + url);
url = url.replaceAll('//', '/'); url = url.replaceAll('//', '/');
console.table(datas); console.table({
let file = new File([JSON.stringify(datas)], "fileParams.jpg", { datas,
type: "text/plain", url,
});
let file = new File([JSON.stringify(datas)], 'fileParams.jpg', {
type: 'text/plain',
}); });
// uploadFile(file); // uploadFile(file);
datas = { datas = {
fileParams: file, fileParams: file,
} };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve({ resolve({
datas, datas,
url, url,
}); });
}); });
} }
} }
} }
...@@ -243,9 +246,9 @@ function giveFilePostData(datas, url){ ...@@ -243,9 +246,9 @@ function giveFilePostData(datas, url){
}); });
} }
export async function giveBase16EnCode(datas, url) {
export async function giveBase16EnCode(datas, url) { // 全局加解密函数. // 全局加解密函数.
if(queryIsSafe()){ if (queryIsSafe()) {
return giveFilePostData(datas, url); return giveFilePostData(datas, url);
} }
if (!checkOpenBase16()) { if (!checkOpenBase16()) {
...@@ -276,7 +279,8 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数. ...@@ -276,7 +279,8 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
} }
} }
if (item.yinShe) { // 映射参数字段. if (item.yinShe) {
// 映射参数字段.
datas.isBase = true; datas.isBase = true;
for (let oldKey in item.yinShe) { for (let oldKey in item.yinShe) {
let newKey = item.yinShe[oldKey]; let newKey = item.yinShe[oldKey];
...@@ -292,5 +296,3 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数. ...@@ -292,5 +296,3 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
} }
return datas; return datas;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论