cloud-web-corejs 1.1.0-dev.41 → 1.1.0-dev.42
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
CHANGED
|
@@ -6,20 +6,32 @@
|
|
|
6
6
|
v-if="showWrap"
|
|
7
7
|
:close-on-click-modal="false"
|
|
8
8
|
width="501px"
|
|
9
|
-
custom-class="dialog-style tips-dialog error "
|
|
9
|
+
:custom-class="structuredDetail ? `dialog-style tips-dialog error error-message-dialog${showTextFlag ? ' is-detail' : ''}` : 'dialog-style tips-dialog error'"
|
|
10
10
|
:append-to-body="true"
|
|
11
11
|
:modal="false"
|
|
12
12
|
@close="closeDialog"
|
|
13
13
|
v-el-drag-dialog
|
|
14
14
|
>
|
|
15
15
|
<div class="cont">
|
|
16
|
-
<p v-if="!rmid">Error:</p>
|
|
16
|
+
<p v-if="!rmid && !errorLabel">Error:</p>
|
|
17
17
|
<p v-if="rmid">Error({{ rmid }}):</p>
|
|
18
|
+
<p v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
|
|
18
19
|
<template v-if="!showTextFlag">
|
|
19
20
|
<p v-html="text1"></p>
|
|
20
21
|
</template>
|
|
21
|
-
<
|
|
22
|
-
|
|
22
|
+
<div v-if="showTextFlag && structuredDetail" class="error-detail-list">
|
|
23
|
+
<div
|
|
24
|
+
v-for="(item, index) in detailItems"
|
|
25
|
+
:key="index"
|
|
26
|
+
class="error-detail-row"
|
|
27
|
+
:class="{ 'is-summary': item.isSummary, 'is-section': item.isSection, 'is-cause': item.isCause }"
|
|
28
|
+
>
|
|
29
|
+
<span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
|
|
30
|
+
<span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<p v-else-if="showTextFlag" class="error-detail-plain" v-html="text2"></p>
|
|
34
|
+
<a class="error-detail-toggle" href="javascript:void(0);" @click="showTextFlag = !showTextFlag">{{
|
|
23
35
|
!showTextFlag
|
|
24
36
|
? $t2("详情", "components.errorMsg.detail")
|
|
25
37
|
: $t2("收起", "components.errorMsg.collapse")
|
|
@@ -44,12 +56,19 @@
|
|
|
44
56
|
<i class="icon"></i>
|
|
45
57
|
<div class="cont">
|
|
46
58
|
<p class="name">{{ title }}</p>
|
|
47
|
-
<p class="txt" v-if="!rmid">Error:</p>
|
|
59
|
+
<p class="txt" v-if="!rmid && !errorLabel">Error:</p>
|
|
48
60
|
<p class="txt" v-if="rmid">Error({{ rmid }}):</p>
|
|
61
|
+
<p class="txt" v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
|
|
49
62
|
<template v-if="!showTextFlag">
|
|
50
63
|
<p class="txt">{{ text1 }}</p>
|
|
51
64
|
</template>
|
|
52
|
-
<
|
|
65
|
+
<div v-if="showTextFlag && structuredDetail" class="error-detail-list">
|
|
66
|
+
<div v-for="(item, index) in detailItems" :key="index" class="error-detail-row" :class="{ 'is-summary': item.isSummary, 'is-section': item.isSection, 'is-cause': item.isCause }">
|
|
67
|
+
<span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
|
|
68
|
+
<span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<p class="txt" v-else-if="showTextFlag" v-html="text2"></p>
|
|
53
72
|
<el-link @click="showTextFlag = !showTextFlag" class="link-underline" :underline="false" type="primary">{{
|
|
54
73
|
!showTextFlag
|
|
55
74
|
? $t2("详情", "components.errorMsg.detail")
|
|
@@ -70,9 +89,123 @@
|
|
|
70
89
|
import { mixins } from "./mixins";
|
|
71
90
|
|
|
72
91
|
export default {
|
|
73
|
-
|
|
92
|
+
name: "ErrorMessage",
|
|
74
93
|
mixins: [mixins],
|
|
75
94
|
};
|
|
76
95
|
</script>
|
|
77
96
|
|
|
78
|
-
<style
|
|
97
|
+
<style lang="scss">
|
|
98
|
+
.error-message-dialog {
|
|
99
|
+
.el-dialog__body .cont {
|
|
100
|
+
padding: 18px 20px 16px;
|
|
101
|
+
max-height: min(520px, calc(100vh - 190px));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&.is-detail .el-dialog__body:after {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.error-detail-list {
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
border: 1px solid #dfe6f1;
|
|
112
|
+
border-radius: 6px;
|
|
113
|
+
background: rgba(255, 255, 255, 0.86);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.error-detail-row {
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-columns: 82px minmax(0, 1fr);
|
|
119
|
+
gap: 12px;
|
|
120
|
+
padding: 7px 12px;
|
|
121
|
+
border-bottom: 1px solid #edf0f5;
|
|
122
|
+
line-height: 1.55;
|
|
123
|
+
word-break: break-word;
|
|
124
|
+
|
|
125
|
+
&:last-child {
|
|
126
|
+
border-bottom: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&.is-summary,
|
|
130
|
+
&.is-section {
|
|
131
|
+
display: block;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&.is-summary {
|
|
135
|
+
padding: 10px 12px;
|
|
136
|
+
background: #edf4ff;
|
|
137
|
+
color: #315f91;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&.is-section {
|
|
142
|
+
padding: 9px 12px 5px;
|
|
143
|
+
border-bottom: 0;
|
|
144
|
+
color: #303133;
|
|
145
|
+
font-weight: 600;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&.is-cause {
|
|
149
|
+
position: relative;
|
|
150
|
+
display: block;
|
|
151
|
+
padding: 4px 12px 4px 30px;
|
|
152
|
+
border-bottom: 0;
|
|
153
|
+
|
|
154
|
+
&:before {
|
|
155
|
+
content: "";
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 13px;
|
|
158
|
+
left: 17px;
|
|
159
|
+
width: 4px;
|
|
160
|
+
height: 4px;
|
|
161
|
+
border-radius: 50%;
|
|
162
|
+
background: #8ca5c2;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.error-detail-label {
|
|
166
|
+
margin-right: 4px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.error-detail-label {
|
|
172
|
+
color: #606266;
|
|
173
|
+
font-weight: 600;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.error-detail-value {
|
|
177
|
+
min-width: 0;
|
|
178
|
+
color: #606266;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.error-detail-toggle {
|
|
182
|
+
display: inline-block;
|
|
183
|
+
margin-top: 12px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.error-detail-plain {
|
|
187
|
+
line-height: 1.65;
|
|
188
|
+
word-break: break-word;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.pop-tipsBox.error .error-detail-list {
|
|
192
|
+
max-height: 42vh;
|
|
193
|
+
overflow: auto;
|
|
194
|
+
text-align: left;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@media (max-width: 640px) {
|
|
198
|
+
.error-detail-row {
|
|
199
|
+
display: block;
|
|
200
|
+
|
|
201
|
+
.error-detail-label {
|
|
202
|
+
display: block;
|
|
203
|
+
margin-bottom: 2px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&.is-cause .error-detail-label {
|
|
207
|
+
display: inline;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
</style>
|
|
@@ -14,6 +14,9 @@ tmixins = {
|
|
|
14
14
|
},
|
|
15
15
|
objx: Object,
|
|
16
16
|
_errorMsg: null,
|
|
17
|
+
errorLabel: {
|
|
18
|
+
default: "",
|
|
19
|
+
},
|
|
17
20
|
},
|
|
18
21
|
created() {
|
|
19
22
|
if (this.$baseEventBus.isMobile) {
|
|
@@ -26,6 +29,8 @@ tmixins = {
|
|
|
26
29
|
title: this.$t2("提示", "components.errorMsg.title"),
|
|
27
30
|
text1: "",
|
|
28
31
|
text2: "",
|
|
32
|
+
detailItems: [],
|
|
33
|
+
structuredDetail: false,
|
|
29
34
|
showWrap: false,
|
|
30
35
|
showTextFlag: false,
|
|
31
36
|
zIndex: null,
|
|
@@ -56,6 +61,26 @@ tmixins = {
|
|
|
56
61
|
if (!text) return text;
|
|
57
62
|
return text.replace(/(\r\n|\n|\r)/gm, "<br />");
|
|
58
63
|
},
|
|
64
|
+
getDetailItems(text) {
|
|
65
|
+
let inCauseSection = false;
|
|
66
|
+
return String(text || "")
|
|
67
|
+
.split(/\r\n|\n|\r/)
|
|
68
|
+
.filter((line) => line.trim())
|
|
69
|
+
.map((line, index) => {
|
|
70
|
+
const separatorIndex = line.search(/[::]/);
|
|
71
|
+
const label = separatorIndex >= 0 ? line.slice(0, separatorIndex) : "";
|
|
72
|
+
const value = separatorIndex >= 0 ? line.slice(separatorIndex + 1).trim() : line;
|
|
73
|
+
const isSection = label === "可能原因";
|
|
74
|
+
if (isSection) inCauseSection = true;
|
|
75
|
+
return {
|
|
76
|
+
label,
|
|
77
|
+
value,
|
|
78
|
+
isSection,
|
|
79
|
+
isSummary: index === 0 && separatorIndex < 0,
|
|
80
|
+
isCause: inCauseSection && !isSection,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
},
|
|
59
84
|
showMsgBox: function () {
|
|
60
85
|
this.removeEnterEvent();
|
|
61
86
|
this.addEnterEvent();
|
|
@@ -79,8 +104,14 @@ tmixins = {
|
|
|
79
104
|
);
|
|
80
105
|
if (this._errorMsg) {
|
|
81
106
|
this.text2 = this.getShowText(this._errorMsg);
|
|
107
|
+
this.structuredDetail = /(^|\n)状态码[::]/.test(this._errorMsg);
|
|
108
|
+
this.detailItems = this.structuredDetail
|
|
109
|
+
? this.getDetailItems(this._errorMsg)
|
|
110
|
+
: [];
|
|
82
111
|
} else {
|
|
83
112
|
this.text2 = this.getShowText(content);
|
|
113
|
+
this.structuredDetail = false;
|
|
114
|
+
this.detailItems = [];
|
|
84
115
|
}
|
|
85
116
|
}
|
|
86
117
|
this.showTextFlag = false;
|
package/src/utils/request.js
CHANGED
|
@@ -111,7 +111,7 @@ service.interceptors.request.use(
|
|
|
111
111
|
}
|
|
112
112
|
);
|
|
113
113
|
|
|
114
|
-
function removeModel(config) {
|
|
114
|
+
function removeModel(config) {
|
|
115
115
|
if (config) {
|
|
116
116
|
if (config.modal !== false && config.ajaxOverlay) {
|
|
117
117
|
config.ajaxOverlay.remove();
|
|
@@ -123,7 +123,76 @@ function removeModel(config) {
|
|
|
123
123
|
}, 200);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function getSafeRequestUrl(config) {
|
|
129
|
+
if (!config || !config.url) return t1("未知");
|
|
130
|
+
const rawUrl = String(config.url).split("?")[0].split("#")[0];
|
|
131
|
+
const baseUrl = config.baseURL || "";
|
|
132
|
+
if (/^https?:\/\//i.test(rawUrl)) return rawUrl;
|
|
133
|
+
return `${baseUrl || ""}${rawUrl}` || t1("未知");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function t1(path, values) {
|
|
137
|
+
const translate = Vue.prototype.$t1;
|
|
138
|
+
return typeof translate === "function" ? translate(path, values) : path;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getRequestErrorMessage(error) {
|
|
142
|
+
const config = (error && error.config) || {};
|
|
143
|
+
const response = error && error.response;
|
|
144
|
+
const status = response && response.status;
|
|
145
|
+
const method = String(config.method || "GET").toUpperCase();
|
|
146
|
+
const requestUrl = getSafeRequestUrl(config);
|
|
147
|
+
const originalMessage = (error && error.message) || "未知错误";
|
|
148
|
+
let summary = t1("请求失败,请稍后重试。");
|
|
149
|
+
|
|
150
|
+
if (error && (error.code === "ECONNABORTED" || /timeout/i.test(originalMessage))) {
|
|
151
|
+
summary = t1("请求超时,请检查网络或稍后重试。");
|
|
152
|
+
} else if (!response) {
|
|
153
|
+
summary = t1("无法连接服务器,请检查网络、VPN/代理及服务状态后重试。");
|
|
154
|
+
} else if ([501, 502, 503, 504].includes(status)) {
|
|
155
|
+
summary = t1("网关或后端服务异常,请稍后重试或联系管理员。");
|
|
156
|
+
} else if (status >= 500) {
|
|
157
|
+
summary = t1("服务器暂时不可用,请稍后重试或联系管理员。");
|
|
158
|
+
} else if (status === 404) {
|
|
159
|
+
summary = t1("请求的服务地址不存在,请联系管理员检查接口配置。");
|
|
160
|
+
} else if (status === 403) {
|
|
161
|
+
summary = t1("服务器拒绝了本次请求,请检查访问权限。");
|
|
162
|
+
} else if (status === 401) {
|
|
163
|
+
summary = t1("登录状态已失效或无效,请重新登录。");
|
|
164
|
+
} else if (status >= 400) {
|
|
165
|
+
summary = t1("服务器未能处理本次请求,请检查输入后重试。");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const details = [
|
|
169
|
+
summary,
|
|
170
|
+
t1("请求:{method} {url}", { method, url: requestUrl }),
|
|
171
|
+
t1("状态码:{status}", {
|
|
172
|
+
status: status || t1("未收到服务器响应(浏览器未提供 HTTP 状态码)"),
|
|
173
|
+
}),
|
|
174
|
+
t1("错误码:{code}", { code: (error && error.code) || t1("无") }),
|
|
175
|
+
t1("原始错误:{message}", { message: originalMessage }),
|
|
176
|
+
t1("发生时间:{time}", { time: new Date().toLocaleString() }),
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
if (!response) {
|
|
180
|
+
details.push(t1("可能原因:"));
|
|
181
|
+
details.push(t1("ERR_CONNECTION_RESET:连接被服务端、网关或安全设备重置;"));
|
|
182
|
+
details.push(t1("CORS:浏览器跨域配置异常;"));
|
|
183
|
+
details.push(t1("ERR_CERT_*:HTTPS 证书异常;"));
|
|
184
|
+
details.push(t1("请求长期 Pending:接口阻塞或连接未释放。"));
|
|
185
|
+
details.push(t1("实际 HTTP 状态码请在浏览器 Network 面板或网关日志中确认。"));
|
|
186
|
+
} else if ([501, 502, 503, 504].includes(status)) {
|
|
187
|
+
details.push(t1("501/502/503/504:网关或后端服务异常。"));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
summary,
|
|
192
|
+
details: details.join("\n"),
|
|
193
|
+
errorLabel: !response ? originalMessage : "",
|
|
194
|
+
};
|
|
195
|
+
}
|
|
127
196
|
|
|
128
197
|
async function handleNickName(option) {
|
|
129
198
|
let { vueTarget, res, callback, config } = option;
|
|
@@ -419,18 +488,24 @@ service.interceptors.response.use(
|
|
|
419
488
|
if (config.modalStrictly !== true) {
|
|
420
489
|
removeModel(config);
|
|
421
490
|
}
|
|
422
|
-
if (config.errorMsg !== false) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
491
|
+
if (config.errorMsg !== false) {
|
|
492
|
+
const requestError = getRequestErrorMessage(error);
|
|
493
|
+
ErroreBox.msg({
|
|
494
|
+
content: requestError.summary,
|
|
495
|
+
_errorMsg: requestError.details,
|
|
496
|
+
errorLabel: requestError.errorLabel,
|
|
497
|
+
type: "error",
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
const requestError = getRequestErrorMessage(error);
|
|
502
|
+
ErroreBox.msg({
|
|
503
|
+
content: requestError.summary,
|
|
504
|
+
_errorMsg: requestError.details,
|
|
505
|
+
errorLabel: requestError.errorLabel,
|
|
506
|
+
type: "error",
|
|
507
|
+
});
|
|
508
|
+
}
|
|
434
509
|
}
|
|
435
510
|
return Promise.reject(error);
|
|
436
511
|
}
|