cloudcc-ccdk 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +257 -249
  2. package/lib/ccdk.js +615 -599
  3. package/lib/ccdk.min.js +1 -1
  4. package/package.json +30 -30
package/lib/ccdk.js CHANGED
@@ -6,69 +6,69 @@ import axios from 'axios';
6
6
  import { Message, MessageBox, Notification } from 'element-ui';
7
7
  import Cookies from 'js-cookie';
8
8
 
9
- /**
10
- * 加密
11
- * @param {String} data 数据
12
- * @param {String} key 密钥
13
- * @param {String} iv 偏移量
14
- * @returns
15
- */
16
- function getAesString(data, key, iv) {
17
- key = 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
- }
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
+ }
72
72
  }
73
73
 
74
74
  var Crypto = /*#__PURE__*/Object.freeze({
@@ -77,27 +77,27 @@ var Crypto = /*#__PURE__*/Object.freeze({
77
77
  decrypt: decrypt
78
78
  });
79
79
 
80
- // 当前应用存储标识
81
- const APPLICATION_DETAIL = 'applicaton_current';
82
- /**
83
- * 获得当前访问的应用对象
84
- */
85
- function getApplicaton() {
86
- let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
87
- if (detail) {
88
- return JSON.parse(detail)
89
- }
90
- return ''
91
- }
92
-
93
- /**
94
- * 设置应用对象信息
95
- * @param {object} detail 应用对象
96
- */
97
- function setApplication(detail = '') {
98
- if (detail) {
99
- localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
100
- }
80
+ // 当前应用存储标识
81
+ const APPLICATION_DETAIL = 'applicaton_current';
82
+ /**
83
+ * 获得当前访问的应用对象
84
+ */
85
+ function getApplicaton() {
86
+ let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
87
+ if (detail) {
88
+ return JSON.parse(detail)
89
+ }
90
+ return ''
91
+ }
92
+
93
+ /**
94
+ * 设置应用对象信息
95
+ * @param {object} detail 应用对象
96
+ */
97
+ function setApplication(detail = '') {
98
+ if (detail) {
99
+ localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
100
+ }
101
101
  }
102
102
 
103
103
  var CCApplication = /*#__PURE__*/Object.freeze({
@@ -106,29 +106,29 @@ var CCApplication = /*#__PURE__*/Object.freeze({
106
106
  setApplication: setApplication
107
107
  });
108
108
 
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);
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);
132
132
  }
133
133
 
134
134
  var CCBus = /*#__PURE__*/Object.freeze({
@@ -138,57 +138,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
138
138
  $off: $off
139
139
  });
140
140
 
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
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
192
192
  }
193
193
 
194
194
  var CCCall = /*#__PURE__*/Object.freeze({
@@ -198,26 +198,26 @@ var CCCall = /*#__PURE__*/Object.freeze({
198
198
  openCallPanel: openCallPanel
199
199
  });
200
200
 
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;
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;
221
221
  }
222
222
 
223
223
  var CCConfig = /*#__PURE__*/Object.freeze({
@@ -227,76 +227,76 @@ var CCConfig = /*#__PURE__*/Object.freeze({
227
227
  getSvc: getSvc
228
228
  });
229
229
 
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
- })
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
+ })
300
300
  }
301
301
 
302
302
  var CCHttp = /*#__PURE__*/Object.freeze({
@@ -308,47 +308,61 @@ var CCHttp = /*#__PURE__*/Object.freeze({
308
308
  postParams: postParams
309
309
  });
310
310
 
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);
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);
352
+ }
353
+ /**
354
+ * 替换一个一级菜单
355
+ * @param {object} options 菜单配置
356
+ */
357
+ function replaceMenu1(options) {
358
+ window.$CCDK.CCBus.$emit('replaceMenu1', options);
359
+ }
360
+ /**
361
+ * 替换一个二级菜单
362
+ * @param {object} options 菜单配置
363
+ */
364
+ function replaceMenu2(options) {
365
+ window.$CCDK.CCBus.$emit('replaceMenu2', options);
352
366
  }
353
367
 
354
368
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -358,46 +372,48 @@ var CCMenu = /*#__PURE__*/Object.freeze({
358
372
  deleteMenu1: deleteMenu1,
359
373
  deleteMenu2: deleteMenu2,
360
374
  refreshMenu1: refreshMenu1,
361
- refreshMenu2: refreshMenu2
375
+ refreshMenu2: refreshMenu2,
376
+ replaceMenu1: replaceMenu1,
377
+ replaceMenu2: replaceMenu2
362
378
  });
363
379
 
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);
380
+ /**
381
+ * 消息提示框
382
+ * @param {string} text 提示文字,支持vhtml渲染
383
+ * @param {string} type 消息类别
384
+ * @param {number} duration 持续时间
385
+ * @param {boolean} showClose 是否显示消息关闭按钮
386
+ * @param {boolean} center 文字是否剧中
387
+ */
388
+ function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
389
+ Message({
390
+ message: text,
391
+ type,
392
+ duration,
393
+ showClose,
394
+ center
395
+ });
396
+ }
397
+ /**
398
+ * 提示确认框
399
+ * @param {string} text 提示信息
400
+ * @param {string} title 标题
401
+ * @param {object} options 配置信息
402
+ */
403
+ function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
404
+ MessageBox.confirm(text, title, options).then(() => {
405
+ confirm();
406
+ }).catch(() => {
407
+ reject();
408
+ });
409
+ }
410
+
411
+ /**
412
+ * 提示消息框
413
+ * @param {object} options 配置信息
414
+ */
415
+ function showNotification(options = {}) {
416
+ Notification(options);
401
417
  }
402
418
 
403
419
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -407,78 +423,78 @@ var CCMessage = /*#__PURE__*/Object.freeze({
407
423
  showNotification: showNotification
408
424
  });
409
425
 
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
- }
426
+ // 对象详情存储标识
427
+ const OBJECT_DETAIL = 'cc_object_detail';
428
+ // 对象存储标识
429
+ const OBJECT = 'cc_object';
430
+
431
+ /**
432
+ * 获得当前标准对象信息
433
+ */
434
+ function getObject( ) {
435
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
436
+ if (detail) {
437
+ return JSON.parse(detail)
438
+ }
439
+ return ''
440
+ }
441
+
442
+ /**
443
+ * 设置当前标准对象信息
444
+ * @param {object} detail 对象数据
445
+ */
446
+ function setObject(detail = '') {
447
+ if (detail) {
448
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
449
+ }
450
+ }
451
+
452
+ /**
453
+ * 获得当前标准对象的详细信息
454
+ * @param {String} apiname: 查找字段的apiname
455
+ */
456
+ function getObjectDetail(apiname) {
457
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
458
+ if (detail) {
459
+ if(apiname){
460
+ let detailObj = JSON.parse(detail).detail;
461
+ let targetField = undefined;
462
+ if(Array.isArray(detailObj)){
463
+ targetField = detailObj.find(item=>item.apiname===apiname);
464
+ }
465
+ return targetField
466
+ }else {
467
+ return JSON.parse(detail)
468
+ }
469
+ }
470
+ return ''
471
+ }
472
+
473
+ /**
474
+ * 设置当前标准对象的详细信息,默认两个小时有效期
475
+ * @param {object} detail 对象详细数据
476
+ */
477
+ function setObjectDetail(detail = '') {
478
+ if (detail) {
479
+ // 减少detail.detail层级
480
+ if(Array.isArray(detail.detail)){
481
+ let data = [];
482
+ detail.detail.forEach(item=>{
483
+ if(item && Array.isArray(item.data)){
484
+ item.data.forEach(itemData=>{
485
+ if(itemData.left && !Array.isArray(itemData.left)){
486
+ data.push(itemData.left);
487
+ }
488
+ if(itemData.right && !Array.isArray(itemData.right)){
489
+ data.push(itemData.right);
490
+ }
491
+ });
492
+ }
493
+ });
494
+ if(data.length > 0){detail.detail = data;}
495
+ }
496
+ localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
497
+ }
482
498
  }
483
499
 
484
500
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -489,125 +505,125 @@ var CCObject = /*#__PURE__*/Object.freeze({
489
505
  setObjectDetail: setObjectDetail
490
506
  });
491
507
 
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
- }
508
+ /**
509
+ * 用于保存打开的页面集合
510
+ */
511
+ let pageList = new Map();
512
+ /**
513
+ * 打开对象视图页面
514
+ * @param {object} obj 对象信息
515
+ * @param {object} options 配置信息
516
+ */
517
+ function openListPage(obj, options = {}) {
518
+ let pageId = Math.random().toString(16).slice(2);
519
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
520
+ return pageId;
521
+ }
522
+
523
+ /**
524
+ * 打开数据详情页
525
+ * @param {object} obj 对象体
526
+ * @param {string} id 数据id
527
+ * @param {object} options 配置信息
528
+ */
529
+ function openDetailPage(obj, id, options = {}) {
530
+ let pageId = Math.random().toString(16).slice(2);
531
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
532
+ return pageId;
533
+ }
534
+
535
+ /**
536
+ * 打开创建页面
537
+ * @param {object} obj 对象体
538
+ * @param {object} options 配置信息
539
+ */
540
+ function openCreatePage(obj, options = {}) {
541
+ let pageId = Math.random().toString(16).slice(2);
542
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
543
+ return pageId;
544
+ }
545
+
546
+ /**
547
+ * 打开修改页面
548
+ * @param {object} obj 对象体
549
+ * @param {string} id 数据id
550
+ * @param {object} options 配置信息
551
+ */
552
+ function openEditPage(obj, id, options = {}) {
553
+ let pageId = Math.random().toString(16).slice(2);
554
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
555
+ return pageId;
556
+ }
557
+ /**
558
+ * 打开自定义页面
559
+ * @param {object} obj 自定义页面参数
560
+ * @param {object} options 配置信息
561
+ */
562
+ function openCustomPage(obj, options = {}) {
563
+ let pageId = Math.random().toString(16).slice(2);
564
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
565
+ return pageId;
566
+ }
567
+
568
+ /**
569
+ * 通过页面id,重新打开某个页面
570
+ * @param {string} pageId 页面id
571
+ * @param {object} options 配置信息
572
+ */
573
+ function reOpenPage(pageId, options) {
574
+ let page;
575
+ if (pageId) {
576
+ page = pageList.get(pageId);
577
+ }
578
+ if (page) {
579
+ page.reOpenPage();
580
+ if (options.refresh) {
581
+ page.refresh();
582
+ }
583
+ }
584
+ }
585
+
586
+ /**
587
+ * 将打开的页面添加到集合中
588
+ * @param {string} id 唯一ID
589
+ * @param {object} page 页面对象
590
+ */
591
+ function addPage(id, page) {
592
+ if (id && page) {
593
+ pageList.set(id, page);
594
+ }
595
+ }
596
+
597
+
598
+ /**
599
+ * 关闭页面,如果pageId为null,那么关闭当前页面
600
+ * @param {string} pageId 页面id
601
+ */
602
+ function close(pageId = '') {
603
+ let page;
604
+ if (pageId) {
605
+ page = pageList.get(pageId);
606
+ } else {
607
+ if (pageList.size > 0) {
608
+ page = [...pageList.values()][pageList.size - 1];
609
+ }
610
+ }
611
+ if (page) {
612
+ page.close();
613
+ }
614
+ }
615
+ /**
616
+ * 刷新页面
617
+ * @param {string} pageId 页面id
618
+ */
619
+ function refresh(pageId = '') {
620
+ let page;
621
+ if (pageId) {
622
+ page = pageList.get(pageId);
623
+ }
624
+ if (page) {
625
+ page.refresh();
626
+ }
611
627
  }
612
628
 
613
629
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -623,19 +639,19 @@ var CCPage = /*#__PURE__*/Object.freeze({
623
639
  refresh: refresh
624
640
  });
625
641
 
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
- }
642
+ /**
643
+ * 获得一级域名
644
+ * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
645
+ */
646
+ function getDomain() {
647
+ // 倒数第二位域名
648
+ let lastTow = document.domain.split('.').slice(-2, -1)[0];
649
+ // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
650
+ if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
651
+ return "." + document.domain.split('.').slice(-3).join('.')
652
+ } else {
653
+ return "." + document.domain.split('.').slice(-2).join('.')
654
+ }
639
655
  }
640
656
 
641
657
  var CCUtils = /*#__PURE__*/Object.freeze({
@@ -643,49 +659,49 @@ var CCUtils = /*#__PURE__*/Object.freeze({
643
659
  getDomain: getDomain
644
660
  });
645
661
 
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));
662
+ // cookie存储标识
663
+ const TOKEN = "cc_token";
664
+ /**
665
+ * 获取URL中参数的数据
666
+ * @param {name} 参数名
667
+ */
668
+ function getUrlQuery(name) {
669
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
670
+ var r = window.location.href.match(reg);
671
+ let res = null;
672
+ if (r != null) res = r[1].trim();
673
+ return res;
674
+ }
675
+ /**
676
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
677
+ * @param {String} urlName 获取token的url名称
678
+ * @returns
679
+ */
680
+ function getToken(urlName = "binding") {
681
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
682
+ // 如果存在token,那么存储到cookies中,刷新有效期
683
+ if (token) {
684
+ setToken(token);
685
+ }
686
+ return token
687
+ }
688
+ /**
689
+ * 存储token
690
+ * @param {String} token token
691
+ * @param {String} domain 域名
692
+ */
693
+ function setToken(token, domain = getDomain()) {
694
+ Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
695
+ Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
696
+ }
697
+
698
+ /**
699
+ * 清除Token数据
700
+ * @param {String} domain 域名
701
+ */
702
+ function clearToken(domain = getDomain()) {
703
+ Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
704
+ Cookies.remove(Crypto.encrypt(TOKEN));
689
705
  }
690
706
 
691
707
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -695,31 +711,31 @@ var CCToken = /*#__PURE__*/Object.freeze({
695
711
  clearToken: clearToken
696
712
  });
697
713
 
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
- }
714
+ // cookie存储标识
715
+ const USER_INFO = "cc_user_info";
716
+
717
+ /**
718
+ * 存储用户信息
719
+ * @param {String} userInfo 用户信息
720
+ * @param {String} domain 域名
721
+ */
722
+ function setUserInfo(userInfo, domain = getDomain()) {
723
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
724
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
725
+ }
726
+
727
+ /**
728
+ * 获取用户信息
729
+ * @returns {String} 用户信息
730
+ */
731
+ function getUserInfo() {
732
+ // 加密的用户信息
733
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
734
+ if (encryptUserInfo) {
735
+ return Crypto.decrypt(encryptUserInfo)
736
+ } else {
737
+ return ""
738
+ }
723
739
  }
724
740
 
725
741
  var CCUser = /*#__PURE__*/Object.freeze({