cloudcc-ccdk 0.8.7 → 0.8.8

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