cloudcc-ccdk 0.6.1 → 0.6.3

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.
Files changed (4) hide show
  1. package/README.md +425 -413
  2. package/lib/ccdk.js +1440 -1440
  3. package/lib/ccdk.min.js +1 -1
  4. package/package.json +32 -32
package/lib/ccdk.js CHANGED
@@ -5,69 +5,69 @@ import cloneDeep from 'lodash/cloneDeep';
5
5
  import Cookies from 'js-cookie';
6
6
  import { Message, MessageBox, Notification } from 'element-ui';
7
7
 
8
- /**
9
- * 加密
10
- * @param {String} data 数据
11
- * @param {String} key 密钥
12
- * @param {String} iv 偏移量
13
- * @returns
14
- */
15
- function getAesString(data, key, iv) {
16
- key = CryptoJS.enc.Utf8.parse(key);
17
- iv = CryptoJS.enc.Utf8.parse(iv);
18
- let encrypted = CryptoJS.AES.encrypt(data, key, {
19
- iv: iv,
20
- padding: CryptoJS.pad.Pkcs7,
21
- });
22
- return encrypted.toString(); //返回的是base64格式的密文
23
- }
24
-
25
- /**
26
- * 解密
27
- * @param {String} encrypted 密文
28
- * @param {String} key 密钥
29
- * @param {String} iv 偏移量
30
- * @returns
31
- */
32
- function getDAesString(encrypted, key, iv) {
33
- key = CryptoJS.enc.Utf8.parse(key);
34
- iv = CryptoJS.enc.Utf8.parse(iv);
35
- let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
36
- iv: iv,
37
- padding: CryptoJS.pad.Pkcs7,
38
- });
39
- return decrypted.toString(CryptoJS.enc.Utf8);
40
- }
41
-
42
- /**
43
- * CryptoJS加密
44
- * @param {String} data 数据
45
- * @param {String} key 密钥
46
- * @param {String} iv 偏移量
47
- * @returns 加密的数据
48
- */
49
- function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
50
- data = JSON.stringify(data);
51
- var encrypted = getAesString(data, key, iv); //密文
52
- return encrypted;
53
- }
54
-
55
- /**
56
- * CryptoJS解密
57
- * @param {String} data 加密的数据
58
- * @param {String} key 密钥
59
- * @param {String} iv 偏移量
60
- * @returns 解密的数据
61
- */
62
- function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
63
- try {
64
- var decryptedStr = getDAesString(data, key, iv);
65
- if (!decryptedStr) return null
66
- return JSON.parse(decryptedStr);
67
- } catch (error) {
68
- console.trace("解密密码错误", error);
69
- return null;
70
- }
8
+ /**
9
+ * 加密
10
+ * @param {String} data 数据
11
+ * @param {String} key 密钥
12
+ * @param {String} iv 偏移量
13
+ * @returns
14
+ */
15
+ function getAesString(data, key, iv) {
16
+ key = CryptoJS.enc.Utf8.parse(key);
17
+ iv = CryptoJS.enc.Utf8.parse(iv);
18
+ let encrypted = CryptoJS.AES.encrypt(data, key, {
19
+ iv: iv,
20
+ padding: CryptoJS.pad.Pkcs7,
21
+ });
22
+ return encrypted.toString(); //返回的是base64格式的密文
23
+ }
24
+
25
+ /**
26
+ * 解密
27
+ * @param {String} encrypted 密文
28
+ * @param {String} key 密钥
29
+ * @param {String} iv 偏移量
30
+ * @returns
31
+ */
32
+ function getDAesString(encrypted, key, iv) {
33
+ key = CryptoJS.enc.Utf8.parse(key);
34
+ iv = CryptoJS.enc.Utf8.parse(iv);
35
+ let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
36
+ iv: iv,
37
+ padding: CryptoJS.pad.Pkcs7,
38
+ });
39
+ return decrypted.toString(CryptoJS.enc.Utf8);
40
+ }
41
+
42
+ /**
43
+ * CryptoJS加密
44
+ * @param {String} data 数据
45
+ * @param {String} key 密钥
46
+ * @param {String} iv 偏移量
47
+ * @returns 加密的数据
48
+ */
49
+ function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
50
+ data = JSON.stringify(data);
51
+ var encrypted = getAesString(data, key, iv); //密文
52
+ return encrypted;
53
+ }
54
+
55
+ /**
56
+ * CryptoJS解密
57
+ * @param {String} data 加密的数据
58
+ * @param {String} key 密钥
59
+ * @param {String} iv 偏移量
60
+ * @returns 解密的数据
61
+ */
62
+ function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
63
+ try {
64
+ var decryptedStr = getDAesString(data, key, iv);
65
+ if (!decryptedStr) return null
66
+ return JSON.parse(decryptedStr);
67
+ } catch (error) {
68
+ console.trace("解密密码错误", error);
69
+ return null;
70
+ }
71
71
  }
72
72
 
73
73
  var Crypto = /*#__PURE__*/Object.freeze({
@@ -76,27 +76,27 @@ var Crypto = /*#__PURE__*/Object.freeze({
76
76
  decrypt: decrypt
77
77
  });
78
78
 
79
- // 当前应用存储标识
80
- const APPLICATION_DETAIL = 'applicaton_current';
81
- /**
82
- * 获得当前访问的应用对象
83
- */
84
- function getApplicaton() {
85
- let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
86
- if (detail) {
87
- return JSON.parse(detail)
88
- }
89
- return ''
90
- }
91
-
92
- /**
93
- * 设置应用对象信息
94
- * @param {object} detail 应用对象
95
- */
96
- function setApplication(detail = '') {
97
- if (detail) {
98
- localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
99
- }
79
+ // 当前应用存储标识
80
+ const APPLICATION_DETAIL = 'applicaton_current';
81
+ /**
82
+ * 获得当前访问的应用对象
83
+ */
84
+ function getApplicaton() {
85
+ let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
86
+ if (detail) {
87
+ return JSON.parse(detail)
88
+ }
89
+ return ''
90
+ }
91
+
92
+ /**
93
+ * 设置应用对象信息
94
+ * @param {object} detail 应用对象
95
+ */
96
+ function setApplication(detail = '') {
97
+ if (detail) {
98
+ localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
99
+ }
100
100
  }
101
101
 
102
102
  var CCApplication = /*#__PURE__*/Object.freeze({
@@ -105,29 +105,29 @@ var CCApplication = /*#__PURE__*/Object.freeze({
105
105
  setApplication: setApplication
106
106
  });
107
107
 
108
- window.ccBus = new Vue;
109
- /**
110
- * 发布信息
111
- * @param {string} event 事件名称
112
- * @param {...any} args 参数列表
113
- */
114
- function $emit(event, ...args) {
115
- window.ccBus.$emit(event, ...args);
116
- }
117
- /**
118
- * 订阅消息
119
- * @param {string} event 事件名称
120
- * @param {function} callback 回调方法
121
- */
122
- function $on(event, callback) {
123
- window.ccBus.$on(event, callback);
124
- }
125
- /**
126
- * 取消订阅
127
- * @param {string} event 事件名称
128
- */
129
- function $off(event) {
130
- window.ccBus.$off(event);
108
+ window.ccBus = new Vue;
109
+ /**
110
+ * 发布信息
111
+ * @param {string} event 事件名称
112
+ * @param {...any} args 参数列表
113
+ */
114
+ function $emit(event, ...args) {
115
+ window.ccBus.$emit(event, ...args);
116
+ }
117
+ /**
118
+ * 订阅消息
119
+ * @param {string} event 事件名称
120
+ * @param {function} callback 回调方法
121
+ */
122
+ function $on(event, callback) {
123
+ window.ccBus.$on(event, callback);
124
+ }
125
+ /**
126
+ * 取消订阅
127
+ * @param {string} event 事件名称
128
+ */
129
+ function $off(event) {
130
+ window.ccBus.$off(event);
131
131
  }
132
132
 
133
133
  var CCBus = /*#__PURE__*/Object.freeze({
@@ -137,57 +137,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
137
137
  $off: $off
138
138
  });
139
139
 
140
- // 电话对象
141
- let ccCall = new Map();
142
- // 电话服务商当前对象
143
- let currentCall;
144
- /**
145
- * 初始化电话条
146
- * @param {string} id 电话服务商唯一标识
147
- * @param {object} callClient 电话对象
148
- */
149
- function init$1(id, callClient) {
150
- if (id && callClient) {
151
- ccCall.set(id, callClient);
152
- currentCall = callClient;
153
- return currentCall
154
- }
155
- }
156
-
157
-
158
- /**
159
- * 拨打电话
160
- * @param {string} id 电话服务商唯一标识
161
- * @param {object} options 配置信息
162
- */
163
- function call(id, options) {
164
- let call;
165
- if (id) {
166
- call = ccCall.get(id);
167
- } else {
168
- call = currentCall;
169
- }
170
- if (call) {
171
- call.call(options);
172
- }
173
- return call
174
- }
175
- /**
176
- * 打开通话面板
177
- * @param {string} id 电话服务商唯一标识
178
- * @param {object} options 配置信息
179
- */
180
- function openCallPanel(id, options) {
181
- let call;
182
- if (id) {
183
- call = ccCall.get(id);
184
- } else {
185
- call = currentCall;
186
- }
187
- if (call) {
188
- call.openCallPanel(options);
189
- }
190
- return call
140
+ // 电话对象
141
+ let ccCall = new Map();
142
+ // 电话服务商当前对象
143
+ let currentCall;
144
+ /**
145
+ * 初始化电话条
146
+ * @param {string} id 电话服务商唯一标识
147
+ * @param {object} callClient 电话对象
148
+ */
149
+ function init$1(id, callClient) {
150
+ if (id && callClient) {
151
+ ccCall.set(id, callClient);
152
+ currentCall = callClient;
153
+ return currentCall
154
+ }
155
+ }
156
+
157
+
158
+ /**
159
+ * 拨打电话
160
+ * @param {string} id 电话服务商唯一标识
161
+ * @param {object} options 配置信息
162
+ */
163
+ function call(id, options) {
164
+ let call;
165
+ if (id) {
166
+ call = ccCall.get(id);
167
+ } else {
168
+ call = currentCall;
169
+ }
170
+ if (call) {
171
+ call.call(options);
172
+ }
173
+ return call
174
+ }
175
+ /**
176
+ * 打开通话面板
177
+ * @param {string} id 电话服务商唯一标识
178
+ * @param {object} options 配置信息
179
+ */
180
+ function openCallPanel(id, options) {
181
+ let call;
182
+ if (id) {
183
+ call = ccCall.get(id);
184
+ } else {
185
+ call = currentCall;
186
+ }
187
+ if (call) {
188
+ call.openCallPanel(options);
189
+ }
190
+ return call
191
191
  }
192
192
 
193
193
  var CCCall = /*#__PURE__*/Object.freeze({
@@ -197,33 +197,33 @@ var CCCall = /*#__PURE__*/Object.freeze({
197
197
  openCallPanel: openCallPanel
198
198
  });
199
199
 
200
- /**
201
- * 获取基础url
202
- * @returns 基础地址
203
- */
204
- function getBaseUrl() {
205
- return window.gw.BASE_URL
206
- }
207
- /**
208
- * 获取网关对象
209
- * @returns 网关对象
210
- */
211
- function getGw() {
212
- return window.gw;
213
- }
214
- /**
215
- * 获取服务对象
216
- * @returns 服务对象
217
- */
218
- function getSvc() {
219
- return window.Glod;
220
- }
221
- /**
222
- * 获取静态资源的访问地址
223
- * @returns 静态资源访问地址
224
- */
225
- function getCDNUrl() {
226
- return window.Glod.CDN_URL;
200
+ /**
201
+ * 获取基础url
202
+ * @returns 基础地址
203
+ */
204
+ function getBaseUrl() {
205
+ return window.gw.BASE_URL
206
+ }
207
+ /**
208
+ * 获取网关对象
209
+ * @returns 网关对象
210
+ */
211
+ function getGw() {
212
+ return window.gw;
213
+ }
214
+ /**
215
+ * 获取服务对象
216
+ * @returns 服务对象
217
+ */
218
+ function getSvc() {
219
+ return window.Glod;
220
+ }
221
+ /**
222
+ * 获取静态资源的访问地址
223
+ * @returns 静态资源访问地址
224
+ */
225
+ function getCDNUrl() {
226
+ return window.Glod.CDN_URL;
227
227
  }
228
228
 
229
229
  var CCConfig = /*#__PURE__*/Object.freeze({
@@ -234,59 +234,59 @@ var CCConfig = /*#__PURE__*/Object.freeze({
234
234
  getCDNUrl: getCDNUrl
235
235
  });
236
236
 
237
- const keyCode = "646576636f6e736f6c652d7376633132";
238
- // const keyCode = "6c6b6a3233346a6b6c6173646877636b"
239
-
240
- function en(word, keyStr = keyCode) {
241
- let enc = CryptoJS.AES.encrypt(word, CryptoJS.enc.Hex.parse(keyStr), {
242
- mode: CryptoJS.mode.ECB,
243
- padding: CryptoJS.pad.Pkcs7
244
- });
245
- return enc.ciphertext.toString()
246
- }
247
-
248
- function de(word, keyStr = keyCode) {
249
- let dec = CryptoJS.AES.decrypt(CryptoJS.format.Hex.parse(word), CryptoJS.enc.Hex.parse(keyStr), {
250
- mode: CryptoJS.mode.ECB,
251
- padding: CryptoJS.pad.Pkcs7
252
- });
253
- return CryptoJS.enc.Utf8.stringify(dec)
254
- }
255
-
256
- /**
257
- * 获得一级域名
258
- * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
259
- */
260
- function getDomain() {
261
- // 倒数第二位域名
262
- let lastTow = document.domain.split('.').slice(-2, -1)[0];
263
- // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
264
- if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
265
- return "." + document.domain.split('.').slice(-3).join('.')
266
- } else {
267
- return "." + document.domain.split('.').slice(-2).join('.')
268
- }
269
- }
270
-
271
- function getUuid() {
272
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
273
- var r = (Math.random() * 16) | 0,
274
- v = c == 'x' ? r : (r & 0x3) | 0x8;
275
- return v.toString(16);
276
- });
277
- }
278
-
279
- function getBinding() {
280
- let binding = window.$CCDK.CCToken.getToken();
281
- if (!binding) {
282
- window.open(window.Glod.LOGIN_URL, '_self');
283
- // this.reLogin();
284
- } else {
285
- // 刷新有效期,而且有的老功能,依赖这个binding了
286
- Cookies.set('binding', binding, { expires: 1 / 12 });
287
- Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
288
- }
289
- return binding
237
+ const keyCode = "646576636f6e736f6c652d7376633132";
238
+ // const keyCode = "6c6b6a3233346a6b6c6173646877636b"
239
+
240
+ function en(word, keyStr = keyCode) {
241
+ let enc = CryptoJS.AES.encrypt(word, CryptoJS.enc.Hex.parse(keyStr), {
242
+ mode: CryptoJS.mode.ECB,
243
+ padding: CryptoJS.pad.Pkcs7
244
+ });
245
+ return enc.ciphertext.toString()
246
+ }
247
+
248
+ function de(word, keyStr = keyCode) {
249
+ let dec = CryptoJS.AES.decrypt(CryptoJS.format.Hex.parse(word), CryptoJS.enc.Hex.parse(keyStr), {
250
+ mode: CryptoJS.mode.ECB,
251
+ padding: CryptoJS.pad.Pkcs7
252
+ });
253
+ return CryptoJS.enc.Utf8.stringify(dec)
254
+ }
255
+
256
+ /**
257
+ * 获得一级域名
258
+ * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
259
+ */
260
+ function getDomain() {
261
+ // 倒数第二位域名
262
+ let lastTow = document.domain.split('.').slice(-2, -1)[0];
263
+ // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
264
+ if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
265
+ return "." + document.domain.split('.').slice(-3).join('.')
266
+ } else {
267
+ return "." + document.domain.split('.').slice(-2).join('.')
268
+ }
269
+ }
270
+
271
+ function getUuid() {
272
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
273
+ var r = (Math.random() * 16) | 0,
274
+ v = c == 'x' ? r : (r & 0x3) | 0x8;
275
+ return v.toString(16);
276
+ });
277
+ }
278
+
279
+ function getBinding() {
280
+ let binding = window.$CCDK.CCToken.getToken();
281
+ if (!binding) {
282
+ window.open(window.Glod.LOGIN_URL, '_self');
283
+ // this.reLogin();
284
+ } else {
285
+ // 刷新有效期,而且有的老功能,依赖这个binding了
286
+ Cookies.set('binding', binding, { expires: 1 / 12 });
287
+ Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
288
+ }
289
+ return binding
290
290
  }
291
291
 
292
292
  var CCUtils = /*#__PURE__*/Object.freeze({
@@ -296,511 +296,511 @@ var CCUtils = /*#__PURE__*/Object.freeze({
296
296
  getBinding: getBinding
297
297
  });
298
298
 
299
- const toStr = Object.prototype.toString;
300
-
301
- const TypeEnum = {
302
- 'FUNCTION': '[object Function]',
303
- 'ARRAY': '[object Array]',
304
- };
305
- // 是否是一个函数
306
- const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
307
-
308
- // 是否是生产环境
309
- const isProduction = () => process.env.NODE_ENV == 'production';
310
-
311
- // 延时
312
- const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
313
-
314
- // 是否是超时请求
315
- const isTimeout = (error = {
316
- code: '',
317
- message: ''
318
- }) => {
319
- return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
320
- };
321
-
322
- // 格式换请求体
323
- const formateData = data => {
324
- return {
325
- head: {
326
- appType: "lightning-main",
327
- appVersion: "1.1.1",
328
- accessToken: getBinding(),
329
- source: "lightning-main"
330
- },
331
- body: {
332
- ...data
333
- }
334
- }
335
- };
336
-
337
- const LRUCache = function (capacity) {
338
- this.capacity = capacity;
339
- this.cache = new Map();
340
- };
341
-
342
- LRUCache.prototype.get = function (key) {
343
- var cacheTemp = this.cache,
344
- curTemp = cacheTemp.get(key);
345
- if (curTemp || curTemp === 0) {
346
- cacheTemp.delete(key);
347
- cacheTemp.set(key, curTemp);
348
- return curTemp
349
- }
350
- return null
299
+ const toStr = Object.prototype.toString;
300
+
301
+ const TypeEnum = {
302
+ 'FUNCTION': '[object Function]',
303
+ 'ARRAY': '[object Array]',
304
+ };
305
+ // 是否是一个函数
306
+ const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
307
+
308
+ // 是否是生产环境
309
+ const isProduction = () => process.env.NODE_ENV == 'production';
310
+
311
+ // 延时
312
+ const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
313
+
314
+ // 是否是超时请求
315
+ const isTimeout = (error = {
316
+ code: '',
317
+ message: ''
318
+ }) => {
319
+ return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
320
+ };
321
+
322
+ // 格式换请求体
323
+ const formateData = data => {
324
+ return {
325
+ head: {
326
+ appType: "lightning-main",
327
+ appVersion: "1.1.1",
328
+ accessToken: getBinding(),
329
+ source: "lightning-main"
330
+ },
331
+ body: {
332
+ ...data
333
+ }
334
+ }
351
335
  };
352
336
 
353
- LRUCache.prototype.put = function (key, value) {
354
- var cacheTemp = this.cache;
355
- if (cacheTemp.get(key)) {
356
- cacheTemp.delete(key);
357
- } else if (cacheTemp.size >= this.capacity) {
358
- cacheTemp.delete(cacheTemp.keys().next().value);
359
- }
360
- cacheTemp.set(key, value);
337
+ const LRUCache = function (capacity) {
338
+ this.capacity = capacity;
339
+ this.cache = new Map();
340
+ };
341
+
342
+ LRUCache.prototype.get = function (key) {
343
+ var cacheTemp = this.cache,
344
+ curTemp = cacheTemp.get(key);
345
+ if (curTemp || curTemp === 0) {
346
+ cacheTemp.delete(key);
347
+ cacheTemp.set(key, curTemp);
348
+ return curTemp
349
+ }
350
+ return null
351
+ };
352
+
353
+ LRUCache.prototype.put = function (key, value) {
354
+ var cacheTemp = this.cache;
355
+ if (cacheTemp.get(key)) {
356
+ cacheTemp.delete(key);
357
+ } else if (cacheTemp.size >= this.capacity) {
358
+ cacheTemp.delete(cacheTemp.keys().next().value);
359
+ }
360
+ cacheTemp.set(key, value);
361
361
  };
362
362
 
363
- class CCAxios {
364
- constructor(opt) {
365
- this.options = opt;
366
- this.axiosInstance = axios.create(opt);
367
- this.setupInterceptors();
368
- this.cachePool = new LRUCache(20);
369
- // FIXME:区分构造函数参数和接口级别的参数
370
- }
371
-
372
- //获取拦截器
373
- getTransform() {
374
- const { transform } = this.options;
375
- return transform;
376
- }
377
-
378
- //准备拦截器
379
- setupInterceptors() {
380
- const transform = this.getTransform();
381
- if (!transform) {
382
- return;
383
- }
384
- const {
385
- requestInterceptors,
386
- requestInterceptorsCatch,
387
- responseInterceptors,
388
- responseInterceptorsCatch,
389
- } = transform;
390
- // 请求拦截器
391
- this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
392
- // 请求拦截器错误处理
393
- requestInterceptorsCatch
394
- && isFn(requestInterceptorsCatch)
395
- && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
396
-
397
- // 响应拦截器
398
- this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
399
- // 响应拦截器错误处理
400
- responseInterceptorsCatch
401
- && isFn(responseInterceptorsCatch)
402
- && this.axiosInstance.interceptors.response.use(undefined, (error) => {
403
- return responseInterceptorsCatch(this.axiosInstance, error)
404
- });
405
- }
406
- get(config, options = {}) {
407
- return this.request({ ...config, method: 'GET', }, options)
408
- }
409
- post(config, options = {}) {
410
- const { envType } = options;
411
- // 公有云专用接口,在私有云不请求
412
- if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
413
- return new Promise(() => { })
414
- }
415
- // 私有云专用接口,在公有云不请求
416
- if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
417
- return new Promise(() => { })
418
- }
419
- return this.request({ ...config, method: 'POST', }, options)
420
- }
421
- postFormat(config, options = {}) {
422
- return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
423
- }
424
- postParams(config, options = {}) {
425
- return this.request({ ...config, method: 'POST', params: config.data }, options)
426
- }
427
- // FIXME:如果初始化时配置了重试那么所有get接口都重试了
428
- // options是接口级定义的参数
429
- request(config, options) {
430
- const transform = this.getTransform();
431
- const conf = config,
432
- { requestOptions } = this.options;
433
- requestOptions.cache = false;
434
- requestOptions.cacheKey = '';
435
- requestOptions.retryRequest = {
436
- isOpenRetry: false,
437
- count: 5,
438
- waitTime: 1000
439
- };
440
-
441
- const opt = Object.assign({}, requestOptions, options);
442
- conf.requestOptions = opt;
443
-
444
- const retPromise = new Promise((resolve, reject) => {
445
- this.axiosInstance(conf)
446
- .then(res => {
447
- const { transformResponseHook } = transform;
448
- if (transformResponseHook && isFn(transformResponseHook)) {
449
- try {
450
- const ret = transformResponseHook(res, opt, this.cachePool);
451
- resolve(ret);
452
- } catch (err) {
453
- reject(err || new Error('request error!'));
454
- }
455
- return;
456
- }
457
- resolve(res);
458
- })
459
- .catch(err => {
460
- reject(err);
461
- });
462
- });
463
- retPromise.cache = (callback) => {
464
- const { cache, cacheKey } = opt;
465
- const cacheData = (cache && this.cachePool.get([cacheKey]));
466
- callback(cacheData ? cacheData : null);
467
- return retPromise
468
- };
469
- return retPromise
470
- }
471
- }
472
-
473
- // import i18n from '@/utils/i18n'
474
-
475
- // const getBaseOptions = () => ({
476
- // confirmButtonText: i18n.t('确定'),
477
- // center: true
478
- // })
479
-
480
- // const createModalOptions = (options) => ({
481
- // ...getBaseOptions(),
482
- // ...options,
483
- // title: options.title || i18n.t('提示'),
484
- // message: options.message || '消息'
485
- // })
486
-
487
- const createErrorModal = (response, options) => {
488
- const { message } = options;
489
- let temp;
490
- if (response.name === 'AxiosError') {
491
- temp = response.response;
492
- temp.data.returnInfo = response.returnInfo || message || temp.error || '';
493
- temp.data.returnCode = response.code || temp.status;
494
- temp.data.requestId = response.config.headers.requestId;
495
- } else {
496
- temp = response;
497
- temp.data.requestId = response.config.headers.requestId;
498
- }
499
- Vue.prototype.$ErrorDialog({
500
- response: temp
501
- });
502
- };
503
-
504
- // MessageBox(createModalOptions(options))
505
-
506
-
363
+ class CCAxios {
364
+ constructor(opt) {
365
+ this.options = opt;
366
+ this.axiosInstance = axios.create(opt);
367
+ this.setupInterceptors();
368
+ this.cachePool = new LRUCache(20);
369
+ // FIXME:区分构造函数参数和接口级别的参数
370
+ }
371
+
372
+ //获取拦截器
373
+ getTransform() {
374
+ const { transform } = this.options;
375
+ return transform;
376
+ }
377
+
378
+ //准备拦截器
379
+ setupInterceptors() {
380
+ const transform = this.getTransform();
381
+ if (!transform) {
382
+ return;
383
+ }
384
+ const {
385
+ requestInterceptors,
386
+ requestInterceptorsCatch,
387
+ responseInterceptors,
388
+ responseInterceptorsCatch,
389
+ } = transform;
390
+ // 请求拦截器
391
+ this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
392
+ // 请求拦截器错误处理
393
+ requestInterceptorsCatch
394
+ && isFn(requestInterceptorsCatch)
395
+ && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
396
+
397
+ // 响应拦截器
398
+ this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
399
+ // 响应拦截器错误处理
400
+ responseInterceptorsCatch
401
+ && isFn(responseInterceptorsCatch)
402
+ && this.axiosInstance.interceptors.response.use(undefined, (error) => {
403
+ return responseInterceptorsCatch(this.axiosInstance, error)
404
+ });
405
+ }
406
+ get(config, options = {}) {
407
+ return this.request({ ...config, method: 'GET', }, options)
408
+ }
409
+ post(config, options = {}) {
410
+ const { envType } = options;
411
+ // 公有云专用接口,在私有云不请求
412
+ if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
413
+ return new Promise(() => { })
414
+ }
415
+ // 私有云专用接口,在公有云不请求
416
+ if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
417
+ return new Promise(() => { })
418
+ }
419
+ return this.request({ ...config, method: 'POST', }, options)
420
+ }
421
+ postFormat(config, options = {}) {
422
+ return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
423
+ }
424
+ postParams(config, options = {}) {
425
+ return this.request({ ...config, method: 'POST', params: config.data }, options)
426
+ }
427
+ // FIXME:如果初始化时配置了重试那么所有get接口都重试了
428
+ // options是接口级定义的参数
429
+ request(config, options) {
430
+ const transform = this.getTransform();
431
+ const conf = config,
432
+ { requestOptions } = this.options;
433
+ requestOptions.cache = false;
434
+ requestOptions.cacheKey = '';
435
+ requestOptions.retryRequest = {
436
+ isOpenRetry: false,
437
+ count: 5,
438
+ waitTime: 1000
439
+ };
440
+
441
+ const opt = Object.assign({}, requestOptions, options);
442
+ conf.requestOptions = opt;
443
+
444
+ const retPromise = new Promise((resolve, reject) => {
445
+ this.axiosInstance(conf)
446
+ .then(res => {
447
+ const { transformResponseHook } = transform;
448
+ if (transformResponseHook && isFn(transformResponseHook)) {
449
+ try {
450
+ const ret = transformResponseHook(res, opt, this.cachePool);
451
+ resolve(ret);
452
+ } catch (err) {
453
+ reject(err || new Error('request error!'));
454
+ }
455
+ return;
456
+ }
457
+ resolve(res);
458
+ })
459
+ .catch(err => {
460
+ reject(err);
461
+ });
462
+ });
463
+ retPromise.cache = (callback) => {
464
+ const { cache, cacheKey } = opt;
465
+ const cacheData = (cache && this.cachePool.get([cacheKey]));
466
+ callback(cacheData ? cacheData : null);
467
+ return retPromise
468
+ };
469
+ return retPromise
470
+ }
471
+ }
472
+
473
+ // import i18n from '@/utils/i18n'
474
+
475
+ // const getBaseOptions = () => ({
476
+ // confirmButtonText: i18n.t('确定'),
477
+ // center: true
478
+ // })
479
+
480
+ // const createModalOptions = (options) => ({
481
+ // ...getBaseOptions(),
482
+ // ...options,
483
+ // title: options.title || i18n.t('提示'),
484
+ // message: options.message || '消息'
485
+ // })
486
+
487
+ const createErrorModal = (response, options) => {
488
+ const { message } = options;
489
+ let temp;
490
+ if (response.name === 'AxiosError') {
491
+ temp = response.response;
492
+ temp.data.returnInfo = response.returnInfo || message || temp.error || '';
493
+ temp.data.returnCode = response.code || temp.status;
494
+ temp.data.requestId = response.config.headers.requestId;
495
+ } else {
496
+ temp = response;
497
+ temp.data.requestId = response.config.headers.requestId;
498
+ }
499
+ Vue.prototype.$ErrorDialog({
500
+ response: temp
501
+ });
502
+ };
503
+
504
+ // MessageBox(createModalOptions(options))
505
+
506
+
507
507
  const createMessage = Message;
508
508
 
509
- // 需要上报的errorType
509
+ // 需要上报的errorType
510
510
  const needReportErrorType = ['901', '999'];
511
511
 
512
- function checkStatus(error, status, msg, errorMessageMode = 'modal') {
513
- // const errorMsg = errorMsgMap[status] || {
514
- // label: "message.error.object.contactadministrators"
515
- // }
516
- // let errMessage = '',
517
- // label = '';
518
-
519
- // label = errorMsg.label;
520
- // [400, 401].includes(status) && msg && (label = msg)
521
- let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
522
-
523
- if (status === 401) {
524
- //重新登录相关逻辑
525
- window.open(window.Glod.LOGIN_URL, '_self');
526
- }
527
-
528
- {
529
- if (errorMessageMode === 'modal') {
530
- createErrorModal(error, { message: errMessage });
531
- } else if (errorMessageMode === 'message') {
532
- createMessage.error(errMessage);
533
- }
534
- }
535
- }
536
-
537
- /**
538
- * 接口请求重试
539
- * @param {object} AxiosInstance实例
540
- * @param {error} AxiosError对象
541
- */
542
- const retry = async (instance, error) => {
543
- const { config } = error,
544
- { waitTime, count = 5} = config.requestOptions || {};
545
- config.__retryCount = config.__retryCount || 0;
546
- if(count <= config.__retryCount ) {
547
- return Promise.reject(error)
548
- }
549
-
550
- config.__retryCount++;
551
-
552
- await delay(waitTime);
553
- //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
554
- delete config.headers;
555
- return instance(config)
512
+ function checkStatus(error, status, msg, errorMessageMode = 'modal') {
513
+ // const errorMsg = errorMsgMap[status] || {
514
+ // label: "message.error.object.contactadministrators"
515
+ // }
516
+ // let errMessage = '',
517
+ // label = '';
518
+
519
+ // label = errorMsg.label;
520
+ // [400, 401].includes(status) && msg && (label = msg)
521
+ let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
522
+
523
+ if (status === 401) {
524
+ //重新登录相关逻辑
525
+ window.open(window.Glod.LOGIN_URL, '_self');
526
+ }
527
+
528
+ {
529
+ if (errorMessageMode === 'modal') {
530
+ createErrorModal(error, { message: errMessage });
531
+ } else if (errorMessageMode === 'message') {
532
+ createMessage.error(errMessage);
533
+ }
534
+ }
535
+ }
536
+
537
+ /**
538
+ * 接口请求重试
539
+ * @param {object} AxiosInstance实例
540
+ * @param {error} AxiosError对象
541
+ */
542
+ const retry = async (instance, error) => {
543
+ const { config } = error,
544
+ { waitTime, count = 5} = config.requestOptions || {};
545
+ config.__retryCount = config.__retryCount || 0;
546
+ if(count <= config.__retryCount ) {
547
+ return Promise.reject(error)
548
+ }
549
+
550
+ config.__retryCount++;
551
+
552
+ await delay(waitTime);
553
+ //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
554
+ delete config.headers;
555
+ return instance(config)
556
556
  };
557
557
 
558
- //需要加密的接口
559
- const encryptList = [
560
- 'sysconfig/auth/pc/1.0/post/unifiedLogin',
561
- 'sysconfig/auth/pc/1.0/get/getUserInfo'
562
- ];
563
- // 需要上报的errorType
564
- // const needReportErrorType = ['901', '999']
565
-
566
- const transform = {
567
- // 请求拦截器
568
- async requestInterceptors(config) {
569
- // 设置日志请求头信息
570
- config.headers.requestId = getUuid();
571
- config.headers.requestIdProducer = "browser";
572
- if (!getBinding()) {
573
- return Promise.reject()
574
- }
575
- // 如果url中不包含网关地址,那么需要设置默认的baseURL
576
- if (!config.url.startsWith("https://") && !config.url.startsWith("https://") && !config.url.startsWith('/test-api')) {
577
- config.baseURL = window.Glod['ccex-apitsf'] + '/api';
578
- }
579
- // 将请求加密
580
- encryptList.forEach((item) => {
581
- if (config.url.indexOf(item) != -1) { config.data = en(JSON.stringify(config.data)); }
582
- });
583
- config.headers.accessToken = window.$CCDK.CCToken.getToken();
584
- return config
585
- },
586
- // 请求拦截器异常处理
587
- requestInterceptorsCatch(error) {
588
- return Promise.reject(error)
589
- },
590
- // 响应拦截器
591
- responseInterceptors(response) {
592
- const { data, config } = response,
593
- { errorType, result } = data;
594
- //失败
595
- if (!result) {
596
- if (needReportErrorType.includes(errorType) && isProduction()) {
597
- const { serviceName, errorLevel, errorType } = config.requestOptions;
598
- // 上报日志
599
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", {}, {
600
- serviceName,
601
- errorType,
602
- errorLevel,
603
- errorMessage: response.data.returnInfo,
604
- printStackTraceInfo: JSON.stringify(response),
605
- }, response);
606
- }
607
- return response
608
- // switch (errorType) {
609
- // case '901':
610
- // normalSystemErrorHandler(response)
611
- // break;
612
- // case '999':
613
- // unsureSystemErrorHandler(response)
614
- // break;
615
- // case '501':
616
- // default:
617
- // businessLogicError(response)
618
- // }
619
- // return Promise.reject(response)
620
- }
621
- // 成功
622
- // 生产环境上报日志
623
- const { serviceName } = config.requestOptions;
624
- isProduction() && window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", {}, { serviceName }, response);
625
- // 返回数据 外面处理
626
- return response
627
- },
628
- // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
629
- async responseInterceptorsCatch(axiosInstance, error) {
630
- const { response, config } = error || {},
631
- err = "",
632
- msg = "",
633
- mode = "modal";
634
- try {
635
- err = error.toString(),
636
- msg = response.data.error,
637
- mode = config.requestOptions.errorMessageMode;
638
- } catch (e) { }
639
-
640
- let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
641
- errMessage = '';
642
-
643
- // 是否是取消的请求
644
- if (axios.isCancel(error)) {
645
- return Promise.reject(error)
646
- }
647
- if (isProduction()) {
648
- const { serviceName, errorLevel, errorType } = config.requestOptions;
649
- // 上报日志
650
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", {}, {
651
- serviceName,
652
- errorType,
653
- errorLevel,
654
- errorMessage: response.data.returnInfo,
655
- printStackTraceInfo: JSON.stringify(response),
656
- }, response);
657
- }
658
- try {
659
- // 处理超时
660
- if (isTimeout(error)) {
661
- errMessage = 'c2487';
662
- }
663
- // 处理网络错误
664
- if (err && err.includes('Network Error')) {
665
- errMessage = 'c929';
666
- }
667
-
668
- if (errMessage) {
669
- if (errorMessageMode === 'modal') {
670
- createErrorModal({
671
- ...error,
672
- response: {
673
- data: {
674
- returnInfo: error.message,
675
- returnCode: error.code,
676
- requestId: error.config.headers.requestId
677
- },
678
- config: error.config
679
- }
680
- }, { message: errMessage });
681
- } else if (errorMessageMode === 'message') {
682
- createMessage.error(errMessage);
683
- }
684
- return Promise.reject(error)
685
- }
686
- } catch (error) {
687
- throw new Error(error);
688
- }
689
- // 根据status处理其他类型错误
690
- checkStatus(error, error && error.response.status, msg, errorMessageMode);
691
-
692
- // 接口重试操作
693
- const { isOpenRetry } = config.requestOptions.retryRequest;
694
- isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
695
-
696
- return Promise.reject(error);
697
- },
698
- // 响应数据处理,包含解密和数据返回结构设置
699
- transformResponseHook(response, options, cachePool) {
700
- const { data, config } = response;
701
- const { url } = config,
702
- { errorType, result } = data;
703
- // 失败
704
- // 501异常处理
705
- const businessLogicError = (response) => {
706
- const { errorMessageMode, silent } = response.config.requestOptions;
707
- // 接口如果设置了出现异常不提醒,则不提醒
708
- if (silent) return;
709
- // 根据errorMessageMode来判断显示错误弹窗的ui
710
- if (errorMessageMode === 'modal') {
711
- createErrorModal(response, { message: '业务出错' });
712
- } else if (errorMessageMode === 'message') {
713
- createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
714
- }
715
- };
716
- if (!result) {
717
- switch (errorType) {
718
- case '901':
719
- createErrorModal(response, { message: '系统错误' });
720
- break;
721
- case '999':
722
- break;
723
- case '501':
724
- default:
725
- businessLogicError(response);
726
- break;
727
- }
728
- return Promise.reject(response)
729
- }
730
- // 成功
731
- const { isReturnNativeResponse, cache, cacheKey } = options;
732
- // 直接返回
733
- if (isReturnNativeResponse) {
734
- cache && cacheKey && (cachePool.put(cacheKey, response));
735
- return response
736
- }
737
- if (encryptList.includes(url)) {
738
- return JSON.parse(de(data))
739
- }
740
- cache && cacheKey && (cachePool.put(cacheKey, data));
741
- return data
742
- }
743
- };
744
-
745
-
746
- function createAxios(opt) {
747
- return new CCAxios(Object.assign({}, {
748
- timeout: 60 * 1000,
749
- headers: {
750
- 'Content-Type': 'application/json;charset=UTF-8',
751
- },
752
- transform: cloneDeep(transform),
753
- requestOptions: {
754
- envType: '',
755
- serviceName: 'lightning-main',
756
- errorLevel: '2',
757
- errorType: 'front-error',
758
- errorMessageMode: 'modal',
759
- //是否静默错误提示
760
- silent: false,
761
- // 接口是否需要缓存
762
- cache: false,
763
- // 接口重试相关
764
- retryRequest: {
765
- isOpenRetry: false,
766
- count: 5,
767
- waitTime: 100,
768
- },
769
- // 是否返回原生响应头 比如:需要获取响应头时使用该属性
770
- isReturnNativeResponse: false,
771
- }
772
- }, opt || {}))
773
- }
774
-
775
- // const axios1 = createAxios({
776
-
777
- // })
778
-
779
- // const testRequest = () => {
780
- // axios1.get({
781
- // url: "/test-api/error/timeout",
782
- // }, {
783
- // isReturnNativeResponse: false,
784
- // cache: true,
785
- // cacheKey: 'timeout'
786
- // // errorMessageMode: 'message'
787
- // // silent: true
788
- // // retryRequest:{
789
- // // isOpenRetry:true
790
- // // }
791
- // })
792
- // .cache((cacheData) => {
793
- // console.log('cache callback cacheData:', cacheData)
794
- // })
795
- // .then(res => console.log('resolve res:', res))
796
- // .catch(err => console.log('catcher: ',err))
797
- // }
798
-
799
-
800
-
801
- // testRequest()
802
- // setTimeout(() => {
803
- // testRequest()
558
+ //需要加密的接口
559
+ const encryptList = [
560
+ 'sysconfig/auth/pc/1.0/post/unifiedLogin',
561
+ 'sysconfig/auth/pc/1.0/get/getUserInfo'
562
+ ];
563
+ // 需要上报的errorType
564
+ // const needReportErrorType = ['901', '999']
565
+
566
+ const transform = {
567
+ // 请求拦截器
568
+ async requestInterceptors(config) {
569
+ // 设置日志请求头信息
570
+ config.headers.requestId = getUuid();
571
+ config.headers.requestIdProducer = "browser";
572
+ if (!getBinding()) {
573
+ return Promise.reject()
574
+ }
575
+ // 如果url中不包含网关地址,那么需要设置默认的baseURL
576
+ if (!config.url.startsWith("https://") && !config.url.startsWith("https://") && !config.url.startsWith('/test-api')) {
577
+ config.baseURL = window.Glod['ccex-apitsf'] + '/api';
578
+ }
579
+ // 将请求加密
580
+ encryptList.forEach((item) => {
581
+ if (config.url.indexOf(item) != -1) { config.data = en(JSON.stringify(config.data)); }
582
+ });
583
+ config.headers.accessToken = window.$CCDK.CCToken.getToken();
584
+ return config
585
+ },
586
+ // 请求拦截器异常处理
587
+ requestInterceptorsCatch(error) {
588
+ return Promise.reject(error)
589
+ },
590
+ // 响应拦截器
591
+ responseInterceptors(response) {
592
+ const { data, config } = response,
593
+ { errorType, result } = data;
594
+ //失败
595
+ if (!result) {
596
+ if (needReportErrorType.includes(errorType) && isProduction()) {
597
+ const { serviceName, errorLevel, errorType } = config.requestOptions;
598
+ // 上报日志
599
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", {}, {
600
+ serviceName,
601
+ errorType,
602
+ errorLevel,
603
+ errorMessage: response.data.returnInfo,
604
+ printStackTraceInfo: JSON.stringify(response),
605
+ }, response);
606
+ }
607
+ return response
608
+ // switch (errorType) {
609
+ // case '901':
610
+ // normalSystemErrorHandler(response)
611
+ // break;
612
+ // case '999':
613
+ // unsureSystemErrorHandler(response)
614
+ // break;
615
+ // case '501':
616
+ // default:
617
+ // businessLogicError(response)
618
+ // }
619
+ // return Promise.reject(response)
620
+ }
621
+ // 成功
622
+ // 生产环境上报日志
623
+ const { serviceName } = config.requestOptions;
624
+ isProduction() && window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", {}, { serviceName }, response);
625
+ // 返回数据 外面处理
626
+ return response
627
+ },
628
+ // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
629
+ async responseInterceptorsCatch(axiosInstance, error) {
630
+ const { response, config } = error || {},
631
+ err = "",
632
+ msg = "",
633
+ mode = "modal";
634
+ try {
635
+ err = error.toString(),
636
+ msg = response.data.error,
637
+ mode = config.requestOptions.errorMessageMode;
638
+ } catch (e) { }
639
+
640
+ let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
641
+ errMessage = '';
642
+
643
+ // 是否是取消的请求
644
+ if (axios.isCancel(error)) {
645
+ return Promise.reject(error)
646
+ }
647
+ if (isProduction()) {
648
+ const { serviceName, errorLevel, errorType } = config.requestOptions;
649
+ // 上报日志
650
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", {}, {
651
+ serviceName,
652
+ errorType,
653
+ errorLevel,
654
+ errorMessage: response.data.returnInfo,
655
+ printStackTraceInfo: JSON.stringify(response),
656
+ }, response);
657
+ }
658
+ try {
659
+ // 处理超时
660
+ if (isTimeout(error)) {
661
+ errMessage = 'c2487';
662
+ }
663
+ // 处理网络错误
664
+ if (err && err.includes('Network Error')) {
665
+ errMessage = 'c929';
666
+ }
667
+
668
+ if (errMessage) {
669
+ if (errorMessageMode === 'modal') {
670
+ createErrorModal({
671
+ ...error,
672
+ response: {
673
+ data: {
674
+ returnInfo: error.message,
675
+ returnCode: error.code,
676
+ requestId: error.config.headers.requestId
677
+ },
678
+ config: error.config
679
+ }
680
+ }, { message: errMessage });
681
+ } else if (errorMessageMode === 'message') {
682
+ createMessage.error(errMessage);
683
+ }
684
+ return Promise.reject(error)
685
+ }
686
+ } catch (error) {
687
+ throw new Error(error);
688
+ }
689
+ // 根据status处理其他类型错误
690
+ checkStatus(error, error && error.response.status, msg, errorMessageMode);
691
+
692
+ // 接口重试操作
693
+ const { isOpenRetry } = config.requestOptions.retryRequest;
694
+ isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
695
+
696
+ return Promise.reject(error);
697
+ },
698
+ // 响应数据处理,包含解密和数据返回结构设置
699
+ transformResponseHook(response, options, cachePool) {
700
+ const { data, config } = response;
701
+ const { url } = config,
702
+ { errorType, result } = data;
703
+ // 失败
704
+ // 501异常处理
705
+ const businessLogicError = (response) => {
706
+ const { errorMessageMode, silent } = response.config.requestOptions;
707
+ // 接口如果设置了出现异常不提醒,则不提醒
708
+ if (silent) return;
709
+ // 根据errorMessageMode来判断显示错误弹窗的ui
710
+ if (errorMessageMode === 'modal') {
711
+ createErrorModal(response, { message: '业务出错' });
712
+ } else if (errorMessageMode === 'message') {
713
+ createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
714
+ }
715
+ };
716
+ if (!result) {
717
+ switch (errorType) {
718
+ case '901':
719
+ createErrorModal(response, { message: '系统错误' });
720
+ break;
721
+ case '999':
722
+ break;
723
+ case '501':
724
+ default:
725
+ businessLogicError(response);
726
+ break;
727
+ }
728
+ return Promise.reject(response)
729
+ }
730
+ // 成功
731
+ const { isReturnNativeResponse, cache, cacheKey } = options;
732
+ // 直接返回
733
+ if (isReturnNativeResponse) {
734
+ cache && cacheKey && (cachePool.put(cacheKey, response));
735
+ return response
736
+ }
737
+ if (encryptList.includes(url)) {
738
+ return JSON.parse(de(data))
739
+ }
740
+ cache && cacheKey && (cachePool.put(cacheKey, data));
741
+ return data
742
+ }
743
+ };
744
+
745
+
746
+ function createAxios(opt) {
747
+ return new CCAxios(Object.assign({}, {
748
+ timeout: 60 * 1000,
749
+ headers: {
750
+ 'Content-Type': 'application/json;charset=UTF-8',
751
+ },
752
+ transform: cloneDeep(transform),
753
+ requestOptions: {
754
+ envType: '',
755
+ serviceName: 'lightning-main',
756
+ errorLevel: '2',
757
+ errorType: 'front-error',
758
+ errorMessageMode: 'modal',
759
+ //是否静默错误提示
760
+ silent: false,
761
+ // 接口是否需要缓存
762
+ cache: false,
763
+ // 接口重试相关
764
+ retryRequest: {
765
+ isOpenRetry: false,
766
+ count: 5,
767
+ waitTime: 100,
768
+ },
769
+ // 是否返回原生响应头 比如:需要获取响应头时使用该属性
770
+ isReturnNativeResponse: false,
771
+ }
772
+ }, opt || {}))
773
+ }
774
+
775
+ // const axios1 = createAxios({
776
+
777
+ // })
778
+
779
+ // const testRequest = () => {
780
+ // axios1.get({
781
+ // url: "/test-api/error/timeout",
782
+ // }, {
783
+ // isReturnNativeResponse: false,
784
+ // cache: true,
785
+ // cacheKey: 'timeout'
786
+ // // errorMessageMode: 'message'
787
+ // // silent: true
788
+ // // retryRequest:{
789
+ // // isOpenRetry:true
790
+ // // }
791
+ // })
792
+ // .cache((cacheData) => {
793
+ // console.log('cache callback cacheData:', cacheData)
794
+ // })
795
+ // .then(res => console.log('resolve res:', res))
796
+ // .catch(err => console.log('catcher: ',err))
797
+ // }
798
+
799
+
800
+
801
+ // testRequest()
802
+ // setTimeout(() => {
803
+ // testRequest()
804
804
  // }, 5000)
805
805
 
806
806
  var CCHttp = /*#__PURE__*/Object.freeze({
@@ -808,64 +808,64 @@ var CCHttp = /*#__PURE__*/Object.freeze({
808
808
  createAxios: createAxios
809
809
  });
810
810
 
811
- /**
812
- * 下载js,并挂载到document上
813
- * @param {string} src js下载路径
814
- * @param {object} scriptOption script配置参数
815
- * @returns
816
- */
817
- function loadJs(src, scriptOption) {
818
- return new Promise((resolve, reject) => {
819
- let scriptTemp = document.createElement('script');
820
- if (scriptOption) {
821
- Object.assign(scriptTemp, scriptOption);
822
- }
823
- scriptTemp.type = "text/javascript";
824
- scriptTemp.src = src;
825
- document.body.appendChild(scriptTemp);
826
-
827
- scriptTemp.onload = () => {
828
- resolve();
829
- };
830
- scriptTemp.onerror = () => {
831
- reject();
832
- };
833
- })
834
- }
835
- /**
836
- * 创建加载js组件
837
- */
838
- function createLoadJsComponent() {
839
- Vue.component('cc-load-script', {
840
- render: function (createElement) {
841
- var self = this;
842
- return createElement('script', {
843
- attrs: {
844
- type: 'text/javascript',
845
- src: this.src
846
- },
847
- on: {
848
- load: function (event) {
849
- self.$emit('load', event);
850
- },
851
- error: function (event) {
852
- self.$emit('error', event);
853
- },
854
- readystatechange: function (event) {
855
- if (this.readyState == 'complete') {
856
- self.$emit('load', event);
857
- }
858
- }
859
- }
860
- });
861
- },
862
- props: {
863
- src: {
864
- type: String,
865
- required: true
866
- }
867
- }
868
- });
811
+ /**
812
+ * 下载js,并挂载到document上
813
+ * @param {string} src js下载路径
814
+ * @param {object} scriptOption script配置参数
815
+ * @returns
816
+ */
817
+ function loadJs(src, scriptOption) {
818
+ return new Promise((resolve, reject) => {
819
+ let scriptTemp = document.createElement('script');
820
+ if (scriptOption) {
821
+ Object.assign(scriptTemp, scriptOption);
822
+ }
823
+ scriptTemp.type = "text/javascript";
824
+ scriptTemp.src = src;
825
+ document.body.appendChild(scriptTemp);
826
+
827
+ scriptTemp.onload = () => {
828
+ resolve();
829
+ };
830
+ scriptTemp.onerror = () => {
831
+ reject();
832
+ };
833
+ })
834
+ }
835
+ /**
836
+ * 创建加载js组件
837
+ */
838
+ function createLoadJsComponent() {
839
+ Vue.component('cc-load-script', {
840
+ render: function (createElement) {
841
+ var self = this;
842
+ return createElement('script', {
843
+ attrs: {
844
+ type: 'text/javascript',
845
+ src: this.src
846
+ },
847
+ on: {
848
+ load: function (event) {
849
+ self.$emit('load', event);
850
+ },
851
+ error: function (event) {
852
+ self.$emit('error', event);
853
+ },
854
+ readystatechange: function (event) {
855
+ if (this.readyState == 'complete') {
856
+ self.$emit('load', event);
857
+ }
858
+ }
859
+ }
860
+ });
861
+ },
862
+ props: {
863
+ src: {
864
+ type: String,
865
+ required: true
866
+ }
867
+ }
868
+ });
869
869
  }
870
870
 
871
871
  var CCLoad = /*#__PURE__*/Object.freeze({
@@ -874,145 +874,145 @@ var CCLoad = /*#__PURE__*/Object.freeze({
874
874
  createLoadJsComponent: createLoadJsComponent
875
875
  });
876
876
 
877
- /**
878
- * 获取日志基础信息
879
- * @returns 日志基础信息
880
- */
881
- function getBaseInfo() {
882
- let userInfo = window.$CCDK.CCUser.getUserInfo();
883
- let old = {
884
- // 用户名,使用登录账号
885
- "userName": userInfo.loginName,
886
- // 用户id
887
- "userId": userInfo.userId,
888
- // 组织id
889
- "orgId": userInfo.orgId,
890
- // 组织名称
891
- "orgName": userInfo.orgName,
892
- // 服务名称
893
- "serviceName": "未知应用",
894
- // 记录类型:paltfrom平台日志,dev开发者日志
895
- "recordType": "paltfrom",
896
- // 日志类型
897
- "logType": "front",
898
- // 发生时间
899
- "operateTime": (new Date()).valueOf(),
900
- // 日志标识码,没有这个标识码,不能上传
901
- "cccode": "hidden",
902
- // 日志显示级别默认2
903
- "displayLevel": "2",
904
- };
905
- return old
906
- }
907
- /**
908
- * 获取网络异常信息
909
- * @param {object} response 网络请求响应体
910
- * @returns 请求体信息
911
- */
912
- function getHttpErrorInfo(response) {
913
- if (response) {
914
- if (window.performance) {
915
- // 通过性能接口精确测量接口用时
916
- let per = performance.getEntriesByName(response.request.responseURL, "resource");
917
- if (per.length > 0) {
918
- response.spendTime = (per[0].fetchStart > 0) ? (per[0].responseEnd - per[0].fetchStart) : "0";
919
- }
920
- }
921
- return {
922
- // 接口用时
923
- "spendTime": response.spendTime || "0",
924
- // 请求地址url
925
- "requestUrl": response.request.responseURL,
926
- // 请求id
927
- "requestId": response.config.headers.requestId,
928
- // 请求id类型
929
- "requestIdProducer": response.config.headers.requestIdProducer,
930
- // 请求体
931
- "requestParameter": response.config.data,
932
- // 错误描述
933
- "errorMessage": response.data.returnInfo,
934
- // 请求结果状态
935
- "requestResult": response.data.result ? "成功" : "失败",
936
- // 日志级别
937
- "errorLevel": "2",
938
- // 堆栈信息
939
- "printStackTraceInfo": response.data.returnInfo,
940
- }
941
- } else {
942
- return {}
943
- }
944
- }
945
-
946
-
947
- /**
948
- * 获取网络信息
949
- * @param {object} response 网络请求响应体
950
- * @returns 请求体信息
951
- */
952
- function getHttpInfo(response) {
953
- if (response) {
954
- if (window.performance) {
955
- // 通过性能接口精确测量接口用时
956
- let per = performance.getEntriesByName(response.request.responseURL, "resource");
957
- if (per.length > 0) {
958
- response.spendTime = (per[0].fetchStart > 0) ? (per[0].responseEnd - per[0].fetchStart) : "0";
959
- }
960
- }
961
- return {
962
- // 接口用时
963
- "spendTime": response.spendTime || "0",
964
- // 请求地址url
965
- "requestUrl": response.request.responseURL,
966
- // 请求id
967
- "requestId": response.config.headers.requestId,
968
- // 请求id类型
969
- "requestIdProducer": response.config.headers.requestIdProducer,
970
- // 请求体
971
- "requestParameter": response.config.data,
972
- // 错误描述
973
- "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\r" + response.config.data,
974
- // 请求结果状态
975
- "requestResult": response.data.result ? "成功" : "失败",
976
- // 日志类型:info,debug
977
- "infoType": "info",
978
- }
979
- } else {
980
- return {}
981
- }
982
- }
983
-
984
- /**
985
- * 上报日志
986
- * @param {string} url 请求地址
987
- * @param {object} response 响应信息
988
- * @param {string} type 日志类型,info,debug,error
989
- * @param {object} logInfo 日志信息
990
- */
991
- function reportLog(url, response, type = "info", logInfo = {}) {
992
- axios.post(url,
993
- {
994
- ...getBaseInfo(),
995
- ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
996
- ...logInfo
997
- });
998
- }
999
- /**
1000
- * 上报info日志
1001
- * @param {object} logInfo 日志信息
1002
- * @param {object} response axios响应信息
1003
- */
1004
- function reportInfoLog(logInfo, response) {
1005
- logInfo.recordType = "dev";
1006
- reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1007
- }
1008
- /**
1009
- * 上报错误信息
1010
- * @param {object} logInfo 日志信息
1011
- * @param {object} response axios响应信息
1012
- */
1013
- function reportErrorLog(logInfo, response) {
1014
- logInfo.recordType = "dev";
1015
- reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
877
+ /**
878
+ * 获取日志基础信息
879
+ * @returns 日志基础信息
880
+ */
881
+ function getBaseInfo() {
882
+ let userInfo = window.$CCDK.CCUser.getUserInfo();
883
+ let old = {
884
+ // 用户名,使用登录账号
885
+ "userName": userInfo.loginName,
886
+ // 用户id
887
+ "userId": userInfo.userId,
888
+ // 组织id
889
+ "orgId": userInfo.orgId,
890
+ // 组织名称
891
+ "orgName": userInfo.orgName,
892
+ // 服务名称
893
+ "serviceName": "未知应用",
894
+ // 记录类型:paltfrom平台日志,dev开发者日志
895
+ "recordType": "paltfrom",
896
+ // 日志类型
897
+ "logType": "front",
898
+ // 发生时间
899
+ "operateTime": (new Date()).valueOf(),
900
+ // 日志标识码,没有这个标识码,不能上传
901
+ "cccode": "hidden",
902
+ // 日志显示级别默认2
903
+ "displayLevel": "2",
904
+ };
905
+ return old
906
+ }
907
+ /**
908
+ * 获取网络异常信息
909
+ * @param {object} response 网络请求响应体
910
+ * @returns 请求体信息
911
+ */
912
+ function getHttpErrorInfo(response) {
913
+ if (response) {
914
+ if (window.performance) {
915
+ // 通过性能接口精确测量接口用时
916
+ let per = performance.getEntriesByName(response.request.responseURL, "resource");
917
+ if (per.length > 0) {
918
+ response.spendTime = (per[0].fetchStart > 0) ? (per[0].responseEnd - per[0].fetchStart) : "0";
919
+ }
920
+ }
921
+ return {
922
+ // 接口用时
923
+ "spendTime": response.spendTime || "0",
924
+ // 请求地址url
925
+ "requestUrl": response.request.responseURL,
926
+ // 请求id
927
+ "requestId": response.config.headers.requestId,
928
+ // 请求id类型
929
+ "requestIdProducer": response.config.headers.requestIdProducer,
930
+ // 请求体
931
+ "requestParameter": response.config.data,
932
+ // 错误描述
933
+ "errorMessage": response.data.returnInfo,
934
+ // 请求结果状态
935
+ "requestResult": response.data.result ? "成功" : "失败",
936
+ // 日志级别
937
+ "errorLevel": "2",
938
+ // 堆栈信息
939
+ "printStackTraceInfo": response.data.returnInfo,
940
+ }
941
+ } else {
942
+ return {}
943
+ }
944
+ }
945
+
946
+
947
+ /**
948
+ * 获取网络信息
949
+ * @param {object} response 网络请求响应体
950
+ * @returns 请求体信息
951
+ */
952
+ function getHttpInfo(response) {
953
+ if (response) {
954
+ if (window.performance) {
955
+ // 通过性能接口精确测量接口用时
956
+ let per = performance.getEntriesByName(response.request.responseURL, "resource");
957
+ if (per.length > 0) {
958
+ response.spendTime = (per[0].fetchStart > 0) ? (per[0].responseEnd - per[0].fetchStart) : "0";
959
+ }
960
+ }
961
+ return {
962
+ // 接口用时
963
+ "spendTime": response.spendTime || "0",
964
+ // 请求地址url
965
+ "requestUrl": response.request.responseURL,
966
+ // 请求id
967
+ "requestId": response.config.headers.requestId,
968
+ // 请求id类型
969
+ "requestIdProducer": response.config.headers.requestIdProducer,
970
+ // 请求体
971
+ "requestParameter": response.config.data,
972
+ // 错误描述
973
+ "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + response.config.data || '',
974
+ // 请求结果状态
975
+ "requestResult": response.data.result ? "成功" : "失败",
976
+ // 日志类型:info,debug
977
+ "infoType": "info",
978
+ }
979
+ } else {
980
+ return {}
981
+ }
982
+ }
983
+
984
+ /**
985
+ * 上报日志
986
+ * @param {string} url 请求地址
987
+ * @param {object} response 响应信息
988
+ * @param {string} type 日志类型,info,debug,error
989
+ * @param {object} logInfo 日志信息
990
+ */
991
+ function reportLog(url, response, type = "info", logInfo = {}) {
992
+ axios.post(url,
993
+ {
994
+ ...getBaseInfo(),
995
+ ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
996
+ ...logInfo
997
+ });
998
+ }
999
+ /**
1000
+ * 上报info日志
1001
+ * @param {object} logInfo 日志信息
1002
+ * @param {object} response axios响应信息
1003
+ */
1004
+ function reportInfoLog(logInfo, response) {
1005
+ logInfo.recordType = "dev";
1006
+ reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1007
+ }
1008
+ /**
1009
+ * 上报错误信息
1010
+ * @param {object} logInfo 日志信息
1011
+ * @param {object} response axios响应信息
1012
+ */
1013
+ function reportErrorLog(logInfo, response) {
1014
+ logInfo.recordType = "dev";
1015
+ reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
1016
1016
  }
1017
1017
 
1018
1018
  var CCLog = /*#__PURE__*/Object.freeze({
@@ -1022,75 +1022,75 @@ var CCLog = /*#__PURE__*/Object.freeze({
1022
1022
  reportErrorLog: reportErrorLog
1023
1023
  });
1024
1024
 
1025
- /**
1026
- * 添加一个一级菜单
1027
- * @param {object} options 菜单配置
1028
- */
1029
- function addMenu1(options) {
1030
- window.$CCDK.CCBus.$emit('addMenu1', options);
1031
- }
1032
- /**
1033
- * 添加一个二级菜单
1034
- * @param {object} options 菜单配置
1035
- */
1036
- function addMenu2(options) {
1037
- window.$CCDK.CCBus.$emit('addMenu2', options);
1038
- }
1039
- /**
1040
- * 删除一个一级菜单
1041
- * @param {object} options 菜单配置
1042
- */
1043
- function deleteMenu1(options) {
1044
- window.$CCDK.CCBus.$emit('deleteMenu1', options);
1045
- }
1046
- /**
1047
- * 删除一个二级菜单
1048
- * @param {object} options 菜单配置
1049
- */
1050
- function deleteMenu2(options) {
1051
- window.$CCDK.CCBus.$emit('deleteMenu2', options);
1052
- }
1053
- /**
1054
- * 刷新一个一级菜单
1055
- * @param {object} options 菜单配置
1056
- */
1057
- function refreshMenu1(options) {
1058
- window.$CCDK.CCBus.$emit('refreshMenu1', options);
1059
- }
1060
- /**
1061
- * 刷新一个二级菜单
1062
- * @param {object} options 菜单配置
1063
- */
1064
- function refreshMenu2(options) {
1065
- window.$CCDK.CCBus.$emit('refreshMenu2', options);
1066
- }
1067
- /**
1068
- * 替换一个一级菜单
1069
- * @param {object} options 菜单配置
1070
- */
1071
- function replaceMenu1(options) {
1072
- window.$CCDK.CCBus.$emit('replaceMenu1', options);
1073
- }
1074
- /**
1075
- * 替换一个二级菜单
1076
- * @param {object} options 菜单配置
1077
- */
1078
- function replaceMenu2(options) {
1079
- window.$CCDK.CCBus.$emit('replaceMenu2', options);
1080
- }
1081
- /**
1082
- * 定位到已经打开的一级菜单
1083
- * @param {object} options 菜单配置
1084
- */
1085
- function reOpenMenu1(options) {
1086
- window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1087
- }
1088
- /**
1089
- * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1090
- * @param {object} options 菜单配置
1091
- */
1092
- function reOpenMenu2(options) {
1093
- window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1025
+ /**
1026
+ * 添加一个一级菜单
1027
+ * @param {object} options 菜单配置
1028
+ */
1029
+ function addMenu1(options) {
1030
+ window.$CCDK.CCBus.$emit('addMenu1', options);
1031
+ }
1032
+ /**
1033
+ * 添加一个二级菜单
1034
+ * @param {object} options 菜单配置
1035
+ */
1036
+ function addMenu2(options) {
1037
+ window.$CCDK.CCBus.$emit('addMenu2', options);
1038
+ }
1039
+ /**
1040
+ * 删除一个一级菜单
1041
+ * @param {object} options 菜单配置
1042
+ */
1043
+ function deleteMenu1(options) {
1044
+ window.$CCDK.CCBus.$emit('deleteMenu1', options);
1045
+ }
1046
+ /**
1047
+ * 删除一个二级菜单
1048
+ * @param {object} options 菜单配置
1049
+ */
1050
+ function deleteMenu2(options) {
1051
+ window.$CCDK.CCBus.$emit('deleteMenu2', options);
1052
+ }
1053
+ /**
1054
+ * 刷新一个一级菜单
1055
+ * @param {object} options 菜单配置
1056
+ */
1057
+ function refreshMenu1(options) {
1058
+ window.$CCDK.CCBus.$emit('refreshMenu1', options);
1059
+ }
1060
+ /**
1061
+ * 刷新一个二级菜单
1062
+ * @param {object} options 菜单配置
1063
+ */
1064
+ function refreshMenu2(options) {
1065
+ window.$CCDK.CCBus.$emit('refreshMenu2', options);
1066
+ }
1067
+ /**
1068
+ * 替换一个一级菜单
1069
+ * @param {object} options 菜单配置
1070
+ */
1071
+ function replaceMenu1(options) {
1072
+ window.$CCDK.CCBus.$emit('replaceMenu1', options);
1073
+ }
1074
+ /**
1075
+ * 替换一个二级菜单
1076
+ * @param {object} options 菜单配置
1077
+ */
1078
+ function replaceMenu2(options) {
1079
+ window.$CCDK.CCBus.$emit('replaceMenu2', options);
1080
+ }
1081
+ /**
1082
+ * 定位到已经打开的一级菜单
1083
+ * @param {object} options 菜单配置
1084
+ */
1085
+ function reOpenMenu1(options) {
1086
+ window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1087
+ }
1088
+ /**
1089
+ * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1090
+ * @param {object} options 菜单配置
1091
+ */
1092
+ function reOpenMenu2(options) {
1093
+ window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1094
1094
  }
1095
1095
 
1096
1096
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -1107,43 +1107,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
1107
1107
  reOpenMenu2: reOpenMenu2
1108
1108
  });
1109
1109
 
1110
- /**
1111
- * 消息提示框
1112
- * @param {string} text 提示文字,支持vhtml渲染
1113
- * @param {string} type 消息类别
1114
- * @param {number} duration 持续时间
1115
- * @param {boolean} showClose 是否显示消息关闭按钮
1116
- * @param {boolean} center 文字是否剧中
1117
- */
1118
- function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1119
- Message({
1120
- message: text,
1121
- type,
1122
- duration,
1123
- showClose,
1124
- center
1125
- });
1126
- }
1127
- /**
1128
- * 提示确认框
1129
- * @param {string} text 提示信息
1130
- * @param {string} title 标题
1131
- * @param {object} options 配置信息
1132
- */
1133
- function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1134
- MessageBox.confirm(text, title, options).then(() => {
1135
- confirm();
1136
- }).catch(() => {
1137
- reject();
1138
- });
1139
- }
1140
-
1141
- /**
1142
- * 提示消息框
1143
- * @param {object} options 配置信息
1144
- */
1145
- function showNotification(options = {}) {
1146
- Notification(options);
1110
+ /**
1111
+ * 消息提示框
1112
+ * @param {string} text 提示文字,支持vhtml渲染
1113
+ * @param {string} type 消息类别
1114
+ * @param {number} duration 持续时间
1115
+ * @param {boolean} showClose 是否显示消息关闭按钮
1116
+ * @param {boolean} center 文字是否剧中
1117
+ */
1118
+ function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1119
+ Message({
1120
+ message: text,
1121
+ type,
1122
+ duration,
1123
+ showClose,
1124
+ center
1125
+ });
1126
+ }
1127
+ /**
1128
+ * 提示确认框
1129
+ * @param {string} text 提示信息
1130
+ * @param {string} title 标题
1131
+ * @param {object} options 配置信息
1132
+ */
1133
+ function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1134
+ MessageBox.confirm(text, title, options).then(() => {
1135
+ confirm();
1136
+ }).catch(() => {
1137
+ reject();
1138
+ });
1139
+ }
1140
+
1141
+ /**
1142
+ * 提示消息框
1143
+ * @param {object} options 配置信息
1144
+ */
1145
+ function showNotification(options = {}) {
1146
+ Notification(options);
1147
1147
  }
1148
1148
 
1149
1149
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -1153,99 +1153,99 @@ var CCMessage = /*#__PURE__*/Object.freeze({
1153
1153
  showNotification: showNotification
1154
1154
  });
1155
1155
 
1156
- // 对象详情存储标识
1157
- const OBJECT_DETAIL = 'cc_object_detail';
1158
- // 对象存储标识
1159
- const OBJECT = 'cc_object';
1160
- // 列表视图存储标识
1161
- const OBJECT_LIST = 'cc_object_list';
1162
-
1163
- /**
1164
- * 获得当前标准对象信息
1165
- */
1166
- function getObject( ) {
1167
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1168
- if (detail) {
1169
- return JSON.parse(detail)
1170
- }
1171
- return ''
1172
- }
1173
-
1174
- /**
1175
- * 设置当前标准对象信息
1176
- * @param {object} detail 对象数据
1177
- */
1178
- function setObject(detail = '') {
1179
- if (detail) {
1180
- localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1181
- }
1182
- }
1183
-
1184
- /**
1185
- * 获得当前标准对象的详细信息
1186
- * @param {String} apiname: 查找字段的apiname
1187
- */
1188
- function getObjectDetail(apiname) {
1189
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
1190
- if (detail) {
1191
- if(apiname){
1192
- let detailObj = JSON.parse(detail).detail;
1193
- let targetField = undefined;
1194
- if(Array.isArray(detailObj)){
1195
- targetField = detailObj.find(item=>item.apiname===apiname);
1196
- }
1197
- return targetField
1198
- }else {
1199
- return JSON.parse(detail)
1200
- }
1201
- }
1202
- return ''
1203
- }
1204
-
1205
- /**
1206
- * 设置当前标准对象的详细信息,默认两个小时有效期
1207
- * @param {object} detail 对象详细数据
1208
- */
1209
- function setObjectDetail(detail = '') {
1210
- if (detail) {
1211
- // 减少detail.detail层级
1212
- if(Array.isArray(detail.detail)){
1213
- let data = [];
1214
- detail.detail.forEach(item=>{
1215
- if(item && Array.isArray(item.data)){
1216
- item.data.forEach(itemData=>{
1217
- if(itemData.left && !Array.isArray(itemData.left)){
1218
- data.push(itemData.left);
1219
- }
1220
- if(itemData.right && !Array.isArray(itemData.right)){
1221
- data.push(itemData.right);
1222
- }
1223
- });
1224
- }
1225
- });
1226
- if(data.length > 0){detail.detail = data;}
1227
- }
1228
- localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
1229
- }
1230
- }
1231
- /**
1232
- * 设置当前标准对象列表选中的信息
1233
- * @param {object} detail 选中数据
1234
- */
1235
- function setObjectList(detail = {}) {
1236
- if (detail.ids) {
1237
- localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1238
- }
1239
- }
1240
- /**
1241
- * 获得当前标准对象列表选中的信息
1242
- */
1243
- function getObjectList() {
1244
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1245
- if (detail) {
1246
- return JSON.parse(detail)
1247
- }
1248
- return {ids:[]}
1156
+ // 对象详情存储标识
1157
+ const OBJECT_DETAIL = 'cc_object_detail';
1158
+ // 对象存储标识
1159
+ const OBJECT = 'cc_object';
1160
+ // 列表视图存储标识
1161
+ const OBJECT_LIST = 'cc_object_list';
1162
+
1163
+ /**
1164
+ * 获得当前标准对象信息
1165
+ */
1166
+ function getObject( ) {
1167
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1168
+ if (detail) {
1169
+ return JSON.parse(detail)
1170
+ }
1171
+ return ''
1172
+ }
1173
+
1174
+ /**
1175
+ * 设置当前标准对象信息
1176
+ * @param {object} detail 对象数据
1177
+ */
1178
+ function setObject(detail = '') {
1179
+ if (detail) {
1180
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1181
+ }
1182
+ }
1183
+
1184
+ /**
1185
+ * 获得当前标准对象的详细信息
1186
+ * @param {String} apiname: 查找字段的apiname
1187
+ */
1188
+ function getObjectDetail(apiname) {
1189
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
1190
+ if (detail) {
1191
+ if(apiname){
1192
+ let detailObj = JSON.parse(detail).detail;
1193
+ let targetField = undefined;
1194
+ if(Array.isArray(detailObj)){
1195
+ targetField = detailObj.find(item=>item.apiname===apiname);
1196
+ }
1197
+ return targetField
1198
+ }else {
1199
+ return JSON.parse(detail)
1200
+ }
1201
+ }
1202
+ return ''
1203
+ }
1204
+
1205
+ /**
1206
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1207
+ * @param {object} detail 对象详细数据
1208
+ */
1209
+ function setObjectDetail(detail = '') {
1210
+ if (detail) {
1211
+ // 减少detail.detail层级
1212
+ if(Array.isArray(detail.detail)){
1213
+ let data = [];
1214
+ detail.detail.forEach(item=>{
1215
+ if(item && Array.isArray(item.data)){
1216
+ item.data.forEach(itemData=>{
1217
+ if(itemData.left && !Array.isArray(itemData.left)){
1218
+ data.push(itemData.left);
1219
+ }
1220
+ if(itemData.right && !Array.isArray(itemData.right)){
1221
+ data.push(itemData.right);
1222
+ }
1223
+ });
1224
+ }
1225
+ });
1226
+ if(data.length > 0){detail.detail = data;}
1227
+ }
1228
+ localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
1229
+ }
1230
+ }
1231
+ /**
1232
+ * 设置当前标准对象列表选中的信息
1233
+ * @param {object} detail 选中数据
1234
+ */
1235
+ function setObjectList(detail = {}) {
1236
+ if (detail.ids) {
1237
+ localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1238
+ }
1239
+ }
1240
+ /**
1241
+ * 获得当前标准对象列表选中的信息
1242
+ */
1243
+ function getObjectList() {
1244
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1245
+ if (detail) {
1246
+ return JSON.parse(detail)
1247
+ }
1248
+ return {ids:[]}
1249
1249
  }
1250
1250
 
1251
1251
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -1258,177 +1258,177 @@ var CCObject = /*#__PURE__*/Object.freeze({
1258
1258
  setObjectDetail: setObjectDetail
1259
1259
  });
1260
1260
 
1261
- /**
1262
- * 用于保存打开的页面集合
1263
- */
1264
- let pageList = new Map();
1265
- /**
1266
- * 打开对象视图页面
1267
- * @param {object} obj 对象信息
1268
- * @param {object} options 配置信息
1269
- */
1270
- function openListPage(obj, options = {}) {
1271
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1272
- window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1273
- return pageId;
1274
- }
1275
-
1276
- /**
1277
- * 打开数据详情页
1278
- * @param {object} obj 对象体
1279
- * @param {string} id 数据id
1280
- * @param {object} options 配置信息
1281
- */
1282
- function openDetailPage(obj, id, options = {}) {
1283
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1284
- window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1285
- return pageId;
1286
- }
1287
-
1288
- /**
1289
- * 打开创建页面
1290
- * @param {object} obj 对象体
1291
- * @param {object} options 配置信息
1292
- */
1293
- function openCreatePage(obj, options = {}) {
1294
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1295
- window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1296
- return pageId;
1297
- }
1298
-
1299
- /**
1300
- * 打开修改页面
1301
- * @param {object} obj 对象体
1302
- * @param {string} id 数据id
1303
- * @param {object} options 配置信息
1304
- */
1305
- function openEditPage(obj, id, options = {}) {
1306
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1307
- window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1308
- return pageId;
1309
- }
1310
- /**
1311
- * 打开自定义页面
1312
- * @param {object} obj 自定义页面参数
1313
- * @param {object} options 配置信息
1314
- */
1315
- function openCustomPage(obj, options = {}) {
1316
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1317
- window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1318
- return pageId;
1319
- }
1320
-
1321
- /**
1322
- * 通过页面id,重新打开某个页面
1323
- * @param {string} pageId 页面id
1324
- * @param {object} options 配置信息
1325
- */
1326
- function reOpenPage(pageId, options) {
1327
- let page;
1328
- if (pageId) {
1329
- page = pageList.get(pageId);
1330
- }
1331
- if (page) {
1332
- page.reOpenPage();
1333
- if (options.refresh) {
1334
- page.refresh();
1335
- }
1336
- }
1337
- }
1338
-
1339
- /**
1340
- * 将打开的页面添加到集合中
1341
- * @param {string} id 唯一ID
1342
- * @param {object} page 页面对象
1343
- */
1344
- function addPage(id, page) {
1345
- if (id && page) {
1346
- pageList.set(id, page);
1347
- }
1348
- }
1349
-
1350
- /**
1351
- * 删除某个页面
1352
- * @param {string} pageId 唯一ID
1353
- */
1354
- function deletePage(pageId) {
1355
- if (pageId) {
1356
- pageList.delete(pageId);
1357
- }
1358
- }
1359
- /**
1360
- * 更改页面数据
1361
- * @param {string} id 唯一ID
1362
- * @param {object} page 页面对象
1363
- */
1364
- function updatePage(id, page) {
1365
- if (id && page) {
1366
- pageList.set(id, page);
1367
- }
1368
- }
1369
-
1370
- /**
1371
- * 通过页面id查询页面
1372
- * @param {string} pageId 唯一ID
1373
- */
1374
- function searchPage(pageId) {
1375
- return pageList.get(pageId)
1376
- }
1377
- /**
1378
- * 关闭页面,如果pageId为null,那么关闭当前页面
1379
- * 如果pageId为all,关闭所有一级菜单
1380
- * @param {string} pageId 页面id
1381
- */
1382
- function close$1(pageId = '') {
1383
- let page;
1384
- if(pageId === 'all'){
1385
- page = [...pageList.values()];
1386
- page.forEach(item => {
1387
- if(item){
1388
- item.close();
1389
- }
1390
- });
1391
- }else if (pageId) {
1392
- page = pageList.get(pageId);
1393
- } else {
1394
- // 不传pageId 默认关闭当前选中的
1395
- // 当前选中菜单的树形结构
1396
- let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
1397
- if (currentMenuTree) {
1398
- // 说明当前选中的是二级菜单
1399
- if (currentMenuTree.level2Id) {
1400
- page = pageList.get(currentMenuTree.level2Id);
1401
- } else {
1402
- // 说明当前选中的是一级菜单
1403
- page = pageList.get(currentMenuTree.id);
1404
- }
1405
- }
1406
- // if (pageList.size > 0) {
1407
- // page = [...pageList.values()][pageList.size - 1]
1408
- // }
1409
- }
1410
- if (page) {
1411
- page.close();
1412
- }
1413
- }
1414
- /**
1415
- * 刷新当前页面
1416
- */
1417
- function refresh() {
1418
- window.$CCDK.CCBus.$emit('refresh');
1419
- }
1420
- /**
1421
- * 获取当前一二级选中菜单的树形结构
1422
- * @param {object} obj 自定义页面参数
1423
- * @param {object} options 配置信息
1424
- */
1425
- function getCurrentPage() {
1426
- // 当前选中菜单的树形结构
1427
- let currentMenuTree = localStorage.getItem('current_page');
1428
- if (currentMenuTree) {
1429
- return JSON.parse(currentMenuTree)
1430
- }
1431
- return ''
1261
+ /**
1262
+ * 用于保存打开的页面集合
1263
+ */
1264
+ let pageList = new Map();
1265
+ /**
1266
+ * 打开对象视图页面
1267
+ * @param {object} obj 对象信息
1268
+ * @param {object} options 配置信息
1269
+ */
1270
+ function openListPage(obj, options = {}) {
1271
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1272
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1273
+ return pageId;
1274
+ }
1275
+
1276
+ /**
1277
+ * 打开数据详情页
1278
+ * @param {object} obj 对象体
1279
+ * @param {string} id 数据id
1280
+ * @param {object} options 配置信息
1281
+ */
1282
+ function openDetailPage(obj, id, options = {}) {
1283
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1284
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1285
+ return pageId;
1286
+ }
1287
+
1288
+ /**
1289
+ * 打开创建页面
1290
+ * @param {object} obj 对象体
1291
+ * @param {object} options 配置信息
1292
+ */
1293
+ function openCreatePage(obj, options = {}) {
1294
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1295
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1296
+ return pageId;
1297
+ }
1298
+
1299
+ /**
1300
+ * 打开修改页面
1301
+ * @param {object} obj 对象体
1302
+ * @param {string} id 数据id
1303
+ * @param {object} options 配置信息
1304
+ */
1305
+ function openEditPage(obj, id, options = {}) {
1306
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1307
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1308
+ return pageId;
1309
+ }
1310
+ /**
1311
+ * 打开自定义页面
1312
+ * @param {object} obj 自定义页面参数
1313
+ * @param {object} options 配置信息
1314
+ */
1315
+ function openCustomPage(obj, options = {}) {
1316
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1317
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1318
+ return pageId;
1319
+ }
1320
+
1321
+ /**
1322
+ * 通过页面id,重新打开某个页面
1323
+ * @param {string} pageId 页面id
1324
+ * @param {object} options 配置信息
1325
+ */
1326
+ function reOpenPage(pageId, options) {
1327
+ let page;
1328
+ if (pageId) {
1329
+ page = pageList.get(pageId);
1330
+ }
1331
+ if (page) {
1332
+ page.reOpenPage();
1333
+ if (options.refresh) {
1334
+ page.refresh();
1335
+ }
1336
+ }
1337
+ }
1338
+
1339
+ /**
1340
+ * 将打开的页面添加到集合中
1341
+ * @param {string} id 唯一ID
1342
+ * @param {object} page 页面对象
1343
+ */
1344
+ function addPage(id, page) {
1345
+ if (id && page) {
1346
+ pageList.set(id, page);
1347
+ }
1348
+ }
1349
+
1350
+ /**
1351
+ * 删除某个页面
1352
+ * @param {string} pageId 唯一ID
1353
+ */
1354
+ function deletePage(pageId) {
1355
+ if (pageId) {
1356
+ pageList.delete(pageId);
1357
+ }
1358
+ }
1359
+ /**
1360
+ * 更改页面数据
1361
+ * @param {string} id 唯一ID
1362
+ * @param {object} page 页面对象
1363
+ */
1364
+ function updatePage(id, page) {
1365
+ if (id && page) {
1366
+ pageList.set(id, page);
1367
+ }
1368
+ }
1369
+
1370
+ /**
1371
+ * 通过页面id查询页面
1372
+ * @param {string} pageId 唯一ID
1373
+ */
1374
+ function searchPage(pageId) {
1375
+ return pageList.get(pageId)
1376
+ }
1377
+ /**
1378
+ * 关闭页面,如果pageId为null,那么关闭当前页面
1379
+ * 如果pageId为all,关闭所有一级菜单
1380
+ * @param {string} pageId 页面id
1381
+ */
1382
+ function close$1(pageId = '') {
1383
+ let page;
1384
+ if(pageId === 'all'){
1385
+ page = [...pageList.values()];
1386
+ page.forEach(item => {
1387
+ if(item){
1388
+ item.close();
1389
+ }
1390
+ });
1391
+ }else if (pageId) {
1392
+ page = pageList.get(pageId);
1393
+ } else {
1394
+ // 不传pageId 默认关闭当前选中的
1395
+ // 当前选中菜单的树形结构
1396
+ let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
1397
+ if (currentMenuTree) {
1398
+ // 说明当前选中的是二级菜单
1399
+ if (currentMenuTree.level2Id) {
1400
+ page = pageList.get(currentMenuTree.level2Id);
1401
+ } else {
1402
+ // 说明当前选中的是一级菜单
1403
+ page = pageList.get(currentMenuTree.id);
1404
+ }
1405
+ }
1406
+ // if (pageList.size > 0) {
1407
+ // page = [...pageList.values()][pageList.size - 1]
1408
+ // }
1409
+ }
1410
+ if (page) {
1411
+ page.close();
1412
+ }
1413
+ }
1414
+ /**
1415
+ * 刷新当前页面
1416
+ */
1417
+ function refresh() {
1418
+ window.$CCDK.CCBus.$emit('refresh');
1419
+ }
1420
+ /**
1421
+ * 获取当前一二级选中菜单的树形结构
1422
+ * @param {object} obj 自定义页面参数
1423
+ * @param {object} options 配置信息
1424
+ */
1425
+ function getCurrentPage() {
1426
+ // 当前选中菜单的树形结构
1427
+ let currentMenuTree = localStorage.getItem('current_page');
1428
+ if (currentMenuTree) {
1429
+ return JSON.parse(currentMenuTree)
1430
+ }
1431
+ return ''
1432
1432
  }
1433
1433
 
1434
1434
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -1448,58 +1448,58 @@ var CCPage = /*#__PURE__*/Object.freeze({
1448
1448
  getCurrentPage: getCurrentPage
1449
1449
  });
1450
1450
 
1451
- /**
1452
- * 设置用户信息
1453
- * @param {object} sentry
1454
- */
1455
- function initUserInfo(sentry) {
1456
- let ccUser = window.$CCDK.CCUser.getUserInfo();
1457
- // 添加日志监控标签:组织id
1458
- sentry.setTag("orgId", ccUser.orgId);
1459
- // 添加日志监控标签:用户id和用户名称
1460
- sentry.setUser({
1461
- username: ccUser.userName,
1462
- id: ccUser.userId,
1463
- });
1464
- }
1465
- /**
1466
- * 内存上报
1467
- * @param {object} sentry
1468
- */
1469
- function reportMemory(sentry) {
1470
- if (performance.memory) {
1471
- let memeryMsg =
1472
- "内存监控:jsHeapSizeLimit=" +
1473
- (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
1474
- "mb、" +
1475
- "totalJSHeapSize=" +
1476
- (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
1477
- "mb、" +
1478
- "usedJSHeapSize=" +
1479
- (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
1480
- "mb";
1481
- initUserInfo(sentry);
1482
- sentry.withScope(function (scope) {
1483
- // 使用内存
1484
- sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
1485
- // 添加日志监控标签:组织id
1486
- scope.setFingerprint(["内存监控"]);
1487
- sentry.captureMessage(memeryMsg);
1488
- });
1489
- }
1490
- }
1491
-
1492
- /**
1493
- * 网络异常上报
1494
- * @param {object} sentry
1495
- * @param {error} error
1496
- */
1497
- function reportHttpException(sentry, error) {
1498
- initUserInfo(sentry);
1499
- sentry.withScope(function (scope) {
1500
- scope.setFingerprint(["接口未捕获异常response"]);
1501
- sentry.captureException(error);
1502
- });
1451
+ /**
1452
+ * 设置用户信息
1453
+ * @param {object} sentry
1454
+ */
1455
+ function initUserInfo(sentry) {
1456
+ let ccUser = window.$CCDK.CCUser.getUserInfo();
1457
+ // 添加日志监控标签:组织id
1458
+ sentry.setTag("orgId", ccUser.orgId);
1459
+ // 添加日志监控标签:用户id和用户名称
1460
+ sentry.setUser({
1461
+ username: ccUser.userName,
1462
+ id: ccUser.userId,
1463
+ });
1464
+ }
1465
+ /**
1466
+ * 内存上报
1467
+ * @param {object} sentry
1468
+ */
1469
+ function reportMemory(sentry) {
1470
+ if (performance.memory) {
1471
+ let memeryMsg =
1472
+ "内存监控:jsHeapSizeLimit=" +
1473
+ (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
1474
+ "mb、" +
1475
+ "totalJSHeapSize=" +
1476
+ (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
1477
+ "mb、" +
1478
+ "usedJSHeapSize=" +
1479
+ (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
1480
+ "mb";
1481
+ initUserInfo(sentry);
1482
+ sentry.withScope(function (scope) {
1483
+ // 使用内存
1484
+ sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
1485
+ // 添加日志监控标签:组织id
1486
+ scope.setFingerprint(["内存监控"]);
1487
+ sentry.captureMessage(memeryMsg);
1488
+ });
1489
+ }
1490
+ }
1491
+
1492
+ /**
1493
+ * 网络异常上报
1494
+ * @param {object} sentry
1495
+ * @param {error} error
1496
+ */
1497
+ function reportHttpException(sentry, error) {
1498
+ initUserInfo(sentry);
1499
+ sentry.withScope(function (scope) {
1500
+ scope.setFingerprint(["接口未捕获异常response"]);
1501
+ sentry.captureException(error);
1502
+ });
1503
1503
  }
1504
1504
 
1505
1505
  var CCSentry = /*#__PURE__*/Object.freeze({
@@ -1508,24 +1508,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
1508
1508
  reportHttpException: reportHttpException
1509
1509
  });
1510
1510
 
1511
- /**
1512
- * 初始化侧边区域
1513
- * @param {object} options 自定义页面配置
1514
- */
1515
- function init(options) {
1516
- window.$CCDK.CCBus.$emit('initSide', options);
1517
- }
1518
- /**
1519
- * 打开侧边区域
1520
- */
1521
- function open() {
1522
- window.$CCDK.CCBus.$emit('openSide');
1523
- }
1524
- /**
1525
- * 关闭侧边区域
1526
- */
1527
- function close() {
1528
- window.$CCDK.CCBus.$emit('closeSide');
1511
+ /**
1512
+ * 初始化侧边区域
1513
+ * @param {object} options 自定义页面配置
1514
+ */
1515
+ function init(options) {
1516
+ window.$CCDK.CCBus.$emit('initSide', options);
1517
+ }
1518
+ /**
1519
+ * 打开侧边区域
1520
+ */
1521
+ function open() {
1522
+ window.$CCDK.CCBus.$emit('openSide');
1523
+ }
1524
+ /**
1525
+ * 关闭侧边区域
1526
+ */
1527
+ function close() {
1528
+ window.$CCDK.CCBus.$emit('closeSide');
1529
1529
  }
1530
1530
 
1531
1531
  var CCSide = /*#__PURE__*/Object.freeze({
@@ -1535,49 +1535,49 @@ var CCSide = /*#__PURE__*/Object.freeze({
1535
1535
  close: close
1536
1536
  });
1537
1537
 
1538
- // cookie存储标识
1539
- const TOKEN = "cc_token";
1540
- /**
1541
- * 获取URL中参数的数据
1542
- * @param {name} 参数名
1543
- */
1544
- function getUrlQuery(name) {
1545
- var reg = new RegExp(name + "=([^&]*)(&|$)");
1546
- var r = window.location.href.match(reg);
1547
- let res = null;
1548
- if (r != null) res = r[1].trim();
1549
- return res;
1550
- }
1551
- /**
1552
- * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
1553
- * @param {String} urlName 获取token的url名称
1554
- * @returns
1555
- */
1556
- function getToken(urlName = "binding") {
1557
- let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
1558
- // 如果存在token,那么存储到cookies中,刷新有效期
1559
- if (token) {
1560
- setToken(token);
1561
- }
1562
- return token
1563
- }
1564
- /**
1565
- * 存储token
1566
- * @param {String} token token
1567
- * @param {String} domain 域名
1568
- */
1569
- function setToken(token, domain = getDomain()) {
1570
- Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
1571
- Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
1572
- }
1573
-
1574
- /**
1575
- * 清除Token数据
1576
- * @param {String} domain 域名
1577
- */
1578
- function clearToken(domain = getDomain()) {
1579
- Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
1580
- Cookies.remove(Crypto.encrypt(TOKEN));
1538
+ // cookie存储标识
1539
+ const TOKEN = "cc_token";
1540
+ /**
1541
+ * 获取URL中参数的数据
1542
+ * @param {name} 参数名
1543
+ */
1544
+ function getUrlQuery(name) {
1545
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
1546
+ var r = window.location.href.match(reg);
1547
+ let res = null;
1548
+ if (r != null) res = r[1].trim();
1549
+ return res;
1550
+ }
1551
+ /**
1552
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
1553
+ * @param {String} urlName 获取token的url名称
1554
+ * @returns
1555
+ */
1556
+ function getToken(urlName = "binding") {
1557
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
1558
+ // 如果存在token,那么存储到cookies中,刷新有效期
1559
+ if (token) {
1560
+ setToken(token);
1561
+ }
1562
+ return token
1563
+ }
1564
+ /**
1565
+ * 存储token
1566
+ * @param {String} token token
1567
+ * @param {String} domain 域名
1568
+ */
1569
+ function setToken(token, domain = getDomain()) {
1570
+ Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
1571
+ Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
1572
+ }
1573
+
1574
+ /**
1575
+ * 清除Token数据
1576
+ * @param {String} domain 域名
1577
+ */
1578
+ function clearToken(domain = getDomain()) {
1579
+ Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
1580
+ Cookies.remove(Crypto.encrypt(TOKEN));
1581
1581
  }
1582
1582
 
1583
1583
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -1588,31 +1588,31 @@ var CCToken = /*#__PURE__*/Object.freeze({
1588
1588
  getUrlQuery: getUrlQuery
1589
1589
  });
1590
1590
 
1591
- // cookie存储标识
1592
- const USER_INFO = "cc_user_info";
1593
-
1594
- /**
1595
- * 存储用户信息
1596
- * @param {String} userInfo 用户信息
1597
- * @param {String} domain 域名
1598
- */
1599
- function setUserInfo(userInfo, domain = getDomain()) {
1600
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
1601
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
1602
- }
1603
-
1604
- /**
1605
- * 获取用户信息
1606
- * @returns {String} 用户信息
1607
- */
1608
- function getUserInfo() {
1609
- // 加密的用户信息
1610
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
1611
- if (encryptUserInfo) {
1612
- return Crypto.decrypt(encryptUserInfo)
1613
- } else {
1614
- return ""
1615
- }
1591
+ // cookie存储标识
1592
+ const USER_INFO = "cc_user_info";
1593
+
1594
+ /**
1595
+ * 存储用户信息
1596
+ * @param {String} userInfo 用户信息
1597
+ * @param {String} domain 域名
1598
+ */
1599
+ function setUserInfo(userInfo, domain = getDomain()) {
1600
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
1601
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
1602
+ }
1603
+
1604
+ /**
1605
+ * 获取用户信息
1606
+ * @returns {String} 用户信息
1607
+ */
1608
+ function getUserInfo() {
1609
+ // 加密的用户信息
1610
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
1611
+ if (encryptUserInfo) {
1612
+ return Crypto.decrypt(encryptUserInfo)
1613
+ } else {
1614
+ return ""
1615
+ }
1616
1616
  }
1617
1617
 
1618
1618
  var CCUser = /*#__PURE__*/Object.freeze({
@@ -1621,8 +1621,8 @@ var CCUser = /*#__PURE__*/Object.freeze({
1621
1621
  getUserInfo: getUserInfo
1622
1622
  });
1623
1623
 
1624
- let CCDK = { CCApplication, CCUser, CCCrypto: Crypto, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCMessage };
1625
- Vue.prototype.$CCDK = CCDK;
1624
+ let CCDK = { CCApplication, CCUser, CCCrypto: Crypto, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCMessage };
1625
+ Vue.prototype.$CCDK = CCDK;
1626
1626
  window.$CCDK = CCDK;
1627
1627
 
1628
1628
  export { CCDK as default };