1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { downloadFile, getIsBei_Dian } from '@/webPublic/zyd_public/utils/utils';
import { getToken } from '@/webPublic/one_stop_public/utils/token';
import { getInfo, transformApi } from '@/highOrderComponent/Service';
import urlTransform from '@/webPublic/zyd_public/request/urlTransform';
export function hrefWithToken(url, arg = {
}) {
const {
justOpenUrl = false,
} = arg;
if (!getIsBei_Dian()) {
if (url.indexOf('?') > -1) {
url = `${url}&token=${getToken()}`;
} else {
url = `${url}?token=${getToken()}`;
}
}
const hrefUrl = transformApi(url);
let u = `${hrefUrl}${url}`;
u = urlTransform(u);
if(justOpenUrl){
window.open(u);
}
console.log('hrefWithToken', u);
if (u && u.indexOf('v1/api/zydsgWeb') > -1 && getIsBei_Dian()) {
downloadFile(u, {}, '', '', 'GET');
return;
}
getInfo({}, '/InstructorConfigApi/getCurrentDate')
.then((response) => {
if (response) {
window.open(`${u}`); // 存在问题 浏览器会自动切换内核到IE 内核导致 文件名称乱码.
return true;
} else {
return false;
}
});
}
export function hrefWithTokenSg(url = '', arg = {}){
return hrefWithToken(url, arg);
}