cloud-web-corejs 1.0.323 → 1.0.325
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
|
@@ -108,9 +108,16 @@ export default {
|
|
|
108
108
|
watch: {
|
|
109
109
|
visibleTabs(tabs) {
|
|
110
110
|
const formRef = this.getFormRef();
|
|
111
|
-
|
|
111
|
+
/* 当前表单根组件是 formDynamicFieldMixin,没有 isFieldControlEnabled。
|
|
112
|
+
开关与 publish_dev 的该方法一致:formConfig.dynamicFieldEnabled。
|
|
113
|
+
直接调用缺失方法会在页签显隐时抛 TypeError。 */
|
|
114
|
+
const fieldControlOn = !!(
|
|
112
115
|
formRef
|
|
113
|
-
&& formRef.
|
|
116
|
+
&& formRef.formConfig
|
|
117
|
+
&& formRef.formConfig.dynamicFieldEnabled
|
|
118
|
+
);
|
|
119
|
+
if (
|
|
120
|
+
fieldControlOn
|
|
114
121
|
&& !tabs.some(tab => tab.options.name === this.activeTabName)
|
|
115
122
|
) {
|
|
116
123
|
this.activeTabName = tabs.length ? tabs[0].options.name : "";
|
package/src/utils/request.js
CHANGED
|
@@ -42,6 +42,40 @@ function isBinaryRequestBody(data) {
|
|
|
42
42
|
return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(data);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
function isAbsoluteHttpUrl(url) {
|
|
46
|
+
return /^(https?:)?\/\//i.test(String(url || ""));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function toOrigin(url) {
|
|
50
|
+
try {
|
|
51
|
+
return new URL(String(url), window.location.href).origin;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 相对地址走当前 baseURL,视为本系统后台。绝对地址只有和后台同源才加密。
|
|
58
|
+
function isOwnBackendRequest(config) {
|
|
59
|
+
const rawUrl = String((config && config.url) || "");
|
|
60
|
+
let targetOrigin = "";
|
|
61
|
+
if (isAbsoluteHttpUrl(rawUrl)) {
|
|
62
|
+
targetOrigin = toOrigin(rawUrl);
|
|
63
|
+
} else {
|
|
64
|
+
const baseUrl =
|
|
65
|
+
config && config.baseURL != null && config.baseURL !== ""
|
|
66
|
+
? config.baseURL
|
|
67
|
+
: configUtil.baseUrl || "";
|
|
68
|
+
targetOrigin = isAbsoluteHttpUrl(baseUrl)
|
|
69
|
+
? toOrigin(baseUrl)
|
|
70
|
+
: window.location.origin;
|
|
71
|
+
}
|
|
72
|
+
const ownBase = configUtil.baseUrl || "";
|
|
73
|
+
const ownOrigin = isAbsoluteHttpUrl(ownBase)
|
|
74
|
+
? toOrigin(ownBase)
|
|
75
|
+
: window.location.origin;
|
|
76
|
+
return !!targetOrigin && targetOrigin === ownOrigin;
|
|
77
|
+
}
|
|
78
|
+
|
|
45
79
|
// 调用方已经 stringify 成对象或数组文本时直接加密,避免再包一层字符串。
|
|
46
80
|
function aesPlainText(data, useEmptyObject) {
|
|
47
81
|
if (typeof data === "string") {
|
|
@@ -89,7 +123,11 @@ service.interceptors.request.use(
|
|
|
89
123
|
);
|
|
90
124
|
}
|
|
91
125
|
const canEncryptBody = !isBinaryRequestBody(config.data);
|
|
92
|
-
if (
|
|
126
|
+
if (
|
|
127
|
+
settingConfig.requestAesEnabled === true &&
|
|
128
|
+
canEncryptBody &&
|
|
129
|
+
isOwnBackendRequest(config)
|
|
130
|
+
) {
|
|
93
131
|
config.data = wrapAesBody(config.data, true);
|
|
94
132
|
config.headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
95
133
|
} else if (
|