cloudcc-ccdk 0.3.5 → 0.3.7

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 +249 -233
  2. package/lib/ccdk.js +599 -597
  3. package/lib/ccdk.min.js +1 -1
  4. package/package.json +29 -28
package/lib/ccdk.js CHANGED
@@ -1,73 +1,74 @@
1
1
  import CryptoJS from 'crypto-js/aes';
2
2
  import UTF8 from 'crypto-js/enc-utf8';
3
3
  import PAD from 'crypto-js/pad-pkcs7';
4
+ import Vue from 'vue';
4
5
  import axios from 'axios';
5
6
  import { Message, MessageBox, Notification } from 'element-ui';
6
7
  import Cookies from 'js-cookie';
7
8
 
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 = UTF8.parse(key);
17
- iv = UTF8.parse(iv);
18
- let encrypted = CryptoJS.encrypt(data, key, {
19
- iv: iv,
20
- padding: PAD,
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 = UTF8.parse(key);
34
- iv = UTF8.parse(iv);
35
- let decrypted = CryptoJS.decrypt(encrypted, key, {
36
- iv: iv,
37
- padding: PAD,
38
- });
39
- return decrypted.toString(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
- }
9
+ /**
10
+ * 加密
11
+ * @param {String} data 数据
12
+ * @param {String} key 密钥
13
+ * @param {String} iv 偏移量
14
+ * @returns
15
+ */
16
+ function getAesString(data, key, iv) {
17
+ key = UTF8.parse(key);
18
+ iv = UTF8.parse(iv);
19
+ let encrypted = CryptoJS.encrypt(data, key, {
20
+ iv: iv,
21
+ padding: PAD,
22
+ });
23
+ return encrypted.toString(); //返回的是base64格式的密文
24
+ }
25
+
26
+ /**
27
+ * 解密
28
+ * @param {String} encrypted 密文
29
+ * @param {String} key 密钥
30
+ * @param {String} iv 偏移量
31
+ * @returns
32
+ */
33
+ function getDAesString(encrypted, key, iv) {
34
+ key = UTF8.parse(key);
35
+ iv = UTF8.parse(iv);
36
+ let decrypted = CryptoJS.decrypt(encrypted, key, {
37
+ iv: iv,
38
+ padding: PAD,
39
+ });
40
+ return decrypted.toString(UTF8);
41
+ }
42
+
43
+ /**
44
+ * CryptoJS加密
45
+ * @param {String} data 数据
46
+ * @param {String} key 密钥
47
+ * @param {String} iv 偏移量
48
+ * @returns 加密的数据
49
+ */
50
+ function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
51
+ data = JSON.stringify(data);
52
+ var encrypted = getAesString(data, key, iv); //密文
53
+ return encrypted;
54
+ }
55
+
56
+ /**
57
+ * CryptoJS解密
58
+ * @param {String} data 加密的数据
59
+ * @param {String} key 密钥
60
+ * @param {String} iv 偏移量
61
+ * @returns 解密的数据
62
+ */
63
+ function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
64
+ try {
65
+ var decryptedStr = getDAesString(data, key, iv);
66
+ if (!decryptedStr) return null
67
+ return JSON.parse(decryptedStr);
68
+ } catch (error) {
69
+ console.trace("解密密码错误", error);
70
+ return null;
71
+ }
71
72
  }
72
73
 
73
74
  var Crypto = /*#__PURE__*/Object.freeze({
@@ -76,27 +77,27 @@ var Crypto = /*#__PURE__*/Object.freeze({
76
77
  decrypt: decrypt
77
78
  });
78
79
 
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
- }
80
+ // 当前应用存储标识
81
+ const APPLICATION_DETAIL = 'applicaton_current';
82
+ /**
83
+ * 获得当前访问的应用对象
84
+ */
85
+ function getApplicaton() {
86
+ let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
87
+ if (detail) {
88
+ return JSON.parse(detail)
89
+ }
90
+ return ''
91
+ }
92
+
93
+ /**
94
+ * 设置应用对象信息
95
+ * @param {object} detail 应用对象
96
+ */
97
+ function setApplication(detail = '') {
98
+ if (detail) {
99
+ localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
100
+ }
100
101
  }
101
102
 
102
103
  var CCApplication = /*#__PURE__*/Object.freeze({
@@ -105,28 +106,29 @@ var CCApplication = /*#__PURE__*/Object.freeze({
105
106
  setApplication: setApplication
106
107
  });
107
108
 
108
- /**
109
- * 发布信息
110
- * @param {string} event 事件名称
111
- * @param {...any} args 参数列表
112
- */
113
- function $emit(event, ...args) {
114
- window.ccBus.$emit(event, ...args);
115
- }
116
- /**
117
- * 订阅消息
118
- * @param {string} event 事件名称
119
- * @param {function} callback 回调方法
120
- */
121
- function $on(event, callback) {
122
- window.ccBus.$on(event, callback);
123
- }
124
- /**
125
- * 取消订阅
126
- * @param {string} event 事件名称
127
- */
128
- function $off(event) {
129
- window.ccBus.$off(event);
109
+ window.ccBus = new Vue;
110
+ /**
111
+ * 发布信息
112
+ * @param {string} event 事件名称
113
+ * @param {...any} args 参数列表
114
+ */
115
+ function $emit(event, ...args) {
116
+ window.ccBus.$emit(event, ...args);
117
+ }
118
+ /**
119
+ * 订阅消息
120
+ * @param {string} event 事件名称
121
+ * @param {function} callback 回调方法
122
+ */
123
+ function $on(event, callback) {
124
+ window.ccBus.$on(event, callback);
125
+ }
126
+ /**
127
+ * 取消订阅
128
+ * @param {string} event 事件名称
129
+ */
130
+ function $off(event) {
131
+ window.ccBus.$off(event);
130
132
  }
131
133
 
132
134
  var CCBus = /*#__PURE__*/Object.freeze({
@@ -136,57 +138,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
136
138
  $off: $off
137
139
  });
138
140
 
139
- // 电话对象
140
- let ccCall = new Map();
141
- // 电话服务商当前对象
142
- let currentCall;
143
- /**
144
- * 初始化电话条
145
- * @param {string} id 电话服务商唯一标识
146
- * @param {object} callClient 电话对象
147
- */
148
- function init(id, callClient) {
149
- if (id && callClient) {
150
- ccCall.set(id, callClient);
151
- currentCall = callClient;
152
- return currentCall
153
- }
154
- }
155
-
156
-
157
- /**
158
- * 拨打电话
159
- * @param {string} id 电话服务商唯一标识
160
- * @param {object} options 配置信息
161
- */
162
- function call(id, options) {
163
- let call;
164
- if (id) {
165
- call = ccCall.get(id);
166
- } else {
167
- call = currentCall;
168
- }
169
- if (call) {
170
- call.call(options);
171
- }
172
- return call
173
- }
174
- /**
175
- * 打开通话面板
176
- * @param {string} id 电话服务商唯一标识
177
- * @param {object} options 配置信息
178
- */
179
- function openCallPanel(id, options) {
180
- let call;
181
- if (id) {
182
- call = ccCall.get(id);
183
- } else {
184
- call = currentCall;
185
- }
186
- if (call) {
187
- call.openCallPanel(options);
188
- }
189
- return call
141
+ // 电话对象
142
+ let ccCall = new Map();
143
+ // 电话服务商当前对象
144
+ let currentCall;
145
+ /**
146
+ * 初始化电话条
147
+ * @param {string} id 电话服务商唯一标识
148
+ * @param {object} callClient 电话对象
149
+ */
150
+ function init(id, callClient) {
151
+ if (id && callClient) {
152
+ ccCall.set(id, callClient);
153
+ currentCall = callClient;
154
+ return currentCall
155
+ }
156
+ }
157
+
158
+
159
+ /**
160
+ * 拨打电话
161
+ * @param {string} id 电话服务商唯一标识
162
+ * @param {object} options 配置信息
163
+ */
164
+ function call(id, options) {
165
+ let call;
166
+ if (id) {
167
+ call = ccCall.get(id);
168
+ } else {
169
+ call = currentCall;
170
+ }
171
+ if (call) {
172
+ call.call(options);
173
+ }
174
+ return call
175
+ }
176
+ /**
177
+ * 打开通话面板
178
+ * @param {string} id 电话服务商唯一标识
179
+ * @param {object} options 配置信息
180
+ */
181
+ function openCallPanel(id, options) {
182
+ let call;
183
+ if (id) {
184
+ call = ccCall.get(id);
185
+ } else {
186
+ call = currentCall;
187
+ }
188
+ if (call) {
189
+ call.openCallPanel(options);
190
+ }
191
+ return call
190
192
  }
191
193
 
192
194
  var CCCall = /*#__PURE__*/Object.freeze({
@@ -196,26 +198,26 @@ var CCCall = /*#__PURE__*/Object.freeze({
196
198
  openCallPanel: openCallPanel
197
199
  });
198
200
 
199
- /**
200
- * 获取基础url
201
- * @returns 基础地址
202
- */
203
- function getBaseUrl() {
204
- return window.gw.BASE_URL
205
- }
206
- /**
207
- * 获取网关对象
208
- * @returns 网关对象
209
- */
210
- function getGw() {
211
- return window.gw;
212
- }
213
- /**
214
- * 获取服务对象
215
- * @returns 服务对象
216
- */
217
- function getSvc() {
218
- return window.Glod;
201
+ /**
202
+ * 获取基础url
203
+ * @returns 基础地址
204
+ */
205
+ function getBaseUrl() {
206
+ return window.gw.BASE_URL
207
+ }
208
+ /**
209
+ * 获取网关对象
210
+ * @returns 网关对象
211
+ */
212
+ function getGw() {
213
+ return window.gw;
214
+ }
215
+ /**
216
+ * 获取服务对象
217
+ * @returns 服务对象
218
+ */
219
+ function getSvc() {
220
+ return window.Glod;
219
221
  }
220
222
 
221
223
  var CCConfig = /*#__PURE__*/Object.freeze({
@@ -225,76 +227,76 @@ var CCConfig = /*#__PURE__*/Object.freeze({
225
227
  getSvc: getSvc
226
228
  });
227
229
 
228
- const service = axios.create({
229
- timeout: 60000,
230
- headers: {
231
- 'Content-Type': 'application/json; charset=utf-8',
232
- },
233
- });
234
-
235
- service.interceptors.request.use(
236
- config => {
237
- config.headers['accessToken'] = $CCDK.CCToken.getToken();
238
- return config
239
- },
240
- error => {
241
- Promise.reject(error);
242
- }
243
- );
244
-
245
- service.interceptors.response.use(
246
- response => {
247
- const code = response.data.code || 200;
248
- if (code !== 200) {
249
- return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
250
- } else {
251
- return response.data
252
- }
253
- },
254
- error => {
255
- return Promise.reject(error)
256
- }
257
- );
258
- function get(url, data = {}, responseType = '') {
259
- return service({
260
- url: url,
261
- method: 'get',
262
- params: data,
263
- responseType: responseType
264
- })
265
- }
266
-
267
- function post(url, data = {}, responseType = '') {
268
- return service({
269
- url: url,
270
- method: 'post',
271
- data: data,
272
- responseType: responseType
273
- })
274
- }
275
-
276
- function put(url, data = {}) {
277
- return service({
278
- url: url,
279
- method: 'put',
280
- data: data
281
- })
282
- }
283
-
284
- function postParams(url, data = {}) {
285
- return service({
286
- url: url,
287
- method: 'post',
288
- params: data
289
- })
290
- }
291
-
292
- function patch(url, data = {}) {
293
- return service({
294
- url: url,
295
- method: 'patch',
296
- data: data
297
- })
230
+ const service = axios.create({
231
+ timeout: 60000,
232
+ headers: {
233
+ 'Content-Type': 'application/json; charset=utf-8',
234
+ },
235
+ });
236
+
237
+ service.interceptors.request.use(
238
+ config => {
239
+ config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
240
+ return config
241
+ },
242
+ error => {
243
+ Promise.reject(error);
244
+ }
245
+ );
246
+
247
+ service.interceptors.response.use(
248
+ response => {
249
+ const code = response.data.code || 200;
250
+ if (code !== 200) {
251
+ return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
252
+ } else {
253
+ return response.data
254
+ }
255
+ },
256
+ error => {
257
+ return Promise.reject(error)
258
+ }
259
+ );
260
+ function get(url, data = {}, responseType = '') {
261
+ return service({
262
+ url: url,
263
+ method: 'get',
264
+ params: data,
265
+ responseType: responseType
266
+ })
267
+ }
268
+
269
+ function post(url, data = {}, responseType = '') {
270
+ return service({
271
+ url: url,
272
+ method: 'post',
273
+ data: data,
274
+ responseType: responseType
275
+ })
276
+ }
277
+
278
+ function put(url, data = {}) {
279
+ return service({
280
+ url: url,
281
+ method: 'put',
282
+ data: data
283
+ })
284
+ }
285
+
286
+ function postParams(url, data = {}) {
287
+ return service({
288
+ url: url,
289
+ method: 'post',
290
+ params: data
291
+ })
292
+ }
293
+
294
+ function patch(url, data = {}) {
295
+ return service({
296
+ url: url,
297
+ method: 'patch',
298
+ data: data
299
+ })
298
300
  }
299
301
 
300
302
  var CCHttp = /*#__PURE__*/Object.freeze({
@@ -306,47 +308,47 @@ var CCHttp = /*#__PURE__*/Object.freeze({
306
308
  postParams: postParams
307
309
  });
308
310
 
309
- /**
310
- * 添加一个一级菜单
311
- * @param {object} options 菜单配置
312
- */
313
- function addMenu1(options) {
314
- $CCDK.CCBus.$emit('addMenu1', options);
315
- }
316
- /**
317
- * 添加一个二级菜单
318
- * @param {object} options 菜单配置
319
- */
320
- function addMenu2(options) {
321
- $CCDK.CCBus.$emit('addMenu2', options);
322
- }
323
- /**
324
- * 删除一个一级菜单
325
- * @param {object} options 菜单配置
326
- */
327
- function deleteMenu1(options) {
328
- $CCDK.CCBus.$emit('deleteMenu1', options);
329
- }
330
- /**
331
- * 删除一个二级菜单
332
- * @param {object} options 菜单配置
333
- */
334
- function deleteMenu2(options) {
335
- $CCDK.CCBus.$emit('deleteMenu2', options);
336
- }
337
- /**
338
- * 刷新一个一级菜单
339
- * @param {object} options 菜单配置
340
- */
341
- function refreshMenu1(options) {
342
- $CCDK.CCBus.$emit('refreshMenu1', options);
343
- }
344
- /**
345
- * 刷新一个二级菜单
346
- * @param {object} options 菜单配置
347
- */
348
- function refreshMenu2(options) {
349
- $CCDK.CCBus.$emit('refreshMenu2', options);
311
+ /**
312
+ * 添加一个一级菜单
313
+ * @param {object} options 菜单配置
314
+ */
315
+ function addMenu1(options) {
316
+ window.$CCDK.CCBus.$emit('addMenu1', options);
317
+ }
318
+ /**
319
+ * 添加一个二级菜单
320
+ * @param {object} options 菜单配置
321
+ */
322
+ function addMenu2(options) {
323
+ window.$CCDK.CCBus.$emit('addMenu2', options);
324
+ }
325
+ /**
326
+ * 删除一个一级菜单
327
+ * @param {object} options 菜单配置
328
+ */
329
+ function deleteMenu1(options) {
330
+ window.$CCDK.CCBus.$emit('deleteMenu1', options);
331
+ }
332
+ /**
333
+ * 删除一个二级菜单
334
+ * @param {object} options 菜单配置
335
+ */
336
+ function deleteMenu2(options) {
337
+ window.$CCDK.CCBus.$emit('deleteMenu2', options);
338
+ }
339
+ /**
340
+ * 刷新一个一级菜单
341
+ * @param {object} options 菜单配置
342
+ */
343
+ function refreshMenu1(options) {
344
+ window.$CCDK.CCBus.$emit('refreshMenu1', options);
345
+ }
346
+ /**
347
+ * 刷新一个二级菜单
348
+ * @param {object} options 菜单配置
349
+ */
350
+ function refreshMenu2(options) {
351
+ window.$CCDK.CCBus.$emit('refreshMenu2', options);
350
352
  }
351
353
 
352
354
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -359,43 +361,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
359
361
  refreshMenu2: refreshMenu2
360
362
  });
361
363
 
362
- /**
363
- * 消息提示框
364
- * @param {string} text 提示文字,支持vhtml渲染
365
- * @param {string} type 消息类别
366
- * @param {number} duration 持续时间
367
- * @param {boolean} showClose 是否显示消息关闭按钮
368
- * @param {boolean} center 文字是否剧中
369
- */
370
- function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
371
- Message({
372
- message: text,
373
- type,
374
- duration,
375
- showClose,
376
- center
377
- });
378
- }
379
- /**
380
- * 提示确认框
381
- * @param {string} text 提示信息
382
- * @param {string} title 标题
383
- * @param {object} options 配置信息
384
- */
385
- function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
386
- MessageBox.confirm(text, title, options).then(() => {
387
- confirm();
388
- }).catch(() => {
389
- reject();
390
- });
391
- }
392
-
393
- /**
394
- * 提示消息框
395
- * @param {object} options 配置信息
396
- */
397
- function showNotification(options = {}) {
398
- Notification(options);
364
+ /**
365
+ * 消息提示框
366
+ * @param {string} text 提示文字,支持vhtml渲染
367
+ * @param {string} type 消息类别
368
+ * @param {number} duration 持续时间
369
+ * @param {boolean} showClose 是否显示消息关闭按钮
370
+ * @param {boolean} center 文字是否剧中
371
+ */
372
+ function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
373
+ Message({
374
+ message: text,
375
+ type,
376
+ duration,
377
+ showClose,
378
+ center
379
+ });
380
+ }
381
+ /**
382
+ * 提示确认框
383
+ * @param {string} text 提示信息
384
+ * @param {string} title 标题
385
+ * @param {object} options 配置信息
386
+ */
387
+ function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
388
+ MessageBox.confirm(text, title, options).then(() => {
389
+ confirm();
390
+ }).catch(() => {
391
+ reject();
392
+ });
393
+ }
394
+
395
+ /**
396
+ * 提示消息框
397
+ * @param {object} options 配置信息
398
+ */
399
+ function showNotification(options = {}) {
400
+ Notification(options);
399
401
  }
400
402
 
401
403
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -405,78 +407,78 @@ var CCMessage = /*#__PURE__*/Object.freeze({
405
407
  showNotification: showNotification
406
408
  });
407
409
 
408
- // 对象详情存储标识
409
- const OBJECT_DETAIL = 'cc_object_detail';
410
- // 对象存储标识
411
- const OBJECT = 'cc_object';
412
-
413
- /**
414
- * 获得当前标准对象信息
415
- */
416
- function getObject( ) {
417
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
418
- if (detail) {
419
- return JSON.parse(detail)
420
- }
421
- return ''
422
- }
423
-
424
- /**
425
- * 设置当前标准对象信息
426
- * @param {object} detail 对象数据
427
- */
428
- function setObject(detail = '') {
429
- if (detail) {
430
- localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
431
- }
432
- }
433
-
434
- /**
435
- * 获得当前标准对象的详细信息
436
- * @param {String} apiname: 查找字段的apiname
437
- */
438
- function getObjectDetail(apiname) {
439
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
440
- if (detail) {
441
- if(apiname){
442
- let detail = JSON.parse(detail).detail;
443
- let targetField = undefined;
444
- if(Array.isArray(detail)){
445
- targetField = detail.find(item=>item.apiname===apiname);
446
- }
447
- return targetField
448
- }else {
449
- return JSON.parse(detail)
450
- }
451
- }
452
- return ''
453
- }
454
-
455
- /**
456
- * 设置当前标准对象的详细信息,默认两个小时有效期
457
- * @param {object} detail 对象详细数据
458
- */
459
- function setObjectDetail(detail = '') {
460
- if (detail) {
461
- // 减少detail.detail层级
462
- if(Array.isArray(detail.detail)){
463
- let data = [];
464
- detail.detail.forEach(item=>{
465
- if(item && Array.isArray(item.data)){
466
- item.data.forEach(itemData=>{
467
- if(itemData.left && !Array.isArray(itemData.left)){
468
- data.push(itemData.left);
469
- }
470
- if(itemData.right && !Array.isArray(itemData.right)){
471
- data.push(itemData.right);
472
- }
473
- });
474
- }
475
- });
476
- if(data.length > 0){detail.detail = data;}
477
- }
478
- localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
479
- }
410
+ // 对象详情存储标识
411
+ const OBJECT_DETAIL = 'cc_object_detail';
412
+ // 对象存储标识
413
+ const OBJECT = 'cc_object';
414
+
415
+ /**
416
+ * 获得当前标准对象信息
417
+ */
418
+ function getObject( ) {
419
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
420
+ if (detail) {
421
+ return JSON.parse(detail)
422
+ }
423
+ return ''
424
+ }
425
+
426
+ /**
427
+ * 设置当前标准对象信息
428
+ * @param {object} detail 对象数据
429
+ */
430
+ function setObject(detail = '') {
431
+ if (detail) {
432
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
433
+ }
434
+ }
435
+
436
+ /**
437
+ * 获得当前标准对象的详细信息
438
+ * @param {String} apiname: 查找字段的apiname
439
+ */
440
+ function getObjectDetail(apiname) {
441
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
442
+ if (detail) {
443
+ if(apiname){
444
+ let detailObj = JSON.parse(detail).detail;
445
+ let targetField = undefined;
446
+ if(Array.isArray(detailObj)){
447
+ targetField = detailObj.find(item=>item.apiname===apiname);
448
+ }
449
+ return targetField
450
+ }else {
451
+ return JSON.parse(detail)
452
+ }
453
+ }
454
+ return ''
455
+ }
456
+
457
+ /**
458
+ * 设置当前标准对象的详细信息,默认两个小时有效期
459
+ * @param {object} detail 对象详细数据
460
+ */
461
+ function setObjectDetail(detail = '') {
462
+ if (detail) {
463
+ // 减少detail.detail层级
464
+ if(Array.isArray(detail.detail)){
465
+ let data = [];
466
+ detail.detail.forEach(item=>{
467
+ if(item && Array.isArray(item.data)){
468
+ item.data.forEach(itemData=>{
469
+ if(itemData.left && !Array.isArray(itemData.left)){
470
+ data.push(itemData.left);
471
+ }
472
+ if(itemData.right && !Array.isArray(itemData.right)){
473
+ data.push(itemData.right);
474
+ }
475
+ });
476
+ }
477
+ });
478
+ if(data.length > 0){detail.detail = data;}
479
+ }
480
+ localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
481
+ }
480
482
  }
481
483
 
482
484
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -487,125 +489,125 @@ var CCObject = /*#__PURE__*/Object.freeze({
487
489
  setObjectDetail: setObjectDetail
488
490
  });
489
491
 
490
- /**
491
- * 用于保存打开的页面集合
492
- */
493
- let pageList = new Map();
494
- /**
495
- * 打开对象视图页面
496
- * @param {object} obj 对象信息
497
- * @param {object} options 配置信息
498
- */
499
- function openListPage(obj, options = {}) {
500
- let pageId = Math.random().toString(16).slice(2);
501
- $CCDK.CCBus.$emit('openListPage', pageId, obj, options);
502
- return pageId;
503
- }
504
-
505
- /**
506
- * 打开数据详情页
507
- * @param {object} obj 对象体
508
- * @param {string} id 数据id
509
- * @param {object} options 配置信息
510
- */
511
- function openDetailPage(obj, id, options = {}) {
512
- let pageId = Math.random().toString(16).slice(2);
513
- $CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
514
- return pageId;
515
- }
516
-
517
- /**
518
- * 打开创建页面
519
- * @param {object} obj 对象体
520
- * @param {object} options 配置信息
521
- */
522
- function openCreatePage(obj, options = {}) {
523
- let pageId = Math.random().toString(16).slice(2);
524
- $CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
525
- return pageId;
526
- }
527
-
528
- /**
529
- * 打开修改页面
530
- * @param {object} obj 对象体
531
- * @param {string} id 数据id
532
- * @param {object} options 配置信息
533
- */
534
- function openEditPage(obj, id, options = {}) {
535
- let pageId = Math.random().toString(16).slice(2);
536
- $CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
537
- return pageId;
538
- }
539
- /**
540
- * 打开自定义页面
541
- * @param {object} obj 自定义页面参数
542
- * @param {object} options 配置信息
543
- */
544
- function openCustomPage(obj, options = {}) {
545
- let pageId = Math.random().toString(16).slice(2);
546
- $CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
547
- return pageId;
548
- }
549
-
550
- /**
551
- * 通过页面id,重新打开某个页面
552
- * @param {string} pageId 页面id
553
- * @param {object} options 配置信息
554
- */
555
- function reOpenPage(pageId, options) {
556
- let page;
557
- if (pageId) {
558
- page = pageList.get(pageId);
559
- }
560
- if (page) {
561
- page.reOpenPage();
562
- if (options.refresh) {
563
- page.refresh();
564
- }
565
- }
566
- }
567
-
568
- /**
569
- * 将打开的页面添加到集合中
570
- * @param {string} id 唯一ID
571
- * @param {object} page 页面对象
572
- */
573
- function addPage(id, page) {
574
- if (id && page) {
575
- pageList.set(id, page);
576
- }
577
- }
578
-
579
-
580
- /**
581
- * 关闭页面,如果pageId为null,那么关闭当前页面
582
- * @param {string} pageId 页面id
583
- */
584
- function close(pageId = '') {
585
- let page;
586
- if (pageId) {
587
- page = pageList.get(pageId);
588
- } else {
589
- if (pageList.size > 0) {
590
- page = [...pageList.values()][pageList.size - 1];
591
- }
592
- }
593
- if (page) {
594
- page.close();
595
- }
596
- }
597
- /**
598
- * 刷新页面
599
- * @param {string} pageId 页面id
600
- */
601
- function refresh(pageId = '') {
602
- let page;
603
- if (pageId) {
604
- page = pageList.get(pageId);
605
- }
606
- if (page) {
607
- page.refresh();
608
- }
492
+ /**
493
+ * 用于保存打开的页面集合
494
+ */
495
+ let pageList = new Map();
496
+ /**
497
+ * 打开对象视图页面
498
+ * @param {object} obj 对象信息
499
+ * @param {object} options 配置信息
500
+ */
501
+ function openListPage(obj, options = {}) {
502
+ let pageId = Math.random().toString(16).slice(2);
503
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
504
+ return pageId;
505
+ }
506
+
507
+ /**
508
+ * 打开数据详情页
509
+ * @param {object} obj 对象体
510
+ * @param {string} id 数据id
511
+ * @param {object} options 配置信息
512
+ */
513
+ function openDetailPage(obj, id, options = {}) {
514
+ let pageId = Math.random().toString(16).slice(2);
515
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
516
+ return pageId;
517
+ }
518
+
519
+ /**
520
+ * 打开创建页面
521
+ * @param {object} obj 对象体
522
+ * @param {object} options 配置信息
523
+ */
524
+ function openCreatePage(obj, options = {}) {
525
+ let pageId = Math.random().toString(16).slice(2);
526
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
527
+ return pageId;
528
+ }
529
+
530
+ /**
531
+ * 打开修改页面
532
+ * @param {object} obj 对象体
533
+ * @param {string} id 数据id
534
+ * @param {object} options 配置信息
535
+ */
536
+ function openEditPage(obj, id, options = {}) {
537
+ let pageId = Math.random().toString(16).slice(2);
538
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
539
+ return pageId;
540
+ }
541
+ /**
542
+ * 打开自定义页面
543
+ * @param {object} obj 自定义页面参数
544
+ * @param {object} options 配置信息
545
+ */
546
+ function openCustomPage(obj, options = {}) {
547
+ let pageId = Math.random().toString(16).slice(2);
548
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
549
+ return pageId;
550
+ }
551
+
552
+ /**
553
+ * 通过页面id,重新打开某个页面
554
+ * @param {string} pageId 页面id
555
+ * @param {object} options 配置信息
556
+ */
557
+ function reOpenPage(pageId, options) {
558
+ let page;
559
+ if (pageId) {
560
+ page = pageList.get(pageId);
561
+ }
562
+ if (page) {
563
+ page.reOpenPage();
564
+ if (options.refresh) {
565
+ page.refresh();
566
+ }
567
+ }
568
+ }
569
+
570
+ /**
571
+ * 将打开的页面添加到集合中
572
+ * @param {string} id 唯一ID
573
+ * @param {object} page 页面对象
574
+ */
575
+ function addPage(id, page) {
576
+ if (id && page) {
577
+ pageList.set(id, page);
578
+ }
579
+ }
580
+
581
+
582
+ /**
583
+ * 关闭页面,如果pageId为null,那么关闭当前页面
584
+ * @param {string} pageId 页面id
585
+ */
586
+ function close(pageId = '') {
587
+ let page;
588
+ if (pageId) {
589
+ page = pageList.get(pageId);
590
+ } else {
591
+ if (pageList.size > 0) {
592
+ page = [...pageList.values()][pageList.size - 1];
593
+ }
594
+ }
595
+ if (page) {
596
+ page.close();
597
+ }
598
+ }
599
+ /**
600
+ * 刷新页面
601
+ * @param {string} pageId 页面id
602
+ */
603
+ function refresh(pageId = '') {
604
+ let page;
605
+ if (pageId) {
606
+ page = pageList.get(pageId);
607
+ }
608
+ if (page) {
609
+ page.refresh();
610
+ }
609
611
  }
610
612
 
611
613
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -621,19 +623,19 @@ var CCPage = /*#__PURE__*/Object.freeze({
621
623
  refresh: refresh
622
624
  });
623
625
 
624
- /**
625
- * 获得一级域名
626
- * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
627
- */
628
- function getDomain() {
629
- // 倒数第二位域名
630
- let lastTow = document.domain.split('.').slice(-2, -1)[0];
631
- // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
632
- if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
633
- return "." + document.domain.split('.').slice(-3).join('.')
634
- } else {
635
- return "." + document.domain.split('.').slice(-2).join('.')
636
- }
626
+ /**
627
+ * 获得一级域名
628
+ * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
629
+ */
630
+ function getDomain() {
631
+ // 倒数第二位域名
632
+ let lastTow = document.domain.split('.').slice(-2, -1)[0];
633
+ // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
634
+ if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
635
+ return "." + document.domain.split('.').slice(-3).join('.')
636
+ } else {
637
+ return "." + document.domain.split('.').slice(-2).join('.')
638
+ }
637
639
  }
638
640
 
639
641
  var CCUtils = /*#__PURE__*/Object.freeze({
@@ -641,49 +643,49 @@ var CCUtils = /*#__PURE__*/Object.freeze({
641
643
  getDomain: getDomain
642
644
  });
643
645
 
644
- // cookie存储标识
645
- const TOKEN = "cc_token";
646
- /**
647
- * 获取URL中参数的数据
648
- * @param {name} 参数名
649
- */
650
- function getUrlQuery(name) {
651
- var reg = new RegExp(name + "=([^&]*)(&|$)");
652
- var r = window.location.href.match(reg);
653
- let res = null;
654
- if (r != null) res = r[1].trim();
655
- return res;
656
- }
657
- /**
658
- * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
659
- * @param {String} urlName 获取token的url名称
660
- * @returns
661
- */
662
- function getToken(urlName = "binding") {
663
- let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
664
- // 如果存在token,那么存储到cookies中,刷新有效期
665
- if (token) {
666
- setToken(token);
667
- }
668
- return token
669
- }
670
- /**
671
- * 存储token
672
- * @param {String} token token
673
- * @param {String} domain 域名
674
- */
675
- function setToken(token, domain = getDomain()) {
676
- Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
677
- Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
678
- }
679
-
680
- /**
681
- * 清除Token数据
682
- * @param {String} domain 域名
683
- */
684
- function clearToken(domain = getDomain()) {
685
- Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
686
- Cookies.remove(Crypto.encrypt(TOKEN));
646
+ // cookie存储标识
647
+ const TOKEN = "cc_token";
648
+ /**
649
+ * 获取URL中参数的数据
650
+ * @param {name} 参数名
651
+ */
652
+ function getUrlQuery(name) {
653
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
654
+ var r = window.location.href.match(reg);
655
+ let res = null;
656
+ if (r != null) res = r[1].trim();
657
+ return res;
658
+ }
659
+ /**
660
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
661
+ * @param {String} urlName 获取token的url名称
662
+ * @returns
663
+ */
664
+ function getToken(urlName = "binding") {
665
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
666
+ // 如果存在token,那么存储到cookies中,刷新有效期
667
+ if (token) {
668
+ setToken(token);
669
+ }
670
+ return token
671
+ }
672
+ /**
673
+ * 存储token
674
+ * @param {String} token token
675
+ * @param {String} domain 域名
676
+ */
677
+ function setToken(token, domain = getDomain()) {
678
+ Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
679
+ Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
680
+ }
681
+
682
+ /**
683
+ * 清除Token数据
684
+ * @param {String} domain 域名
685
+ */
686
+ function clearToken(domain = getDomain()) {
687
+ Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
688
+ Cookies.remove(Crypto.encrypt(TOKEN));
687
689
  }
688
690
 
689
691
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -693,31 +695,31 @@ var CCToken = /*#__PURE__*/Object.freeze({
693
695
  clearToken: clearToken
694
696
  });
695
697
 
696
- // cookie存储标识
697
- const USER_INFO = "cc_user_info";
698
-
699
- /**
700
- * 存储用户信息
701
- * @param {String} userInfo 用户信息
702
- * @param {String} domain 域名
703
- */
704
- function setUserInfo(userInfo, domain = getDomain()) {
705
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
706
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
707
- }
708
-
709
- /**
710
- * 获取用户信息
711
- * @returns {String} 用户信息
712
- */
713
- function getUserInfo() {
714
- // 加密的用户信息
715
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
716
- if (encryptUserInfo) {
717
- return Crypto.decrypt(encryptUserInfo)
718
- } else {
719
- return ""
720
- }
698
+ // cookie存储标识
699
+ const USER_INFO = "cc_user_info";
700
+
701
+ /**
702
+ * 存储用户信息
703
+ * @param {String} userInfo 用户信息
704
+ * @param {String} domain 域名
705
+ */
706
+ function setUserInfo(userInfo, domain = getDomain()) {
707
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
708
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
709
+ }
710
+
711
+ /**
712
+ * 获取用户信息
713
+ * @returns {String} 用户信息
714
+ */
715
+ function getUserInfo() {
716
+ // 加密的用户信息
717
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
718
+ if (encryptUserInfo) {
719
+ return Crypto.decrypt(encryptUserInfo)
720
+ } else {
721
+ return ""
722
+ }
721
723
  }
722
724
 
723
725
  var CCUser = /*#__PURE__*/Object.freeze({