cloudcc-ccdk 0.8.4 → 0.8.6

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 +566 -554
  2. package/lib/ccdk.js +1574 -1557
  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]',
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
160
208
  };
161
209
 
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
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);
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,173 @@ 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
- // 记录类型:paltfrom平台日志,dev开发者日志
1001
- "recordType": "paltfrom",
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
+ * 上报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
+ }
1150
1150
  }
1151
1151
 
1152
1152
  var CCLog = /*#__PURE__*/Object.freeze({
@@ -1158,75 +1158,75 @@ var CCLog = /*#__PURE__*/Object.freeze({
1158
1158
  reportCCInfo: reportCCInfo
1159
1159
  });
1160
1160
 
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);
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);
1230
1230
  }
1231
1231
 
1232
1232
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -1243,43 +1243,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
1243
1243
  reOpenMenu2: reOpenMenu2
1244
1244
  });
1245
1245
 
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);
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);
1283
1283
  }
1284
1284
 
1285
1285
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -1289,99 +1289,116 @@ var CCMessage = /*#__PURE__*/Object.freeze({
1289
1289
  showNotification: showNotification
1290
1290
  });
1291
1291
 
1292
- // 对象详情存储标识
1293
- const OBJECT_DETAIL = 'cc_object_detail';
1294
- // 对象存储标识
1295
- const OBJECT = 'cc_object';
1296
- // 列表视图存储标识
1297
- const OBJECT_LIST = 'cc_object_list';
1298
-
1299
- /**
1300
- * 获得当前标准对象信息
1301
- */
1302
- function getObject( ) {
1303
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1304
- if (detail) {
1305
- return JSON.parse(detail)
1306
- }
1307
- return ''
1308
- }
1309
-
1310
- /**
1311
- * 设置当前标准对象信息
1312
- * @param {object} detail 对象数据
1313
- */
1314
- function setObject(detail = '') {
1315
- if (detail) {
1316
- localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1317
- }
1318
- }
1319
-
1320
- /**
1321
- * 获得当前标准对象的详细信息
1322
- * @param {String} apiname: 查找字段的apiname
1323
- */
1324
- function getObjectDetail(apiname) {
1325
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
1326
- if (detail) {
1327
- if(apiname){
1328
- let detailObj = JSON.parse(detail).detail;
1329
- let targetField = undefined;
1330
- if(Array.isArray(detailObj)){
1331
- targetField = detailObj.find(item=>item.apiname===apiname);
1332
- }
1333
- return targetField
1334
- }else {
1335
- return JSON.parse(detail)
1336
- }
1337
- }
1338
- return ''
1339
- }
1340
-
1341
- /**
1342
- * 设置当前标准对象的详细信息,默认两个小时有效期
1343
- * @param {object} detail 对象详细数据
1344
- */
1345
- function setObjectDetail(detail = '') {
1346
- if (detail) {
1347
- // 减少detail.detail层级
1348
- if(Array.isArray(detail.detail)){
1349
- let data = [];
1350
- detail.detail.forEach(item=>{
1351
- if(item && Array.isArray(item.data)){
1352
- item.data.forEach(itemData=>{
1353
- if(itemData.left && !Array.isArray(itemData.left)){
1354
- data.push(itemData.left);
1355
- }
1356
- if(itemData.right && !Array.isArray(itemData.right)){
1357
- data.push(itemData.right);
1358
- }
1359
- });
1360
- }
1361
- });
1362
- if(data.length > 0){detail.detail = data;}
1363
- }
1364
- localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
1365
- }
1366
- }
1367
- /**
1368
- * 设置当前标准对象列表选中的信息
1369
- * @param {object} detail 选中数据
1370
- */
1371
- function setObjectList(detail = {}) {
1372
- if (detail.ids) {
1373
- localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1374
- }
1375
- }
1376
- /**
1377
- * 获得当前标准对象列表选中的信息
1378
- */
1379
- function getObjectList() {
1380
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1381
- if (detail) {
1382
- return JSON.parse(detail)
1383
- }
1384
- return {ids:[]}
1292
+ // 对象详情存储标识
1293
+ const OBJECT_DETAIL = 'cc_object_detail';
1294
+ // 对象存储标识
1295
+ const OBJECT = 'cc_object';
1296
+ // 列表视图存储标识
1297
+ const OBJECT_LIST = 'cc_object_list';
1298
+
1299
+ /**
1300
+ * 获得当前标准对象信息
1301
+ */
1302
+ function getObject() {
1303
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1304
+ if (detail) {
1305
+ return JSON.parse(detail)
1306
+ }
1307
+ return ''
1308
+ }
1309
+
1310
+ /**
1311
+ * 设置当前标准对象信息
1312
+ * @param {object} detail 对象数据
1313
+ */
1314
+ function setObject(detail = '') {
1315
+ if (detail) {
1316
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1317
+ }
1318
+ }
1319
+
1320
+ /**
1321
+ * 获得当前标准对象的详细信息
1322
+ * @param {String} apiname: 查找字段的apiname
1323
+ * @param {String} detailId: 详情页数据id
1324
+ */
1325
+ function getObjectDetail(apiname, detailId) {
1326
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
1327
+ if (detail) {
1328
+ // 转为对象
1329
+ detail = JSON.parse(detail);
1330
+ // 没有指定详情页id,获取最后一次的id
1331
+ if (!detailId) {
1332
+ detailId = detail.id;
1333
+ } else {
1334
+ detail.id = detailId;
1335
+ }
1336
+ // 通过详情页id获取对应的详情页数据
1337
+ let detailList = JSON.parse(sessionStorage.getItem(detailId));
1338
+ if (apiname) {
1339
+ let targetField = undefined;
1340
+ if (Array.isArray(detailList)) {
1341
+ targetField = detailList.find(item => item.apiname === apiname);
1342
+ }
1343
+ return targetField
1344
+ } else {
1345
+ detail.detail = detailList;
1346
+ return detail
1347
+ }
1348
+ } else {
1349
+ return ''
1350
+ }
1351
+
1352
+ }
1353
+
1354
+ /**
1355
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1356
+ * @param {object} detail 对象详细数据
1357
+ */
1358
+ function setObjectDetail(detail = '') {
1359
+ if (detail && detail.id) {
1360
+ // 减少detail.detail层级
1361
+ if (Array.isArray(detail.detail) && detail.detail.length > 0) {
1362
+ let data = [];
1363
+ detail.detail.forEach(item => {
1364
+ if (item && Array.isArray(item.data)) {
1365
+ item.data.forEach(itemData => {
1366
+ if (itemData.left && !Array.isArray(itemData.left)) {
1367
+ data.push(itemData.left);
1368
+ }
1369
+ if (itemData.right && !Array.isArray(itemData.right)) {
1370
+ data.push(itemData.right);
1371
+ }
1372
+ });
1373
+ }
1374
+ });
1375
+ if (data.length > 0) {
1376
+ detail.detail = data;
1377
+ // 根据详情页id,记录详情页信息
1378
+ sessionStorage.setItem(detail.id, JSON.stringify(data));
1379
+ }
1380
+ }
1381
+ localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
1382
+ }
1383
+ }
1384
+ /**
1385
+ * 设置当前标准对象列表选中的信息
1386
+ * @param {object} detail 选中数据
1387
+ */
1388
+ function setObjectList(detail = {}) {
1389
+ if (detail.ids) {
1390
+ localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1391
+ }
1392
+ }
1393
+ /**
1394
+ * 获得当前标准对象列表选中的信息
1395
+ */
1396
+ function getObjectList() {
1397
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1398
+ if (detail) {
1399
+ return JSON.parse(detail)
1400
+ }
1401
+ return { ids: [] }
1385
1402
  }
1386
1403
 
1387
1404
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -1394,177 +1411,177 @@ var CCObject = /*#__PURE__*/Object.freeze({
1394
1411
  setObjectDetail: setObjectDetail
1395
1412
  });
1396
1413
 
1397
- /**
1398
- * 用于保存打开的页面集合
1399
- */
1400
- let pageList = new Map();
1401
- /**
1402
- * 打开对象视图页面
1403
- * @param {object} obj 对象信息
1404
- * @param {object} options 配置信息
1405
- */
1406
- function openListPage(obj, options = {}) {
1407
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1408
- window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1409
- return pageId;
1410
- }
1411
-
1412
- /**
1413
- * 打开数据详情页
1414
- * @param {object} obj 对象体
1415
- * @param {string} id 数据id
1416
- * @param {object} options 配置信息
1417
- */
1418
- function openDetailPage(obj, id, options = {}) {
1419
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1420
- window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1421
- return pageId;
1422
- }
1423
-
1424
- /**
1425
- * 打开创建页面
1426
- * @param {object} obj 对象体
1427
- * @param {object} options 配置信息
1428
- */
1429
- function openCreatePage(obj, options = {}) {
1430
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1431
- window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1432
- return pageId;
1433
- }
1434
-
1435
- /**
1436
- * 打开修改页面
1437
- * @param {object} obj 对象体
1438
- * @param {string} id 数据id
1439
- * @param {object} options 配置信息
1440
- */
1441
- function openEditPage(obj, id, options = {}) {
1442
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1443
- window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1444
- return pageId;
1445
- }
1446
- /**
1447
- * 打开自定义页面
1448
- * @param {object} obj 自定义页面参数
1449
- * @param {object} options 配置信息
1450
- */
1451
- function openCustomPage(obj, options = {}) {
1452
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1453
- window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1454
- return pageId;
1455
- }
1456
-
1457
- /**
1458
- * 通过页面id,重新打开某个页面
1459
- * @param {string} pageId 页面id
1460
- * @param {object} options 配置信息
1461
- */
1462
- function reOpenPage(pageId, options) {
1463
- let page;
1464
- if (pageId) {
1465
- page = pageList.get(pageId);
1466
- }
1467
- if (page) {
1468
- page.reOpenPage();
1469
- if (options.refresh) {
1470
- page.refresh();
1471
- }
1472
- }
1473
- }
1474
-
1475
- /**
1476
- * 将打开的页面添加到集合中
1477
- * @param {string} id 唯一ID
1478
- * @param {object} page 页面对象
1479
- */
1480
- function addPage(id, page) {
1481
- if (id && page) {
1482
- pageList.set(id, page);
1483
- }
1484
- }
1485
-
1486
- /**
1487
- * 删除某个页面
1488
- * @param {string} pageId 唯一ID
1489
- */
1490
- function deletePage(pageId) {
1491
- if (pageId) {
1492
- pageList.delete(pageId);
1493
- }
1494
- }
1495
- /**
1496
- * 更改页面数据
1497
- * @param {string} id 唯一ID
1498
- * @param {object} page 页面对象
1499
- */
1500
- function updatePage(id, page) {
1501
- if (id && page) {
1502
- pageList.set(id, page);
1503
- }
1504
- }
1505
-
1506
- /**
1507
- * 通过页面id查询页面
1508
- * @param {string} pageId 唯一ID
1509
- */
1510
- function searchPage(pageId) {
1511
- return pageList.get(pageId)
1512
- }
1513
- /**
1514
- * 关闭页面,如果pageId为null,那么关闭当前页面
1515
- * 如果pageId为all,关闭所有一级菜单
1516
- * @param {string} pageId 页面id
1517
- */
1518
- function close$1(pageId = '') {
1519
- let page;
1520
- if(pageId === 'all'){
1521
- page = [...pageList.values()];
1522
- page.forEach(item => {
1523
- if(item){
1524
- item.close();
1525
- }
1526
- });
1527
- }else if (pageId) {
1528
- page = pageList.get(pageId);
1529
- } else {
1530
- // 不传pageId 默认关闭当前选中的
1531
- // 当前选中菜单的树形结构
1532
- let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
1533
- if (currentMenuTree) {
1534
- // 说明当前选中的是二级菜单
1535
- if (currentMenuTree.level2Id) {
1536
- page = pageList.get(currentMenuTree.level2Id);
1537
- } else {
1538
- // 说明当前选中的是一级菜单
1539
- page = pageList.get(currentMenuTree.id);
1540
- }
1541
- }
1542
- // if (pageList.size > 0) {
1543
- // page = [...pageList.values()][pageList.size - 1]
1544
- // }
1545
- }
1546
- if (page) {
1547
- page.close();
1548
- }
1549
- }
1550
- /**
1551
- * 刷新当前页面
1552
- */
1553
- function refresh() {
1554
- window.$CCDK.CCBus.$emit('refresh');
1555
- }
1556
- /**
1557
- * 获取当前一二级选中菜单的树形结构
1558
- * @param {object} obj 自定义页面参数
1559
- * @param {object} options 配置信息
1560
- */
1561
- function getCurrentPage() {
1562
- // 当前选中菜单的树形结构
1563
- let currentMenuTree = localStorage.getItem('current_page');
1564
- if (currentMenuTree) {
1565
- return JSON.parse(currentMenuTree)
1566
- }
1567
- return ''
1414
+ /**
1415
+ * 用于保存打开的页面集合
1416
+ */
1417
+ let pageList = new Map();
1418
+ /**
1419
+ * 打开对象视图页面
1420
+ * @param {object} obj 对象信息
1421
+ * @param {object} options 配置信息
1422
+ */
1423
+ function openListPage(obj, options = {}) {
1424
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1425
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1426
+ return pageId;
1427
+ }
1428
+
1429
+ /**
1430
+ * 打开数据详情页
1431
+ * @param {object} obj 对象体
1432
+ * @param {string} id 数据id
1433
+ * @param {object} options 配置信息
1434
+ */
1435
+ function openDetailPage(obj, id, options = {}) {
1436
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1437
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1438
+ return pageId;
1439
+ }
1440
+
1441
+ /**
1442
+ * 打开创建页面
1443
+ * @param {object} obj 对象体
1444
+ * @param {object} options 配置信息
1445
+ */
1446
+ function openCreatePage(obj, options = {}) {
1447
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1448
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1449
+ return pageId;
1450
+ }
1451
+
1452
+ /**
1453
+ * 打开修改页面
1454
+ * @param {object} obj 对象体
1455
+ * @param {string} id 数据id
1456
+ * @param {object} options 配置信息
1457
+ */
1458
+ function openEditPage(obj, id, options = {}) {
1459
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1460
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1461
+ return pageId;
1462
+ }
1463
+ /**
1464
+ * 打开自定义页面
1465
+ * @param {object} obj 自定义页面参数
1466
+ * @param {object} options 配置信息
1467
+ */
1468
+ function openCustomPage(obj, options = {}) {
1469
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1470
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1471
+ return pageId;
1472
+ }
1473
+
1474
+ /**
1475
+ * 通过页面id,重新打开某个页面
1476
+ * @param {string} pageId 页面id
1477
+ * @param {object} options 配置信息
1478
+ */
1479
+ function reOpenPage(pageId, options) {
1480
+ let page;
1481
+ if (pageId) {
1482
+ page = pageList.get(pageId);
1483
+ }
1484
+ if (page) {
1485
+ page.reOpenPage();
1486
+ if (options.refresh) {
1487
+ page.refresh();
1488
+ }
1489
+ }
1490
+ }
1491
+
1492
+ /**
1493
+ * 将打开的页面添加到集合中
1494
+ * @param {string} id 唯一ID
1495
+ * @param {object} page 页面对象
1496
+ */
1497
+ function addPage(id, page) {
1498
+ if (id && page) {
1499
+ pageList.set(id, page);
1500
+ }
1501
+ }
1502
+
1503
+ /**
1504
+ * 删除某个页面
1505
+ * @param {string} pageId 唯一ID
1506
+ */
1507
+ function deletePage(pageId) {
1508
+ if (pageId) {
1509
+ pageList.delete(pageId);
1510
+ }
1511
+ }
1512
+ /**
1513
+ * 更改页面数据
1514
+ * @param {string} id 唯一ID
1515
+ * @param {object} page 页面对象
1516
+ */
1517
+ function updatePage(id, page) {
1518
+ if (id && page) {
1519
+ pageList.set(id, page);
1520
+ }
1521
+ }
1522
+
1523
+ /**
1524
+ * 通过页面id查询页面
1525
+ * @param {string} pageId 唯一ID
1526
+ */
1527
+ function searchPage(pageId) {
1528
+ return pageList.get(pageId)
1529
+ }
1530
+ /**
1531
+ * 关闭页面,如果pageId为null,那么关闭当前页面
1532
+ * 如果pageId为all,关闭所有一级菜单
1533
+ * @param {string} pageId 页面id
1534
+ */
1535
+ function close$1(pageId = '') {
1536
+ let page;
1537
+ if(pageId === 'all'){
1538
+ page = [...pageList.values()];
1539
+ page.forEach(item => {
1540
+ if(item){
1541
+ item.close();
1542
+ }
1543
+ });
1544
+ }else if (pageId) {
1545
+ page = pageList.get(pageId);
1546
+ } else {
1547
+ // 不传pageId 默认关闭当前选中的
1548
+ // 当前选中菜单的树形结构
1549
+ let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
1550
+ if (currentMenuTree) {
1551
+ // 说明当前选中的是二级菜单
1552
+ if (currentMenuTree.level2Id) {
1553
+ page = pageList.get(currentMenuTree.level2Id);
1554
+ } else {
1555
+ // 说明当前选中的是一级菜单
1556
+ page = pageList.get(currentMenuTree.id);
1557
+ }
1558
+ }
1559
+ // if (pageList.size > 0) {
1560
+ // page = [...pageList.values()][pageList.size - 1]
1561
+ // }
1562
+ }
1563
+ if (page) {
1564
+ page.close();
1565
+ }
1566
+ }
1567
+ /**
1568
+ * 刷新当前页面
1569
+ */
1570
+ function refresh() {
1571
+ window.$CCDK.CCBus.$emit('refresh');
1572
+ }
1573
+ /**
1574
+ * 获取当前一二级选中菜单的树形结构
1575
+ * @param {object} obj 自定义页面参数
1576
+ * @param {object} options 配置信息
1577
+ */
1578
+ function getCurrentPage() {
1579
+ // 当前选中菜单的树形结构
1580
+ let currentMenuTree = localStorage.getItem('current_page');
1581
+ if (currentMenuTree) {
1582
+ return JSON.parse(currentMenuTree)
1583
+ }
1584
+ return ''
1568
1585
  }
1569
1586
 
1570
1587
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -1584,58 +1601,58 @@ var CCPage = /*#__PURE__*/Object.freeze({
1584
1601
  getCurrentPage: getCurrentPage
1585
1602
  });
1586
1603
 
1587
- /**
1588
- * 设置用户信息
1589
- * @param {object} sentry
1590
- */
1591
- function initUserInfo(sentry) {
1592
- let ccUser = window.$CCDK.CCUser.getUserInfo();
1593
- // 添加日志监控标签:组织id
1594
- sentry.setTag("orgId", ccUser.orgId);
1595
- // 添加日志监控标签:用户id和用户名称
1596
- sentry.setUser({
1597
- username: ccUser.userName,
1598
- id: ccUser.userId,
1599
- });
1600
- }
1601
- /**
1602
- * 内存上报
1603
- * @param {object} sentry
1604
- */
1605
- function reportMemory(sentry) {
1606
- if (performance.memory) {
1607
- let memeryMsg =
1608
- "内存监控:jsHeapSizeLimit=" +
1609
- (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
1610
- "mb、" +
1611
- "totalJSHeapSize=" +
1612
- (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
1613
- "mb、" +
1614
- "usedJSHeapSize=" +
1615
- (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
1616
- "mb";
1617
- initUserInfo(sentry);
1618
- sentry.withScope(function (scope) {
1619
- // 使用内存
1620
- sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
1621
- // 添加日志监控标签:组织id
1622
- scope.setFingerprint(["内存监控"]);
1623
- sentry.captureMessage(memeryMsg);
1624
- });
1625
- }
1626
- }
1627
-
1628
- /**
1629
- * 网络异常上报
1630
- * @param {object} sentry
1631
- * @param {error} error
1632
- */
1633
- function reportHttpException(sentry, error) {
1634
- initUserInfo(sentry);
1635
- sentry.withScope(function (scope) {
1636
- scope.setFingerprint(["接口未捕获异常response"]);
1637
- sentry.captureException(error);
1638
- });
1604
+ /**
1605
+ * 设置用户信息
1606
+ * @param {object} sentry
1607
+ */
1608
+ function initUserInfo(sentry) {
1609
+ let ccUser = window.$CCDK.CCUser.getUserInfo();
1610
+ // 添加日志监控标签:组织id
1611
+ sentry.setTag("orgId", ccUser.orgId);
1612
+ // 添加日志监控标签:用户id和用户名称
1613
+ sentry.setUser({
1614
+ username: ccUser.userName,
1615
+ id: ccUser.userId,
1616
+ });
1617
+ }
1618
+ /**
1619
+ * 内存上报
1620
+ * @param {object} sentry
1621
+ */
1622
+ function reportMemory(sentry) {
1623
+ if (performance.memory) {
1624
+ let memeryMsg =
1625
+ "内存监控:jsHeapSizeLimit=" +
1626
+ (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
1627
+ "mb、" +
1628
+ "totalJSHeapSize=" +
1629
+ (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
1630
+ "mb、" +
1631
+ "usedJSHeapSize=" +
1632
+ (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
1633
+ "mb";
1634
+ initUserInfo(sentry);
1635
+ sentry.withScope(function (scope) {
1636
+ // 使用内存
1637
+ sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
1638
+ // 添加日志监控标签:组织id
1639
+ scope.setFingerprint(["内存监控"]);
1640
+ sentry.captureMessage(memeryMsg);
1641
+ });
1642
+ }
1643
+ }
1644
+
1645
+ /**
1646
+ * 网络异常上报
1647
+ * @param {object} sentry
1648
+ * @param {error} error
1649
+ */
1650
+ function reportHttpException(sentry, error) {
1651
+ initUserInfo(sentry);
1652
+ sentry.withScope(function (scope) {
1653
+ scope.setFingerprint(["接口未捕获异常response"]);
1654
+ sentry.captureException(error);
1655
+ });
1639
1656
  }
1640
1657
 
1641
1658
  var CCSentry = /*#__PURE__*/Object.freeze({
@@ -1644,24 +1661,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
1644
1661
  reportHttpException: reportHttpException
1645
1662
  });
1646
1663
 
1647
- /**
1648
- * 初始化侧边区域
1649
- * @param {object} options 自定义页面配置
1650
- */
1651
- function init(options) {
1652
- window.$CCDK.CCBus.$emit('initSide', options);
1653
- }
1654
- /**
1655
- * 打开侧边区域
1656
- */
1657
- function open() {
1658
- window.$CCDK.CCBus.$emit('openSide');
1659
- }
1660
- /**
1661
- * 关闭侧边区域
1662
- */
1663
- function close() {
1664
- window.$CCDK.CCBus.$emit('closeSide');
1664
+ /**
1665
+ * 初始化侧边区域
1666
+ * @param {object} options 自定义页面配置
1667
+ */
1668
+ function init(options) {
1669
+ window.$CCDK.CCBus.$emit('initSide', options);
1670
+ }
1671
+ /**
1672
+ * 打开侧边区域
1673
+ */
1674
+ function open() {
1675
+ window.$CCDK.CCBus.$emit('openSide');
1676
+ }
1677
+ /**
1678
+ * 关闭侧边区域
1679
+ */
1680
+ function close() {
1681
+ window.$CCDK.CCBus.$emit('closeSide');
1665
1682
  }
1666
1683
 
1667
1684
  var CCSide = /*#__PURE__*/Object.freeze({
@@ -1671,52 +1688,52 @@ var CCSide = /*#__PURE__*/Object.freeze({
1671
1688
  close: close
1672
1689
  });
1673
1690
 
1674
- // cookie存储标识
1675
- const TOKEN = "cc_token";
1676
- /**
1677
- * 获取URL中参数的数据
1678
- * @param {name} 参数名
1679
- */
1680
- function getUrlQuery(name) {
1681
- var reg = new RegExp(name + "=([^&]*)(&|$)");
1682
- var r = window.location.href.match(reg);
1683
- let res = null;
1684
- if (r != null) res = r[1].trim();
1685
- return res;
1686
- }
1687
- /**
1688
- * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
1689
- * @param {String} urlName 获取token的url名称
1690
- * @param {String} cookieName 获取token的cookie名称
1691
- * @returns
1692
- */
1693
- function getToken(urlName = "binding", cookieName = TOKEN) {
1694
- let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName||TOKEN);
1695
- // 如果存在token,那么存储到cookies中,刷新有效期
1696
- if (token) {
1697
- setToken(token, cookieName);
1698
- }
1699
- return token
1700
- }
1701
- /**
1702
- * 存储token
1703
- * @param {String} token token
1704
- * @param {String} cookieName 获取token的cookie名称
1705
- * @param {String} domain 域名
1706
- */
1707
- function setToken(token, cookieName = TOKEN, domain = getDomain()) {
1708
- Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
1709
- Cookies.set(Crypto.encrypt(cookieName), token, { expires: 1 / 12 });
1710
- }
1711
-
1712
- /**
1713
- * 清除Token数据
1714
- * @param {String} domain 域名
1715
- * @param {String} cookieName 获取token的cookie名称
1716
- */
1717
- function clearToken(cookieName = TOKEN, domain = getDomain()) {
1718
- Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
1719
- Cookies.remove(Crypto.encrypt(cookieName));
1691
+ // cookie存储标识
1692
+ const TOKEN = "cc_token";
1693
+ /**
1694
+ * 获取URL中参数的数据
1695
+ * @param {name} 参数名
1696
+ */
1697
+ function getUrlQuery(name) {
1698
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
1699
+ var r = window.location.href.match(reg);
1700
+ let res = null;
1701
+ if (r != null) res = r[1].trim();
1702
+ return res;
1703
+ }
1704
+ /**
1705
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
1706
+ * @param {String} urlName 获取token的url名称
1707
+ * @param {String} cookieName 获取token的cookie名称
1708
+ * @returns
1709
+ */
1710
+ function getToken(urlName = "binding", cookieName = TOKEN) {
1711
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName||TOKEN);
1712
+ // 如果存在token,那么存储到cookies中,刷新有效期
1713
+ if (token) {
1714
+ setToken(token, cookieName);
1715
+ }
1716
+ return token
1717
+ }
1718
+ /**
1719
+ * 存储token
1720
+ * @param {String} token token
1721
+ * @param {String} cookieName 获取token的cookie名称
1722
+ * @param {String} domain 域名
1723
+ */
1724
+ function setToken(token, cookieName = TOKEN, domain = getDomain()) {
1725
+ Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
1726
+ Cookies.set(Crypto.encrypt(cookieName), token, { expires: 1 / 12 });
1727
+ }
1728
+
1729
+ /**
1730
+ * 清除Token数据
1731
+ * @param {String} domain 域名
1732
+ * @param {String} cookieName 获取token的cookie名称
1733
+ */
1734
+ function clearToken(cookieName = TOKEN, domain = getDomain()) {
1735
+ Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
1736
+ Cookies.remove(Crypto.encrypt(cookieName));
1720
1737
  }
1721
1738
 
1722
1739
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -1727,31 +1744,31 @@ var CCToken = /*#__PURE__*/Object.freeze({
1727
1744
  getUrlQuery: getUrlQuery
1728
1745
  });
1729
1746
 
1730
- // cookie存储标识
1731
- const USER_INFO = "cc_user_info";
1732
-
1733
- /**
1734
- * 存储用户信息
1735
- * @param {String} userInfo 用户信息
1736
- * @param {String} domain 域名
1737
- */
1738
- function setUserInfo(userInfo, domain = getDomain()) {
1739
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
1740
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
1741
- }
1742
-
1743
- /**
1744
- * 获取用户信息
1745
- * @returns {String} 用户信息
1746
- */
1747
- function getUserInfo() {
1748
- // 加密的用户信息
1749
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
1750
- if (encryptUserInfo) {
1751
- return Crypto.decrypt(encryptUserInfo)
1752
- } else {
1753
- return ""
1754
- }
1747
+ // cookie存储标识
1748
+ const USER_INFO = "cc_user_info";
1749
+
1750
+ /**
1751
+ * 存储用户信息
1752
+ * @param {String} userInfo 用户信息
1753
+ * @param {String} domain 域名
1754
+ */
1755
+ function setUserInfo(userInfo, domain = getDomain()) {
1756
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
1757
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
1758
+ }
1759
+
1760
+ /**
1761
+ * 获取用户信息
1762
+ * @returns {String} 用户信息
1763
+ */
1764
+ function getUserInfo() {
1765
+ // 加密的用户信息
1766
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
1767
+ if (encryptUserInfo) {
1768
+ return Crypto.decrypt(encryptUserInfo)
1769
+ } else {
1770
+ return ""
1771
+ }
1755
1772
  }
1756
1773
 
1757
1774
  var CCUser = /*#__PURE__*/Object.freeze({
@@ -1760,8 +1777,8 @@ var CCUser = /*#__PURE__*/Object.freeze({
1760
1777
  getUserInfo: getUserInfo
1761
1778
  });
1762
1779
 
1763
- let CCDK = { CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
1764
- Vue.prototype.$CCDK = CCDK;
1780
+ let CCDK = { CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
1781
+ Vue.prototype.$CCDK = CCDK;
1765
1782
  window.$CCDK = CCDK;
1766
1783
 
1767
1784
  export { CCDK as default };