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

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

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