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

优化基础组件

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