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

接口加密函数

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