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

加密修改

上级 fae599e5
import baseX from 'base-x'; import baseX from 'base-x';
import { apiRequest, qqCw } from '../utils/request'; import { apiRequest, qqCw } from '../utils/request';
import { isJSON } from '@/webPublic/zyd_public/utils/utils'; import { isJSON } from '@/webPublic/zyd_public/utils/utils';
import { queryApiActionPath, queryIsSafe } from '@/webPublic/one_stop_public/utils/queryConfig'; import {
queryApiActionPath,
queryIsBinary,
queryIsSafe
} from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token'; import { getToken, getUserInfo } from '@/webPublic/one_stop_public/utils/token';
import encryptApiList from './encryptApiList'; import encryptApiList from './encryptApiList';
import { uploadFile } from '@/webPublic/one_stop_public/libs/PictureSignature/ShowItem'; import { uploadFile } from '@/webPublic/one_stop_public/libs/PictureSignature/ShowItem';
...@@ -120,6 +124,25 @@ export function requestFileInfo(url, datas) { ...@@ -120,6 +124,25 @@ export function requestFileInfo(url, datas) {
}); });
} }
function formatDatas(datas) {
let datasCode = JSON.stringify(datas);
const openIsBinary = window.CONFIG?.IS_BINARY;
if (openIsBinary) {
datasCode = strToBinary(datasCode);
}
let file = new File([datasCode], 'fileParams.jpeg', {
type: 'image/jpeg',
});
let datasTrue = {
fileParams: file,
};
if(openIsBinary){
datasTrue.bin = true;
}
return datasTrue;
}
export function giveFilePostDataInfoForTrue(datas, url) { export function giveFilePostDataInfoForTrue(datas, url) {
if (!window.CONFIG?.IS_SAFE) { if (!window.CONFIG?.IS_SAFE) {
...@@ -129,7 +152,6 @@ export function giveFilePostDataInfoForTrue(datas, url) { ...@@ -129,7 +152,6 @@ export function giveFilePostDataInfoForTrue(datas, url) {
}; };
} }
datas = deepCopy(datas); datas = deepCopy(datas);
// console.log(datas);
for (let i in datas) { for (let i in datas) {
if (datas[i] === null || (Array.isArray(datas[i]) && datas[i].length === 0) || datas[i] === undefined) { if (datas[i] === null || (Array.isArray(datas[i]) && datas[i].length === 0) || datas[i] === undefined) {
delete datas[i]; delete datas[i];
...@@ -143,23 +165,27 @@ export function giveFilePostDataInfoForTrue(datas, url) { ...@@ -143,23 +165,27 @@ export function giveFilePostDataInfoForTrue(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,
// url,
// });
let file = new File([JSON.stringify(datas)], 'fileParams.jpeg', {
type: 'image/jpeg',
});
datas = {
fileParams: file,
};
return { return {
datas, datas: formatDatas(datas),
url, url,
}; };
} }
} }
function strToBinary(str) { // 字符串转二进制
let result = [];
let list = str.split('');
for (let i = 0; i < list.length; i++) {
if (i !== 0) {
result.push(' ');
}
let item = list[i];
let binaryStr = item.charCodeAt().toString(2);
result.push(binaryStr);
}
return result.join('');
}
function giveFilePostData(datas, url) { function giveFilePostData(datas, url) {
for (let i in datas) { for (let i in datas) {
...@@ -177,20 +203,9 @@ function giveFilePostData(datas, url) { ...@@ -177,20 +203,9 @@ 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,
// url,
// });
let file = new File([JSON.stringify(datas)], 'fileParams.jpeg', {
type: 'image/jpeg',
});
// uploadFile(file);
datas = {
fileParams: file,
};
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve({ resolve({
datas, datas: formatDatas(datas),
url, url,
}); });
}); });
......
...@@ -136,5 +136,6 @@ export const queryLoginRedirect = () => queryConfig('LOGIN_REDIRECT'); ...@@ -136,5 +136,6 @@ export const queryLoginRedirect = () => queryConfig('LOGIN_REDIRECT');
export const queryApiVersion = () => queryConfig('apiVersion'); export const queryApiVersion = () => queryConfig('apiVersion');
export const queryUiaApi = () => queryConfig('oauthServer'); export const queryUiaApi = () => queryConfig('oauthServer');
export const queryIsSafe = () => queryConfig('IS_SAFE'); // 是否开启文件上传加密 2022年5月24日 钟是志 解决北电科安全防火墙bug export const queryIsSafe = () => queryConfig('IS_SAFE'); // 是否开启文件上传加密 2022年5月24日 钟是志 解决北电科安全防火墙bug
export const queryIsBinary = () => queryConfig('IS_BINARY'); // 是否开启接口加密二进制上传 2022年6月9日 钟是志 解决北电科安全测评 27448
export default queryConfig; export default queryConfig;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论