cloud-web-corejs 1.0.297 → 1.0.299

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.297",
4
+ "version": "1.0.299",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -13,9 +13,7 @@
13
13
  v-el-drag-dialog
14
14
  >
15
15
  <div class="cont">
16
- <p v-if="!rmid && !errorLabel">Error:</p>
17
- <p v-if="rmid">Error({{ rmid }}):</p>
18
- <p v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
16
+ <p>{{ errorTitle }}</p>
19
17
  <template v-if="!showTextFlag">
20
18
  <p v-html="text1"></p>
21
19
  </template>
@@ -51,9 +49,7 @@
51
49
  <i class="icon"></i>
52
50
  <div class="cont">
53
51
  <p class="name">{{ title }}</p>
54
- <p class="txt" v-if="!rmid && !errorLabel">Error:</p>
55
- <p class="txt" v-if="rmid">Error({{ rmid }}):</p>
56
- <p class="txt" v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
52
+ <p class="txt">{{ errorTitle }}</p>
57
53
  <template v-if="!showTextFlag">
58
54
  <p class="txt">{{ text1 }}</p>
59
55
  </template>
@@ -33,9 +33,21 @@ tmixins = {
33
33
  structuredDetail: false,
34
34
  showWrap: false,
35
35
  showTextFlag: false,
36
+ displayErrorLabel: "",
36
37
  zIndex: null,
37
38
  };
38
39
  },
40
+ computed: {
41
+ errorTitle() {
42
+ if (this.rmid) return `Error(${this.rmid}):`;
43
+ if (!this.displayErrorLabel) return "Error:";
44
+ if (this.isNetworkErrorLabel) return `${this.displayErrorLabel}:`;
45
+ return `Error(${this.displayErrorLabel}):`;
46
+ },
47
+ isNetworkErrorLabel() {
48
+ return /^network error$/i.test(String(this.displayErrorLabel).trim());
49
+ },
50
+ },
39
51
  beforeDestroy() {
40
52
  this.removeEnterEvent();
41
53
  },
@@ -61,6 +73,11 @@ tmixins = {
61
73
  if (!text) return text;
62
74
  return text.replace(/(\r\n|\n|\r)/gm, "<br />");
63
75
  },
76
+ getHttpStatusCode(detailItems) {
77
+ const item = (detailItems || []).find((row) => row.label === "状态码");
78
+ const value = item && String(item.value).trim();
79
+ return /^\d{3}$/.test(value) ? value : "";
80
+ },
64
81
  getDetailItems(text) {
65
82
  let inCauseSection = false;
66
83
  return String(text || "")
@@ -113,7 +130,12 @@ tmixins = {
113
130
  this.structuredDetail = false;
114
131
  this.detailItems = [];
115
132
  }
133
+ } else {
134
+ this.detailItems = [];
135
+ this.structuredDetail = false;
116
136
  }
137
+ this.displayErrorLabel =
138
+ this.errorLabel || this.getHttpStatusCode(this.detailItems) || "";
117
139
  this.showTextFlag = false;
118
140
  this.showWrap = true;
119
141
  this.promise = new Promise((resolve, reject) => {
@@ -272,7 +272,7 @@ tmixins = {
272
272
  }
273
273
  });
274
274
  },
275
- getUserPage(flag) {
275
+ getUserPage(flag, silent) {
276
276
  if (!this.dialogTableVisible) return
277
277
  if (!this.inited) {
278
278
  flag = null;
@@ -284,6 +284,7 @@ tmixins = {
284
284
  method: `post`,
285
285
  data: {operateTime: time},
286
286
  modal: false,
287
+ ...(silent ? { ignoreNetworkError: true } : {}),
287
288
  success: res => {
288
289
  let records = res.objx || [];
289
290
  records.forEach(record => {
@@ -368,7 +369,7 @@ tmixins = {
368
369
  }
369
370
  return lastTalkRecordId;
370
371
  },
371
- getList(direction, callback) {
372
+ getList(direction, callback, silent) {
372
373
  if (!this.dialogTableVisible) return
373
374
  if (!this.talkUserId) return
374
375
  let talkUser = this.talkUser;
@@ -387,6 +388,7 @@ tmixins = {
387
388
  direction: direction
388
389
  },
389
390
  modal: false,
391
+ ...(silent ? { ignoreNetworkError: true } : {}),
390
392
  success: res => {
391
393
  let rows = res.objx || [];
392
394
  if (rows.length) {
@@ -456,15 +458,15 @@ tmixins = {
456
458
  createTimerHandle() {
457
459
  this.clearTimerHandle();
458
460
  this.handleExitsRead();
459
- this.talkHandle();
461
+ this.talkHandle(true);
460
462
  this.timer = setInterval(() => {
461
463
  this.handleExitsRead();
462
- this.talkHandle();
464
+ this.talkHandle(true);
463
465
  }, 10000)
464
466
  },
465
- talkHandle() {
466
- this.getUserPage(1);
467
- this.getList(0);
467
+ talkHandle(silent) {
468
+ this.getUserPage(1, silent);
469
+ this.getList(0, null, silent);
468
470
  },
469
471
  clearTimerHandle() {
470
472
  if (this.timer) {
@@ -488,6 +490,7 @@ tmixins = {
488
490
  method: `post`,
489
491
  data: {},
490
492
  modal: false,
493
+ ignoreNetworkError: true,
491
494
  success: res => {
492
495
  this.isExitsRead = res.objx === 1;
493
496
  }
@@ -121,7 +121,11 @@ export default {
121
121
  if (this.$t1) {
122
122
  title = this.$t1(title)
123
123
  }
124
- if (item.repeatIndex > 1) {
124
+ if (item.query?._tabSuffix) {
125
+ let suffix = this.$t1 ? this.$t1(item.query._tabSuffix) : item.query._tabSuffix
126
+ title = `${title}(${suffix})`
127
+ }
128
+ if (!item.query?._tabSuffix && item.repeatIndex > 1) {
125
129
  title = `${title} (${item.repeatIndex})`
126
130
  }
127
131
  return title;
@@ -8,8 +8,8 @@ import ErroreBox from "../components/errorMsg/index.js";
8
8
  import PopupManager from "element-ui/src/utils/popup/popup-manager.js";
9
9
  import settingConfig from "@/settings.js";
10
10
  import { encode } from "js-base64";
11
- import { encrypt } from "@base/utils/aes";
12
- import { handleRequestNetworkError } from "@base/utils/runtimeRecovery";
11
+ import { encrypt } from "@base/utils/aes";
12
+ import { handleRequestNetworkError } from "@base/utils/runtimeRecovery";
13
13
 
14
14
  let configUtil = {
15
15
  baseUrl: process.env.VUE_APP_BASE_API,
@@ -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,76 +123,96 @@ function removeModel(config) {
123
123
  }, 200);
124
124
  }
125
125
  }
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
- }
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 isAxiosNetworkError(error) {
142
+ if (!error || error.response) return false;
143
+ const message = (error.message || "").toString();
144
+ if (error.code === "ECONNABORTED" || /timeout/i.test(message)) return false;
145
+ return error.code === "ERR_NETWORK" || /network error/i.test(message);
146
+ }
147
+
148
+ function shouldSwallowNetworkError(config, error) {
149
+ return !!(
150
+ config &&
151
+ config.ignoreNetworkError === true &&
152
+ isAxiosNetworkError(error)
153
+ );
154
+ }
155
+
156
+ function getRequestErrorMessage(error) {
157
+ const config = (error && error.config) || {};
158
+ const response = error && error.response;
159
+ const status = response && response.status;
160
+ const method = String(config.method || "GET").toUpperCase();
161
+ const requestUrl = getSafeRequestUrl(config);
162
+ const originalMessage = (error && error.message) || "未知错误";
163
+ let summary = t1("请求失败,请稍后重试。");
164
+
165
+ if (error && (error.code === "ECONNABORTED" || /timeout/i.test(originalMessage))) {
166
+ summary = t1("请求超时,请检查网络或稍后重试。");
167
+ } else if (!response) {
168
+ summary = t1("无法连接服务器,请检查网络、VPN/代理及服务状态后重试。");
169
+ } else if ([501, 502, 503, 504].includes(status)) {
170
+ summary = t1("网关或后端服务异常,请稍后重试或联系管理员。");
171
+ } else if (status >= 500) {
172
+ summary = t1("服务器暂时不可用,请稍后重试或联系管理员。");
173
+ } else if (status === 404) {
174
+ summary = t1("请求的服务地址不存在,请联系管理员检查接口配置。");
175
+ } else if (status === 403) {
176
+ summary = t1("服务器拒绝了本次请求,请检查访问权限。");
177
+ } else if (status === 401) {
178
+ summary = t1("登录状态已失效或无效,请重新登录。");
179
+ } else if (status >= 400) {
180
+ summary = t1("服务器未能处理本次请求,请检查输入后重试。");
181
+ }
182
+
183
+ const details = [
184
+ summary,
185
+ t1("请求:{method} {url}", { method, url: requestUrl }),
186
+ t1("状态码:{status}", {
187
+ status: status || t1("未收到服务器响应(浏览器未提供 HTTP 状态码)"),
188
+ }),
189
+ ];
190
+ if (error && error.code) {
191
+ details.push(t1("错误码:{code}", { code: error.code }));
192
+ }
193
+ details.push(
194
+ t1("原始错误:{message}", { message: originalMessage }),
195
+ t1("发生时间:{time}", { time: new Date().toLocaleString() })
196
+ );
197
+
198
+ if (!response) {
199
+ details.push(t1("可能原因:"));
200
+ details.push(t1("ERR_CONNECTION_RESET:连接被服务端、网关或安全设备重置;"));
201
+ details.push(t1("CORS:浏览器跨域配置异常;"));
202
+ details.push(t1("ERR_CERT_*:HTTPS 证书异常;"));
203
+ details.push(t1("请求长期 Pending:接口阻塞或连接未释放。"));
204
+ details.push(t1("实际 HTTP 状态码请在浏览器 Network 面板或网关日志中确认。"));
205
+ } else if ([501, 502, 503, 504].includes(status)) {
206
+ details.push(t1("501/502/503/504:网关或后端服务异常。"));
207
+ }
208
+
209
+ return {
210
+ summary,
211
+ details: details.join("\n"),
212
+ // 有 HTTP 状态码时直接挂到弹窗标题 Error(502),不用点开「详情」
213
+ errorLabel: status ? String(status) : !response ? originalMessage : "",
214
+ };
215
+ }
196
216
 
197
217
  async function handleNickName(option) {
198
218
  let { vueTarget, res, callback, config } = option;
@@ -467,14 +487,17 @@ service.interceptors.response.use(
467
487
  // 那个 else 分支无条件弹 ErroreBox —— 而 ErroreBox 是弹窗不是 toast,取消 N 个
468
488
  // 在途请求就会连弹 N 个错误框。config.errorMsg 那条逃生口在 if (config) 里面,
469
489
  // Cancel 走不到,所以只能在这里拦。调用方按需自行 catch。
470
- if (axios.isCancel(error)) {
471
- return Promise.reject(error);
472
- }
473
- let config = error.config;
474
- if (handleRequestNetworkError()) {
475
- if (config && config.modalStrictly !== true) removeModel(config);
476
- return Promise.reject(error);
477
- }
490
+ if (axios.isCancel(error)) {
491
+ return Promise.reject(error);
492
+ }
493
+ let config = error.config;
494
+ // 仅 Network Error 可被 ignoreNetworkError 吞掉(首页/在线聊天定时轮询)。
495
+ // 超时、5xx、业务失败等其它异常照常弹窗并 reject。
496
+ const swallowNetworkError = shouldSwallowNetworkError(config, error);
497
+ if (handleRequestNetworkError()) {
498
+ if (config && config.modalStrictly !== true) removeModel(config);
499
+ return swallowNetworkError ? Promise.resolve() : Promise.reject(error);
500
+ }
478
501
  if (
479
502
  error.response &&
480
503
  error.response.data &&
@@ -488,26 +511,26 @@ service.interceptors.response.use(
488
511
  if (config.modalStrictly !== true) {
489
512
  removeModel(config);
490
513
  }
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
- }
514
+ if (config.errorMsg !== false && !swallowNetworkError) {
515
+ const requestError = getRequestErrorMessage(error);
516
+ ErroreBox.msg({
517
+ content: requestError.summary,
518
+ _errorMsg: requestError.details,
519
+ errorLabel: requestError.errorLabel,
520
+ type: "error",
521
+ });
522
+ }
523
+ } else {
524
+ const requestError = getRequestErrorMessage(error);
525
+ ErroreBox.msg({
526
+ content: requestError.summary,
527
+ _errorMsg: requestError.details,
528
+ errorLabel: requestError.errorLabel,
529
+ type: "error",
530
+ });
531
+ }
509
532
  }
510
- return Promise.reject(error);
533
+ return swallowNetworkError ? Promise.resolve() : Promise.reject(error);
511
534
  }
512
535
  );
513
536