cloudcc-ccdk 0.9.8 → 0.9.10
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/README.md +654 -644
- package/lib/ccdk.js +1819 -1817
- package/lib/ccdk.min.js +1 -1
- package/package.json +33 -33
package/lib/ccdk.js
CHANGED
|
@@ -6,69 +6,69 @@ import Cookies from 'js-cookie';
|
|
|
6
6
|
import Jwt from 'jsonwebtoken';
|
|
7
7
|
import { Message, MessageBox, Notification } from 'element-ui';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* 加密
|
|
11
|
-
* @param {String} data 数据
|
|
12
|
-
* @param {String} key 密钥
|
|
13
|
-
* @param {String} iv 偏移量
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
function getAesString(data, key, iv) {
|
|
17
|
-
key = CryptoJS.enc.Utf8.parse(key);
|
|
18
|
-
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
19
|
-
let encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
20
|
-
iv: iv,
|
|
21
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
22
|
-
});
|
|
23
|
-
return encrypted.toString(); //返回的是base64格式的密文
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 解密
|
|
28
|
-
* @param {String} encrypted 密文
|
|
29
|
-
* @param {String} key 密钥
|
|
30
|
-
* @param {String} iv 偏移量
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
function getDAesString(encrypted, key, iv) {
|
|
34
|
-
key = CryptoJS.enc.Utf8.parse(key);
|
|
35
|
-
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
36
|
-
let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
|
|
37
|
-
iv: iv,
|
|
38
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
39
|
-
});
|
|
40
|
-
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* CryptoJS加密
|
|
45
|
-
* @param {String} data 数据
|
|
46
|
-
* @param {String} key 密钥
|
|
47
|
-
* @param {String} iv 偏移量
|
|
48
|
-
* @returns 加密的数据
|
|
49
|
-
*/
|
|
50
|
-
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
51
|
-
data = JSON.stringify(data);
|
|
52
|
-
var encrypted = getAesString(data, key, iv); //密文
|
|
53
|
-
return encrypted;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* CryptoJS解密
|
|
58
|
-
* @param {String} data 加密的数据
|
|
59
|
-
* @param {String} key 密钥
|
|
60
|
-
* @param {String} iv 偏移量
|
|
61
|
-
* @returns 解密的数据
|
|
62
|
-
*/
|
|
63
|
-
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
64
|
-
try {
|
|
65
|
-
var decryptedStr = getDAesString(data, key, iv);
|
|
66
|
-
if (!decryptedStr) return null
|
|
67
|
-
return JSON.parse(decryptedStr);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.trace("解密密码错误", error);
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* 加密
|
|
11
|
+
* @param {String} data 数据
|
|
12
|
+
* @param {String} key 密钥
|
|
13
|
+
* @param {String} iv 偏移量
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function getAesString(data, key, iv) {
|
|
17
|
+
key = CryptoJS.enc.Utf8.parse(key);
|
|
18
|
+
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
19
|
+
let encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
20
|
+
iv: iv,
|
|
21
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
22
|
+
});
|
|
23
|
+
return encrypted.toString(); //返回的是base64格式的密文
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 解密
|
|
28
|
+
* @param {String} encrypted 密文
|
|
29
|
+
* @param {String} key 密钥
|
|
30
|
+
* @param {String} iv 偏移量
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
function getDAesString(encrypted, key, iv) {
|
|
34
|
+
key = CryptoJS.enc.Utf8.parse(key);
|
|
35
|
+
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
36
|
+
let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
|
|
37
|
+
iv: iv,
|
|
38
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
39
|
+
});
|
|
40
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* CryptoJS加密
|
|
45
|
+
* @param {String} data 数据
|
|
46
|
+
* @param {String} key 密钥
|
|
47
|
+
* @param {String} iv 偏移量
|
|
48
|
+
* @returns 加密的数据
|
|
49
|
+
*/
|
|
50
|
+
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
51
|
+
data = JSON.stringify(data);
|
|
52
|
+
var encrypted = getAesString(data, key, iv); //密文
|
|
53
|
+
return encrypted;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* CryptoJS解密
|
|
58
|
+
* @param {String} data 加密的数据
|
|
59
|
+
* @param {String} key 密钥
|
|
60
|
+
* @param {String} iv 偏移量
|
|
61
|
+
* @returns 解密的数据
|
|
62
|
+
*/
|
|
63
|
+
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
64
|
+
try {
|
|
65
|
+
var decryptedStr = getDAesString(data, key, iv);
|
|
66
|
+
if (!decryptedStr) return null
|
|
67
|
+
return JSON.parse(decryptedStr);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.trace("解密密码错误", error);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
var Crypto = /*#__PURE__*/Object.freeze({
|
|
@@ -77,27 +77,27 @@ var Crypto = /*#__PURE__*/Object.freeze({
|
|
|
77
77
|
decrypt: decrypt
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
// 当前应用存储标识
|
|
81
|
-
const APPLICATION_DETAIL = 'applicaton_current';
|
|
82
|
-
/**
|
|
83
|
-
* 获得当前访问的应用对象
|
|
84
|
-
*/
|
|
85
|
-
function getApplicaton() {
|
|
86
|
-
let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
|
|
87
|
-
if (detail) {
|
|
88
|
-
return JSON.parse(detail)
|
|
89
|
-
}
|
|
90
|
-
return ''
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 设置应用对象信息
|
|
95
|
-
* @param {object} detail 应用对象
|
|
96
|
-
*/
|
|
97
|
-
function setApplication(detail = '') {
|
|
98
|
-
if (detail) {
|
|
99
|
-
localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
|
|
100
|
-
}
|
|
80
|
+
// 当前应用存储标识
|
|
81
|
+
const APPLICATION_DETAIL = 'applicaton_current';
|
|
82
|
+
/**
|
|
83
|
+
* 获得当前访问的应用对象
|
|
84
|
+
*/
|
|
85
|
+
function getApplicaton() {
|
|
86
|
+
let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
|
|
87
|
+
if (detail) {
|
|
88
|
+
return JSON.parse(detail)
|
|
89
|
+
}
|
|
90
|
+
return ''
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 设置应用对象信息
|
|
95
|
+
* @param {object} detail 应用对象
|
|
96
|
+
*/
|
|
97
|
+
function setApplication(detail = '') {
|
|
98
|
+
if (detail) {
|
|
99
|
+
localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
|
|
100
|
+
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
var CCApplication = /*#__PURE__*/Object.freeze({
|
|
@@ -106,104 +106,104 @@ var CCApplication = /*#__PURE__*/Object.freeze({
|
|
|
106
106
|
setApplication: setApplication
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
/**
|
|
110
|
-
* 获得一级域名
|
|
111
|
-
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
112
|
-
*/
|
|
113
|
-
function getDomain() {
|
|
114
|
-
let domain = document.domain;
|
|
115
|
-
if (isValidIP(domain)) {
|
|
116
|
-
return domain
|
|
117
|
-
} else {
|
|
118
|
-
// 倒数第二位域名
|
|
119
|
-
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
120
|
-
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
121
|
-
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
122
|
-
return "." + document.domain.split('.').slice(-3).join('.')
|
|
123
|
-
} else {
|
|
124
|
-
return "." + document.domain.split('.').slice(-2).join('.')
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* 检测是否为有效IP
|
|
130
|
-
* @param {string} ip ip地址
|
|
131
|
-
* @returns 是否为ip地址
|
|
132
|
-
*/
|
|
133
|
-
function isValidIP(ip) {
|
|
134
|
-
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
135
|
-
return reg.test(ip);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 校验token是否有效
|
|
139
|
-
* {
|
|
140
|
-
"versionType": "Unlimited",
|
|
141
|
-
"loginName": "admin@cloudcc.com",
|
|
142
|
-
"binding": "1eaabe2e24844904b443308f48fb0dee",
|
|
143
|
-
"userId": "0052017BE8702F1PIi4j",
|
|
144
|
-
"orgId": "exorg20235419690prod"
|
|
145
|
-
}
|
|
146
|
-
* @param {string} token 认证信息
|
|
147
|
-
*/
|
|
148
|
-
function verifyToken(token) {
|
|
149
|
-
let j = Jwt.decode(token);
|
|
150
|
-
return { result: j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 格式化时间:yyyy-MM-dd HH:mm:ss
|
|
155
|
-
* @returns
|
|
156
|
-
*/
|
|
157
|
-
function getNowFormatDate() {
|
|
158
|
-
var myDate = new Date;
|
|
159
|
-
var year = myDate.getFullYear(); //获取当前年
|
|
160
|
-
var mon = myDate.getMonth() + 1; //获取当前月
|
|
161
|
-
if (mon < 10) {
|
|
162
|
-
mon = "0" + mon;
|
|
163
|
-
}
|
|
164
|
-
var date = myDate.getDate(); //获取当前日
|
|
165
|
-
if (date < 10) {
|
|
166
|
-
date = "0" + date;
|
|
167
|
-
}
|
|
168
|
-
var hours = myDate.getHours(); //获取当前小时
|
|
169
|
-
if (hours < 10) {
|
|
170
|
-
hours = "0" + hours;
|
|
171
|
-
}
|
|
172
|
-
var minutes = myDate.getMinutes(); //获取当前分钟
|
|
173
|
-
if (minutes < 10) {
|
|
174
|
-
minutes = "0" + minutes;
|
|
175
|
-
}
|
|
176
|
-
var seconds = myDate.getSeconds(); //获取当前秒
|
|
177
|
-
if (seconds < 10) {
|
|
178
|
-
seconds = "0" + seconds;
|
|
179
|
-
}
|
|
180
|
-
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
|
|
181
|
-
return now;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* 获得16位标识
|
|
186
|
-
* @returns 16位标识
|
|
187
|
-
*/
|
|
188
|
-
function getUuid() {
|
|
189
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
190
|
-
var r = (Math.random() * 16) | 0,
|
|
191
|
-
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
192
|
-
return v.toString(16);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function getBinding() {
|
|
197
|
-
let binding = window.$CCDK.CCToken.getToken();
|
|
198
|
-
if (!binding) {
|
|
199
|
-
window.open(window.Glod.LOGIN_URL, '_self');
|
|
200
|
-
// this.reLogin();
|
|
201
|
-
} else {
|
|
202
|
-
// 刷新有效期,而且有的老功能,依赖这个binding了
|
|
203
|
-
Cookies.set('binding', binding, { expires: 1 / 12 });
|
|
204
|
-
Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
|
|
205
|
-
}
|
|
206
|
-
return binding
|
|
109
|
+
/**
|
|
110
|
+
* 获得一级域名
|
|
111
|
+
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
112
|
+
*/
|
|
113
|
+
function getDomain() {
|
|
114
|
+
let domain = document.domain;
|
|
115
|
+
if (isValidIP(domain)) {
|
|
116
|
+
return domain
|
|
117
|
+
} else {
|
|
118
|
+
// 倒数第二位域名
|
|
119
|
+
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
120
|
+
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
121
|
+
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
122
|
+
return "." + document.domain.split('.').slice(-3).join('.')
|
|
123
|
+
} else {
|
|
124
|
+
return "." + document.domain.split('.').slice(-2).join('.')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 检测是否为有效IP
|
|
130
|
+
* @param {string} ip ip地址
|
|
131
|
+
* @returns 是否为ip地址
|
|
132
|
+
*/
|
|
133
|
+
function isValidIP(ip) {
|
|
134
|
+
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
135
|
+
return reg.test(ip);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 校验token是否有效
|
|
139
|
+
* {
|
|
140
|
+
"versionType": "Unlimited",
|
|
141
|
+
"loginName": "admin@cloudcc.com",
|
|
142
|
+
"binding": "1eaabe2e24844904b443308f48fb0dee",
|
|
143
|
+
"userId": "0052017BE8702F1PIi4j",
|
|
144
|
+
"orgId": "exorg20235419690prod"
|
|
145
|
+
}
|
|
146
|
+
* @param {string} token 认证信息
|
|
147
|
+
*/
|
|
148
|
+
function verifyToken(token) {
|
|
149
|
+
let j = Jwt.decode(token);
|
|
150
|
+
return { result: j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 格式化时间:yyyy-MM-dd HH:mm:ss
|
|
155
|
+
* @returns
|
|
156
|
+
*/
|
|
157
|
+
function getNowFormatDate() {
|
|
158
|
+
var myDate = new Date;
|
|
159
|
+
var year = myDate.getFullYear(); //获取当前年
|
|
160
|
+
var mon = myDate.getMonth() + 1; //获取当前月
|
|
161
|
+
if (mon < 10) {
|
|
162
|
+
mon = "0" + mon;
|
|
163
|
+
}
|
|
164
|
+
var date = myDate.getDate(); //获取当前日
|
|
165
|
+
if (date < 10) {
|
|
166
|
+
date = "0" + date;
|
|
167
|
+
}
|
|
168
|
+
var hours = myDate.getHours(); //获取当前小时
|
|
169
|
+
if (hours < 10) {
|
|
170
|
+
hours = "0" + hours;
|
|
171
|
+
}
|
|
172
|
+
var minutes = myDate.getMinutes(); //获取当前分钟
|
|
173
|
+
if (minutes < 10) {
|
|
174
|
+
minutes = "0" + minutes;
|
|
175
|
+
}
|
|
176
|
+
var seconds = myDate.getSeconds(); //获取当前秒
|
|
177
|
+
if (seconds < 10) {
|
|
178
|
+
seconds = "0" + seconds;
|
|
179
|
+
}
|
|
180
|
+
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
|
|
181
|
+
return now;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 获得16位标识
|
|
186
|
+
* @returns 16位标识
|
|
187
|
+
*/
|
|
188
|
+
function getUuid() {
|
|
189
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
190
|
+
var r = (Math.random() * 16) | 0,
|
|
191
|
+
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
192
|
+
return v.toString(16);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function getBinding() {
|
|
197
|
+
let binding = window.$CCDK.CCToken.getToken();
|
|
198
|
+
if (!binding) {
|
|
199
|
+
window.open(window.Glod.LOGIN_URL, '_self');
|
|
200
|
+
// this.reLogin();
|
|
201
|
+
} else {
|
|
202
|
+
// 刷新有效期,而且有的老功能,依赖这个binding了
|
|
203
|
+
Cookies.set('binding', binding, { expires: 1 / 12 });
|
|
204
|
+
Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
|
|
205
|
+
}
|
|
206
|
+
return binding
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -215,453 +215,453 @@ var CCUtils = /*#__PURE__*/Object.freeze({
|
|
|
215
215
|
verifyToken: verifyToken
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
const toStr = Object.prototype.toString;
|
|
219
|
-
|
|
220
|
-
const TypeEnum = {
|
|
221
|
-
'FUNCTION': '[object Function]',
|
|
222
|
-
'ARRAY': '[object Array]',
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// 是否是一个函数
|
|
226
|
-
const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
|
|
227
|
-
|
|
228
|
-
// 是否是生产环境
|
|
229
|
-
const isProduction = () => true ;
|
|
230
|
-
|
|
231
|
-
// 延时
|
|
232
|
-
const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
|
|
233
|
-
|
|
234
|
-
// 是否是超时请求
|
|
235
|
-
const isTimeout = (error = {
|
|
236
|
-
code: '',
|
|
237
|
-
message: ''
|
|
238
|
-
}) => {
|
|
239
|
-
return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
// 格式换请求体
|
|
243
|
-
const formateData = data => {
|
|
244
|
-
return {
|
|
245
|
-
head: {
|
|
246
|
-
appType: "lightning-main",
|
|
247
|
-
appVersion: "1.1.1",
|
|
248
|
-
accessToken: getBinding(),
|
|
249
|
-
source: "lightning-main"
|
|
250
|
-
},
|
|
251
|
-
body: {
|
|
252
|
-
...data
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* 深度合并
|
|
258
|
-
* @param {object} source 合并的基础对象
|
|
259
|
-
* @param {object} target 新的数据
|
|
260
|
-
*/
|
|
261
|
-
const deepMerge = (source, target) => {
|
|
262
|
-
const res = cloneDeep(source);
|
|
263
|
-
for (let key in target) {
|
|
264
|
-
if (target.hasOwnProperty(key)) {
|
|
265
|
-
res[key] = isObject(target[key])
|
|
266
|
-
? deepMerge(res[key], target[key])
|
|
267
|
-
: target[key];
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return res
|
|
218
|
+
const toStr = Object.prototype.toString;
|
|
219
|
+
|
|
220
|
+
const TypeEnum = {
|
|
221
|
+
'FUNCTION': '[object Function]',
|
|
222
|
+
'ARRAY': '[object Array]',
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// 是否是一个函数
|
|
226
|
+
const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
|
|
227
|
+
|
|
228
|
+
// 是否是生产环境
|
|
229
|
+
const isProduction = () => true ;
|
|
230
|
+
|
|
231
|
+
// 延时
|
|
232
|
+
const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
|
|
233
|
+
|
|
234
|
+
// 是否是超时请求
|
|
235
|
+
const isTimeout = (error = {
|
|
236
|
+
code: '',
|
|
237
|
+
message: ''
|
|
238
|
+
}) => {
|
|
239
|
+
return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
|
|
271
240
|
};
|
|
272
241
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
242
|
+
// 格式换请求体
|
|
243
|
+
const formateData = data => {
|
|
244
|
+
return {
|
|
245
|
+
head: {
|
|
246
|
+
appType: "lightning-main",
|
|
247
|
+
appVersion: "1.1.1",
|
|
248
|
+
accessToken: getBinding(),
|
|
249
|
+
source: "lightning-main"
|
|
250
|
+
},
|
|
251
|
+
body: {
|
|
252
|
+
...data
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* 深度合并
|
|
258
|
+
* @param {object} source 合并的基础对象
|
|
259
|
+
* @param {object} target 新的数据
|
|
260
|
+
*/
|
|
261
|
+
const deepMerge = (source, target) => {
|
|
262
|
+
const res = cloneDeep(source);
|
|
263
|
+
for (let key in target) {
|
|
264
|
+
if (target.hasOwnProperty(key)) {
|
|
265
|
+
res[key] = isObject(target[key])
|
|
266
|
+
? deepMerge(res[key], target[key])
|
|
267
|
+
: target[key];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return res
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* LRU算法
|
|
275
|
+
* @param {number} capacity 最大缓存容量
|
|
276
|
+
*/
|
|
277
|
+
const LRUCache = function (capacity) {
|
|
278
|
+
this.capacity = capacity;
|
|
279
|
+
this.cache = new Map();
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 获取指定key的缓存
|
|
284
|
+
* @param {string} key 缓存的key
|
|
285
|
+
*/
|
|
286
|
+
LRUCache.prototype.get = function (key) {
|
|
287
|
+
var cacheTemp = this.cache,
|
|
288
|
+
curTemp = cacheTemp.get(key);
|
|
289
|
+
if (curTemp || curTemp === 0) {
|
|
290
|
+
cacheTemp.delete(key);
|
|
291
|
+
cacheTemp.set(key, curTemp);
|
|
292
|
+
return curTemp
|
|
293
|
+
}
|
|
294
|
+
return null
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 指定key添加缓存
|
|
299
|
+
* @param {string} key 缓存的key
|
|
300
|
+
* @param {object} value 缓存的值
|
|
301
|
+
*/
|
|
302
|
+
LRUCache.prototype.put = function (key, value) {
|
|
303
|
+
var cacheTemp = this.cache;
|
|
304
|
+
if (cacheTemp.get(key)) {
|
|
305
|
+
cacheTemp.delete(key);
|
|
306
|
+
} else if (cacheTemp.size >= this.capacity) {
|
|
307
|
+
cacheTemp.delete(cacheTemp.keys().next().value);
|
|
308
|
+
}
|
|
309
|
+
cacheTemp.set(key, value);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
class CCAxios {
|
|
313
|
+
constructor(opt) {
|
|
314
|
+
this.options = opt;
|
|
315
|
+
this.axiosInstance = axios.create(opt);
|
|
316
|
+
this.setupInterceptors();
|
|
317
|
+
this.cachePool = new LRUCache(20);
|
|
318
|
+
// FIXME:区分构造函数参数和接口级别的参数
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
//获取拦截器
|
|
322
|
+
getTransform() {
|
|
323
|
+
const { transform } = this.options;
|
|
324
|
+
return transform;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
//准备拦截器
|
|
328
|
+
setupInterceptors() {
|
|
329
|
+
const transform = this.getTransform();
|
|
330
|
+
if (!transform) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const {
|
|
334
|
+
requestInterceptors,
|
|
335
|
+
requestInterceptorsCatch,
|
|
336
|
+
responseInterceptors,
|
|
337
|
+
responseInterceptorsCatch,
|
|
338
|
+
} = transform;
|
|
339
|
+
// 请求拦截器
|
|
340
|
+
this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
|
|
341
|
+
// 请求拦截器错误处理
|
|
342
|
+
requestInterceptorsCatch
|
|
343
|
+
&& isFn(requestInterceptorsCatch)
|
|
344
|
+
&& this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
|
|
345
|
+
|
|
346
|
+
// 响应拦截器
|
|
347
|
+
this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
|
|
348
|
+
// 响应拦截器错误处理
|
|
349
|
+
responseInterceptorsCatch
|
|
350
|
+
&& isFn(responseInterceptorsCatch)
|
|
351
|
+
&& this.axiosInstance.interceptors.response.use(undefined, (error) => {
|
|
352
|
+
return responseInterceptorsCatch(this.axiosInstance, error)
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
get(config, options = {}) {
|
|
356
|
+
return this.request({ ...config, method: 'GET', }, options)
|
|
357
|
+
}
|
|
358
|
+
post(config, options = {}) {
|
|
359
|
+
const { envType } = options;
|
|
360
|
+
// 公有云专用接口,在私有云不请求
|
|
361
|
+
if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
|
|
362
|
+
return new Promise(() => { })
|
|
363
|
+
}
|
|
364
|
+
// 私有云专用接口,在公有云不请求
|
|
365
|
+
if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
|
|
366
|
+
return new Promise(() => { })
|
|
367
|
+
}
|
|
368
|
+
return this.request({ ...config, method: 'POST', }, options)
|
|
369
|
+
}
|
|
370
|
+
postFormat(config, options = {}) {
|
|
371
|
+
return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
|
|
372
|
+
}
|
|
373
|
+
postParams(config, options = {}) {
|
|
374
|
+
return this.request({ ...config, method: 'POST', params: config.data }, options)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// FIXME:如果初始化时配置了重试那么所有get接口都重试了
|
|
378
|
+
// options是接口级定义的参数
|
|
379
|
+
request(config, options) {
|
|
380
|
+
const transform = this.getTransform();
|
|
381
|
+
const conf = config,
|
|
382
|
+
{ requestOptions } = this.options;
|
|
383
|
+
requestOptions.cache = false;
|
|
384
|
+
requestOptions.cacheKey = '';
|
|
385
|
+
requestOptions.retryRequest = {
|
|
386
|
+
isOpenRetry: false,
|
|
387
|
+
count: 5,
|
|
388
|
+
waitTime: 1000
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const opt = Object.assign({}, requestOptions, options);
|
|
392
|
+
conf.requestOptions = opt;
|
|
393
|
+
|
|
394
|
+
const retPromise = new Promise((resolve, reject) => {
|
|
395
|
+
this.axiosInstance(conf)
|
|
396
|
+
.then(res => {
|
|
397
|
+
const { transformResponseHook } = transform;
|
|
398
|
+
if (transformResponseHook && isFn(transformResponseHook)) {
|
|
399
|
+
try {
|
|
400
|
+
const ret = transformResponseHook(res, opt, this.cachePool);
|
|
401
|
+
resolve(ret);
|
|
402
|
+
} catch (err) {
|
|
403
|
+
reject(err || new Error('request error!'));
|
|
404
|
+
}
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
resolve(res);
|
|
408
|
+
})
|
|
409
|
+
.catch(err => {
|
|
410
|
+
reject(err);
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
// 缓存
|
|
414
|
+
retPromise.cache = (callback) => {
|
|
415
|
+
const { cache, cacheKey } = opt;
|
|
416
|
+
const cacheData = (cache && this.cachePool.get([cacheKey]));
|
|
417
|
+
callback(cacheData ? cacheData : null);
|
|
418
|
+
return retPromise
|
|
419
|
+
};
|
|
420
|
+
return retPromise
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// 使用全局弹窗进行提示
|
|
425
|
+
const createErrorModal = (response, options) => {
|
|
426
|
+
const { message } = options;
|
|
427
|
+
let temp;
|
|
428
|
+
if (response.name === 'AxiosError') {
|
|
429
|
+
temp = response.response;
|
|
430
|
+
temp.data.returnInfo = response.returnInfo || message || temp.error || '';
|
|
431
|
+
temp.data.returnCode = response.code || temp.status;
|
|
432
|
+
temp.data.requestId = response.config.headers.requestId;
|
|
433
|
+
} else {
|
|
434
|
+
temp = response;
|
|
435
|
+
temp.data.requestId = response.config.headers.requestId;
|
|
436
|
+
}
|
|
437
|
+
// 存在全局错误弹窗时才调用
|
|
438
|
+
isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
|
|
439
|
+
response: temp
|
|
440
|
+
});
|
|
310
441
|
};
|
|
311
442
|
|
|
312
|
-
class CCAxios {
|
|
313
|
-
constructor(opt) {
|
|
314
|
-
this.options = opt;
|
|
315
|
-
this.axiosInstance = axios.create(opt);
|
|
316
|
-
this.setupInterceptors();
|
|
317
|
-
this.cachePool = new LRUCache(20);
|
|
318
|
-
// FIXME:区分构造函数参数和接口级别的参数
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
//获取拦截器
|
|
322
|
-
getTransform() {
|
|
323
|
-
const { transform } = this.options;
|
|
324
|
-
return transform;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
//准备拦截器
|
|
328
|
-
setupInterceptors() {
|
|
329
|
-
const transform = this.getTransform();
|
|
330
|
-
if (!transform) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const {
|
|
334
|
-
requestInterceptors,
|
|
335
|
-
requestInterceptorsCatch,
|
|
336
|
-
responseInterceptors,
|
|
337
|
-
responseInterceptorsCatch,
|
|
338
|
-
} = transform;
|
|
339
|
-
// 请求拦截器
|
|
340
|
-
this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
|
|
341
|
-
// 请求拦截器错误处理
|
|
342
|
-
requestInterceptorsCatch
|
|
343
|
-
&& isFn(requestInterceptorsCatch)
|
|
344
|
-
&& this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
|
|
345
|
-
|
|
346
|
-
// 响应拦截器
|
|
347
|
-
this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
|
|
348
|
-
// 响应拦截器错误处理
|
|
349
|
-
responseInterceptorsCatch
|
|
350
|
-
&& isFn(responseInterceptorsCatch)
|
|
351
|
-
&& this.axiosInstance.interceptors.response.use(undefined, (error) => {
|
|
352
|
-
return responseInterceptorsCatch(this.axiosInstance, error)
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
get(config, options = {}) {
|
|
356
|
-
return this.request({ ...config, method: 'GET', }, options)
|
|
357
|
-
}
|
|
358
|
-
post(config, options = {}) {
|
|
359
|
-
const { envType } = options;
|
|
360
|
-
// 公有云专用接口,在私有云不请求
|
|
361
|
-
if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
|
|
362
|
-
return new Promise(() => { })
|
|
363
|
-
}
|
|
364
|
-
// 私有云专用接口,在公有云不请求
|
|
365
|
-
if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
|
|
366
|
-
return new Promise(() => { })
|
|
367
|
-
}
|
|
368
|
-
return this.request({ ...config, method: 'POST', }, options)
|
|
369
|
-
}
|
|
370
|
-
postFormat(config, options = {}) {
|
|
371
|
-
return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
|
|
372
|
-
}
|
|
373
|
-
postParams(config, options = {}) {
|
|
374
|
-
return this.request({ ...config, method: 'POST', params: config.data }, options)
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// FIXME:如果初始化时配置了重试那么所有get接口都重试了
|
|
378
|
-
// options是接口级定义的参数
|
|
379
|
-
request(config, options) {
|
|
380
|
-
const transform = this.getTransform();
|
|
381
|
-
const conf = config,
|
|
382
|
-
{ requestOptions } = this.options;
|
|
383
|
-
requestOptions.cache = false;
|
|
384
|
-
requestOptions.cacheKey = '';
|
|
385
|
-
requestOptions.retryRequest = {
|
|
386
|
-
isOpenRetry: false,
|
|
387
|
-
count: 5,
|
|
388
|
-
waitTime: 1000
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const opt = Object.assign({}, requestOptions, options);
|
|
392
|
-
conf.requestOptions = opt;
|
|
393
|
-
|
|
394
|
-
const retPromise = new Promise((resolve, reject) => {
|
|
395
|
-
this.axiosInstance(conf)
|
|
396
|
-
.then(res => {
|
|
397
|
-
const { transformResponseHook } = transform;
|
|
398
|
-
if (transformResponseHook && isFn(transformResponseHook)) {
|
|
399
|
-
try {
|
|
400
|
-
const ret = transformResponseHook(res, opt, this.cachePool);
|
|
401
|
-
resolve(ret);
|
|
402
|
-
} catch (err) {
|
|
403
|
-
reject(err || new Error('request error!'));
|
|
404
|
-
}
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
resolve(res);
|
|
408
|
-
})
|
|
409
|
-
.catch(err => {
|
|
410
|
-
reject(err);
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
// 缓存
|
|
414
|
-
retPromise.cache = (callback) => {
|
|
415
|
-
const { cache, cacheKey } = opt;
|
|
416
|
-
const cacheData = (cache && this.cachePool.get([cacheKey]));
|
|
417
|
-
callback(cacheData ? cacheData : null);
|
|
418
|
-
return retPromise
|
|
419
|
-
};
|
|
420
|
-
return retPromise
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
// 使用全局弹窗进行提示
|
|
425
|
-
const createErrorModal = (response, options) => {
|
|
426
|
-
const { message } = options;
|
|
427
|
-
let temp;
|
|
428
|
-
if (response.name === 'AxiosError') {
|
|
429
|
-
temp = response.response;
|
|
430
|
-
temp.data.returnInfo = response.returnInfo || message || temp.error || '';
|
|
431
|
-
temp.data.returnCode = response.code || temp.status;
|
|
432
|
-
temp.data.requestId = response.config.headers.requestId;
|
|
433
|
-
} else {
|
|
434
|
-
temp = response;
|
|
435
|
-
temp.data.requestId = response.config.headers.requestId;
|
|
436
|
-
}
|
|
437
|
-
// 存在全局错误弹窗时才调用
|
|
438
|
-
isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
|
|
439
|
-
response: temp
|
|
440
|
-
});
|
|
441
|
-
};
|
|
442
|
-
|
|
443
443
|
const createMessage = Message;
|
|
444
444
|
|
|
445
|
-
// 需要上报的errorType
|
|
445
|
+
// 需要上报的errorType
|
|
446
446
|
const needReportErrorType = ['901', '999'];
|
|
447
447
|
|
|
448
|
-
function checkStatus(error, status, msg, errorMessageMode = 'modal') {
|
|
449
|
-
// const errorMsg = errorMsgMap[status] || {
|
|
450
|
-
// label: "message.error.object.contactadministrators"
|
|
451
|
-
// }
|
|
452
|
-
// let errMessage = '',
|
|
453
|
-
// label = '';
|
|
454
|
-
|
|
455
|
-
// label = errorMsg.label;
|
|
456
|
-
// [400, 401].includes(status) && msg && (label = msg)
|
|
457
|
-
let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
|
|
458
|
-
|
|
459
|
-
if (status === 401) {
|
|
460
|
-
//重新登录相关逻辑
|
|
461
|
-
window.open(window.Glod.LOGIN_URL, '_self');
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
{
|
|
465
|
-
if (errorMessageMode === 'modal') {
|
|
466
|
-
createErrorModal(error, { message: errMessage });
|
|
467
|
-
} else if (errorMessageMode === 'message') {
|
|
468
|
-
createMessage.error(errMessage);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* 接口请求重试
|
|
475
|
-
* @param {object} AxiosInstance实例
|
|
476
|
-
* @param {error} AxiosError对象
|
|
477
|
-
*/
|
|
478
|
-
const retry = async (instance, error) => {
|
|
479
|
-
const { config } = error,
|
|
480
|
-
{ waitTime, count = 5} = config.requestOptions || {};
|
|
481
|
-
config.__retryCount = config.__retryCount || 0;
|
|
482
|
-
if(count <= config.__retryCount ) {
|
|
483
|
-
return Promise.reject(error)
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
config.__retryCount++;
|
|
487
|
-
|
|
488
|
-
await delay(waitTime);
|
|
489
|
-
//请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
|
|
490
|
-
delete config.headers;
|
|
491
|
-
return instance(config)
|
|
448
|
+
function checkStatus(error, status, msg, errorMessageMode = 'modal') {
|
|
449
|
+
// const errorMsg = errorMsgMap[status] || {
|
|
450
|
+
// label: "message.error.object.contactadministrators"
|
|
451
|
+
// }
|
|
452
|
+
// let errMessage = '',
|
|
453
|
+
// label = '';
|
|
454
|
+
|
|
455
|
+
// label = errorMsg.label;
|
|
456
|
+
// [400, 401].includes(status) && msg && (label = msg)
|
|
457
|
+
let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
|
|
458
|
+
|
|
459
|
+
if (status === 401) {
|
|
460
|
+
//重新登录相关逻辑
|
|
461
|
+
window.open(window.Glod.LOGIN_URL, '_self');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
{
|
|
465
|
+
if (errorMessageMode === 'modal') {
|
|
466
|
+
createErrorModal(error, { message: errMessage });
|
|
467
|
+
} else if (errorMessageMode === 'message') {
|
|
468
|
+
createMessage.error(errMessage);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* 接口请求重试
|
|
475
|
+
* @param {object} AxiosInstance实例
|
|
476
|
+
* @param {error} AxiosError对象
|
|
477
|
+
*/
|
|
478
|
+
const retry = async (instance, error) => {
|
|
479
|
+
const { config } = error,
|
|
480
|
+
{ waitTime, count = 5} = config.requestOptions || {};
|
|
481
|
+
config.__retryCount = config.__retryCount || 0;
|
|
482
|
+
if(count <= config.__retryCount ) {
|
|
483
|
+
return Promise.reject(error)
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
config.__retryCount++;
|
|
487
|
+
|
|
488
|
+
await delay(waitTime);
|
|
489
|
+
//请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
|
|
490
|
+
delete config.headers;
|
|
491
|
+
return instance(config)
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
const transform = {
|
|
495
|
+
// 请求拦截器
|
|
496
|
+
requestInterceptors(config) {
|
|
497
|
+
// 设置日志请求头信息
|
|
498
|
+
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
499
|
+
config.headers.requestIdProducer = "browser";
|
|
500
|
+
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
501
|
+
return config
|
|
502
|
+
},
|
|
503
|
+
// 响应拦截器
|
|
504
|
+
responseInterceptors(response) {
|
|
505
|
+
const { data, config } = response,
|
|
506
|
+
{ errorType, result } = data;
|
|
507
|
+
//失败
|
|
508
|
+
if (!result) {
|
|
509
|
+
if (needReportErrorType.includes(errorType) && isProduction()) {
|
|
510
|
+
const { errorReporter } = config.requestOptions;
|
|
511
|
+
//如果存在错误上报对象,则上报错误
|
|
512
|
+
if (errorReporter && isFn(errorReporter)) {
|
|
513
|
+
errorReporter(response);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return response
|
|
517
|
+
}
|
|
518
|
+
// 成功
|
|
519
|
+
// 生产环境上报日志
|
|
520
|
+
const { infoReporter } = config.requestOptions;
|
|
521
|
+
//如果存在日志上报对象,则上报日志
|
|
522
|
+
if (infoReporter && isFn(infoReporter)) {
|
|
523
|
+
infoReporter(response);
|
|
524
|
+
}
|
|
525
|
+
// 返回数据 外面处理
|
|
526
|
+
return response
|
|
527
|
+
},
|
|
528
|
+
// 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
|
|
529
|
+
async responseInterceptorsCatch(axiosInstance, error) {
|
|
530
|
+
const { response, config } = error || {};
|
|
531
|
+
|
|
532
|
+
let err = "",
|
|
533
|
+
msg = "",
|
|
534
|
+
mode = "modal";
|
|
535
|
+
try {
|
|
536
|
+
err = error.toString(),
|
|
537
|
+
msg = response.data.error,
|
|
538
|
+
mode = config.requestOptions.errorMessageMode;
|
|
539
|
+
} catch (e) { }
|
|
540
|
+
|
|
541
|
+
let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
|
|
542
|
+
errMessage = '';
|
|
543
|
+
|
|
544
|
+
// 是否是取消的请求
|
|
545
|
+
if (axios.isCancel(error)) {
|
|
546
|
+
return Promise.reject(error)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
try {
|
|
550
|
+
//如果存在错误上报对象,则上报错误
|
|
551
|
+
if (isProduction()) {
|
|
552
|
+
// 接口级的错误上报方式会覆盖实例初始化时的错误上报
|
|
553
|
+
const { errorReporter } = config.requestOptions;
|
|
554
|
+
if (errorReporter && isFn(errorReporter)) {
|
|
555
|
+
errorReporter(error);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
// 处理超时
|
|
559
|
+
if (isTimeout(error)) {
|
|
560
|
+
errMessage = 'c2487';
|
|
561
|
+
}
|
|
562
|
+
// 处理网络错误
|
|
563
|
+
if (err && err.includes('Network Error')) {
|
|
564
|
+
errMessage = 'c929';
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (errMessage) {
|
|
568
|
+
if (errorMessageMode === 'modal') {
|
|
569
|
+
createErrorModal({
|
|
570
|
+
...error,
|
|
571
|
+
response: {
|
|
572
|
+
data: {
|
|
573
|
+
returnInfo: error.message,
|
|
574
|
+
returnCode: error.code,
|
|
575
|
+
requestId: error.config.headers.requestId
|
|
576
|
+
},
|
|
577
|
+
config: error.config
|
|
578
|
+
}
|
|
579
|
+
}, { message: errMessage });
|
|
580
|
+
} else if (errorMessageMode === 'message') {
|
|
581
|
+
createMessage.error(errMessage);
|
|
582
|
+
}
|
|
583
|
+
return Promise.reject(error)
|
|
584
|
+
}
|
|
585
|
+
} catch (error) {
|
|
586
|
+
throw new Error(error);
|
|
587
|
+
}
|
|
588
|
+
// 根据status处理其他类型错误
|
|
589
|
+
checkStatus(error, error && error.response.status, msg, errorMessageMode);
|
|
590
|
+
|
|
591
|
+
// 接口重试操作
|
|
592
|
+
const { isOpenRetry } = config;
|
|
593
|
+
isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
|
|
594
|
+
|
|
595
|
+
return Promise.reject(error);
|
|
596
|
+
},
|
|
597
|
+
// 响应数据处理,包含解密和数据返回结构设置
|
|
598
|
+
transformResponseHook(response, options, cachePool) {
|
|
599
|
+
const { data } = response;
|
|
600
|
+
const { errorType, result } = data;
|
|
601
|
+
// 失败
|
|
602
|
+
// 501异常处理
|
|
603
|
+
const businessLogicError = (response) => {
|
|
604
|
+
const { errorMessageMode, silent } = response.config.requestOptions;
|
|
605
|
+
// 接口如果设置了出现异常不提醒,则不提醒
|
|
606
|
+
if (silent) return;
|
|
607
|
+
// 根据errorMessageMode来判断显示错误弹窗的ui
|
|
608
|
+
if (errorMessageMode === 'modal') {
|
|
609
|
+
createErrorModal(response, { message: '业务出错' });
|
|
610
|
+
} else if (errorMessageMode === 'message') {
|
|
611
|
+
createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
if (!result) {
|
|
615
|
+
switch (errorType) {
|
|
616
|
+
case '901':
|
|
617
|
+
createErrorModal(response, { message: '系统错误' });
|
|
618
|
+
break;
|
|
619
|
+
case '999':
|
|
620
|
+
break;
|
|
621
|
+
case '501':
|
|
622
|
+
default:
|
|
623
|
+
businessLogicError(response);
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
return Promise.reject(response)
|
|
627
|
+
}
|
|
628
|
+
// 成功
|
|
629
|
+
const { isReturnNativeResponse, cache, cacheKey } = options;
|
|
630
|
+
// 直接返回
|
|
631
|
+
if (isReturnNativeResponse) {
|
|
632
|
+
cache && cacheKey && (cachePool.put(cacheKey, response));
|
|
633
|
+
return response
|
|
634
|
+
}
|
|
635
|
+
cache && cacheKey && (cachePool.put(cacheKey, data));
|
|
636
|
+
return data
|
|
637
|
+
}
|
|
492
638
|
};
|
|
493
639
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// 生产环境上报日志
|
|
520
|
-
const { infoReporter } = config.requestOptions;
|
|
521
|
-
//如果存在日志上报对象,则上报日志
|
|
522
|
-
if (infoReporter && isFn(infoReporter)) {
|
|
523
|
-
infoReporter(response);
|
|
524
|
-
}
|
|
525
|
-
// 返回数据 外面处理
|
|
526
|
-
return response
|
|
527
|
-
},
|
|
528
|
-
// 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
|
|
529
|
-
async responseInterceptorsCatch(axiosInstance, error) {
|
|
530
|
-
const { response, config } = error || {};
|
|
531
|
-
|
|
532
|
-
let err = "",
|
|
533
|
-
msg = "",
|
|
534
|
-
mode = "modal";
|
|
535
|
-
try {
|
|
536
|
-
err = error.toString(),
|
|
537
|
-
msg = response.data.error,
|
|
538
|
-
mode = config.requestOptions.errorMessageMode;
|
|
539
|
-
} catch (e) { }
|
|
540
|
-
|
|
541
|
-
let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
|
|
542
|
-
errMessage = '';
|
|
543
|
-
|
|
544
|
-
// 是否是取消的请求
|
|
545
|
-
if (axios.isCancel(error)) {
|
|
546
|
-
return Promise.reject(error)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
try {
|
|
550
|
-
//如果存在错误上报对象,则上报错误
|
|
551
|
-
if (isProduction()) {
|
|
552
|
-
// 接口级的错误上报方式会覆盖实例初始化时的错误上报
|
|
553
|
-
const { errorReporter } = config.requestOptions;
|
|
554
|
-
if (errorReporter && isFn(errorReporter)) {
|
|
555
|
-
errorReporter(error);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
// 处理超时
|
|
559
|
-
if (isTimeout(error)) {
|
|
560
|
-
errMessage = 'c2487';
|
|
561
|
-
}
|
|
562
|
-
// 处理网络错误
|
|
563
|
-
if (err && err.includes('Network Error')) {
|
|
564
|
-
errMessage = 'c929';
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
if (errMessage) {
|
|
568
|
-
if (errorMessageMode === 'modal') {
|
|
569
|
-
createErrorModal({
|
|
570
|
-
...error,
|
|
571
|
-
response: {
|
|
572
|
-
data: {
|
|
573
|
-
returnInfo: error.message,
|
|
574
|
-
returnCode: error.code,
|
|
575
|
-
requestId: error.config.headers.requestId
|
|
576
|
-
},
|
|
577
|
-
config: error.config
|
|
578
|
-
}
|
|
579
|
-
}, { message: errMessage });
|
|
580
|
-
} else if (errorMessageMode === 'message') {
|
|
581
|
-
createMessage.error(errMessage);
|
|
582
|
-
}
|
|
583
|
-
return Promise.reject(error)
|
|
584
|
-
}
|
|
585
|
-
} catch (error) {
|
|
586
|
-
throw new Error(error);
|
|
587
|
-
}
|
|
588
|
-
// 根据status处理其他类型错误
|
|
589
|
-
checkStatus(error, error && error.response.status, msg, errorMessageMode);
|
|
590
|
-
|
|
591
|
-
// 接口重试操作
|
|
592
|
-
const { isOpenRetry } = config;
|
|
593
|
-
isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
|
|
594
|
-
|
|
595
|
-
return Promise.reject(error);
|
|
596
|
-
},
|
|
597
|
-
// 响应数据处理,包含解密和数据返回结构设置
|
|
598
|
-
transformResponseHook(response, options, cachePool) {
|
|
599
|
-
const { data } = response;
|
|
600
|
-
const { errorType, result } = data;
|
|
601
|
-
// 失败
|
|
602
|
-
// 501异常处理
|
|
603
|
-
const businessLogicError = (response) => {
|
|
604
|
-
const { errorMessageMode, silent } = response.config.requestOptions;
|
|
605
|
-
// 接口如果设置了出现异常不提醒,则不提醒
|
|
606
|
-
if (silent) return;
|
|
607
|
-
// 根据errorMessageMode来判断显示错误弹窗的ui
|
|
608
|
-
if (errorMessageMode === 'modal') {
|
|
609
|
-
createErrorModal(response, { message: '业务出错' });
|
|
610
|
-
} else if (errorMessageMode === 'message') {
|
|
611
|
-
createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
if (!result) {
|
|
615
|
-
switch (errorType) {
|
|
616
|
-
case '901':
|
|
617
|
-
createErrorModal(response, { message: '系统错误' });
|
|
618
|
-
break;
|
|
619
|
-
case '999':
|
|
620
|
-
break;
|
|
621
|
-
case '501':
|
|
622
|
-
default:
|
|
623
|
-
businessLogicError(response);
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
return Promise.reject(response)
|
|
627
|
-
}
|
|
628
|
-
// 成功
|
|
629
|
-
const { isReturnNativeResponse, cache, cacheKey } = options;
|
|
630
|
-
// 直接返回
|
|
631
|
-
if (isReturnNativeResponse) {
|
|
632
|
-
cache && cacheKey && (cachePool.put(cacheKey, response));
|
|
633
|
-
return response
|
|
634
|
-
}
|
|
635
|
-
cache && cacheKey && (cachePool.put(cacheKey, data));
|
|
636
|
-
return data
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
function createAxios(opt) {
|
|
642
|
-
return new CCAxios(deepMerge({
|
|
643
|
-
timeout: 60 * 1000,
|
|
644
|
-
headers: {
|
|
645
|
-
'Content-Type': 'application/json;charset=UTF-8',
|
|
646
|
-
},
|
|
647
|
-
transform: cloneDeep(transform),
|
|
648
|
-
requestOptions: {
|
|
649
|
-
envType: '',
|
|
650
|
-
errorMessageMode: 'modal',
|
|
651
|
-
//是否静默错误提示
|
|
652
|
-
silent: false,
|
|
653
|
-
// 接口是否需要缓存
|
|
654
|
-
cache: false,
|
|
655
|
-
// 接口重试相关
|
|
656
|
-
retryRequest: {
|
|
657
|
-
isOpenRetry: false,
|
|
658
|
-
count: 5,
|
|
659
|
-
waitTime: 100,
|
|
660
|
-
},
|
|
661
|
-
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
662
|
-
isReturnNativeResponse: false,
|
|
663
|
-
}
|
|
664
|
-
}, opt || {}))
|
|
640
|
+
|
|
641
|
+
function createAxios(opt) {
|
|
642
|
+
return new CCAxios(deepMerge({
|
|
643
|
+
timeout: 60 * 1000,
|
|
644
|
+
headers: {
|
|
645
|
+
'Content-Type': 'application/json;charset=UTF-8',
|
|
646
|
+
},
|
|
647
|
+
transform: cloneDeep(transform),
|
|
648
|
+
requestOptions: {
|
|
649
|
+
envType: '',
|
|
650
|
+
errorMessageMode: 'modal',
|
|
651
|
+
//是否静默错误提示
|
|
652
|
+
silent: false,
|
|
653
|
+
// 接口是否需要缓存
|
|
654
|
+
cache: false,
|
|
655
|
+
// 接口重试相关
|
|
656
|
+
retryRequest: {
|
|
657
|
+
isOpenRetry: false,
|
|
658
|
+
count: 5,
|
|
659
|
+
waitTime: 100,
|
|
660
|
+
},
|
|
661
|
+
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
662
|
+
isReturnNativeResponse: false,
|
|
663
|
+
}
|
|
664
|
+
}, opt || {}))
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
var CCHttp$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -669,30 +669,30 @@ var CCHttp$1 = /*#__PURE__*/Object.freeze({
|
|
|
669
669
|
createAxios: createAxios
|
|
670
670
|
});
|
|
671
671
|
|
|
672
|
-
window.ccBus = new Vue;
|
|
673
|
-
/**
|
|
674
|
-
* 发布信息
|
|
675
|
-
* @param {string} event 事件名称
|
|
676
|
-
* @param {...any} args 参数列表
|
|
677
|
-
*/
|
|
678
|
-
function $emit( ...args) {
|
|
679
|
-
window.ccBus.$emit( ...args);
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* 订阅消息
|
|
683
|
-
* @param {string} event 事件名称
|
|
684
|
-
* @param {function} callback 回调方法
|
|
685
|
-
*/
|
|
686
|
-
function $on(...args) {
|
|
687
|
-
window.ccBus.$on(...args);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* 取消订阅
|
|
691
|
-
* @param {string} event 事件名称
|
|
692
|
-
* @param { function | function[] | undefined } callbacks 需要解除监听的事件
|
|
693
|
-
*/
|
|
694
|
-
function $off(...args) {
|
|
695
|
-
window.ccBus.$off(...args);
|
|
672
|
+
window.ccBus = new Vue;
|
|
673
|
+
/**
|
|
674
|
+
* 发布信息
|
|
675
|
+
* @param {string} event 事件名称
|
|
676
|
+
* @param {...any} args 参数列表
|
|
677
|
+
*/
|
|
678
|
+
function $emit( ...args) {
|
|
679
|
+
window.ccBus.$emit( ...args);
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* 订阅消息
|
|
683
|
+
* @param {string} event 事件名称
|
|
684
|
+
* @param {function} callback 回调方法
|
|
685
|
+
*/
|
|
686
|
+
function $on(...args) {
|
|
687
|
+
window.ccBus.$on(...args);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* 取消订阅
|
|
691
|
+
* @param {string} event 事件名称
|
|
692
|
+
* @param { function | function[] | undefined } callbacks 需要解除监听的事件
|
|
693
|
+
*/
|
|
694
|
+
function $off(...args) {
|
|
695
|
+
window.ccBus.$off(...args);
|
|
696
696
|
}
|
|
697
697
|
|
|
698
698
|
var CCBus = /*#__PURE__*/Object.freeze({
|
|
@@ -702,57 +702,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
|
|
|
702
702
|
$off: $off
|
|
703
703
|
});
|
|
704
704
|
|
|
705
|
-
// 电话对象
|
|
706
|
-
let ccCall = new Map();
|
|
707
|
-
// 电话服务商当前对象
|
|
708
|
-
let currentCall;
|
|
709
|
-
/**
|
|
710
|
-
* 初始化电话条
|
|
711
|
-
* @param {string} id 电话服务商唯一标识
|
|
712
|
-
* @param {object} callClient 电话对象
|
|
713
|
-
*/
|
|
714
|
-
function init$1(id, callClient) {
|
|
715
|
-
if (id && callClient) {
|
|
716
|
-
ccCall.set(id, callClient);
|
|
717
|
-
currentCall = callClient;
|
|
718
|
-
return currentCall
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
/**
|
|
724
|
-
* 拨打电话
|
|
725
|
-
* @param {string} id 电话服务商唯一标识
|
|
726
|
-
* @param {object} options 配置信息
|
|
727
|
-
*/
|
|
728
|
-
function call(id, options) {
|
|
729
|
-
let call;
|
|
730
|
-
if (id) {
|
|
731
|
-
call = ccCall.get(id);
|
|
732
|
-
} else {
|
|
733
|
-
call = currentCall;
|
|
734
|
-
}
|
|
735
|
-
if (call) {
|
|
736
|
-
call.call(options);
|
|
737
|
-
}
|
|
738
|
-
return call
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* 打开通话面板
|
|
742
|
-
* @param {string} id 电话服务商唯一标识
|
|
743
|
-
* @param {object} options 配置信息
|
|
744
|
-
*/
|
|
745
|
-
function openCallPanel(id, options) {
|
|
746
|
-
let call;
|
|
747
|
-
if (id) {
|
|
748
|
-
call = ccCall.get(id);
|
|
749
|
-
} else {
|
|
750
|
-
call = currentCall;
|
|
751
|
-
}
|
|
752
|
-
if (call) {
|
|
753
|
-
call.openCallPanel(options);
|
|
754
|
-
}
|
|
755
|
-
return call
|
|
705
|
+
// 电话对象
|
|
706
|
+
let ccCall = new Map();
|
|
707
|
+
// 电话服务商当前对象
|
|
708
|
+
let currentCall;
|
|
709
|
+
/**
|
|
710
|
+
* 初始化电话条
|
|
711
|
+
* @param {string} id 电话服务商唯一标识
|
|
712
|
+
* @param {object} callClient 电话对象
|
|
713
|
+
*/
|
|
714
|
+
function init$1(id, callClient) {
|
|
715
|
+
if (id && callClient) {
|
|
716
|
+
ccCall.set(id, callClient);
|
|
717
|
+
currentCall = callClient;
|
|
718
|
+
return currentCall
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* 拨打电话
|
|
725
|
+
* @param {string} id 电话服务商唯一标识
|
|
726
|
+
* @param {object} options 配置信息
|
|
727
|
+
*/
|
|
728
|
+
function call(id, options) {
|
|
729
|
+
let call;
|
|
730
|
+
if (id) {
|
|
731
|
+
call = ccCall.get(id);
|
|
732
|
+
} else {
|
|
733
|
+
call = currentCall;
|
|
734
|
+
}
|
|
735
|
+
if (call) {
|
|
736
|
+
call.call(options);
|
|
737
|
+
}
|
|
738
|
+
return call
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* 打开通话面板
|
|
742
|
+
* @param {string} id 电话服务商唯一标识
|
|
743
|
+
* @param {object} options 配置信息
|
|
744
|
+
*/
|
|
745
|
+
function openCallPanel(id, options) {
|
|
746
|
+
let call;
|
|
747
|
+
if (id) {
|
|
748
|
+
call = ccCall.get(id);
|
|
749
|
+
} else {
|
|
750
|
+
call = currentCall;
|
|
751
|
+
}
|
|
752
|
+
if (call) {
|
|
753
|
+
call.openCallPanel(options);
|
|
754
|
+
}
|
|
755
|
+
return call
|
|
756
756
|
}
|
|
757
757
|
|
|
758
758
|
var CCCall = /*#__PURE__*/Object.freeze({
|
|
@@ -762,96 +762,96 @@ var CCCall = /*#__PURE__*/Object.freeze({
|
|
|
762
762
|
openCallPanel: openCallPanel
|
|
763
763
|
});
|
|
764
764
|
|
|
765
|
-
/**
|
|
766
|
-
* 错误日志上报
|
|
767
|
-
* @param {object} response 响应体
|
|
768
|
-
*/
|
|
769
|
-
function reportError(response) {
|
|
770
|
-
if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
771
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* 常规日志上报
|
|
776
|
-
* @param {object} response 响应体
|
|
777
|
-
*/
|
|
778
|
-
function reportInfo(response) {
|
|
779
|
-
if ("2" === window.Glod['CC_LOG_LEVEL']) {
|
|
780
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
|
|
781
|
-
serviceName: "lightning-custom-page"
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
const service$1 = axios.create({
|
|
787
|
-
timeout: 60 * 1000,
|
|
788
|
-
headers: {
|
|
789
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
790
|
-
},
|
|
791
|
-
});
|
|
792
|
-
|
|
793
|
-
service$1.interceptors.request.use(
|
|
794
|
-
config => {
|
|
795
|
-
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
796
|
-
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
797
|
-
config.headers.requestIdProducer = "browser";
|
|
798
|
-
return config
|
|
799
|
-
},
|
|
800
|
-
error => {
|
|
801
|
-
Promise.reject(error);
|
|
802
|
-
}
|
|
803
|
-
);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
service$1.interceptors.response.use(
|
|
807
|
-
response => {
|
|
808
|
-
if (response.data.result) {
|
|
809
|
-
// 上报日志
|
|
810
|
-
reportInfo(response);
|
|
811
|
-
return response.data
|
|
812
|
-
} else {
|
|
813
|
-
reportError(response);
|
|
814
|
-
return Promise.reject(response)
|
|
815
|
-
}
|
|
816
|
-
},
|
|
817
|
-
error => {
|
|
818
|
-
// 上报错误日志
|
|
819
|
-
if (error) {
|
|
820
|
-
reportError(error.response);
|
|
821
|
-
}
|
|
822
|
-
return Promise.reject(error)
|
|
823
|
-
}
|
|
824
|
-
);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
var http = {
|
|
828
|
-
get: (url, data = {}, responseType = '') => {
|
|
829
|
-
return service$1({
|
|
830
|
-
url: url,
|
|
831
|
-
method: 'get',
|
|
832
|
-
params: data,
|
|
833
|
-
responseType: responseType
|
|
834
|
-
})
|
|
835
|
-
},
|
|
836
|
-
post: (url, data = {}, responseType = '') => {
|
|
837
|
-
return service$1({
|
|
838
|
-
url: url,
|
|
839
|
-
method: 'post',
|
|
840
|
-
data: data,
|
|
841
|
-
responseType: responseType
|
|
842
|
-
})
|
|
843
|
-
},
|
|
765
|
+
/**
|
|
766
|
+
* 错误日志上报
|
|
767
|
+
* @param {object} response 响应体
|
|
768
|
+
*/
|
|
769
|
+
function reportError(response) {
|
|
770
|
+
if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
771
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* 常规日志上报
|
|
776
|
+
* @param {object} response 响应体
|
|
777
|
+
*/
|
|
778
|
+
function reportInfo(response) {
|
|
779
|
+
if ("2" === window.Glod['CC_LOG_LEVEL']) {
|
|
780
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
|
|
781
|
+
serviceName: "lightning-custom-page"
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const service$1 = axios.create({
|
|
787
|
+
timeout: 60 * 1000,
|
|
788
|
+
headers: {
|
|
789
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
790
|
+
},
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
service$1.interceptors.request.use(
|
|
794
|
+
config => {
|
|
795
|
+
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
796
|
+
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
797
|
+
config.headers.requestIdProducer = "browser";
|
|
798
|
+
return config
|
|
799
|
+
},
|
|
800
|
+
error => {
|
|
801
|
+
Promise.reject(error);
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
service$1.interceptors.response.use(
|
|
807
|
+
response => {
|
|
808
|
+
if (response.data.result) {
|
|
809
|
+
// 上报日志
|
|
810
|
+
reportInfo(response);
|
|
811
|
+
return response.data
|
|
812
|
+
} else {
|
|
813
|
+
reportError(response);
|
|
814
|
+
return Promise.reject(response)
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
error => {
|
|
818
|
+
// 上报错误日志
|
|
819
|
+
if (error) {
|
|
820
|
+
reportError(error.response);
|
|
821
|
+
}
|
|
822
|
+
return Promise.reject(error)
|
|
823
|
+
}
|
|
824
|
+
);
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
var http = {
|
|
828
|
+
get: (url, data = {}, responseType = '') => {
|
|
829
|
+
return service$1({
|
|
830
|
+
url: url,
|
|
831
|
+
method: 'get',
|
|
832
|
+
params: data,
|
|
833
|
+
responseType: responseType
|
|
834
|
+
})
|
|
835
|
+
},
|
|
836
|
+
post: (url, data = {}, responseType = '') => {
|
|
837
|
+
return service$1({
|
|
838
|
+
url: url,
|
|
839
|
+
method: 'post',
|
|
840
|
+
data: data,
|
|
841
|
+
responseType: responseType
|
|
842
|
+
})
|
|
843
|
+
},
|
|
844
844
|
};
|
|
845
845
|
|
|
846
|
-
/**
|
|
847
|
-
* 请求common接口
|
|
848
|
-
* @param {string} className 类名
|
|
849
|
-
* @param {string} methodName 方法名
|
|
850
|
-
* @param {Array} params 参数集合
|
|
851
|
-
* @returns {Promise}
|
|
852
|
-
*/
|
|
853
|
-
function post$1(className, methodName, params) {
|
|
854
|
-
return http.post(window.$CCDK.CCConfig.getSvc()['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
|
|
846
|
+
/**
|
|
847
|
+
* 请求common接口
|
|
848
|
+
* @param {string} className 类名
|
|
849
|
+
* @param {string} methodName 方法名
|
|
850
|
+
* @param {Array} params 参数集合
|
|
851
|
+
* @returns {Promise}
|
|
852
|
+
*/
|
|
853
|
+
function post$1(className, methodName, params) {
|
|
854
|
+
return http.post(window.$CCDK.CCConfig.getSvc()['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
|
|
855
855
|
}
|
|
856
856
|
|
|
857
857
|
var CCCommon = /*#__PURE__*/Object.freeze({
|
|
@@ -859,33 +859,33 @@ var CCCommon = /*#__PURE__*/Object.freeze({
|
|
|
859
859
|
post: post$1
|
|
860
860
|
});
|
|
861
861
|
|
|
862
|
-
/**
|
|
863
|
-
* 获取基础url
|
|
864
|
-
* @returns 基础地址
|
|
865
|
-
*/
|
|
866
|
-
function getBaseUrl() {
|
|
867
|
-
return window.gw.BASE_URL
|
|
868
|
-
}
|
|
869
|
-
/**
|
|
870
|
-
* 获取网关对象
|
|
871
|
-
* @returns 网关对象
|
|
872
|
-
*/
|
|
873
|
-
function getGw() {
|
|
874
|
-
return window.gw;
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
* 获取服务对象
|
|
878
|
-
* @returns 服务对象
|
|
879
|
-
*/
|
|
880
|
-
function getSvc() {
|
|
881
|
-
return window.Glod;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* 获取静态资源的访问地址
|
|
885
|
-
* @returns 静态资源访问地址
|
|
886
|
-
*/
|
|
887
|
-
function getCDNUrl() {
|
|
888
|
-
return window.Glod.CDN_URL;
|
|
862
|
+
/**
|
|
863
|
+
* 获取基础url
|
|
864
|
+
* @returns 基础地址
|
|
865
|
+
*/
|
|
866
|
+
function getBaseUrl() {
|
|
867
|
+
return window.gw.BASE_URL
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* 获取网关对象
|
|
871
|
+
* @returns 网关对象
|
|
872
|
+
*/
|
|
873
|
+
function getGw() {
|
|
874
|
+
return window.gw;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* 获取服务对象
|
|
878
|
+
* @returns 服务对象
|
|
879
|
+
*/
|
|
880
|
+
function getSvc() {
|
|
881
|
+
return window.Glod;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* 获取静态资源的访问地址
|
|
885
|
+
* @returns 静态资源访问地址
|
|
886
|
+
*/
|
|
887
|
+
function getCDNUrl() {
|
|
888
|
+
return window.Glod.CDN_URL;
|
|
889
889
|
}
|
|
890
890
|
|
|
891
891
|
var CCConfig = /*#__PURE__*/Object.freeze({
|
|
@@ -896,76 +896,76 @@ var CCConfig = /*#__PURE__*/Object.freeze({
|
|
|
896
896
|
getCDNUrl: getCDNUrl
|
|
897
897
|
});
|
|
898
898
|
|
|
899
|
-
const service = axios.create({
|
|
900
|
-
timeout: 60000,
|
|
901
|
-
headers: {
|
|
902
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
903
|
-
},
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
service.interceptors.request.use(
|
|
907
|
-
config => {
|
|
908
|
-
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
909
|
-
return config
|
|
910
|
-
},
|
|
911
|
-
error => {
|
|
912
|
-
Promise.reject(error);
|
|
913
|
-
}
|
|
914
|
-
);
|
|
915
|
-
|
|
916
|
-
service.interceptors.response.use(
|
|
917
|
-
response => {
|
|
918
|
-
const code = response.data.code || 200;
|
|
919
|
-
if (code !== 200) {
|
|
920
|
-
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
921
|
-
} else {
|
|
922
|
-
return response.data
|
|
923
|
-
}
|
|
924
|
-
},
|
|
925
|
-
error => {
|
|
926
|
-
return Promise.reject(error)
|
|
927
|
-
}
|
|
928
|
-
);
|
|
929
|
-
function get(url, data = {}, responseType = '') {
|
|
930
|
-
return service({
|
|
931
|
-
url: url,
|
|
932
|
-
method: 'get',
|
|
933
|
-
params: data,
|
|
934
|
-
responseType: responseType
|
|
935
|
-
})
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
function post(url, data = {}, responseType = '') {
|
|
939
|
-
return service({
|
|
940
|
-
url: url,
|
|
941
|
-
method: 'post',
|
|
942
|
-
data: data,
|
|
943
|
-
responseType: responseType
|
|
944
|
-
})
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
function put(url, data = {}) {
|
|
948
|
-
return service({
|
|
949
|
-
url: url,
|
|
950
|
-
method: 'put',
|
|
951
|
-
data: data
|
|
952
|
-
})
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
function postParams(url, data = {}) {
|
|
956
|
-
return service({
|
|
957
|
-
url: url,
|
|
958
|
-
method: 'post',
|
|
959
|
-
params: data
|
|
960
|
-
})
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
function patch(url, data = {}) {
|
|
964
|
-
return service({
|
|
965
|
-
url: url,
|
|
966
|
-
method: 'patch',
|
|
967
|
-
data: data
|
|
968
|
-
})
|
|
899
|
+
const service = axios.create({
|
|
900
|
+
timeout: 60000,
|
|
901
|
+
headers: {
|
|
902
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
903
|
+
},
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
service.interceptors.request.use(
|
|
907
|
+
config => {
|
|
908
|
+
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
909
|
+
return config
|
|
910
|
+
},
|
|
911
|
+
error => {
|
|
912
|
+
Promise.reject(error);
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
|
|
916
|
+
service.interceptors.response.use(
|
|
917
|
+
response => {
|
|
918
|
+
const code = response.data.code || 200;
|
|
919
|
+
if (code !== 200) {
|
|
920
|
+
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
921
|
+
} else {
|
|
922
|
+
return response.data
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
error => {
|
|
926
|
+
return Promise.reject(error)
|
|
927
|
+
}
|
|
928
|
+
);
|
|
929
|
+
function get(url, data = {}, responseType = '') {
|
|
930
|
+
return service({
|
|
931
|
+
url: url,
|
|
932
|
+
method: 'get',
|
|
933
|
+
params: data,
|
|
934
|
+
responseType: responseType
|
|
935
|
+
})
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
function post(url, data = {}, responseType = '') {
|
|
939
|
+
return service({
|
|
940
|
+
url: url,
|
|
941
|
+
method: 'post',
|
|
942
|
+
data: data,
|
|
943
|
+
responseType: responseType
|
|
944
|
+
})
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
function put(url, data = {}) {
|
|
948
|
+
return service({
|
|
949
|
+
url: url,
|
|
950
|
+
method: 'put',
|
|
951
|
+
data: data
|
|
952
|
+
})
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function postParams(url, data = {}) {
|
|
956
|
+
return service({
|
|
957
|
+
url: url,
|
|
958
|
+
method: 'post',
|
|
959
|
+
params: data
|
|
960
|
+
})
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function patch(url, data = {}) {
|
|
964
|
+
return service({
|
|
965
|
+
url: url,
|
|
966
|
+
method: 'patch',
|
|
967
|
+
data: data
|
|
968
|
+
})
|
|
969
969
|
}
|
|
970
970
|
|
|
971
971
|
var CCHttp = /*#__PURE__*/Object.freeze({
|
|
@@ -977,64 +977,64 @@ var CCHttp = /*#__PURE__*/Object.freeze({
|
|
|
977
977
|
postParams: postParams
|
|
978
978
|
});
|
|
979
979
|
|
|
980
|
-
/**
|
|
981
|
-
* 下载js,并挂载到document上
|
|
982
|
-
* @param {string} src js下载路径
|
|
983
|
-
* @param {object} scriptOption script配置参数
|
|
984
|
-
* @returns
|
|
985
|
-
*/
|
|
986
|
-
function loadJs(src, scriptOption) {
|
|
987
|
-
return new Promise((resolve, reject) => {
|
|
988
|
-
let scriptTemp = document.createElement('script');
|
|
989
|
-
if (scriptOption) {
|
|
990
|
-
Object.assign(scriptTemp, scriptOption);
|
|
991
|
-
}
|
|
992
|
-
scriptTemp.type = "text/javascript";
|
|
993
|
-
scriptTemp.src = src;
|
|
994
|
-
document.body.appendChild(scriptTemp);
|
|
995
|
-
|
|
996
|
-
scriptTemp.onload = () => {
|
|
997
|
-
resolve();
|
|
998
|
-
};
|
|
999
|
-
scriptTemp.onerror = () => {
|
|
1000
|
-
reject();
|
|
1001
|
-
};
|
|
1002
|
-
})
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* 创建加载js组件
|
|
1006
|
-
*/
|
|
1007
|
-
function createLoadJsComponent() {
|
|
1008
|
-
Vue.component('cc-load-script', {
|
|
1009
|
-
render: function (createElement) {
|
|
1010
|
-
var self = this;
|
|
1011
|
-
return createElement('script', {
|
|
1012
|
-
attrs: {
|
|
1013
|
-
type: 'text/javascript',
|
|
1014
|
-
src: this.src
|
|
1015
|
-
},
|
|
1016
|
-
on: {
|
|
1017
|
-
load: function (event) {
|
|
1018
|
-
self.$emit('load', event);
|
|
1019
|
-
},
|
|
1020
|
-
error: function (event) {
|
|
1021
|
-
self.$emit('error', event);
|
|
1022
|
-
},
|
|
1023
|
-
readystatechange: function (event) {
|
|
1024
|
-
if (this.readyState == 'complete') {
|
|
1025
|
-
self.$emit('load', event);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
},
|
|
1031
|
-
props: {
|
|
1032
|
-
src: {
|
|
1033
|
-
type: String,
|
|
1034
|
-
required: true
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
980
|
+
/**
|
|
981
|
+
* 下载js,并挂载到document上
|
|
982
|
+
* @param {string} src js下载路径
|
|
983
|
+
* @param {object} scriptOption script配置参数
|
|
984
|
+
* @returns
|
|
985
|
+
*/
|
|
986
|
+
function loadJs(src, scriptOption) {
|
|
987
|
+
return new Promise((resolve, reject) => {
|
|
988
|
+
let scriptTemp = document.createElement('script');
|
|
989
|
+
if (scriptOption) {
|
|
990
|
+
Object.assign(scriptTemp, scriptOption);
|
|
991
|
+
}
|
|
992
|
+
scriptTemp.type = "text/javascript";
|
|
993
|
+
scriptTemp.src = src;
|
|
994
|
+
document.body.appendChild(scriptTemp);
|
|
995
|
+
|
|
996
|
+
scriptTemp.onload = () => {
|
|
997
|
+
resolve();
|
|
998
|
+
};
|
|
999
|
+
scriptTemp.onerror = () => {
|
|
1000
|
+
reject();
|
|
1001
|
+
};
|
|
1002
|
+
})
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* 创建加载js组件
|
|
1006
|
+
*/
|
|
1007
|
+
function createLoadJsComponent() {
|
|
1008
|
+
Vue.component('cc-load-script', {
|
|
1009
|
+
render: function (createElement) {
|
|
1010
|
+
var self = this;
|
|
1011
|
+
return createElement('script', {
|
|
1012
|
+
attrs: {
|
|
1013
|
+
type: 'text/javascript',
|
|
1014
|
+
src: this.src
|
|
1015
|
+
},
|
|
1016
|
+
on: {
|
|
1017
|
+
load: function (event) {
|
|
1018
|
+
self.$emit('load', event);
|
|
1019
|
+
},
|
|
1020
|
+
error: function (event) {
|
|
1021
|
+
self.$emit('error', event);
|
|
1022
|
+
},
|
|
1023
|
+
readystatechange: function (event) {
|
|
1024
|
+
if (this.readyState == 'complete') {
|
|
1025
|
+
self.$emit('load', event);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
},
|
|
1031
|
+
props: {
|
|
1032
|
+
src: {
|
|
1033
|
+
type: String,
|
|
1034
|
+
required: true
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
1040
|
var CCLoad = /*#__PURE__*/Object.freeze({
|
|
@@ -1043,201 +1043,201 @@ var CCLoad = /*#__PURE__*/Object.freeze({
|
|
|
1043
1043
|
createLoadJsComponent: createLoadJsComponent
|
|
1044
1044
|
});
|
|
1045
1045
|
|
|
1046
|
-
/**
|
|
1047
|
-
* 获取日志基础信息
|
|
1048
|
-
* @returns 日志基础信息
|
|
1049
|
-
*/
|
|
1050
|
-
function getBaseInfo() {
|
|
1051
|
-
let userInfo = window.$CCDK.CCUser.getUserInfo();
|
|
1052
|
-
let old = {
|
|
1053
|
-
// 用户名,使用登录账号
|
|
1054
|
-
"userName": userInfo.loginName || "未知用户",
|
|
1055
|
-
// 用户id
|
|
1056
|
-
"userId": userInfo.userId,
|
|
1057
|
-
// 组织id
|
|
1058
|
-
"orgId": userInfo.orgId,
|
|
1059
|
-
// 组织名称
|
|
1060
|
-
"orgName": userInfo.orgName,
|
|
1061
|
-
// 服务名称
|
|
1062
|
-
"serviceName": "未知应用",
|
|
1063
|
-
// 记录类型:platform平台日志,dev开发者日志
|
|
1064
|
-
"recordType": "platform",
|
|
1065
|
-
// 日志类型
|
|
1066
|
-
"logType": "front",
|
|
1067
|
-
// 发生时间
|
|
1068
|
-
"operateTime": (new Date()).valueOf(),
|
|
1069
|
-
// 发生时间的str格式:yyyy-MM-dd HH:mm:ss
|
|
1070
|
-
"operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
|
|
1071
|
-
// 日志标识码,没有这个标识码,不能上传
|
|
1072
|
-
"cccode": "hidden",
|
|
1073
|
-
// 日志显示级别默认2
|
|
1074
|
-
"displayLevel": "2",
|
|
1075
|
-
};
|
|
1076
|
-
return old
|
|
1077
|
-
}
|
|
1078
|
-
/**
|
|
1079
|
-
* 获取网络异常信息
|
|
1080
|
-
* @param {object} response 网络请求响应体
|
|
1081
|
-
* @returns 请求体信息
|
|
1082
|
-
*/
|
|
1083
|
-
function getHttpErrorInfo(error = {}) {
|
|
1084
|
-
let { config = {}, data = {} } = error;
|
|
1085
|
-
if (config) {
|
|
1086
|
-
return {
|
|
1087
|
-
// 请求地址url
|
|
1088
|
-
"requestUrl": config.baseURL + config.url,
|
|
1089
|
-
// 请求id
|
|
1090
|
-
"requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1091
|
-
// 请求id类型
|
|
1092
|
-
"requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
|
|
1093
|
-
// 请求体
|
|
1094
|
-
"requestParameter": config.data,
|
|
1095
|
-
// 错误描述
|
|
1096
|
-
"errorMessage": error.message || data.returnInfo || "未知错误",
|
|
1097
|
-
// 请求结果状态
|
|
1098
|
-
"requestResult": "失败",
|
|
1099
|
-
// 日志级别
|
|
1100
|
-
"errorLevel": "2",
|
|
1101
|
-
// 堆栈信息
|
|
1102
|
-
"printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
|
|
1103
|
-
}
|
|
1104
|
-
} else {
|
|
1105
|
-
return {}
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* 获取网络信息
|
|
1112
|
-
* @param {object} response 网络请求响应体
|
|
1113
|
-
* @returns 请求体信息
|
|
1114
|
-
*/
|
|
1115
|
-
function getHttpInfo(response) {
|
|
1116
|
-
if (response) {
|
|
1117
|
-
if (window.performance) {
|
|
1118
|
-
// 通过性能接口精确测量接口用时
|
|
1119
|
-
let per = performance.getEntriesByName(response.request.responseURL, "resource");
|
|
1120
|
-
if (per.length > 0) {
|
|
1121
|
-
let index = per.length - 1;
|
|
1122
|
-
response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
return {
|
|
1126
|
-
// 接口用时
|
|
1127
|
-
"spendTime": response.spendTime || "0",
|
|
1128
|
-
// 请求地址url
|
|
1129
|
-
"requestUrl": response.request ? response.request.responseURL : "",
|
|
1130
|
-
// 请求id
|
|
1131
|
-
"requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1132
|
-
// 请求id类型
|
|
1133
|
-
"requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
|
|
1134
|
-
// 请求体
|
|
1135
|
-
"requestParameter": response.config.data,
|
|
1136
|
-
// 错误描述
|
|
1137
|
-
"infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
|
|
1138
|
-
// 请求结果状态
|
|
1139
|
-
"requestResult": response.data.result ? "成功" : "失败",
|
|
1140
|
-
// 日志类型:info,debug
|
|
1141
|
-
"infoType": "info",
|
|
1142
|
-
}
|
|
1143
|
-
} else {
|
|
1144
|
-
return {}
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
/**
|
|
1149
|
-
* 上报日志
|
|
1150
|
-
* @param {string} url 请求地址
|
|
1151
|
-
* @param {object} response 响应信息
|
|
1152
|
-
* @param {string} type 日志类型,info,debug,error
|
|
1153
|
-
* @param {object} logInfo 日志信息
|
|
1154
|
-
*/
|
|
1155
|
-
function reportLog(url, response, type = "info", logInfo = {}) {
|
|
1156
|
-
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1157
|
-
let userInfo = getBaseInfo();
|
|
1158
|
-
if ("未知用户" != userInfo.userName && userInfo.userName) {
|
|
1159
|
-
axios.post(url,
|
|
1160
|
-
{
|
|
1161
|
-
...userInfo,
|
|
1162
|
-
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1163
|
-
...logInfo
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* 批量上报日志
|
|
1172
|
-
* @param {string} url 请求地址
|
|
1173
|
-
* @param {object} response 响应信息
|
|
1174
|
-
* @param {string} type 日志类型,info,debug,error
|
|
1175
|
-
* @param {object} logInfo 日志信息
|
|
1176
|
-
*/
|
|
1177
|
-
function batchReportLog(url, response, type = "info", logInfo = []) {
|
|
1178
|
-
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1179
|
-
let userInfo = getBaseInfo();
|
|
1180
|
-
if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
|
|
1181
|
-
let datas = logInfo.map(info => {
|
|
1182
|
-
return {
|
|
1183
|
-
...userInfo,
|
|
1184
|
-
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1185
|
-
...info
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
axios.post(url, datas);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* 上报info日志
|
|
1195
|
-
* @param {object} logInfo 日志信息
|
|
1196
|
-
* @param {object} response axios响应信息
|
|
1197
|
-
*/
|
|
1198
|
-
function reportInfoLog(logInfo, response) {
|
|
1199
|
-
logInfo.recordType = "dev";
|
|
1200
|
-
reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* 上报错误信息
|
|
1204
|
-
* @param {object} logInfo 日志信息
|
|
1205
|
-
* @param {object} response axios响应信息
|
|
1206
|
-
*/
|
|
1207
|
-
function reportErrorLog(logInfo, response) {
|
|
1208
|
-
logInfo.recordType = "dev";
|
|
1209
|
-
reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* CC错误日志上报:这个api目前没有使用的场景
|
|
1215
|
-
* @param {object} error 响应体
|
|
1216
|
-
* @param {object} options 配置信息
|
|
1217
|
-
*/
|
|
1218
|
-
function reportCCError(error, options = { serviceName: "lightning-main" }) {
|
|
1219
|
-
if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1220
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* CC常规日志上报:这个api目前没有使用的场景
|
|
1225
|
-
* @param {object} response 响应体
|
|
1226
|
-
* @param {object} options 配置信息
|
|
1227
|
-
*/
|
|
1228
|
-
function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
|
|
1229
|
-
if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1230
|
-
if (response.config.data) {
|
|
1231
|
-
try {
|
|
1232
|
-
let data = JSON.parse(response.config.data);
|
|
1233
|
-
if (data.head && data.head.accessToken) {
|
|
1234
|
-
data.head.accessToken = "******";
|
|
1235
|
-
response.config.data = JSON.stringify(data);
|
|
1236
|
-
}
|
|
1237
|
-
} catch (e) { }
|
|
1238
|
-
}
|
|
1239
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
|
|
1240
|
-
}
|
|
1046
|
+
/**
|
|
1047
|
+
* 获取日志基础信息
|
|
1048
|
+
* @returns 日志基础信息
|
|
1049
|
+
*/
|
|
1050
|
+
function getBaseInfo() {
|
|
1051
|
+
let userInfo = window.$CCDK.CCUser.getUserInfo();
|
|
1052
|
+
let old = {
|
|
1053
|
+
// 用户名,使用登录账号
|
|
1054
|
+
"userName": userInfo.loginName || "未知用户",
|
|
1055
|
+
// 用户id
|
|
1056
|
+
"userId": userInfo.userId,
|
|
1057
|
+
// 组织id
|
|
1058
|
+
"orgId": userInfo.orgId,
|
|
1059
|
+
// 组织名称
|
|
1060
|
+
"orgName": userInfo.orgName,
|
|
1061
|
+
// 服务名称
|
|
1062
|
+
"serviceName": "未知应用",
|
|
1063
|
+
// 记录类型:platform平台日志,dev开发者日志
|
|
1064
|
+
"recordType": "platform",
|
|
1065
|
+
// 日志类型
|
|
1066
|
+
"logType": "front",
|
|
1067
|
+
// 发生时间
|
|
1068
|
+
"operateTime": (new Date()).valueOf(),
|
|
1069
|
+
// 发生时间的str格式:yyyy-MM-dd HH:mm:ss
|
|
1070
|
+
"operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
|
|
1071
|
+
// 日志标识码,没有这个标识码,不能上传
|
|
1072
|
+
"cccode": "hidden",
|
|
1073
|
+
// 日志显示级别默认2
|
|
1074
|
+
"displayLevel": "2",
|
|
1075
|
+
};
|
|
1076
|
+
return old
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* 获取网络异常信息
|
|
1080
|
+
* @param {object} response 网络请求响应体
|
|
1081
|
+
* @returns 请求体信息
|
|
1082
|
+
*/
|
|
1083
|
+
function getHttpErrorInfo(error = {}) {
|
|
1084
|
+
let { config = {}, data = {} } = error;
|
|
1085
|
+
if (config) {
|
|
1086
|
+
return {
|
|
1087
|
+
// 请求地址url
|
|
1088
|
+
"requestUrl": config.baseURL + config.url,
|
|
1089
|
+
// 请求id
|
|
1090
|
+
"requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1091
|
+
// 请求id类型
|
|
1092
|
+
"requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
|
|
1093
|
+
// 请求体
|
|
1094
|
+
"requestParameter": config.data,
|
|
1095
|
+
// 错误描述
|
|
1096
|
+
"errorMessage": error.message || data.returnInfo || "未知错误",
|
|
1097
|
+
// 请求结果状态
|
|
1098
|
+
"requestResult": "失败",
|
|
1099
|
+
// 日志级别
|
|
1100
|
+
"errorLevel": "2",
|
|
1101
|
+
// 堆栈信息
|
|
1102
|
+
"printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
|
|
1103
|
+
}
|
|
1104
|
+
} else {
|
|
1105
|
+
return {}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* 获取网络信息
|
|
1112
|
+
* @param {object} response 网络请求响应体
|
|
1113
|
+
* @returns 请求体信息
|
|
1114
|
+
*/
|
|
1115
|
+
function getHttpInfo(response) {
|
|
1116
|
+
if (response) {
|
|
1117
|
+
if (window.performance) {
|
|
1118
|
+
// 通过性能接口精确测量接口用时
|
|
1119
|
+
let per = performance.getEntriesByName(response.request.responseURL, "resource");
|
|
1120
|
+
if (per.length > 0) {
|
|
1121
|
+
let index = per.length - 1;
|
|
1122
|
+
response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return {
|
|
1126
|
+
// 接口用时
|
|
1127
|
+
"spendTime": response.spendTime || "0",
|
|
1128
|
+
// 请求地址url
|
|
1129
|
+
"requestUrl": response.request ? response.request.responseURL : "",
|
|
1130
|
+
// 请求id
|
|
1131
|
+
"requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1132
|
+
// 请求id类型
|
|
1133
|
+
"requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
|
|
1134
|
+
// 请求体
|
|
1135
|
+
"requestParameter": response.config.data,
|
|
1136
|
+
// 错误描述
|
|
1137
|
+
"infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
|
|
1138
|
+
// 请求结果状态
|
|
1139
|
+
"requestResult": response.data.result ? "成功" : "失败",
|
|
1140
|
+
// 日志类型:info,debug
|
|
1141
|
+
"infoType": "info",
|
|
1142
|
+
}
|
|
1143
|
+
} else {
|
|
1144
|
+
return {}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* 上报日志
|
|
1150
|
+
* @param {string} url 请求地址
|
|
1151
|
+
* @param {object} response 响应信息
|
|
1152
|
+
* @param {string} type 日志类型,info,debug,error
|
|
1153
|
+
* @param {object} logInfo 日志信息
|
|
1154
|
+
*/
|
|
1155
|
+
function reportLog(url, response, type = "info", logInfo = {}) {
|
|
1156
|
+
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1157
|
+
let userInfo = getBaseInfo();
|
|
1158
|
+
if ("未知用户" != userInfo.userName && userInfo.userName) {
|
|
1159
|
+
axios.post(url,
|
|
1160
|
+
{
|
|
1161
|
+
...userInfo,
|
|
1162
|
+
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1163
|
+
...logInfo
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* 批量上报日志
|
|
1172
|
+
* @param {string} url 请求地址
|
|
1173
|
+
* @param {object} response 响应信息
|
|
1174
|
+
* @param {string} type 日志类型,info,debug,error
|
|
1175
|
+
* @param {object} logInfo 日志信息
|
|
1176
|
+
*/
|
|
1177
|
+
function batchReportLog(url, response, type = "info", logInfo = []) {
|
|
1178
|
+
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1179
|
+
let userInfo = getBaseInfo();
|
|
1180
|
+
if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
|
|
1181
|
+
let datas = logInfo.map(info => {
|
|
1182
|
+
return {
|
|
1183
|
+
...userInfo,
|
|
1184
|
+
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1185
|
+
...info
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
axios.post(url, datas);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* 上报info日志
|
|
1195
|
+
* @param {object} logInfo 日志信息
|
|
1196
|
+
* @param {object} response axios响应信息
|
|
1197
|
+
*/
|
|
1198
|
+
function reportInfoLog(logInfo, response) {
|
|
1199
|
+
logInfo.recordType = "dev";
|
|
1200
|
+
reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* 上报错误信息
|
|
1204
|
+
* @param {object} logInfo 日志信息
|
|
1205
|
+
* @param {object} response axios响应信息
|
|
1206
|
+
*/
|
|
1207
|
+
function reportErrorLog(logInfo, response) {
|
|
1208
|
+
logInfo.recordType = "dev";
|
|
1209
|
+
reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* CC错误日志上报:这个api目前没有使用的场景
|
|
1215
|
+
* @param {object} error 响应体
|
|
1216
|
+
* @param {object} options 配置信息
|
|
1217
|
+
*/
|
|
1218
|
+
function reportCCError(error, options = { serviceName: "lightning-main" }) {
|
|
1219
|
+
if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1220
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* CC常规日志上报:这个api目前没有使用的场景
|
|
1225
|
+
* @param {object} response 响应体
|
|
1226
|
+
* @param {object} options 配置信息
|
|
1227
|
+
*/
|
|
1228
|
+
function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
|
|
1229
|
+
if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1230
|
+
if (response.config.data) {
|
|
1231
|
+
try {
|
|
1232
|
+
let data = JSON.parse(response.config.data);
|
|
1233
|
+
if (data.head && data.head.accessToken) {
|
|
1234
|
+
data.head.accessToken = "******";
|
|
1235
|
+
response.config.data = JSON.stringify(data);
|
|
1236
|
+
}
|
|
1237
|
+
} catch (e) { }
|
|
1238
|
+
}
|
|
1239
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
|
|
1240
|
+
}
|
|
1241
1241
|
}
|
|
1242
1242
|
|
|
1243
1243
|
var CCLog = /*#__PURE__*/Object.freeze({
|
|
@@ -1250,123 +1250,123 @@ var CCLog = /*#__PURE__*/Object.freeze({
|
|
|
1250
1250
|
batchReportLog: batchReportLog
|
|
1251
1251
|
});
|
|
1252
1252
|
|
|
1253
|
-
// 存储所有菜单标识
|
|
1254
|
-
const ALL_MENU_LIST = 'all_menu_list';
|
|
1255
|
-
// 存储当前选中的菜单
|
|
1256
|
-
const CURRENT_MENU = 'current_menu';
|
|
1257
|
-
|
|
1258
|
-
/**
|
|
1259
|
-
* 获取全部菜单
|
|
1260
|
-
*/
|
|
1261
|
-
function getAllMenu() {
|
|
1262
|
-
let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
|
|
1263
|
-
if (data) {
|
|
1264
|
-
return JSON.parse(data)
|
|
1265
|
-
}
|
|
1266
|
-
return []
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
/**
|
|
1270
|
-
* 设置全部菜单
|
|
1271
|
-
* @param {object} data 菜单集合
|
|
1272
|
-
*/
|
|
1273
|
-
function setAllMenu(data = []) {
|
|
1274
|
-
if (data) {
|
|
1275
|
-
localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
/**
|
|
1280
|
-
* 缓存当前选中菜单对象
|
|
1281
|
-
* @param {object} data 菜单对象
|
|
1282
|
-
*/
|
|
1283
|
-
function setCurrentMenu(data = {}) {
|
|
1284
|
-
if (data) {
|
|
1285
|
-
localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* 获取当前选中菜单对象
|
|
1291
|
-
* @param {object} data 菜单对象
|
|
1292
|
-
*/
|
|
1293
|
-
function getCurrentMenu() {
|
|
1294
|
-
let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
|
|
1295
|
-
if (data) {
|
|
1296
|
-
return JSON.parse(data)
|
|
1297
|
-
}
|
|
1298
|
-
return {}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* 添加一个一级菜单
|
|
1303
|
-
* @param {object} options 菜单配置
|
|
1304
|
-
*/
|
|
1305
|
-
function addMenu1(options) {
|
|
1306
|
-
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
1307
|
-
}
|
|
1308
|
-
/**
|
|
1309
|
-
* 添加一个二级菜单
|
|
1310
|
-
* @param {object} options 菜单配置
|
|
1311
|
-
*/
|
|
1312
|
-
function addMenu2(options) {
|
|
1313
|
-
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* 删除一个一级菜单
|
|
1317
|
-
* @param {object} options 菜单配置
|
|
1318
|
-
*/
|
|
1319
|
-
function deleteMenu1(options) {
|
|
1320
|
-
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* 删除一个二级菜单
|
|
1324
|
-
* @param {object} options 菜单配置
|
|
1325
|
-
*/
|
|
1326
|
-
function deleteMenu2(options) {
|
|
1327
|
-
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* 刷新一个一级菜单
|
|
1331
|
-
* @param {object} options 菜单配置
|
|
1332
|
-
*/
|
|
1333
|
-
function refreshMenu1(options) {
|
|
1334
|
-
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
1335
|
-
}
|
|
1336
|
-
/**
|
|
1337
|
-
* 刷新一个二级菜单
|
|
1338
|
-
* @param {object} options 菜单配置
|
|
1339
|
-
*/
|
|
1340
|
-
function refreshMenu2(options) {
|
|
1341
|
-
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
1342
|
-
}
|
|
1343
|
-
/**
|
|
1344
|
-
* 替换一个一级菜单
|
|
1345
|
-
* @param {object} options 菜单配置
|
|
1346
|
-
*/
|
|
1347
|
-
function replaceMenu1(options) {
|
|
1348
|
-
window.$CCDK.CCBus.$emit('replaceMenu1', options);
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* 替换一个二级菜单
|
|
1352
|
-
* @param {object} options 菜单配置
|
|
1353
|
-
*/
|
|
1354
|
-
function replaceMenu2(options) {
|
|
1355
|
-
window.$CCDK.CCBus.$emit('replaceMenu2', options);
|
|
1356
|
-
}
|
|
1357
|
-
/**
|
|
1358
|
-
* 定位到已经打开的一级菜单
|
|
1359
|
-
* @param {object} options 菜单配置
|
|
1360
|
-
*/
|
|
1361
|
-
function reOpenMenu1(options) {
|
|
1362
|
-
window.$CCDK.CCBus.$emit('reOpenMenu1', options);
|
|
1363
|
-
}
|
|
1364
|
-
/**
|
|
1365
|
-
* 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
|
|
1366
|
-
* @param {object} options 菜单配置
|
|
1367
|
-
*/
|
|
1368
|
-
function reOpenMenu2(options) {
|
|
1369
|
-
window.$CCDK.CCBus.$emit('reOpenMenu2', options);
|
|
1253
|
+
// 存储所有菜单标识
|
|
1254
|
+
const ALL_MENU_LIST = 'all_menu_list';
|
|
1255
|
+
// 存储当前选中的菜单
|
|
1256
|
+
const CURRENT_MENU = 'current_menu';
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* 获取全部菜单
|
|
1260
|
+
*/
|
|
1261
|
+
function getAllMenu() {
|
|
1262
|
+
let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
|
|
1263
|
+
if (data) {
|
|
1264
|
+
return JSON.parse(data)
|
|
1265
|
+
}
|
|
1266
|
+
return []
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* 设置全部菜单
|
|
1271
|
+
* @param {object} data 菜单集合
|
|
1272
|
+
*/
|
|
1273
|
+
function setAllMenu(data = []) {
|
|
1274
|
+
if (data) {
|
|
1275
|
+
localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* 缓存当前选中菜单对象
|
|
1281
|
+
* @param {object} data 菜单对象
|
|
1282
|
+
*/
|
|
1283
|
+
function setCurrentMenu(data = {}) {
|
|
1284
|
+
if (data) {
|
|
1285
|
+
localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* 获取当前选中菜单对象
|
|
1291
|
+
* @param {object} data 菜单对象
|
|
1292
|
+
*/
|
|
1293
|
+
function getCurrentMenu() {
|
|
1294
|
+
let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
|
|
1295
|
+
if (data) {
|
|
1296
|
+
return JSON.parse(data)
|
|
1297
|
+
}
|
|
1298
|
+
return {}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* 添加一个一级菜单
|
|
1303
|
+
* @param {object} options 菜单配置
|
|
1304
|
+
*/
|
|
1305
|
+
function addMenu1(options) {
|
|
1306
|
+
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* 添加一个二级菜单
|
|
1310
|
+
* @param {object} options 菜单配置
|
|
1311
|
+
*/
|
|
1312
|
+
function addMenu2(options) {
|
|
1313
|
+
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
1314
|
+
}
|
|
1315
|
+
/**
|
|
1316
|
+
* 删除一个一级菜单
|
|
1317
|
+
* @param {object} options 菜单配置
|
|
1318
|
+
*/
|
|
1319
|
+
function deleteMenu1(options) {
|
|
1320
|
+
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* 删除一个二级菜单
|
|
1324
|
+
* @param {object} options 菜单配置
|
|
1325
|
+
*/
|
|
1326
|
+
function deleteMenu2(options) {
|
|
1327
|
+
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* 刷新一个一级菜单
|
|
1331
|
+
* @param {object} options 菜单配置
|
|
1332
|
+
*/
|
|
1333
|
+
function refreshMenu1(options) {
|
|
1334
|
+
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* 刷新一个二级菜单
|
|
1338
|
+
* @param {object} options 菜单配置
|
|
1339
|
+
*/
|
|
1340
|
+
function refreshMenu2(options) {
|
|
1341
|
+
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* 替换一个一级菜单
|
|
1345
|
+
* @param {object} options 菜单配置
|
|
1346
|
+
*/
|
|
1347
|
+
function replaceMenu1(options) {
|
|
1348
|
+
window.$CCDK.CCBus.$emit('replaceMenu1', options);
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* 替换一个二级菜单
|
|
1352
|
+
* @param {object} options 菜单配置
|
|
1353
|
+
*/
|
|
1354
|
+
function replaceMenu2(options) {
|
|
1355
|
+
window.$CCDK.CCBus.$emit('replaceMenu2', options);
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* 定位到已经打开的一级菜单
|
|
1359
|
+
* @param {object} options 菜单配置
|
|
1360
|
+
*/
|
|
1361
|
+
function reOpenMenu1(options) {
|
|
1362
|
+
window.$CCDK.CCBus.$emit('reOpenMenu1', options);
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
|
|
1366
|
+
* @param {object} options 菜单配置
|
|
1367
|
+
*/
|
|
1368
|
+
function reOpenMenu2(options) {
|
|
1369
|
+
window.$CCDK.CCBus.$emit('reOpenMenu2', options);
|
|
1370
1370
|
}
|
|
1371
1371
|
|
|
1372
1372
|
var CCMenu = /*#__PURE__*/Object.freeze({
|
|
@@ -1387,43 +1387,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
|
|
|
1387
1387
|
getCurrentMenu: getCurrentMenu
|
|
1388
1388
|
});
|
|
1389
1389
|
|
|
1390
|
-
/**
|
|
1391
|
-
* 消息提示框
|
|
1392
|
-
* @param {string} text 提示文字,支持vhtml渲染
|
|
1393
|
-
* @param {string} type 消息类别
|
|
1394
|
-
* @param {number} duration 持续时间
|
|
1395
|
-
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
1396
|
-
* @param {boolean} center 文字是否剧中
|
|
1397
|
-
*/
|
|
1398
|
-
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
1399
|
-
Message({
|
|
1400
|
-
message: text,
|
|
1401
|
-
type,
|
|
1402
|
-
duration,
|
|
1403
|
-
showClose,
|
|
1404
|
-
center
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
/**
|
|
1408
|
-
* 提示确认框
|
|
1409
|
-
* @param {string} text 提示信息
|
|
1410
|
-
* @param {string} title 标题
|
|
1411
|
-
* @param {object} options 配置信息
|
|
1412
|
-
*/
|
|
1413
|
-
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
1414
|
-
MessageBox.confirm(text, title, options).then(() => {
|
|
1415
|
-
confirm();
|
|
1416
|
-
}).catch(() => {
|
|
1417
|
-
reject();
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
/**
|
|
1422
|
-
* 提示消息框
|
|
1423
|
-
* @param {object} options 配置信息
|
|
1424
|
-
*/
|
|
1425
|
-
function showNotification(options = {}) {
|
|
1426
|
-
Notification(options);
|
|
1390
|
+
/**
|
|
1391
|
+
* 消息提示框
|
|
1392
|
+
* @param {string} text 提示文字,支持vhtml渲染
|
|
1393
|
+
* @param {string} type 消息类别
|
|
1394
|
+
* @param {number} duration 持续时间
|
|
1395
|
+
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
1396
|
+
* @param {boolean} center 文字是否剧中
|
|
1397
|
+
*/
|
|
1398
|
+
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
1399
|
+
Message({
|
|
1400
|
+
message: text,
|
|
1401
|
+
type,
|
|
1402
|
+
duration,
|
|
1403
|
+
showClose,
|
|
1404
|
+
center
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* 提示确认框
|
|
1409
|
+
* @param {string} text 提示信息
|
|
1410
|
+
* @param {string} title 标题
|
|
1411
|
+
* @param {object} options 配置信息
|
|
1412
|
+
*/
|
|
1413
|
+
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
1414
|
+
MessageBox.confirm(text, title, options).then(() => {
|
|
1415
|
+
confirm();
|
|
1416
|
+
}).catch(() => {
|
|
1417
|
+
reject();
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* 提示消息框
|
|
1423
|
+
* @param {object} options 配置信息
|
|
1424
|
+
*/
|
|
1425
|
+
function showNotification(options = {}) {
|
|
1426
|
+
Notification(options);
|
|
1427
1427
|
}
|
|
1428
1428
|
|
|
1429
1429
|
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
@@ -1433,133 +1433,133 @@ var CCMessage = /*#__PURE__*/Object.freeze({
|
|
|
1433
1433
|
showNotification: showNotification
|
|
1434
1434
|
});
|
|
1435
1435
|
|
|
1436
|
-
// 对象详情存储标识
|
|
1437
|
-
const OBJECT_DETAIL = 'cc_object_detail';
|
|
1438
|
-
// 对象详情id存储标识
|
|
1439
|
-
const OBJECT_DETAIL_ID = 'cc_object_detail_id';
|
|
1440
|
-
// 对象存储标识
|
|
1441
|
-
const OBJECT = 'cc_object';
|
|
1442
|
-
// 列表视图存储标识
|
|
1443
|
-
const OBJECT_LIST = 'cc_object_list';
|
|
1444
|
-
|
|
1445
|
-
/**
|
|
1446
|
-
* 获得当前标准对象信息
|
|
1447
|
-
*/
|
|
1448
|
-
function getObject() {
|
|
1449
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
1450
|
-
if (detail) {
|
|
1451
|
-
return JSON.parse(detail)
|
|
1452
|
-
}
|
|
1453
|
-
return ''
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
/**
|
|
1457
|
-
* 设置当前标准对象信息
|
|
1458
|
-
* @param {object} detail 对象数据
|
|
1459
|
-
*/
|
|
1460
|
-
function setObject(detail = '') {
|
|
1461
|
-
if (detail) {
|
|
1462
|
-
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
/**
|
|
1467
|
-
* 获得当前标准对象的详细信息
|
|
1468
|
-
* @param {String} apiname: 查找字段的apiname
|
|
1469
|
-
* @param {String} detailId: 详情页数据id
|
|
1470
|
-
*/
|
|
1471
|
-
function getObjectDetail(apiname, detailId) {
|
|
1472
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
1473
|
-
if (detail) {
|
|
1474
|
-
// 转为对象
|
|
1475
|
-
detail = JSON.parse(detail);
|
|
1476
|
-
// 没有指定详情页id,获取最后一次的id
|
|
1477
|
-
if (!detailId) {
|
|
1478
|
-
detailId = detail.id;
|
|
1479
|
-
} else {
|
|
1480
|
-
detail.id = detailId;
|
|
1481
|
-
}
|
|
1482
|
-
// 通过详情页id获取对应的详情页数据
|
|
1483
|
-
let detailList = JSON.parse(sessionStorage.getItem(detailId));
|
|
1484
|
-
if (apiname) {
|
|
1485
|
-
let targetField = undefined;
|
|
1486
|
-
if (Array.isArray(detailList)) {
|
|
1487
|
-
targetField = detailList.find(item => item.apiname === apiname);
|
|
1488
|
-
}
|
|
1489
|
-
return targetField
|
|
1490
|
-
} else {
|
|
1491
|
-
detail.detail = detailList;
|
|
1492
|
-
return detail
|
|
1493
|
-
}
|
|
1494
|
-
} else {
|
|
1495
|
-
return ''
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
/**
|
|
1501
|
-
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1502
|
-
* @param {object} detail 对象详细数据
|
|
1503
|
-
*/
|
|
1504
|
-
function setObjectDetail(detail = '') {
|
|
1505
|
-
if (detail && detail.id) {
|
|
1506
|
-
// 减少detail.detail层级
|
|
1507
|
-
if (Array.isArray(detail.detail) && detail.detail.length > 0) {
|
|
1508
|
-
let data = [];
|
|
1509
|
-
detail.detail.forEach(item => {
|
|
1510
|
-
if (item && Array.isArray(item.data)) {
|
|
1511
|
-
item.data.forEach(itemData => {
|
|
1512
|
-
if (itemData.left && !Array.isArray(itemData.left)) {
|
|
1513
|
-
data.push(itemData.left);
|
|
1514
|
-
}
|
|
1515
|
-
if (itemData.right && !Array.isArray(itemData.right)) {
|
|
1516
|
-
data.push(itemData.right);
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
});
|
|
1521
|
-
if (data.length > 0) {
|
|
1522
|
-
detail.detail = data;
|
|
1523
|
-
// 根据详情页id,记录详情页信息
|
|
1524
|
-
sessionStorage.setItem(detail.id, JSON.stringify(data));
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* 设置当前标准对象列表选中的信息
|
|
1532
|
-
* @param {object} detail 选中数据
|
|
1533
|
-
*/
|
|
1534
|
-
function setObjectList(detail = {}) {
|
|
1535
|
-
if (detail.ids) {
|
|
1536
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
/**
|
|
1540
|
-
* 获得当前标准对象列表选中的信息
|
|
1541
|
-
*/
|
|
1542
|
-
function getObjectList() {
|
|
1543
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
|
|
1544
|
-
if (detail) {
|
|
1545
|
-
return JSON.parse(detail)
|
|
1546
|
-
}
|
|
1547
|
-
return { ids: [] }
|
|
1548
|
-
}
|
|
1549
|
-
/**
|
|
1550
|
-
* 设置当前标准对象的详情页id
|
|
1551
|
-
* @param {object} id 对象详情页id
|
|
1552
|
-
*/
|
|
1553
|
-
function setObjectDetailId(id = '') {
|
|
1554
|
-
if (id) {
|
|
1555
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
/**
|
|
1559
|
-
* 获取最后访问标准对象的详情页id
|
|
1560
|
-
*/
|
|
1561
|
-
function getObjectDetailId() {
|
|
1562
|
-
return localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
|
|
1436
|
+
// 对象详情存储标识
|
|
1437
|
+
const OBJECT_DETAIL = 'cc_object_detail';
|
|
1438
|
+
// 对象详情id存储标识
|
|
1439
|
+
const OBJECT_DETAIL_ID = 'cc_object_detail_id';
|
|
1440
|
+
// 对象存储标识
|
|
1441
|
+
const OBJECT = 'cc_object';
|
|
1442
|
+
// 列表视图存储标识
|
|
1443
|
+
const OBJECT_LIST = 'cc_object_list';
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* 获得当前标准对象信息
|
|
1447
|
+
*/
|
|
1448
|
+
function getObject() {
|
|
1449
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
1450
|
+
if (detail) {
|
|
1451
|
+
return JSON.parse(detail)
|
|
1452
|
+
}
|
|
1453
|
+
return ''
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* 设置当前标准对象信息
|
|
1458
|
+
* @param {object} detail 对象数据
|
|
1459
|
+
*/
|
|
1460
|
+
function setObject(detail = '') {
|
|
1461
|
+
if (detail) {
|
|
1462
|
+
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* 获得当前标准对象的详细信息
|
|
1468
|
+
* @param {String} apiname: 查找字段的apiname
|
|
1469
|
+
* @param {String} detailId: 详情页数据id
|
|
1470
|
+
*/
|
|
1471
|
+
function getObjectDetail(apiname, detailId) {
|
|
1472
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
1473
|
+
if (detail) {
|
|
1474
|
+
// 转为对象
|
|
1475
|
+
detail = JSON.parse(detail);
|
|
1476
|
+
// 没有指定详情页id,获取最后一次的id
|
|
1477
|
+
if (!detailId) {
|
|
1478
|
+
detailId = detail.id;
|
|
1479
|
+
} else {
|
|
1480
|
+
detail.id = detailId;
|
|
1481
|
+
}
|
|
1482
|
+
// 通过详情页id获取对应的详情页数据
|
|
1483
|
+
let detailList = JSON.parse(sessionStorage.getItem(detailId));
|
|
1484
|
+
if (apiname) {
|
|
1485
|
+
let targetField = undefined;
|
|
1486
|
+
if (Array.isArray(detailList)) {
|
|
1487
|
+
targetField = detailList.find(item => item.apiname === apiname);
|
|
1488
|
+
}
|
|
1489
|
+
return targetField
|
|
1490
|
+
} else {
|
|
1491
|
+
detail.detail = detailList;
|
|
1492
|
+
return detail
|
|
1493
|
+
}
|
|
1494
|
+
} else {
|
|
1495
|
+
return ''
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1502
|
+
* @param {object} detail 对象详细数据
|
|
1503
|
+
*/
|
|
1504
|
+
function setObjectDetail(detail = '') {
|
|
1505
|
+
if (detail && detail.id) {
|
|
1506
|
+
// 减少detail.detail层级
|
|
1507
|
+
if (Array.isArray(detail.detail) && detail.detail.length > 0) {
|
|
1508
|
+
let data = [];
|
|
1509
|
+
detail.detail.forEach(item => {
|
|
1510
|
+
if (item && Array.isArray(item.data)) {
|
|
1511
|
+
item.data.forEach(itemData => {
|
|
1512
|
+
if (itemData.left && !Array.isArray(itemData.left)) {
|
|
1513
|
+
data.push(itemData.left);
|
|
1514
|
+
}
|
|
1515
|
+
if (itemData.right && !Array.isArray(itemData.right)) {
|
|
1516
|
+
data.push(itemData.right);
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
if (data.length > 0) {
|
|
1522
|
+
detail.detail = data;
|
|
1523
|
+
// 根据详情页id,记录详情页信息
|
|
1524
|
+
sessionStorage.setItem(detail.id, JSON.stringify(data));
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* 设置当前标准对象列表选中的信息
|
|
1532
|
+
* @param {object} detail 选中数据
|
|
1533
|
+
*/
|
|
1534
|
+
function setObjectList(detail = {}) {
|
|
1535
|
+
if (detail.ids) {
|
|
1536
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* 获得当前标准对象列表选中的信息
|
|
1541
|
+
*/
|
|
1542
|
+
function getObjectList() {
|
|
1543
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
|
|
1544
|
+
if (detail) {
|
|
1545
|
+
return JSON.parse(detail)
|
|
1546
|
+
}
|
|
1547
|
+
return { ids: [] }
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
* 设置当前标准对象的详情页id
|
|
1551
|
+
* @param {object} id 对象详情页id
|
|
1552
|
+
*/
|
|
1553
|
+
function setObjectDetailId(id = '') {
|
|
1554
|
+
if (id) {
|
|
1555
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* 获取最后访问标准对象的详情页id
|
|
1560
|
+
*/
|
|
1561
|
+
function getObjectDetailId() {
|
|
1562
|
+
return localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
|
|
1563
1563
|
}
|
|
1564
1564
|
|
|
1565
1565
|
var CCObject = /*#__PURE__*/Object.freeze({
|
|
@@ -1574,47 +1574,47 @@ var CCObject = /*#__PURE__*/Object.freeze({
|
|
|
1574
1574
|
getObjectDetailId: getObjectDetailId
|
|
1575
1575
|
});
|
|
1576
1576
|
|
|
1577
|
-
/**
|
|
1578
|
-
* 详情页的一些操作
|
|
1579
|
-
*/
|
|
1580
|
-
|
|
1581
|
-
/**
|
|
1582
|
-
* 获得详情页数据
|
|
1583
|
-
* @param {String} apiname: 查找字段的apiname
|
|
1584
|
-
* @param {String} detailId: 详情页数据id
|
|
1585
|
-
*/
|
|
1586
|
-
function getDetail(apiname, detailId) {
|
|
1587
|
-
return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
|
|
1588
|
-
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
/**
|
|
1592
|
-
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1593
|
-
* @param {object} detail 对象详细数据
|
|
1594
|
-
*/
|
|
1595
|
-
function setDetail(detail = '') {
|
|
1596
|
-
window.$CCDK.CCObject.setObjectDetail(detail);
|
|
1597
|
-
}
|
|
1598
|
-
/**
|
|
1599
|
-
* 设置当前标准对象的详情页id
|
|
1600
|
-
* @param {object} id 对象详情页id
|
|
1601
|
-
*/
|
|
1602
|
-
function setDetailId(id = '') {
|
|
1603
|
-
window.$CCDK.CCObject.setObjectDetailId(id);
|
|
1604
|
-
}
|
|
1605
|
-
/**
|
|
1606
|
-
* 获取最后访问标准对象的详情页id
|
|
1607
|
-
*/
|
|
1608
|
-
function getDetailId() {
|
|
1609
|
-
return window.$CCDK.CCObject.getObjectDetailId()
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
/**
|
|
1613
|
-
* 刷新相关列表
|
|
1614
|
-
* @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
|
|
1615
|
-
*/
|
|
1616
|
-
function refreshRelatedList(ids) {
|
|
1617
|
-
window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
|
|
1577
|
+
/**
|
|
1578
|
+
* 详情页的一些操作
|
|
1579
|
+
*/
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* 获得详情页数据
|
|
1583
|
+
* @param {String} apiname: 查找字段的apiname
|
|
1584
|
+
* @param {String} detailId: 详情页数据id
|
|
1585
|
+
*/
|
|
1586
|
+
function getDetail(apiname, detailId) {
|
|
1587
|
+
return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
|
|
1588
|
+
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1593
|
+
* @param {object} detail 对象详细数据
|
|
1594
|
+
*/
|
|
1595
|
+
function setDetail(detail = '') {
|
|
1596
|
+
window.$CCDK.CCObject.setObjectDetail(detail);
|
|
1597
|
+
}
|
|
1598
|
+
/**
|
|
1599
|
+
* 设置当前标准对象的详情页id
|
|
1600
|
+
* @param {object} id 对象详情页id
|
|
1601
|
+
*/
|
|
1602
|
+
function setDetailId(id = '') {
|
|
1603
|
+
window.$CCDK.CCObject.setObjectDetailId(id);
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* 获取最后访问标准对象的详情页id
|
|
1607
|
+
*/
|
|
1608
|
+
function getDetailId() {
|
|
1609
|
+
return window.$CCDK.CCObject.getObjectDetailId()
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* 刷新相关列表
|
|
1614
|
+
* @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
|
|
1615
|
+
*/
|
|
1616
|
+
function refreshRelatedList(ids) {
|
|
1617
|
+
window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
|
|
1618
1618
|
}
|
|
1619
1619
|
|
|
1620
1620
|
var CCDetail = /*#__PURE__*/Object.freeze({
|
|
@@ -1626,21 +1626,21 @@ var CCDetail = /*#__PURE__*/Object.freeze({
|
|
|
1626
1626
|
refreshRelatedList: refreshRelatedList
|
|
1627
1627
|
});
|
|
1628
1628
|
|
|
1629
|
-
/**
|
|
1630
|
-
* 对象视图页一些操作
|
|
1631
|
-
*/
|
|
1632
|
-
/**
|
|
1633
|
-
* 设置当前标准对象列表选中的信息
|
|
1634
|
-
* @param {object} detail 选中数据
|
|
1635
|
-
*/
|
|
1636
|
-
function setSelected(detail = {}) {
|
|
1637
|
-
window.$CCDK.CCObject.setObjectList(detail);
|
|
1638
|
-
}
|
|
1639
|
-
/**
|
|
1640
|
-
* 获得当前标准对象列表选中的信息
|
|
1641
|
-
*/
|
|
1642
|
-
function getSelected() {
|
|
1643
|
-
return window.$CCDK.CCObject.getObjectList()
|
|
1629
|
+
/**
|
|
1630
|
+
* 对象视图页一些操作
|
|
1631
|
+
*/
|
|
1632
|
+
/**
|
|
1633
|
+
* 设置当前标准对象列表选中的信息
|
|
1634
|
+
* @param {object} detail 选中数据
|
|
1635
|
+
*/
|
|
1636
|
+
function setSelected(detail = {}) {
|
|
1637
|
+
window.$CCDK.CCObject.setObjectList(detail);
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* 获得当前标准对象列表选中的信息
|
|
1641
|
+
*/
|
|
1642
|
+
function getSelected() {
|
|
1643
|
+
return window.$CCDK.CCObject.getObjectList()
|
|
1644
1644
|
}
|
|
1645
1645
|
|
|
1646
1646
|
var CCList = /*#__PURE__*/Object.freeze({
|
|
@@ -1649,177 +1649,177 @@ var CCList = /*#__PURE__*/Object.freeze({
|
|
|
1649
1649
|
getSelected: getSelected
|
|
1650
1650
|
});
|
|
1651
1651
|
|
|
1652
|
-
/**
|
|
1653
|
-
* 用于保存打开的页面集合
|
|
1654
|
-
*/
|
|
1655
|
-
let pageList = new Map();
|
|
1656
|
-
/**
|
|
1657
|
-
* 打开对象视图页面
|
|
1658
|
-
* @param {object} obj 对象信息
|
|
1659
|
-
* @param {object} options 配置信息
|
|
1660
|
-
*/
|
|
1661
|
-
function openListPage(obj, options = {}) {
|
|
1662
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1663
|
-
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
1664
|
-
return pageId;
|
|
1665
|
-
}
|
|
1666
|
-
|
|
1667
|
-
/**
|
|
1668
|
-
* 打开数据详情页
|
|
1669
|
-
* @param {object} obj 对象体
|
|
1670
|
-
* @param {string} id 数据id
|
|
1671
|
-
* @param {object} options 配置信息
|
|
1672
|
-
*/
|
|
1673
|
-
function openDetailPage(obj, id, options = {}) {
|
|
1674
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1675
|
-
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
1676
|
-
return pageId;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
/**
|
|
1680
|
-
* 打开创建页面
|
|
1681
|
-
* @param {object} obj 对象体
|
|
1682
|
-
* @param {object} options 配置信息
|
|
1683
|
-
*/
|
|
1684
|
-
function openCreatePage(obj, options = {}) {
|
|
1685
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1686
|
-
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
1687
|
-
return pageId;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
/**
|
|
1691
|
-
* 打开修改页面
|
|
1692
|
-
* @param {object} obj 对象体
|
|
1693
|
-
* @param {string} id 数据id
|
|
1694
|
-
* @param {object} options 配置信息
|
|
1695
|
-
*/
|
|
1696
|
-
function openEditPage(obj, id, options = {}) {
|
|
1697
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1698
|
-
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
1699
|
-
return pageId;
|
|
1700
|
-
}
|
|
1701
|
-
/**
|
|
1702
|
-
* 打开自定义页面
|
|
1703
|
-
* @param {object} obj 自定义页面参数
|
|
1704
|
-
* @param {object} options 配置信息
|
|
1705
|
-
*/
|
|
1706
|
-
function openCustomPage(obj, options = {}) {
|
|
1707
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1708
|
-
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
1709
|
-
return pageId;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
/**
|
|
1713
|
-
* 通过页面id,重新打开某个页面
|
|
1714
|
-
* @param {string} pageId 页面id
|
|
1715
|
-
* @param {object} options 配置信息
|
|
1716
|
-
*/
|
|
1717
|
-
function reOpenPage(pageId, options) {
|
|
1718
|
-
let page;
|
|
1719
|
-
if (pageId) {
|
|
1720
|
-
page = pageList.get(pageId);
|
|
1721
|
-
}
|
|
1722
|
-
if (page) {
|
|
1723
|
-
page.reOpenPage();
|
|
1724
|
-
if (options.refresh) {
|
|
1725
|
-
page.refresh();
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
/**
|
|
1731
|
-
* 将打开的页面添加到集合中
|
|
1732
|
-
* @param {string} id 唯一ID
|
|
1733
|
-
* @param {object} page 页面对象
|
|
1734
|
-
*/
|
|
1735
|
-
function addPage(id, page) {
|
|
1736
|
-
if (id && page) {
|
|
1737
|
-
pageList.set(id, page);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
|
|
1741
|
-
/**
|
|
1742
|
-
* 删除某个页面
|
|
1743
|
-
* @param {string} pageId 唯一ID
|
|
1744
|
-
*/
|
|
1745
|
-
function deletePage(pageId) {
|
|
1746
|
-
if (pageId) {
|
|
1747
|
-
pageList.delete(pageId);
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
/**
|
|
1751
|
-
* 更改页面数据
|
|
1752
|
-
* @param {string} id 唯一ID
|
|
1753
|
-
* @param {object} page 页面对象
|
|
1754
|
-
*/
|
|
1755
|
-
function updatePage(id, page) {
|
|
1756
|
-
if (id && page) {
|
|
1757
|
-
pageList.set(id, page);
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
* 通过页面id查询页面
|
|
1763
|
-
* @param {string} pageId 唯一ID
|
|
1764
|
-
*/
|
|
1765
|
-
function searchPage(pageId) {
|
|
1766
|
-
return pageList.get(pageId)
|
|
1767
|
-
}
|
|
1768
|
-
/**
|
|
1769
|
-
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
1770
|
-
* 如果pageId为all,关闭所有一级菜单
|
|
1771
|
-
* @param {string} pageId 页面id
|
|
1772
|
-
*/
|
|
1773
|
-
function close$1(pageId = '') {
|
|
1774
|
-
let page;
|
|
1775
|
-
if(pageId === 'all'){
|
|
1776
|
-
page = [...pageList.values()];
|
|
1777
|
-
page.forEach(item => {
|
|
1778
|
-
if(item){
|
|
1779
|
-
item.close();
|
|
1780
|
-
}
|
|
1781
|
-
});
|
|
1782
|
-
}else if (pageId) {
|
|
1783
|
-
page = pageList.get(pageId);
|
|
1784
|
-
} else {
|
|
1785
|
-
// 不传pageId 默认关闭当前选中的
|
|
1786
|
-
// 当前选中菜单的树形结构
|
|
1787
|
-
let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
|
|
1788
|
-
if (currentMenuTree) {
|
|
1789
|
-
// 说明当前选中的是二级菜单
|
|
1790
|
-
if (currentMenuTree.level2Id) {
|
|
1791
|
-
page = pageList.get(currentMenuTree.level2Id);
|
|
1792
|
-
} else {
|
|
1793
|
-
// 说明当前选中的是一级菜单
|
|
1794
|
-
page = pageList.get(currentMenuTree.id);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
// if (pageList.size > 0) {
|
|
1798
|
-
// page = [...pageList.values()][pageList.size - 1]
|
|
1799
|
-
// }
|
|
1800
|
-
}
|
|
1801
|
-
if (page) {
|
|
1802
|
-
page.close();
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
/**
|
|
1806
|
-
* 刷新当前页面
|
|
1807
|
-
*/
|
|
1808
|
-
function refresh() {
|
|
1809
|
-
window.$CCDK.CCBus.$emit('refresh');
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* 获取当前一二级选中菜单的树形结构
|
|
1813
|
-
* @param {object} obj 自定义页面参数
|
|
1814
|
-
* @param {object} options 配置信息
|
|
1815
|
-
*/
|
|
1816
|
-
function getCurrentPage() {
|
|
1817
|
-
// 当前选中菜单的树形结构
|
|
1818
|
-
let currentMenuTree = localStorage.getItem('current_page');
|
|
1819
|
-
if (currentMenuTree) {
|
|
1820
|
-
return JSON.parse(currentMenuTree)
|
|
1821
|
-
}
|
|
1822
|
-
return ''
|
|
1652
|
+
/**
|
|
1653
|
+
* 用于保存打开的页面集合
|
|
1654
|
+
*/
|
|
1655
|
+
let pageList = new Map();
|
|
1656
|
+
/**
|
|
1657
|
+
* 打开对象视图页面
|
|
1658
|
+
* @param {object} obj 对象信息
|
|
1659
|
+
* @param {object} options 配置信息
|
|
1660
|
+
*/
|
|
1661
|
+
function openListPage(obj, options = {}) {
|
|
1662
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1663
|
+
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
1664
|
+
return pageId;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* 打开数据详情页
|
|
1669
|
+
* @param {object} obj 对象体
|
|
1670
|
+
* @param {string} id 数据id
|
|
1671
|
+
* @param {object} options 配置信息
|
|
1672
|
+
*/
|
|
1673
|
+
function openDetailPage(obj, id, options = {}) {
|
|
1674
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1675
|
+
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
1676
|
+
return pageId;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* 打开创建页面
|
|
1681
|
+
* @param {object} obj 对象体
|
|
1682
|
+
* @param {object} options 配置信息
|
|
1683
|
+
*/
|
|
1684
|
+
function openCreatePage(obj, options = {}) {
|
|
1685
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1686
|
+
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
1687
|
+
return pageId;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/**
|
|
1691
|
+
* 打开修改页面
|
|
1692
|
+
* @param {object} obj 对象体
|
|
1693
|
+
* @param {string} id 数据id
|
|
1694
|
+
* @param {object} options 配置信息
|
|
1695
|
+
*/
|
|
1696
|
+
function openEditPage(obj, id, options = {}) {
|
|
1697
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1698
|
+
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
1699
|
+
return pageId;
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* 打开自定义页面
|
|
1703
|
+
* @param {object} obj 自定义页面参数
|
|
1704
|
+
* @param {object} options 配置信息
|
|
1705
|
+
*/
|
|
1706
|
+
function openCustomPage(obj, options = {}) {
|
|
1707
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1708
|
+
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
1709
|
+
return pageId;
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* 通过页面id,重新打开某个页面
|
|
1714
|
+
* @param {string} pageId 页面id
|
|
1715
|
+
* @param {object} options 配置信息
|
|
1716
|
+
*/
|
|
1717
|
+
function reOpenPage(pageId, options) {
|
|
1718
|
+
let page;
|
|
1719
|
+
if (pageId) {
|
|
1720
|
+
page = pageList.get(pageId);
|
|
1721
|
+
}
|
|
1722
|
+
if (page) {
|
|
1723
|
+
page.reOpenPage();
|
|
1724
|
+
if (options.refresh) {
|
|
1725
|
+
page.refresh();
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* 将打开的页面添加到集合中
|
|
1732
|
+
* @param {string} id 唯一ID
|
|
1733
|
+
* @param {object} page 页面对象
|
|
1734
|
+
*/
|
|
1735
|
+
function addPage(id, page) {
|
|
1736
|
+
if (id && page) {
|
|
1737
|
+
pageList.set(id, page);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* 删除某个页面
|
|
1743
|
+
* @param {string} pageId 唯一ID
|
|
1744
|
+
*/
|
|
1745
|
+
function deletePage(pageId) {
|
|
1746
|
+
if (pageId) {
|
|
1747
|
+
pageList.delete(pageId);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* 更改页面数据
|
|
1752
|
+
* @param {string} id 唯一ID
|
|
1753
|
+
* @param {object} page 页面对象
|
|
1754
|
+
*/
|
|
1755
|
+
function updatePage(id, page) {
|
|
1756
|
+
if (id && page) {
|
|
1757
|
+
pageList.set(id, page);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* 通过页面id查询页面
|
|
1763
|
+
* @param {string} pageId 唯一ID
|
|
1764
|
+
*/
|
|
1765
|
+
function searchPage(pageId) {
|
|
1766
|
+
return pageList.get(pageId)
|
|
1767
|
+
}
|
|
1768
|
+
/**
|
|
1769
|
+
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
1770
|
+
* 如果pageId为all,关闭所有一级菜单
|
|
1771
|
+
* @param {string} pageId 页面id
|
|
1772
|
+
*/
|
|
1773
|
+
function close$1(pageId = '') {
|
|
1774
|
+
let page;
|
|
1775
|
+
if(pageId === 'all'){
|
|
1776
|
+
page = [...pageList.values()];
|
|
1777
|
+
page.forEach(item => {
|
|
1778
|
+
if(item){
|
|
1779
|
+
item.close();
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
}else if (pageId) {
|
|
1783
|
+
page = pageList.get(pageId);
|
|
1784
|
+
} else {
|
|
1785
|
+
// 不传pageId 默认关闭当前选中的
|
|
1786
|
+
// 当前选中菜单的树形结构
|
|
1787
|
+
let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
|
|
1788
|
+
if (currentMenuTree) {
|
|
1789
|
+
// 说明当前选中的是二级菜单
|
|
1790
|
+
if (currentMenuTree.level2Id) {
|
|
1791
|
+
page = pageList.get(currentMenuTree.level2Id);
|
|
1792
|
+
} else {
|
|
1793
|
+
// 说明当前选中的是一级菜单
|
|
1794
|
+
page = pageList.get(currentMenuTree.id);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
// if (pageList.size > 0) {
|
|
1798
|
+
// page = [...pageList.values()][pageList.size - 1]
|
|
1799
|
+
// }
|
|
1800
|
+
}
|
|
1801
|
+
if (page) {
|
|
1802
|
+
page.close();
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* 刷新当前页面
|
|
1807
|
+
*/
|
|
1808
|
+
function refresh() {
|
|
1809
|
+
window.$CCDK.CCBus.$emit('refresh');
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* 获取当前一二级选中菜单的树形结构
|
|
1813
|
+
* @param {object} obj 自定义页面参数
|
|
1814
|
+
* @param {object} options 配置信息
|
|
1815
|
+
*/
|
|
1816
|
+
function getCurrentPage() {
|
|
1817
|
+
// 当前选中菜单的树形结构
|
|
1818
|
+
let currentMenuTree = localStorage.getItem('current_page');
|
|
1819
|
+
if (currentMenuTree) {
|
|
1820
|
+
return JSON.parse(currentMenuTree)
|
|
1821
|
+
}
|
|
1822
|
+
return ''
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
1825
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
@@ -1839,62 +1839,62 @@ var CCPage = /*#__PURE__*/Object.freeze({
|
|
|
1839
1839
|
getCurrentPage: getCurrentPage
|
|
1840
1840
|
});
|
|
1841
1841
|
|
|
1842
|
-
/**
|
|
1843
|
-
* 设置用户信息
|
|
1844
|
-
* @param {object} sentry
|
|
1845
|
-
* @param {object} ccUser 用户信息
|
|
1846
|
-
*/
|
|
1847
|
-
function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
|
|
1848
|
-
if (ccUser && ccUser != "") {
|
|
1849
|
-
// 添加日志监控标签:组织id
|
|
1850
|
-
sentry.setTag("orgId", ccUser.orgId);
|
|
1851
|
-
// 添加日志监控标签:组织名称
|
|
1852
|
-
sentry.setTag("orgName", ccUser.orgName);
|
|
1853
|
-
// 添加日志监控标签:用户id和用户名称
|
|
1854
|
-
sentry.setUser({
|
|
1855
|
-
username: ccUser.userName,
|
|
1856
|
-
id: ccUser.userId,
|
|
1857
|
-
});
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
/**
|
|
1861
|
-
* 内存上报
|
|
1862
|
-
* @param {object} sentry
|
|
1863
|
-
*/
|
|
1864
|
-
function reportMemory(sentry, ccUser) {
|
|
1865
|
-
if (performance.memory) {
|
|
1866
|
-
let memeryMsg =
|
|
1867
|
-
"内存监控:jsHeapSizeLimit=" +
|
|
1868
|
-
(performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
|
|
1869
|
-
"mb、" +
|
|
1870
|
-
"totalJSHeapSize=" +
|
|
1871
|
-
(performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
1872
|
-
"mb、" +
|
|
1873
|
-
"usedJSHeapSize=" +
|
|
1874
|
-
(performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
1875
|
-
"mb";
|
|
1876
|
-
initUserInfo(sentry, ccUser);
|
|
1877
|
-
sentry.withScope(function (scope) {
|
|
1878
|
-
// 使用内存
|
|
1879
|
-
sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
|
|
1880
|
-
// 添加日志监控标签:组织id
|
|
1881
|
-
scope.setFingerprint(["内存监控"]);
|
|
1882
|
-
sentry.captureMessage(memeryMsg);
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
/**
|
|
1888
|
-
* 网络异常上报
|
|
1889
|
-
* @param {object} sentry
|
|
1890
|
-
* @param {error} error
|
|
1891
|
-
*/
|
|
1892
|
-
function reportHttpException(sentry, error, ccUser) {
|
|
1893
|
-
initUserInfo(sentry, ccUser);
|
|
1894
|
-
sentry.withScope(function (scope) {
|
|
1895
|
-
scope.setFingerprint(["接口未捕获异常response"]);
|
|
1896
|
-
sentry.captureException(error);
|
|
1897
|
-
});
|
|
1842
|
+
/**
|
|
1843
|
+
* 设置用户信息
|
|
1844
|
+
* @param {object} sentry
|
|
1845
|
+
* @param {object} ccUser 用户信息
|
|
1846
|
+
*/
|
|
1847
|
+
function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
|
|
1848
|
+
if (ccUser && ccUser != "") {
|
|
1849
|
+
// 添加日志监控标签:组织id
|
|
1850
|
+
sentry.setTag("orgId", ccUser.orgId);
|
|
1851
|
+
// 添加日志监控标签:组织名称
|
|
1852
|
+
sentry.setTag("orgName", ccUser.orgName);
|
|
1853
|
+
// 添加日志监控标签:用户id和用户名称
|
|
1854
|
+
sentry.setUser({
|
|
1855
|
+
username: ccUser.userName,
|
|
1856
|
+
id: ccUser.userId,
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* 内存上报
|
|
1862
|
+
* @param {object} sentry
|
|
1863
|
+
*/
|
|
1864
|
+
function reportMemory(sentry, ccUser) {
|
|
1865
|
+
if (performance.memory) {
|
|
1866
|
+
let memeryMsg =
|
|
1867
|
+
"内存监控:jsHeapSizeLimit=" +
|
|
1868
|
+
(performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
|
|
1869
|
+
"mb、" +
|
|
1870
|
+
"totalJSHeapSize=" +
|
|
1871
|
+
(performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
1872
|
+
"mb、" +
|
|
1873
|
+
"usedJSHeapSize=" +
|
|
1874
|
+
(performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
1875
|
+
"mb";
|
|
1876
|
+
initUserInfo(sentry, ccUser);
|
|
1877
|
+
sentry.withScope(function (scope) {
|
|
1878
|
+
// 使用内存
|
|
1879
|
+
sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
|
|
1880
|
+
// 添加日志监控标签:组织id
|
|
1881
|
+
scope.setFingerprint(["内存监控"]);
|
|
1882
|
+
sentry.captureMessage(memeryMsg);
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
/**
|
|
1888
|
+
* 网络异常上报
|
|
1889
|
+
* @param {object} sentry
|
|
1890
|
+
* @param {error} error
|
|
1891
|
+
*/
|
|
1892
|
+
function reportHttpException(sentry, error, ccUser) {
|
|
1893
|
+
initUserInfo(sentry, ccUser);
|
|
1894
|
+
sentry.withScope(function (scope) {
|
|
1895
|
+
scope.setFingerprint(["接口未捕获异常response"]);
|
|
1896
|
+
sentry.captureException(error);
|
|
1897
|
+
});
|
|
1898
1898
|
}
|
|
1899
1899
|
|
|
1900
1900
|
var CCSentry = /*#__PURE__*/Object.freeze({
|
|
@@ -1904,24 +1904,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
|
|
|
1904
1904
|
reportHttpException: reportHttpException
|
|
1905
1905
|
});
|
|
1906
1906
|
|
|
1907
|
-
/**
|
|
1908
|
-
* 初始化侧边区域
|
|
1909
|
-
* @param {object} options 自定义页面配置
|
|
1910
|
-
*/
|
|
1911
|
-
function init(options) {
|
|
1912
|
-
window.$CCDK.CCBus.$emit('initSide', options);
|
|
1913
|
-
}
|
|
1914
|
-
/**
|
|
1915
|
-
* 打开侧边区域
|
|
1916
|
-
*/
|
|
1917
|
-
function open() {
|
|
1918
|
-
window.$CCDK.CCBus.$emit('openSide');
|
|
1919
|
-
}
|
|
1920
|
-
/**
|
|
1921
|
-
* 关闭侧边区域
|
|
1922
|
-
*/
|
|
1923
|
-
function close() {
|
|
1924
|
-
window.$CCDK.CCBus.$emit('closeSide');
|
|
1907
|
+
/**
|
|
1908
|
+
* 初始化侧边区域
|
|
1909
|
+
* @param {object} options 自定义页面配置
|
|
1910
|
+
*/
|
|
1911
|
+
function init(options) {
|
|
1912
|
+
window.$CCDK.CCBus.$emit('initSide', options);
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* 打开侧边区域
|
|
1916
|
+
*/
|
|
1917
|
+
function open() {
|
|
1918
|
+
window.$CCDK.CCBus.$emit('openSide');
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* 关闭侧边区域
|
|
1922
|
+
*/
|
|
1923
|
+
function close() {
|
|
1924
|
+
window.$CCDK.CCBus.$emit('closeSide');
|
|
1925
1925
|
}
|
|
1926
1926
|
|
|
1927
1927
|
var CCSide = /*#__PURE__*/Object.freeze({
|
|
@@ -1931,58 +1931,60 @@ var CCSide = /*#__PURE__*/Object.freeze({
|
|
|
1931
1931
|
close: close
|
|
1932
1932
|
});
|
|
1933
1933
|
|
|
1934
|
-
// cookie存储标识
|
|
1935
|
-
const TOKEN = "cc_token";
|
|
1936
|
-
/**
|
|
1937
|
-
* 获取URL中参数的数据
|
|
1938
|
-
* @param {name} 参数名
|
|
1939
|
-
*/
|
|
1940
|
-
function getUrlQuery(name) {
|
|
1941
|
-
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
1942
|
-
var r = window.location.href.match(reg);
|
|
1943
|
-
let res = null;
|
|
1944
|
-
if (r != null) res = r[1].trim();
|
|
1945
|
-
return res;
|
|
1946
|
-
}
|
|
1947
|
-
/**
|
|
1948
|
-
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
|
|
1949
|
-
* @param {String} urlName 获取token的url名称
|
|
1950
|
-
* @param {String} cookieName 获取token的cookie名称
|
|
1951
|
-
* @returns
|
|
1952
|
-
*/
|
|
1953
|
-
function getToken(urlName = "binding", cookieName = TOKEN) {
|
|
1954
|
-
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN) || localStorage.getItem(Crypto.encrypt(cookieName));
|
|
1955
|
-
if (token) {
|
|
1956
|
-
token = setToken(token, cookieName);
|
|
1957
|
-
}
|
|
1958
|
-
return token
|
|
1959
|
-
}
|
|
1960
|
-
/**
|
|
1961
|
-
* 存储token
|
|
1962
|
-
* @param {String} token token
|
|
1963
|
-
* @param {String} cookieName 获取token的cookie名称
|
|
1964
|
-
* @param {String} domain 域名
|
|
1965
|
-
*/
|
|
1966
|
-
function setToken(token, cookieName = TOKEN, domain = getDomain()) {
|
|
1967
|
-
let { result } = verifyToken(token);
|
|
1968
|
-
if (result) {
|
|
1969
|
-
Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
*
|
|
1980
|
-
* @param {String}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
Cookies.remove(Crypto.encrypt(cookieName));
|
|
1985
|
-
|
|
1934
|
+
// cookie存储标识
|
|
1935
|
+
const TOKEN = "cc_token";
|
|
1936
|
+
/**
|
|
1937
|
+
* 获取URL中参数的数据
|
|
1938
|
+
* @param {name} 参数名
|
|
1939
|
+
*/
|
|
1940
|
+
function getUrlQuery(name) {
|
|
1941
|
+
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
1942
|
+
var r = window.location.href.match(reg);
|
|
1943
|
+
let res = null;
|
|
1944
|
+
if (r != null) res = r[1].trim();
|
|
1945
|
+
return res;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
|
|
1949
|
+
* @param {String} urlName 获取token的url名称
|
|
1950
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
1951
|
+
* @returns
|
|
1952
|
+
*/
|
|
1953
|
+
function getToken(urlName = "binding", cookieName = TOKEN) {
|
|
1954
|
+
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN) || localStorage.getItem(Crypto.encrypt(cookieName));
|
|
1955
|
+
if (token) {
|
|
1956
|
+
token = setToken(token, cookieName);
|
|
1957
|
+
}
|
|
1958
|
+
return token
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* 存储token
|
|
1962
|
+
* @param {String} token token
|
|
1963
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
1964
|
+
* @param {String} domain 域名
|
|
1965
|
+
*/
|
|
1966
|
+
function setToken(token, cookieName = TOKEN, domain = getDomain()) {
|
|
1967
|
+
let { result } = verifyToken(token);
|
|
1968
|
+
if (result) {
|
|
1969
|
+
Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
|
|
1970
|
+
Cookies.set("JSESSIONID", token, { expires: 1 / 12 });
|
|
1971
|
+
// localStorage.setItem(Crypto.encrypt(cookieName), token);
|
|
1972
|
+
return token
|
|
1973
|
+
} else {
|
|
1974
|
+
return null
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* 清除Token数据
|
|
1980
|
+
* @param {String} domain 域名
|
|
1981
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
1982
|
+
*/
|
|
1983
|
+
function clearToken(cookieName = TOKEN, domain = getDomain()) {
|
|
1984
|
+
Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
|
|
1985
|
+
Cookies.remove(Crypto.encrypt(cookieName));
|
|
1986
|
+
Cookies.remove("JSESSIONID");
|
|
1987
|
+
localStorage.removeItem(Crypto.encrypt(cookieName));
|
|
1986
1988
|
}
|
|
1987
1989
|
|
|
1988
1990
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
@@ -1993,55 +1995,55 @@ var CCToken = /*#__PURE__*/Object.freeze({
|
|
|
1993
1995
|
getUrlQuery: getUrlQuery
|
|
1994
1996
|
});
|
|
1995
1997
|
|
|
1996
|
-
// 用户cookie存储标识
|
|
1997
|
-
const USER_INFO = "cc_user_info";
|
|
1998
|
-
// JWT的cookie存储标识
|
|
1999
|
-
const USER_JWT_INFO = "cc_user_jwt_info";
|
|
2000
|
-
|
|
2001
|
-
/**
|
|
2002
|
-
* 存储用户信息
|
|
2003
|
-
* @param {String} userInfo 用户信息
|
|
2004
|
-
* @param {String} domain 域名
|
|
2005
|
-
*/
|
|
2006
|
-
function setUserInfo(userInfo, domain = getDomain()) {
|
|
2007
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
/**
|
|
2011
|
-
* 获取用户信息
|
|
2012
|
-
* @returns {String} 用户信息
|
|
2013
|
-
*/
|
|
2014
|
-
function getUserInfo() {
|
|
2015
|
-
// 加密的用户信息
|
|
2016
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
2017
|
-
if (encryptUserInfo) {
|
|
2018
|
-
return Crypto.decrypt(encryptUserInfo)
|
|
2019
|
-
} else {
|
|
2020
|
-
return ""
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
/**
|
|
2025
|
-
* 存储用户jwt信息
|
|
2026
|
-
* @param {String} jwtInfo 用户信息
|
|
2027
|
-
* @param {String} domain 域名
|
|
2028
|
-
*/
|
|
2029
|
-
function setUserJwtInfo(jwtInfo, domain = getDomain()) {
|
|
2030
|
-
Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 });
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
/**
|
|
2034
|
-
* 获取用户jwt信息
|
|
2035
|
-
* @returns {Object} 用户信息
|
|
2036
|
-
*/
|
|
2037
|
-
function getUserJwtInfo() {
|
|
2038
|
-
// 加密的用户信息
|
|
2039
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
|
|
2040
|
-
if (encryptUserInfo) {
|
|
2041
|
-
return JSON.parse(Crypto.decrypt(encryptUserInfo))
|
|
2042
|
-
} else {
|
|
2043
|
-
return {}
|
|
2044
|
-
}
|
|
1998
|
+
// 用户cookie存储标识
|
|
1999
|
+
const USER_INFO = "cc_user_info";
|
|
2000
|
+
// JWT的cookie存储标识
|
|
2001
|
+
const USER_JWT_INFO = "cc_user_jwt_info";
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* 存储用户信息
|
|
2005
|
+
* @param {String} userInfo 用户信息
|
|
2006
|
+
* @param {String} domain 域名
|
|
2007
|
+
*/
|
|
2008
|
+
function setUserInfo(userInfo, domain = getDomain()) {
|
|
2009
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
/**
|
|
2013
|
+
* 获取用户信息
|
|
2014
|
+
* @returns {String} 用户信息
|
|
2015
|
+
*/
|
|
2016
|
+
function getUserInfo() {
|
|
2017
|
+
// 加密的用户信息
|
|
2018
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
2019
|
+
if (encryptUserInfo) {
|
|
2020
|
+
return Crypto.decrypt(encryptUserInfo)
|
|
2021
|
+
} else {
|
|
2022
|
+
return ""
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* 存储用户jwt信息
|
|
2028
|
+
* @param {String} jwtInfo 用户信息
|
|
2029
|
+
* @param {String} domain 域名
|
|
2030
|
+
*/
|
|
2031
|
+
function setUserJwtInfo(jwtInfo, domain = getDomain()) {
|
|
2032
|
+
Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 });
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
/**
|
|
2036
|
+
* 获取用户jwt信息
|
|
2037
|
+
* @returns {Object} 用户信息
|
|
2038
|
+
*/
|
|
2039
|
+
function getUserJwtInfo() {
|
|
2040
|
+
// 加密的用户信息
|
|
2041
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
|
|
2042
|
+
if (encryptUserInfo) {
|
|
2043
|
+
return JSON.parse(Crypto.decrypt(encryptUserInfo))
|
|
2044
|
+
} else {
|
|
2045
|
+
return {}
|
|
2046
|
+
}
|
|
2045
2047
|
}
|
|
2046
2048
|
|
|
2047
2049
|
var CCUser = /*#__PURE__*/Object.freeze({
|
|
@@ -2052,8 +2054,8 @@ var CCUser = /*#__PURE__*/Object.freeze({
|
|
|
2052
2054
|
getUserJwtInfo: getUserJwtInfo
|
|
2053
2055
|
});
|
|
2054
2056
|
|
|
2055
|
-
let CCDK = { CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
|
|
2056
|
-
Vue.prototype.$CCDK = CCDK;
|
|
2057
|
+
let CCDK = { CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
|
|
2058
|
+
Vue.prototype.$CCDK = CCDK;
|
|
2057
2059
|
window.$CCDK = CCDK;
|
|
2058
2060
|
|
|
2059
2061
|
export { CCDK as default };
|