zmdms-utils 0.0.73 → 0.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/publish.py +12 -0
- package/src/index.ts +3 -0
- package/src/locales/i18n.ts +18 -0
- package/src/locales/index.ts +8 -0
- package/src/locales/t-in-non-react.ts +65 -0
- package/src/locales/t-options.ts +24 -0
- package/src/locales/use-translation.ts +76 -0
- package/src/locales//345/244/232/350/257/255/350/250/200.md +1 -0
- package/src/math.ts +6 -1
- package/src/microAppCreator.ts +47 -8
- package/dist/es/_virtual/_commonjsHelpers.js +0 -3
- package/dist/es/_virtual/_tslib.js +0 -87
- package/dist/es/_virtual/decimal.js +0 -7
- package/dist/es/_virtual/parseTimeTest.js +0 -3
- package/dist/es/_virtual/test.js +0 -3
- package/dist/es/auth.d.ts +0 -9
- package/dist/es/auth.js +0 -49
- package/dist/es/baseUrl.d.ts +0 -23
- package/dist/es/baseUrl.js +0 -50
- package/dist/es/canvas.d.ts +0 -6
- package/dist/es/canvas.js +0 -14
- package/dist/es/common.d.ts +0 -81
- package/dist/es/common.js +0 -304
- package/dist/es/constants.d.ts +0 -20
- package/dist/es/constants.js +0 -33
- package/dist/es/crypto.d.ts +0 -51
- package/dist/es/crypto.js +0 -97
- package/dist/es/file.d.ts +0 -127
- package/dist/es/file.js +0 -373
- package/dist/es/htmlToPdf.d.ts +0 -44
- package/dist/es/htmlToPdf.js +0 -84
- package/dist/es/mainApp.d.ts +0 -36
- package/dist/es/mainApp.js +0 -44
- package/dist/es/math.d.ts +0 -29
- package/dist/es/math.js +0 -142
- package/dist/es/microAppCreator.d.ts +0 -23
- package/dist/es/microAppCreator.js +0 -67
- package/dist/es/node_modules/decimal.js/decimal.js +0 -4896
- package/dist/es/node_modules/decimal.js/decimal2.js +0 -4930
- package/dist/es/node_modules/js-base64/base64.js +0 -273
- package/dist/es/node_modules/jwt-decode/build/jwt-decode.esm.js +0 -3
- package/dist/es/node_modules/mitt/dist/mitt.js +0 -3
- package/dist/es/node_modules/pinyin-pro/dist/index.js +0 -12627
- package/dist/es/parseTime.d.ts +0 -29
- package/dist/es/parseTime.js +0 -189
- package/dist/es/parseTimeTest.js +0 -2
- package/dist/es/passwordValidate.d.ts +0 -9
- package/dist/es/passwordValidate.js +0 -169
- package/dist/es/pdf.d.ts +0 -49
- package/dist/es/pdf.js +0 -176
- package/dist/es/pinyin.js +0 -1
- package/dist/es/print.d.ts +0 -23
- package/dist/es/print.js +0 -43
- package/dist/es/qiankunUtils.d.ts +0 -13
- package/dist/es/qiankunUtils.js +0 -32
- package/dist/es/request.d.ts +0 -87
- package/dist/es/request.js +0 -308
- package/dist/es/src/parseTimeTest.js +0 -288
- package/dist/es/src/test.js +0 -245
- package/dist/es/test.js +0 -2
- package/dist/es/validate.d.ts +0 -26
- package/dist/es/validate.js +0 -47
- package/dist/es/water.d.ts +0 -53
- package/dist/es/water.js +0 -88
- package/dist/index.d.ts +0 -21
- package/dist/index.js +0 -21
package/dist/es/print.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { __spreadArray, __assign } from './_virtual/_tslib.js';
|
|
2
|
-
import printJS from 'print-js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 打印页面 直接调用window.print方法打印
|
|
6
|
-
*/
|
|
7
|
-
function windowPrint(config) {
|
|
8
|
-
if (config === null || config === void 0 ? void 0 : config.hiddenClassNames) {
|
|
9
|
-
var hiddenClassNames = config.hiddenClassNames;
|
|
10
|
-
var printStyleDom = document.getElementById("print--window__00100");
|
|
11
|
-
if (printStyleDom) {
|
|
12
|
-
printStyleDom.remove();
|
|
13
|
-
}
|
|
14
|
-
var styleDom = document.createElement("style");
|
|
15
|
-
styleDom.setAttribute("type", "text/css");
|
|
16
|
-
styleDom.setAttribute("id", "print--window__00100");
|
|
17
|
-
styleDom.innerHTML = "@media print{ ".concat(__spreadArray(__spreadArray([], (hiddenClassNames || []), true), [
|
|
18
|
-
".non-printable",
|
|
19
|
-
], false).join(","), " { display: none; } }");
|
|
20
|
-
document.head.appendChild(styleDom);
|
|
21
|
-
}
|
|
22
|
-
window.print();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 打印页面dom 通过库来打印
|
|
26
|
-
*/
|
|
27
|
-
function htmlPrint(config) {
|
|
28
|
-
printJS(__assign({ type: "html" }, config));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 打印图片
|
|
32
|
-
*/
|
|
33
|
-
function imgPrint(config) {
|
|
34
|
-
printJS(__assign({ type: "image" }, config));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 打印pdf
|
|
38
|
-
*/
|
|
39
|
-
function pdfPrint(config) {
|
|
40
|
-
printJS(__assign({ type: "pdf" }, config));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { htmlPrint, imgPrint, pdfPrint, windowPrint };
|
package/dist/es/qiankunUtils.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description 关于qiankun的一些方法
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @description 环境判断
|
|
6
|
-
*/
|
|
7
|
-
function isQiankun() {
|
|
8
|
-
return window.__POWERED_BY_QIANKUN__;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @description 取微应用地址
|
|
12
|
-
*/
|
|
13
|
-
function getMicroUrl(appKey, apps) {
|
|
14
|
-
var _a;
|
|
15
|
-
if (apps === void 0) { apps = []; }
|
|
16
|
-
var result = (_a = apps === null || apps === void 0 ? void 0 : apps.find) === null || _a === void 0 ? void 0 : _a.call(apps, function (app) { return (app === null || app === void 0 ? void 0 : app.appCode) === appKey; });
|
|
17
|
-
if (result && result.appUrl) {
|
|
18
|
-
try {
|
|
19
|
-
return result.appUrl.endsWith("/")
|
|
20
|
-
? result.appUrl.slice(result.appUrl.length - 1)
|
|
21
|
-
: result.appUrl;
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
console.log("未取到对应的微应用地址!");
|
|
25
|
-
return "";
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
console.log("未取到对应的微应用地址!");
|
|
29
|
-
return "";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { getMicroUrl, isQiankun };
|
package/dist/es/request.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { Crypto } from './crypto.js';
|
|
3
|
-
|
|
4
|
-
declare class AxiosRequest {
|
|
5
|
-
private otherOptions;
|
|
6
|
-
private crypto;
|
|
7
|
-
private jumpCallback;
|
|
8
|
-
private isExpired;
|
|
9
|
-
private isOffline;
|
|
10
|
-
private isNotFound;
|
|
11
|
-
private isTimeout;
|
|
12
|
-
private isTimeoutConfirm?;
|
|
13
|
-
private isTimeoutConfirmStr?;
|
|
14
|
-
private messageWarning?;
|
|
15
|
-
private modalConfirm?;
|
|
16
|
-
private instanceAxios;
|
|
17
|
-
private tokenKey;
|
|
18
|
-
constructor(otherOptions: IOtherOptions);
|
|
19
|
-
private defaultSetting;
|
|
20
|
-
private interceptorsRequest;
|
|
21
|
-
private interceptorsResponse;
|
|
22
|
-
private responseSuccess;
|
|
23
|
-
private responseError;
|
|
24
|
-
private logoutHandle;
|
|
25
|
-
request(options: IOptions): Promise<AxiosResponse<any, any>>;
|
|
26
|
-
}
|
|
27
|
-
interface IOptions extends AxiosRequestConfig {
|
|
28
|
-
isFormData?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* 是否需要携带请求头默认携带
|
|
31
|
-
*/
|
|
32
|
-
isAuth?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* 是否对传输数据开启加密模式
|
|
35
|
-
*/
|
|
36
|
-
isCrypto?: boolean | "aes" | "des";
|
|
37
|
-
/**
|
|
38
|
-
* 是否交给实例处理异常
|
|
39
|
-
*/
|
|
40
|
-
isErrorMessage?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* 实例返回信息 简化处理
|
|
43
|
-
*/
|
|
44
|
-
isEasyMessage?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 登录过期是否交给自己处理
|
|
47
|
-
*/
|
|
48
|
-
isHandleLoginExpiration?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* 登录过期跳转逻辑交给实例自己处理
|
|
51
|
-
*/
|
|
52
|
-
expirationHandle?: (options: any) => void;
|
|
53
|
-
}
|
|
54
|
-
interface IOtherOptions {
|
|
55
|
-
/** token过期等 需要跳转到登录页 */
|
|
56
|
-
jumpCallback?: (status: number) => void;
|
|
57
|
-
/** 提示方法 外部传入 */
|
|
58
|
-
messageWarning?: (msg: string, duration: number, callback?: () => void) => void;
|
|
59
|
-
modalConfirm?: (msg: string, callback?: () => void) => void;
|
|
60
|
-
/** @deprecated 租户ID,只有登录接口 需要 传递。 */
|
|
61
|
-
TenantId?: string;
|
|
62
|
-
/** auth值 */
|
|
63
|
-
Authorization?: string;
|
|
64
|
-
/** 公用请求头 */
|
|
65
|
-
commonHeaders?: {
|
|
66
|
-
[prop: string]: any;
|
|
67
|
-
};
|
|
68
|
-
/** 请求认证TOKEN KEY */
|
|
69
|
-
tokenKey?: string;
|
|
70
|
-
/** 超时时间 */
|
|
71
|
-
timeout?: number;
|
|
72
|
-
/** 基础url */
|
|
73
|
-
baseURL?: string;
|
|
74
|
-
/** 加密实例方法 */
|
|
75
|
-
crypto?: Crypto;
|
|
76
|
-
/** 超时是否需要弹框 */
|
|
77
|
-
isTimeoutConfirm?: boolean;
|
|
78
|
-
/** 超时弹框提示内容 */
|
|
79
|
-
isTimeoutConfirmStr?: string;
|
|
80
|
-
/** 拦截器自定义 */
|
|
81
|
-
interceptorsRequestHandle?: () => void;
|
|
82
|
-
interceptorsRequestConfig?: (config: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any>;
|
|
83
|
-
/** 响应器自定义 */
|
|
84
|
-
interceptorsResponseHandle?: () => void;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { AxiosRequest, IOptions, IOtherOptions };
|
package/dist/es/request.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import { __rest, __assign } from './_virtual/_tslib.js';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
import { removeToken, getToken } from './auth.js';
|
|
4
|
-
import { TOKEN_KEY } from './constants.js';
|
|
5
|
-
|
|
6
|
-
var defaultOptions = {
|
|
7
|
-
// TenantId: "000000", // 租户ID不需要了
|
|
8
|
-
Authorization: "Basic em1kbXM6em1kbXNfc2VjcmV0",
|
|
9
|
-
timeout: 60000,
|
|
10
|
-
};
|
|
11
|
-
var AxiosRequest = /** @class */ (function () {
|
|
12
|
-
function AxiosRequest(otherOptions) {
|
|
13
|
-
// 登录是否过期 这个变量是为了让弹出提示只展示一次
|
|
14
|
-
this.isExpired = false;
|
|
15
|
-
// 被挤下线 定义变量的目的同上
|
|
16
|
-
this.isOffline = false;
|
|
17
|
-
// 404
|
|
18
|
-
this.isNotFound = false;
|
|
19
|
-
// timeout
|
|
20
|
-
this.isTimeout = false;
|
|
21
|
-
// axios单例
|
|
22
|
-
this.instanceAxios = axios.create();
|
|
23
|
-
// tokenKey
|
|
24
|
-
this.tokenKey = TOKEN_KEY;
|
|
25
|
-
var crypto = otherOptions.crypto, jumpCallback = otherOptions.jumpCallback, isTimeoutConfirm = otherOptions.isTimeoutConfirm, isTimeoutConfirmStr = otherOptions.isTimeoutConfirmStr, messageWarning = otherOptions.messageWarning, modalConfirm = otherOptions.modalConfirm, tokenKey = otherOptions.tokenKey, resetOtherOptions = __rest(otherOptions, ["crypto", "jumpCallback", "isTimeoutConfirm", "isTimeoutConfirmStr", "messageWarning", "modalConfirm", "tokenKey"]);
|
|
26
|
-
this.otherOptions = __assign(__assign({}, defaultOptions), resetOtherOptions);
|
|
27
|
-
this.crypto = crypto;
|
|
28
|
-
this.tokenKey = tokenKey || TOKEN_KEY;
|
|
29
|
-
this.isTimeoutConfirm = isTimeoutConfirm;
|
|
30
|
-
this.isTimeoutConfirmStr = isTimeoutConfirmStr;
|
|
31
|
-
this.jumpCallback = jumpCallback;
|
|
32
|
-
this.messageWarning = messageWarning;
|
|
33
|
-
this.modalConfirm = modalConfirm;
|
|
34
|
-
this.defaultSetting();
|
|
35
|
-
this.interceptorsRequest();
|
|
36
|
-
this.interceptorsResponse();
|
|
37
|
-
}
|
|
38
|
-
// 设置axios方法默认值
|
|
39
|
-
AxiosRequest.prototype.defaultSetting = function () {
|
|
40
|
-
var _this = this;
|
|
41
|
-
// 设置默认请求头
|
|
42
|
-
// 租户ID只有登录的时候才需要传递
|
|
43
|
-
// this.instanceAxios.defaults.headers.common["Tenant-Id"] =
|
|
44
|
-
// this.otherOptions.TenantId;
|
|
45
|
-
this.instanceAxios.defaults.headers.common["Authorization"] =
|
|
46
|
-
this.otherOptions.Authorization;
|
|
47
|
-
if (this.otherOptions.commonHeaders) {
|
|
48
|
-
Object.keys(this.otherOptions.commonHeaders).forEach(function (key) {
|
|
49
|
-
var _a;
|
|
50
|
-
_this.instanceAxios.defaults.headers.common[key] =
|
|
51
|
-
(_a = _this.otherOptions.commonHeaders) === null || _a === void 0 ? void 0 : _a[key];
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// 其他默认参数
|
|
55
|
-
this.instanceAxios.defaults.timeout = this.otherOptions.timeout;
|
|
56
|
-
this.instanceAxios.defaults.baseURL = this.otherOptions.baseURL;
|
|
57
|
-
};
|
|
58
|
-
// 拦截请求
|
|
59
|
-
AxiosRequest.prototype.interceptorsRequest = function () {
|
|
60
|
-
var _this = this;
|
|
61
|
-
if (this.otherOptions.interceptorsRequestHandle) {
|
|
62
|
-
this.otherOptions.interceptorsRequestHandle();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this.instanceAxios.interceptors.request.use(function (config) {
|
|
66
|
-
if (_this.otherOptions.interceptorsRequestConfig) {
|
|
67
|
-
return _this.otherOptions.interceptorsRequestConfig(config);
|
|
68
|
-
}
|
|
69
|
-
return config;
|
|
70
|
-
}, function (error) {
|
|
71
|
-
return Promise.reject(error);
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
// 拦截响应
|
|
75
|
-
AxiosRequest.prototype.interceptorsResponse = function () {
|
|
76
|
-
var _this = this;
|
|
77
|
-
if (this.otherOptions.interceptorsResponseHandle) {
|
|
78
|
-
this.otherOptions.interceptorsResponseHandle();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this.instanceAxios.interceptors.response.use(function (response) {
|
|
82
|
-
// console.log(response);
|
|
83
|
-
// 统一处理响应正常
|
|
84
|
-
var result = _this.responseSuccess(response);
|
|
85
|
-
return result;
|
|
86
|
-
}, function (error) {
|
|
87
|
-
console.log(error);
|
|
88
|
-
// 统一处理响应异常
|
|
89
|
-
_this.responseError(error);
|
|
90
|
-
return Promise.reject(error);
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
// 响应成功处理
|
|
94
|
-
AxiosRequest.prototype.responseSuccess = function (response) {
|
|
95
|
-
var _a;
|
|
96
|
-
var config = response.config, status = response.status, data = response.data;
|
|
97
|
-
// 对返回数据进行解密后 返回给客户端
|
|
98
|
-
if ((_a = response.config) === null || _a === void 0 ? void 0 : _a.isCrypto) ;
|
|
99
|
-
if (!config.isEasyMessage) {
|
|
100
|
-
return response;
|
|
101
|
-
}
|
|
102
|
-
// 简化处理信息
|
|
103
|
-
if (status === 200) {
|
|
104
|
-
// 字符串的情况也基本不会出现
|
|
105
|
-
if (typeof data === "string") {
|
|
106
|
-
return {
|
|
107
|
-
success: true,
|
|
108
|
-
msg: "操作成功",
|
|
109
|
-
data: data,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
// 这里的data 不存在 可能说明这个接口没有返回信息
|
|
113
|
-
// 大多数情况下 不会这样 如果这种情况 也认为接口返回正常
|
|
114
|
-
if (!data) {
|
|
115
|
-
return {
|
|
116
|
-
success: true,
|
|
117
|
-
msg: "操作成功",
|
|
118
|
-
data: data,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
// 大多数情况下 都是这种逻辑
|
|
122
|
-
if ((data === null || data === void 0 ? void 0 : data.code) === 200) {
|
|
123
|
-
return data;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// 201也可能出现,比如附件下载
|
|
127
|
-
if (status === 201) {
|
|
128
|
-
return response;
|
|
129
|
-
}
|
|
130
|
-
return Promise.reject(response.data);
|
|
131
|
-
};
|
|
132
|
-
// 响应错误处理
|
|
133
|
-
AxiosRequest.prototype.responseError = function (error) {
|
|
134
|
-
var _this = this;
|
|
135
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
136
|
-
if (error === void 0) { error = {}; }
|
|
137
|
-
var response = error.response;
|
|
138
|
-
// 登录过期是否自己处理
|
|
139
|
-
var isHandleLoginExpiration = (_a = error === null || error === void 0 ? void 0 : error.config) === null || _a === void 0 ? void 0 : _a.isHandleLoginExpiration;
|
|
140
|
-
var expirationHandle = (_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.expirationHandle;
|
|
141
|
-
// 处理token失效
|
|
142
|
-
// TODO: 刷新token逻辑
|
|
143
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 401 && !isHandleLoginExpiration) {
|
|
144
|
-
removeToken();
|
|
145
|
-
if (!this.isExpired) {
|
|
146
|
-
this.isExpired = true;
|
|
147
|
-
(_c = this.messageWarning) === null || _c === void 0 ? void 0 : _c.call(this, "登录过期", 3.5, function () {
|
|
148
|
-
_this.isExpired = false;
|
|
149
|
-
});
|
|
150
|
-
if (expirationHandle) {
|
|
151
|
-
expirationHandle(response);
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this.logoutHandle(response.status);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
// 处理被挤下线逻辑
|
|
160
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 501 && !isHandleLoginExpiration) {
|
|
161
|
-
removeToken();
|
|
162
|
-
if (!this.isOffline) {
|
|
163
|
-
this.isOffline = true;
|
|
164
|
-
(_d = this.messageWarning) === null || _d === void 0 ? void 0 : _d.call(this, "你的账号已在其他地方登录!", 3.5, function () {
|
|
165
|
-
_this.isOffline = false;
|
|
166
|
-
});
|
|
167
|
-
if (expirationHandle) {
|
|
168
|
-
expirationHandle(response);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
this.logoutHandle(response.status);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
// 处理404逻辑
|
|
177
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 404) {
|
|
178
|
-
if (!this.isNotFound) {
|
|
179
|
-
this.isNotFound = true;
|
|
180
|
-
(_e = this.messageWarning) === null || _e === void 0 ? void 0 : _e.call(this, "\u63A5\u53E3\uFF1A".concat(response.config.url, " \u672A\u627E\u5230\uFF01"), 3.5, function () {
|
|
181
|
-
_this.isNotFound = false;
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
// 处理接口超时逻辑
|
|
187
|
-
if (this.isTimeoutConfirm &&
|
|
188
|
-
((_h = (_g = (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.method) === null || _g === void 0 ? void 0 : _g.toUpperCase) === null || _h === void 0 ? void 0 : _h.call(_g)) === "POST" &&
|
|
189
|
-
!response &&
|
|
190
|
-
error.code === "ECONNABORTED" &&
|
|
191
|
-
((_k = (_j = error.message) === null || _j === void 0 ? void 0 : _j.indexOf) === null || _k === void 0 ? void 0 : _k.call(_j, "".concat(error.config.timeout, "ms"))) !== -1) {
|
|
192
|
-
if (!this.isTimeout) {
|
|
193
|
-
this.isTimeout = true;
|
|
194
|
-
(_l = this.modalConfirm) === null || _l === void 0 ? void 0 : _l.call(this, "".concat(this.isTimeoutConfirmStr
|
|
195
|
-
? this.isTimeoutConfirmStr
|
|
196
|
-
: "请求超时,请稍后再试,或联系相关人员确认后处理!", "\n \u63A5\u53E3\u5730\u5740: ").concat((_m = error === null || error === void 0 ? void 0 : error.config) === null || _m === void 0 ? void 0 : _m.url, "\n \u8BF7\u6C42\u65B9\u5F0F: ").concat((_o = error === null || error === void 0 ? void 0 : error.config) === null || _o === void 0 ? void 0 : _o.method, "\n \u8BF7\u6C42\u8D85\u65F6\u65F6\u95F4: ").concat(((_p = error === null || error === void 0 ? void 0 : error.config) === null || _p === void 0 ? void 0 : _p.timeout) / 1000, "\u79D2\n "), function () {
|
|
197
|
-
_this.isTimeout = false;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
// 提示业务错误
|
|
203
|
-
if ((_q = error === null || error === void 0 ? void 0 : error.config) === null || _q === void 0 ? void 0 : _q.isErrorMessage) {
|
|
204
|
-
// 详细信息 再开发模式开启 之后上到别的环境会去掉
|
|
205
|
-
(_r = this.modalConfirm) === null || _r === void 0 ? void 0 : _r.call(this, "".concat(((_t = (_s = error === null || error === void 0 ? void 0 : error.response) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.msg) || (error === null || error === void 0 ? void 0 : error.msg) || "服务器异常"));
|
|
206
|
-
// 接口地址: ${error?.config?.url}
|
|
207
|
-
// 响应状态码: ${error?.response?.status}
|
|
208
|
-
// 请求方式: ${error?.config?.method}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
// 跳转逻辑处理
|
|
213
|
-
AxiosRequest.prototype.logoutHandle = function (status) {
|
|
214
|
-
// 自定义跳转
|
|
215
|
-
if (this.jumpCallback) {
|
|
216
|
-
this.jumpCallback(status);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
window.location.href = "/login";
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
// 实例方法
|
|
223
|
-
AxiosRequest.prototype.request = function (options) {
|
|
224
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
225
|
-
var isFormData = options.isFormData, _k = options.isAuth, isAuth = _k === void 0 ? true : _k, resetOptions = __rest(options, ["isFormData", "isAuth"]);
|
|
226
|
-
var newOptions = resetOptions;
|
|
227
|
-
// 自定义请求头
|
|
228
|
-
if (!newOptions.headers) {
|
|
229
|
-
newOptions.headers = {};
|
|
230
|
-
}
|
|
231
|
-
if (isAuth) {
|
|
232
|
-
var token = getToken();
|
|
233
|
-
newOptions.headers[this.tokenKey] = "bearer ".concat(token);
|
|
234
|
-
}
|
|
235
|
-
// 遍历params,将undefined值 转为null值
|
|
236
|
-
if (newOptions.data) {
|
|
237
|
-
newOptions.data = transformData(newOptions.data);
|
|
238
|
-
}
|
|
239
|
-
if (newOptions.params) {
|
|
240
|
-
newOptions.params = transformData(newOptions.params);
|
|
241
|
-
}
|
|
242
|
-
// 处理特殊请求
|
|
243
|
-
var specialMethod = ["POST", "PUT", "PATCH"];
|
|
244
|
-
var method = ((_a = newOptions.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) || "";
|
|
245
|
-
if (specialMethod.includes(method)) {
|
|
246
|
-
if (isFormData) {
|
|
247
|
-
var formData = new FormData();
|
|
248
|
-
var dataObj = newOptions.data || {};
|
|
249
|
-
var dataKey = Object.keys(dataObj);
|
|
250
|
-
var dataVal = Object.values(dataObj);
|
|
251
|
-
for (var i = 0; i < dataKey.length; i++) {
|
|
252
|
-
if (dataVal[i]) {
|
|
253
|
-
formData.append(dataKey[i], dataVal[i]);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
newOptions.headers["Content-Type"] = "multipart/form-data";
|
|
257
|
-
newOptions.data = formData;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
newOptions.headers = __assign({ "Content-Type": "application/json" }, newOptions.headers);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// 数据加密处理 TODO:
|
|
264
|
-
// 将参数进行aes加密
|
|
265
|
-
if (newOptions.isCrypto === true || newOptions.isCrypto === "aes") {
|
|
266
|
-
if (newOptions.data) {
|
|
267
|
-
newOptions.data = (_c = (_b = this.crypto) === null || _b === void 0 ? void 0 : _b.encrypt) === null || _c === void 0 ? void 0 : _c.call(_b, JSON.stringify(newOptions.data));
|
|
268
|
-
}
|
|
269
|
-
if (newOptions.params) {
|
|
270
|
-
newOptions.params = (_e = (_d = this.crypto) === null || _d === void 0 ? void 0 : _d.encrypt) === null || _e === void 0 ? void 0 : _e.call(_d, JSON.stringify(newOptions.params));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// 将参数进行des加密
|
|
274
|
-
if (newOptions.isCrypto === "des") {
|
|
275
|
-
if (newOptions.data) {
|
|
276
|
-
newOptions.data = (_g = (_f = this.crypto) === null || _f === void 0 ? void 0 : _f.encrypt_des) === null || _g === void 0 ? void 0 : _g.call(_f, JSON.stringify(newOptions.data));
|
|
277
|
-
}
|
|
278
|
-
if (newOptions.params) {
|
|
279
|
-
newOptions.params = (_j = (_h = this.crypto) === null || _h === void 0 ? void 0 : _h.encrypt_des) === null || _j === void 0 ? void 0 : _j.call(_h, JSON.stringify(newOptions.params));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return this.instanceAxios(newOptions);
|
|
283
|
-
};
|
|
284
|
-
return AxiosRequest;
|
|
285
|
-
}());
|
|
286
|
-
function transformData(data) {
|
|
287
|
-
if (data == null) {
|
|
288
|
-
return data;
|
|
289
|
-
}
|
|
290
|
-
if (typeof data !== "object") {
|
|
291
|
-
return data;
|
|
292
|
-
}
|
|
293
|
-
if (Array.isArray(data)) {
|
|
294
|
-
return data.map(function (item) { return transformData(item); });
|
|
295
|
-
}
|
|
296
|
-
if (Object.prototype.toString.call(data) === "[object Object]") {
|
|
297
|
-
var newData = {};
|
|
298
|
-
for (var key in data) {
|
|
299
|
-
if (data.hasOwnProperty(key)) {
|
|
300
|
-
newData[key] = transformData(data[key]);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return newData;
|
|
304
|
-
}
|
|
305
|
-
return data;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export { AxiosRequest };
|