[JavaScript] 纯文本查看 复制代码
R.interceptors.request.use((Y = i()(o.a.mark(function e(t) {
var n,
r,
a,
i,
s,
u,
c,
l,
d,
f,
p;
return o.a.wrap(function (e) {
for (; ; )
switch (e.prev = e.next) {
case 0:
if (n = "object" == m()(t.data) && !Array.isArray(t.data) && "size" in t.data && "current" in t.data, !(t.cacheEnabled || t.url.indexOf("select") >= 0 || t.url.indexOf("search") >= 0 || n)) {
e.next = 22;
break
}
if (t.cacheKey = J(t.url, t.data), r = B.source(), t.cancelToken = r.token, a = L[t.cacheKey], i = X(), !(a && i - a.expire < 3e3)) {
e.next = 11;
break
}
r.cancel(a),
e.next = 22;
break;
case 11:
if (!a) {
e.next = 16;
break
}
delete L[t.cacheKey],
delete A[t.cacheKey],
e.next = 22;
break;
case 16:
if (A[t.cacheKey] ? A[t.cacheKey] += 1 : A[t.cacheKey] = 1, !(A[t.cacheKey] > 3)) {
e.next = 22;
break
}
return e.next = 20,
Q(200);
case 20:
A[t.cacheKey] = 1,
Z(t, r);
case 22:
return (s = Object(O.b)()) && (t.headers.Authorization = "Bearer " + s),
(u = Object(S.h)()) && (t.headers.language = u),
(c = Object(O.d)()) && (t.headers["tms-sybOrgCode"] = c.sybOrgCode, t.headers["tms-personNumber"] = c.personNumber),
t.headers["Content-Type"] = "application/json;charset=UTF-8",
t.headers["Validate-Key"] = "Hash " + t.cacheKey,
t.headers["tms-time-offset"] = I,
t.headers["tms-hash"] = location.hash,
l = (new Date).getTime(),
d = l + "_" + parseInt(1e5 * Math.random()),
t.headers["tms-reqTime"] = d,
t.headers["tms-reqKey"] = (o = s + d, void 0, void 0, void 0, h = CryptoJS.MD5(o.trim()), v = CryptoJS.enc.Utf8.parse("1234567812345678"), g = CryptoJS.enc.Utf8.parse(h), CryptoJS.AES.encrypt(g, v, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}).ciphertext.toString()),
f = D.some(function (e) {
return t.url.indexOf(e) > -1
}),
p = U.some(function (e) {
return t.url.indexOf(e) > -1
}),
t.url = f ? p ? t.url : Object(T.getBasePath)() + t.url : p ? "/" + C + t.url : Object(T.getBasePath)() + "/" + C + t.url,
t.url.indexOf("/tms/") < 0 && (t.url = N + t.url),
!t.noLoading && t.showLoading && q(),
K(),
e.abrupt("return", t);
case 43:
case "end":
return e.stop()
}
var o,
h,
v,
g
}, e, k)
})), function (e) {
return Y.apply(this, arguments)
}), function (e) {
H(),
z()
}),
R.interceptors.response.use(function (e) {
e.config && !e.config.noLoading && e.config.showLoading && H(),
z();
var t = e.data;
if (t instanceof Blob) {
if (t.type && "application/json" == t.type) {
var n = new FileReader;
return n.readAsText(t, "utf-8"),
n.onloadend = function (e) {
((t = JSON.parse(n.result)).mesg || t.msg) && Object(_.a)(t.mesg || t.msg)
},