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

hrefWithToken函数修改

上级 b689f826
......@@ -42,7 +42,6 @@ export default class Detail extends Component {
render() {
const { id, showAll } = this.state;
const url = config.onestopPC.split('/#/');
// console.log(url);
const iframeUrl = `${url[0]}/#/IFrameSnapshot?token=${getToken()}`;
// iframeUrl = `http://localhost:8000/onestop/IframeForDetail?id=${id}&token=${getToken()}`;
return (
......
......@@ -362,7 +362,6 @@ export function handleColumns(columns) {
if (item.extendType === 'qrCode') {
if (text && typeof text === 'string' && text) {
let url = text.replace('{window.location.origin}', config.gateWayPort);
console.log(url);
const clickUrl = () => {
Modal.info({
title: item.title,
......
......@@ -136,7 +136,6 @@ export async function requestFileInfo(url, datas) {
formData.append(key, datas[key]);
}
if (!url || typeof url !== 'string') {
console.log(url);
return false;
}
return fetch(url && url.indexOf('http') > -1 ? url : queryApiActionPath() + url, {
......
......@@ -118,7 +118,6 @@ export default class Index extends Component {
// if (!('value' in this.props)) {
// this.setState({ url: url });
// }
// console.log(url);
// this.triggerChange(url);
//
......
......@@ -130,7 +130,6 @@ export default function request(
url = url.replace(config.httpServer, '');
return uaaRequest(url, options.body);
}
console.log(url);
if (process.env.NODE_ENV === 'development' && getIsBei_Dian()) {
url = url.replace('https://yx.bpi.edu.cn/produce', 'http://localhost:8010/produce');
url = url.replace('http://scjoyedu.eicp.net:51352/produce', 'http://localhost:8010/produce');
......
......@@ -6,6 +6,8 @@ import { getHeaders, getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils';
/**
* 本地开发可能会存在跨域问题
* 只能用于学工的接口的下载文件
* 2022年7月8日
* 如果ext 传空字符串 则从response.headers 中获取文件名
* */
export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx', method = 'POST') {
if (process.env.NODE_ENV === 'development' && getIsBei_Dian()) {
......@@ -14,6 +16,8 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
}
url = urlTransform(url);
let responseHeadersFileName = '';
fetch(url, {
method,
body: method === 'GET' ? undefined : FormdataWrapper(params),
......@@ -27,8 +31,8 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
let fileNameEncode = contentDisposition && contentDisposition.split('filename=');
if(fileNameEncode.length > 1){
fileNameEncode = fileNameEncode[1];
fileName = decodeURIComponent(fileNameEncode);
console.log('fileName', fileName);
responseHeadersFileName = decodeURIComponent(fileNameEncode);
console.log(responseHeadersFileName);
}
// 解码
return res.blob();
......@@ -37,10 +41,9 @@ export function downloadFile(url, params, fileName = '导出文件', ext = 'xlsx
.then((data) => {
if (data instanceof Blob) {
let a = document.createElement('a');
let url = window.URL.createObjectURL(data);
let filename = fileName + '.' + ext;
url = window.URL.createObjectURL(data);
a.href = url;
a.download = filename;
a.download = !ext ? responseHeadersFileName : fileName + '.' + ext; // 如果传入的ext 为空字符串(不等于不传) 则使用响应头中的文件作为文件名
a.click();
window.URL.revokeObjectURL(url);
a = null;
......
......@@ -3,8 +3,10 @@ import { getToken } from '@/webPublic/one_stop_public/utils/token';
import config from '@/config/config';
import { getInfo, transformApi } from '@/highOrderComponent/Service';
import urlTransform from '@/webPublic/zyd_public/request/urlTransform';
import request from '@/utils/request';
export function hrefWithToken(url) {
export function hrefWithToken(url, arg = {
}) {
if (!getIsBei_Dian()) {
if (url.indexOf('?') > -1) {
url = `${url}&token=${getToken()}`;
......@@ -15,18 +17,14 @@ export function hrefWithToken(url) {
const hrefUrl = transformApi(url);
let u = `${hrefUrl}${url}`;
u = urlTransform(u);
console.log(u);
if(u && u.indexOf('v1/api/zydsgWeb') > -1){
console.log('hrefWithToken', u);
if (u && u.indexOf('v1/api/zydsgWeb') > -1 && getIsBei_Dian()) {
downloadFile(u, {}, '', '', 'GET');
return;
}
console.log('hrefWithToken', u);
getInfo({}, '/InstructorConfigApi/getCurrentDate')
.then((response) => {
// const hrefUrl = transformApi(url);
// let u = `${hrefUrl}${url}`;
// u = urlTransform(u);
if (response) {
window.open(`${u}`); // 存在问题 浏览器会自动切换内核到IE 内核导致 文件名称乱码.
return true;
......@@ -35,26 +33,3 @@ export function hrefWithToken(url) {
}
});
}
export function hrefWithTokenSg(url) {
if (!getIsBei_Dian()) {
if (url.indexOf('?') > -1) {
url = `${url}&token=${getToken()}`;
} else {
url = `${url}?token=${getToken()}`;
}
}
getInfo({}, '/InstructorConfigApi/getCurrentDate')
.then((response) => {
const hrefUrl = `${config.mockServer}/${config.gateWayUrl.zydsg}`;
if (response) {
let u = `${hrefUrl}${url}`;
u = urlTransform(u);
window.open(u); // 存在问题 浏览器会自动切换内核到IE 内核导致 文件名称乱码.
return true;
} else {
return false;
}
});
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论