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

接口加密函数

上级 c8521b5f
......@@ -12,6 +12,7 @@ import ButtonDiy from '../ButtonDiy/ButtonDiy';
import { giveFilePostData, giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16';
import SelectModal from '@/webPublic/one_stop_public/App/ExportCurrentInfo/SelectModal';
import { getHeaders } from '@/webPublic/zyd_public/utils/utils';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
/**
*
* 2019/02/21 修改导出方式为fetch
......@@ -71,16 +72,17 @@ export default class ExportCurrentInfo extends React.Component {
this.downloadFile(downloadUrl, param);
};
downloadFile(url, params) {
downloadFile = async (url, params) => {
this.setState({ confirmLoading: true });
let newApi = giveFilePostDataInfoForTrue(params, url);
if(newApi && newApi.datas){
newApi.datas.token = getToken();
}
fetch(newApi.url, {
const { transformApi, headersApi } = await getTransformApi(newApi.url);
fetch(transformApi, {
method: 'POST',
body: FormdataWrapper(newApi.datas),
...getHeaders(),
...getHeaders('', headersApi),
})
.then((res) => {
if (res.status != '200') {
......
......@@ -13,17 +13,18 @@ import {
renderContentAll,
renderContentRow, downloadFile, getListWord
} from './globalFunction';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
export function giveSmartFormGlobalProps({
fromStart = false,
hasSingle = false,
isHandle = false,
onlyRead = false, // 是否此表单所有组件只读
taskCells = [],
data = {},
nextUsers = {}, //
calculateFlowData = [], // 移动端使用 用于分块块 禅道 23933 移动端全表单后审核步骤的显示问题优化
}) {
fromStart = false,
hasSingle = false,
isHandle = false,
onlyRead = false, // 是否此表单所有组件只读
taskCells = [],
data = {},
nextUsers = {}, //
calculateFlowData = [], // 移动端使用 用于分块块 禅道 23933 移动端全表单后审核步骤的显示问题优化
}) {
window.smartFormGlobalProps = {
fromStart,
hasSingle,
......@@ -45,6 +46,7 @@ export function giveSmartFormGlobalProps({
downloadFile,
renderContentAll,
renderContentRow,
getTransformApi,
remark: {
downloadFile: '下载文件函数.',
'giveFilePostDataInfoForTrue(params, url) ':
......@@ -67,6 +69,7 @@ export function giveSmartFormGlobalProps({
`ant表头横向、纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentAll(value, row, index,"inst_name",spanData,cloumnNames)}`,
'renderContentRow(value, row, index, key, spanData, cloumnNames) ':
`ant表头纵向合并 ;参数->所有必填 value, row, index, key, spanData, cloumnNames 实例:render:(value, row, index)=>{return renderContentRow(value, row, index,"inst_name",spanData,cloumnNames)}`,
'getTransformApi': '接口转换函数用于一站式接口地址加密',
},
},
activeJsonConfig: {}, // 27282 双选会报名后管理员修改举办时间 但是单位申请信息么有随着更新
......
......@@ -4,6 +4,7 @@ import { giveFilePostDataInfoForTrue } from '@/webPublic/one_stop_public/Base16'
import { queryOauthActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
import { getToken } from '@/webPublic/one_stop_public/utils/token';
import { deepCopy } from '@/webPublic/zyd_public/utils/utils';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
const apiUrl = queryOauthActionPath();
......@@ -751,13 +752,15 @@ function FormdataWrapper(obj, fd, pre) {
return fd;
}
export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx') {
export async function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx') {
// console.log("downloadFile",url);
fetch(url, {
const { transformApi, headersApi } = await getTransformApi(url);
fetch(transformApi, {
method: 'POST',
body: FormdataWrapper(params),
headers: {
Authorization: `bearer ${localStorage.getItem('antd-pro-token-onestop')}`,
apis: headersApi,
},
})
.then((res) => {
......@@ -789,13 +792,15 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
}
export function downloadFileAndShowModal(url, params, fileName = '导出文件', ext = 'xlsx') {
export async function downloadFileAndShowModal(url, params, fileName = '导出文件', ext = 'xlsx') {
// console.log("downloadFile",url);
fetch(url, {
const { transformApi, headersApi } = await getTransformApi(url);
fetch(transformApi, {
method: 'POST',
body: FormdataWrapper(params),
headers: {
Authorization: `bearer ${localStorage.getItem('antd-pro-token-onestop')}`,
apis: headersApi,
},
})
.then((res) => {
......
......@@ -5,7 +5,7 @@ import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
const isTest = getUrlInfo().test;
export function getHeaders(url = '') {
export function getHeaders(url = '', headersApi = undefined) {
const token = getToken();
const currentInfo = getCurrentUser() || {};
const user = getUserInfo() || {};
......@@ -13,31 +13,20 @@ export function getHeaders(url = '') {
// debugger;
const timestamp = user.differenceBetweenServerAndClientTime ? new Date().getTime() + user.differenceBetweenServerAndClientTime : new Date().getTime();
const secretString = token + userId + timestamp;
if(!token || token === 'null'){
return {
headers: {},
}
}
const res = {
headers: {
Authorization: `bearer ${token}`,
},
headers: {},
};
if(headersApi){
res.headers.apis = headersApi;
}
if(!token || token === 'null'){
return res;
}
res.headers.Authorization = `bearer ${token}`;
if (getIsBei_Dian() && userId
) {
res.headers.auth = gg5xxxxx(secretString);
res.headers.timestamp = timestamp;
if (isTest) {
// console.log(
// {
// url: url,
// secretString,
// md5S: gg5xxxxx(secretString),
// timestamp,
// userId: userId,
// },
// );
}
}
return res;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论