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

优化基础组件

上级 f9c1f092
......@@ -189,21 +189,16 @@ export default function request(
if (newOptions.method === 'GET') {
url = url + '&' + qs.stringify(newOptions.body || {});
newOptions = omit(newOptions, 'body');
newOptions.headers = {
...getHeaders().headers,
};
}
if (!token || token === 'null' || url.indexOf('uia/logout') > -1) {
delete newOptions.headers.Authorization;
}
// console.log({
// url,
// newOptions,
// })
for (let i = 0; i < 100; i++) {
new Promise((resolve) => {
resolve(true);
});
}
console.log(newOptions);
return fetch(url, newOptions)
.then(checkStatus)
......
......@@ -11,11 +11,22 @@ export function hrefWithToken(url) {
url = `${url}?token=${getToken()}`;
}
}
getInfo({}, '/InstructorConfigApi/getCurrentDate')
.then((response) => {
const hrefUrl = transformApi(url);
let u = `${hrefUrl}${url}`;
u = urlTransform(u);
if(u && u.indexOf('v1/api/zydsgWeb')){
getInfo({}, u, {
method: '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;
......
......@@ -11,6 +11,7 @@ import { getCurrentUser, getToken } from '@/webPublic/one_stop_public/utils/toke
import urlTransform from '@/webPublic/zyd_public/request/urlTransform';
// import Md5 from './md5.min';
import Md5 from 'js-md5';
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
let messageTime = new Date().getTime() - 3000;
......@@ -384,19 +385,31 @@ export function checkInputType(data, type) {
return true;
}
const isTest = getUrlInfo().test;
export function getHeaders(url = '') {
const token = getToken();
const currentInfo = getCurrentUser();
const awc_timestamp = window.serviceCurrentDate || new Date().getTime();
const secretString = token + currentInfo.xgUserId + currentInfo.typeString + awc_timestamp;
const timestamp = window.serviceCurrentDate || new Date().getTime();
const secretString = token + currentInfo.xgUserId + currentInfo.typeString + timestamp;
// console.log(secretString, awc_timestamp);
console.log(Md5(secretString));
// console.log(Md5(secretString));
if (isTest) {
console.log(
{
secretString,
md5S: Md5(secretString),
timestamp,
userId: currentInfo.xgUserId,
typeString: currentInfo.typeString,
},
);
}
return {
headers: {
Authorization: `bearer ${token}`,
awc_auth: Md5(secretString),
awc_timestamp,
auth: Md5(secretString),
timestamp,
},
};
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论