ns-base-module 1.1.76 → 1.1.78
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/dist/utils/errorMsg.js
CHANGED
|
@@ -1,16 +1,86 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CloseCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
2
|
+
import { message, Modal as ModalPC } from "antd";
|
|
2
3
|
import React from "react";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
var msgTimer = false;
|
|
5
|
+
export default (function (res, defaultMsg) {
|
|
6
|
+
if (msgTimer) return;
|
|
7
|
+
msgTimer = true;
|
|
8
|
+
setTimeout(function () {
|
|
9
|
+
msgTimer = false;
|
|
10
|
+
}, 800);
|
|
11
|
+
var _key = new Date().getTime() + Math.random();
|
|
12
|
+
// 手动关闭按钮
|
|
13
|
+
var closeDom = /*#__PURE__*/React.createElement("span", {
|
|
14
|
+
style: {
|
|
15
|
+
position: "absolute",
|
|
16
|
+
right: "-7px",
|
|
17
|
+
top: "-7px",
|
|
18
|
+
cursor: "pointer",
|
|
19
|
+
color: "#fff",
|
|
20
|
+
background: "rgba(0, 0, 0, 0.8)",
|
|
21
|
+
width: "14px",
|
|
22
|
+
height: "14px",
|
|
23
|
+
lineHeight: "12px",
|
|
24
|
+
borderRadius: "50%",
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
display: "block"
|
|
28
|
+
// fontSize: '12px',
|
|
29
|
+
},
|
|
30
|
+
onClick: function onClick() {
|
|
31
|
+
message.destroy(_key);
|
|
32
|
+
}
|
|
33
|
+
}, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
|
|
34
|
+
style: {
|
|
35
|
+
fontSize: "16px",
|
|
36
|
+
marginTop: "-2px",
|
|
37
|
+
marginLeft: "-1px",
|
|
38
|
+
color: "#fff"
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
// React.createElement(
|
|
42
|
+
// 'span',
|
|
43
|
+
// {
|
|
44
|
+
// style: {
|
|
45
|
+
// position: 'absolute',
|
|
46
|
+
// right: '-7px',
|
|
47
|
+
// top: '-7px',
|
|
48
|
+
// cursor: 'pointer',
|
|
49
|
+
// color: '#fff',
|
|
50
|
+
// background: 'rgba(0, 0, 0, 0.8)',
|
|
51
|
+
// width: '14px',
|
|
52
|
+
// height: '14px',
|
|
53
|
+
// lineHeight: '14px',
|
|
54
|
+
// borderRadius: '50%',
|
|
55
|
+
// fontSize: '12px',
|
|
56
|
+
// },
|
|
57
|
+
// onClick: () => {
|
|
58
|
+
// message.destroy(_key);
|
|
59
|
+
// },
|
|
60
|
+
// },
|
|
61
|
+
// 'x',
|
|
62
|
+
// );
|
|
63
|
+
|
|
64
|
+
var _msg = (res === null || res === void 0 ? void 0 : res.msg) || defaultMsg || "请求失败";
|
|
5
65
|
if (res !== null && res !== void 0 && res.errorCode && res !== null && res !== void 0 && res.error && res !== null && res !== void 0 && res.msg) {
|
|
6
66
|
var split = res === null || res === void 0 ? void 0 : res.msg.split(res === null || res === void 0 ? void 0 : res.errorCode);
|
|
7
|
-
if (
|
|
67
|
+
if (res !== null && res !== void 0 && res.errorCode) _msg = /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
style: {
|
|
69
|
+
paddingTop: "5px",
|
|
70
|
+
lineHeight: "12px",
|
|
71
|
+
alignItems: "center",
|
|
72
|
+
display: "inline-flex"
|
|
73
|
+
}
|
|
74
|
+
}, split[0], /*#__PURE__*/React.createElement(QuestionCircleOutlined, {
|
|
75
|
+
style: {
|
|
76
|
+
fontSize: "12px",
|
|
77
|
+
marginTop: "-2px",
|
|
78
|
+
color: "#999"
|
|
79
|
+
},
|
|
8
80
|
onClick: function onClick() {
|
|
9
|
-
|
|
81
|
+
ModalPC.info({
|
|
10
82
|
title: "详细信息",
|
|
11
83
|
width: 900,
|
|
12
|
-
className: "modal-error-msg",
|
|
13
|
-
zIndex: 1040,
|
|
14
84
|
content: /*#__PURE__*/React.createElement("div", {
|
|
15
85
|
dangerouslySetInnerHTML: {
|
|
16
86
|
__html: res.error
|
|
@@ -24,7 +94,81 @@ export default (function (res) {
|
|
|
24
94
|
closable: true
|
|
25
95
|
});
|
|
26
96
|
}
|
|
27
|
-
}
|
|
97
|
+
}), closeDom);
|
|
98
|
+
|
|
99
|
+
// React.createElement(
|
|
100
|
+
// 'span',
|
|
101
|
+
// null,
|
|
102
|
+
// React.createElement('span', {
|
|
103
|
+
// dangerouslySetInnerHTML: { __html: split[0] },
|
|
104
|
+
// }),
|
|
105
|
+
// React.createElement(
|
|
106
|
+
// 'a',
|
|
107
|
+
// {
|
|
108
|
+
// onClick: () => {
|
|
109
|
+
// ModalPC.info({
|
|
110
|
+
// title: '详细信息',
|
|
111
|
+
// width: 900,
|
|
112
|
+
// content: React.createElement('div', {
|
|
113
|
+
// dangerouslySetInnerHTML: { __html: res.error },
|
|
114
|
+
// style: {
|
|
115
|
+
// maxHeight: '60vh',
|
|
116
|
+
// overflow: 'auto',
|
|
117
|
+
// },
|
|
118
|
+
// }),
|
|
119
|
+
// onOk() {},
|
|
120
|
+
// closable: true,
|
|
121
|
+
// });
|
|
122
|
+
// },
|
|
123
|
+
// },
|
|
124
|
+
// res?.errorCode,
|
|
125
|
+
// ),
|
|
126
|
+
// // split[1],
|
|
127
|
+
// <QuestionCircleOutlined />,
|
|
128
|
+
// closeDom,
|
|
129
|
+
// );
|
|
130
|
+
}
|
|
131
|
+
if (typeof _msg == "string") {
|
|
132
|
+
_msg = /*#__PURE__*/React.createElement("span", null, _msg, closeDom);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// 520 后端只提示作用 成功状态
|
|
136
|
+
if ((res === null || res === void 0 ? void 0 : res.code) == 520) {
|
|
137
|
+
message.info({
|
|
138
|
+
content: _msg,
|
|
139
|
+
duration: 3,
|
|
140
|
+
key: _key
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// 200 成功状态
|
|
145
|
+
if ((res === null || res === void 0 ? void 0 : res.code) == 200 && (res !== null && res !== void 0 && res.msg || defaultMsg)) {
|
|
146
|
+
message.success({
|
|
147
|
+
content: _msg,
|
|
148
|
+
duration: 3,
|
|
149
|
+
key: _key
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 600 后端只提示作用 警告状态
|
|
155
|
+
if ((res === null || res === void 0 ? void 0 : res.code) == 600) {
|
|
156
|
+
message.warning({
|
|
157
|
+
content: _msg,
|
|
158
|
+
duration: 3,
|
|
159
|
+
key: _key
|
|
160
|
+
});
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 305 右上角有弹窗处理
|
|
165
|
+
if ((res === null || res === void 0 ? void 0 : res.code) === 305) {
|
|
166
|
+
return;
|
|
28
167
|
}
|
|
29
|
-
message.error(
|
|
168
|
+
message.error({
|
|
169
|
+
className: "msg-config-wrap",
|
|
170
|
+
content: _msg,
|
|
171
|
+
duration: 3,
|
|
172
|
+
key: _key
|
|
173
|
+
});
|
|
30
174
|
});
|