cloudcc-ccdk 0.2.0 → 0.2.2
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.
- package/README.md +17 -0
- package/lib/ccdk.js +253 -124
- package/lib/ccdk.min.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
#### 发布版本:0.2.2
|
|
2
|
+
#### 更新日期:2022/11/7
|
|
3
|
+
#### 更新内容:
|
|
4
|
+
* 修复
|
|
5
|
+
* 迭代
|
|
6
|
+
* 优化
|
|
7
|
+
* 更新CCPage逻辑,更新CCMenu逻辑
|
|
8
|
+
|
|
9
|
+
#### 发布版本:0.2.1
|
|
10
|
+
#### 更新日期:2022/11/2
|
|
11
|
+
#### 更新内容:
|
|
12
|
+
* 修复
|
|
13
|
+
* 迭代
|
|
14
|
+
* 添加CCMenu
|
|
15
|
+
* 添加CCApplication
|
|
16
|
+
* 优化
|
|
17
|
+
|
|
1
18
|
#### 发布版本:0.2.0
|
|
2
19
|
#### 更新日期:2022/11/2
|
|
3
20
|
#### 更新内容:
|
package/lib/ccdk.js
CHANGED
|
@@ -5,6 +5,106 @@ import axios from 'axios';
|
|
|
5
5
|
import { Message, MessageBox, Notification } from 'element-ui';
|
|
6
6
|
import Cookies from 'js-cookie';
|
|
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 = 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
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var Crypto = /*#__PURE__*/Object.freeze({
|
|
74
|
+
__proto__: null,
|
|
75
|
+
encrypt: encrypt,
|
|
76
|
+
decrypt: decrypt
|
|
77
|
+
});
|
|
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
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var CCApplication = /*#__PURE__*/Object.freeze({
|
|
103
|
+
__proto__: null,
|
|
104
|
+
getApplicaton: getApplicaton,
|
|
105
|
+
setApplication: setApplication
|
|
106
|
+
});
|
|
107
|
+
|
|
8
108
|
/**
|
|
9
109
|
* 发布信息
|
|
10
110
|
* @param {string} event 事件名称
|
|
@@ -30,10 +130,10 @@ function $off(event) {
|
|
|
30
130
|
}
|
|
31
131
|
|
|
32
132
|
var CCBus = /*#__PURE__*/Object.freeze({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
133
|
+
__proto__: null,
|
|
134
|
+
$emit: $emit,
|
|
135
|
+
$on: $on,
|
|
136
|
+
$off: $off
|
|
37
137
|
});
|
|
38
138
|
|
|
39
139
|
// 电话对象
|
|
@@ -90,10 +190,10 @@ function openCallPanel(id, options) {
|
|
|
90
190
|
}
|
|
91
191
|
|
|
92
192
|
var CCCall = /*#__PURE__*/Object.freeze({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
193
|
+
__proto__: null,
|
|
194
|
+
init: init,
|
|
195
|
+
call: call,
|
|
196
|
+
openCallPanel: openCallPanel
|
|
97
197
|
});
|
|
98
198
|
|
|
99
199
|
/**
|
|
@@ -119,81 +219,10 @@ function getSvc() {
|
|
|
119
219
|
}
|
|
120
220
|
|
|
121
221
|
var CCConfig = /*#__PURE__*/Object.freeze({
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 加密
|
|
130
|
-
* @param {String} data 数据
|
|
131
|
-
* @param {String} key 密钥
|
|
132
|
-
* @param {String} iv 偏移量
|
|
133
|
-
* @returns
|
|
134
|
-
*/
|
|
135
|
-
function getAesString(data, key, iv) {
|
|
136
|
-
key = UTF8.parse(key);
|
|
137
|
-
iv = UTF8.parse(iv);
|
|
138
|
-
let encrypted = CryptoJS.encrypt(data, key, {
|
|
139
|
-
iv: iv,
|
|
140
|
-
padding: PAD,
|
|
141
|
-
});
|
|
142
|
-
return encrypted.toString(); //返回的是base64格式的密文
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* 解密
|
|
147
|
-
* @param {String} encrypted 密文
|
|
148
|
-
* @param {String} key 密钥
|
|
149
|
-
* @param {String} iv 偏移量
|
|
150
|
-
* @returns
|
|
151
|
-
*/
|
|
152
|
-
function getDAesString(encrypted, key, iv) {
|
|
153
|
-
key = UTF8.parse(key);
|
|
154
|
-
iv = UTF8.parse(iv);
|
|
155
|
-
let decrypted = CryptoJS.decrypt(encrypted, key, {
|
|
156
|
-
iv: iv,
|
|
157
|
-
padding: PAD,
|
|
158
|
-
});
|
|
159
|
-
return decrypted.toString(UTF8);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* CryptoJS加密
|
|
164
|
-
* @param {String} data 数据
|
|
165
|
-
* @param {String} key 密钥
|
|
166
|
-
* @param {String} iv 偏移量
|
|
167
|
-
* @returns 加密的数据
|
|
168
|
-
*/
|
|
169
|
-
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
170
|
-
data = JSON.stringify(data);
|
|
171
|
-
var encrypted = getAesString(data, key, iv); //密文
|
|
172
|
-
return encrypted;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* CryptoJS解密
|
|
177
|
-
* @param {String} data 加密的数据
|
|
178
|
-
* @param {String} key 密钥
|
|
179
|
-
* @param {String} iv 偏移量
|
|
180
|
-
* @returns 解密的数据
|
|
181
|
-
*/
|
|
182
|
-
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
183
|
-
try {
|
|
184
|
-
var decryptedStr = getDAesString(data, key, iv);
|
|
185
|
-
if (!decryptedStr) return null
|
|
186
|
-
return JSON.parse(decryptedStr);
|
|
187
|
-
} catch (error) {
|
|
188
|
-
console.trace("解密密码错误", error);
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
var Crypto = /*#__PURE__*/Object.freeze({
|
|
194
|
-
__proto__: null,
|
|
195
|
-
encrypt: encrypt,
|
|
196
|
-
decrypt: decrypt
|
|
222
|
+
__proto__: null,
|
|
223
|
+
getBaseUrl: getBaseUrl,
|
|
224
|
+
getGw: getGw,
|
|
225
|
+
getSvc: getSvc
|
|
197
226
|
});
|
|
198
227
|
|
|
199
228
|
const service = axios.create({
|
|
@@ -269,12 +298,65 @@ function patch(url, data = {}) {
|
|
|
269
298
|
}
|
|
270
299
|
|
|
271
300
|
var CCHttp = /*#__PURE__*/Object.freeze({
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
301
|
+
__proto__: null,
|
|
302
|
+
get: get,
|
|
303
|
+
post: post,
|
|
304
|
+
put: put,
|
|
305
|
+
patch: patch,
|
|
306
|
+
postParams: postParams
|
|
307
|
+
});
|
|
308
|
+
|
|
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);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
var CCMenu = /*#__PURE__*/Object.freeze({
|
|
353
|
+
__proto__: null,
|
|
354
|
+
addMenu1: addMenu1,
|
|
355
|
+
addMenu2: addMenu2,
|
|
356
|
+
deleteMenu1: deleteMenu1,
|
|
357
|
+
deleteMenu2: deleteMenu2,
|
|
358
|
+
refreshMenu1: refreshMenu1,
|
|
359
|
+
refreshMenu2: refreshMenu2
|
|
278
360
|
});
|
|
279
361
|
|
|
280
362
|
/**
|
|
@@ -317,10 +399,10 @@ function showNotification(options = {}) {
|
|
|
317
399
|
}
|
|
318
400
|
|
|
319
401
|
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
402
|
+
__proto__: null,
|
|
403
|
+
showMessage: showMessage,
|
|
404
|
+
showConfirm: showConfirm,
|
|
405
|
+
showNotification: showNotification
|
|
324
406
|
});
|
|
325
407
|
|
|
326
408
|
// 对象详情存储标识
|
|
@@ -371,20 +453,26 @@ function setObjectDetail(detail = '') {
|
|
|
371
453
|
}
|
|
372
454
|
|
|
373
455
|
var CCObject = /*#__PURE__*/Object.freeze({
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
456
|
+
__proto__: null,
|
|
457
|
+
getObject: getObject,
|
|
458
|
+
setObject: setObject,
|
|
459
|
+
getObjectDetail: getObjectDetail,
|
|
460
|
+
setObjectDetail: setObjectDetail
|
|
379
461
|
});
|
|
380
462
|
|
|
463
|
+
/**
|
|
464
|
+
* 用于保存打开的页面集合
|
|
465
|
+
*/
|
|
466
|
+
let pageList = new Map();
|
|
381
467
|
/**
|
|
382
468
|
* 打开对象视图页面
|
|
383
469
|
* @param {string} objectType 对象类型
|
|
384
470
|
* @param {object} options 配置信息
|
|
385
471
|
*/
|
|
386
472
|
function openListPage(objectType, options = {}) {
|
|
387
|
-
|
|
473
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
474
|
+
$CCDK.CCBus.$emit('openListPage', pageId, objectType, id, options);
|
|
475
|
+
return pageId;
|
|
388
476
|
}
|
|
389
477
|
|
|
390
478
|
/**
|
|
@@ -394,7 +482,9 @@ function openListPage(objectType, options = {}) {
|
|
|
394
482
|
* @param {object} options 配置信息
|
|
395
483
|
*/
|
|
396
484
|
function openDetailPage(objectType, id, options = {}) {
|
|
397
|
-
|
|
485
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
486
|
+
$CCDK.CCBus.$emit('openCreatePage', pageId, objectType, id, options);
|
|
487
|
+
return pageId;
|
|
398
488
|
}
|
|
399
489
|
|
|
400
490
|
/**
|
|
@@ -403,7 +493,9 @@ function openDetailPage(objectType, id, options = {}) {
|
|
|
403
493
|
* @param {object} options 配置信息
|
|
404
494
|
*/
|
|
405
495
|
function openCreatePage(objectType, options = {}) {
|
|
406
|
-
|
|
496
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
497
|
+
$CCDK.CCBus.$emit('openCreatePage', pageId, objectType, options);
|
|
498
|
+
return pageId;
|
|
407
499
|
}
|
|
408
500
|
|
|
409
501
|
/**
|
|
@@ -413,32 +505,69 @@ function openCreatePage(objectType, options = {}) {
|
|
|
413
505
|
* @param {object} options 配置信息
|
|
414
506
|
*/
|
|
415
507
|
function openEditPage(objectType, id, options = {}) {
|
|
416
|
-
|
|
508
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
509
|
+
$CCDK.CCBus.$emit('openEditPage', pageId, objectType, id, options);
|
|
510
|
+
return pageId;
|
|
417
511
|
}
|
|
418
512
|
/**
|
|
419
513
|
* 打开自定义页面
|
|
420
|
-
* @param {string}
|
|
514
|
+
* @param {string} pageApi 自定义页面id
|
|
421
515
|
* @param {object} options 配置信息
|
|
422
516
|
*/
|
|
423
|
-
function openCustomPage(
|
|
424
|
-
|
|
517
|
+
function openCustomPage(pageApi, options = {}) {
|
|
518
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
519
|
+
$CCDK.CCBus.$emit('openCustomPage', pageId, pageApi, options);
|
|
520
|
+
return pageId;
|
|
425
521
|
}
|
|
426
522
|
|
|
427
523
|
/**
|
|
428
|
-
*
|
|
524
|
+
* 将打开的页面添加到集合中
|
|
525
|
+
* @param {string} id 唯一ID
|
|
526
|
+
* @param {object} page 页面对象
|
|
429
527
|
*/
|
|
430
|
-
function
|
|
528
|
+
function addPage(id, page) {
|
|
529
|
+
if (id && page) {
|
|
530
|
+
pageList.set(id, page);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
431
533
|
|
|
534
|
+
/**
|
|
535
|
+
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
536
|
+
* @param {string} pageId 页面id
|
|
537
|
+
*/
|
|
538
|
+
function close(pageId = '') {
|
|
539
|
+
let page;
|
|
540
|
+
if (pageId) {
|
|
541
|
+
page = pageList.get(pageId);
|
|
542
|
+
}
|
|
543
|
+
if (page) {
|
|
544
|
+
page.close();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* 刷新页面
|
|
549
|
+
* @param {string} pageId 页面id
|
|
550
|
+
*/
|
|
551
|
+
function refresh(pageId = '') {
|
|
552
|
+
let page;
|
|
553
|
+
if (pageId) {
|
|
554
|
+
page = pageList.get(pageId);
|
|
555
|
+
}
|
|
556
|
+
if (page) {
|
|
557
|
+
page.refresh();
|
|
558
|
+
}
|
|
432
559
|
}
|
|
433
560
|
|
|
434
561
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
562
|
+
__proto__: null,
|
|
563
|
+
openListPage: openListPage,
|
|
564
|
+
openDetailPage: openDetailPage,
|
|
565
|
+
openCreatePage: openCreatePage,
|
|
566
|
+
openEditPage: openEditPage,
|
|
567
|
+
openCustomPage: openCustomPage,
|
|
568
|
+
addPage: addPage,
|
|
569
|
+
close: close,
|
|
570
|
+
refresh: refresh
|
|
442
571
|
});
|
|
443
572
|
|
|
444
573
|
/**
|
|
@@ -457,8 +586,8 @@ function getDomain() {
|
|
|
457
586
|
}
|
|
458
587
|
|
|
459
588
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
460
|
-
|
|
461
|
-
|
|
589
|
+
__proto__: null,
|
|
590
|
+
getDomain: getDomain
|
|
462
591
|
});
|
|
463
592
|
|
|
464
593
|
// cookie存储标识
|
|
@@ -507,10 +636,10 @@ function clearToken(domain = getDomain()) {
|
|
|
507
636
|
}
|
|
508
637
|
|
|
509
638
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
639
|
+
__proto__: null,
|
|
640
|
+
setToken: setToken,
|
|
641
|
+
getToken: getToken,
|
|
642
|
+
clearToken: clearToken
|
|
514
643
|
});
|
|
515
644
|
|
|
516
645
|
// cookie存储标识
|
|
@@ -541,9 +670,9 @@ function getUserInfo() {
|
|
|
541
670
|
}
|
|
542
671
|
|
|
543
672
|
var CCUser = /*#__PURE__*/Object.freeze({
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
673
|
+
__proto__: null,
|
|
674
|
+
setUserInfo: setUserInfo,
|
|
675
|
+
getUserInfo: getUserInfo
|
|
547
676
|
});
|
|
548
677
|
|
|
549
|
-
export { CCBus, CCCall, CCConfig, Crypto as CCCrypto, CCHttp, CCMessage, CCObject, CCPage, CCToken, CCUser, CCUtils };
|
|
678
|
+
export { CCApplication, CCBus, CCCall, CCConfig, Crypto as CCCrypto, CCHttp, CCMenu, CCMessage, CCObject, CCPage, CCToken, CCUser, CCUtils };
|
package/lib/ccdk.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import CryptoJS from"crypto-js/aes";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";import axios from"axios";import{Message,MessageBox,Notification}from"element-ui";import Cookies from"js-cookie";function $emit(event,...args){window.ccBus.$emit(event,...args)}function $on(event,callback){window.ccBus.$on(event,callback)}function $off(event){window.ccBus.$off(event)}var CCBus=Object.freeze({__proto__:null,$emit:$emit,$on:$on,$off:$off});let ccCall=new Map;let currentCall;function init(id,callClient){if(id&&callClient){ccCall.set(id,callClient);currentCall=callClient;return currentCall}}function call(id,options){let call;if(id){call=ccCall.get(id)}else{call=currentCall}if(call){call.call(options)}return call}function openCallPanel(id,options){let call;if(id){call=ccCall.get(id)}else{call=currentCall}if(call){call.openCallPanel(options)}return call}var CCCall=Object.freeze({__proto__:null,init:init,call:call,openCallPanel:openCallPanel});function getBaseUrl(){return window.gw.BASE_URL}function getGw(){return window.gw}function getSvc(){return window.Glod}var CCConfig=Object.freeze({__proto__:null,getBaseUrl:getBaseUrl,getGw:getGw,getSvc:getSvc});
|
|
1
|
+
import CryptoJS from"crypto-js/aes";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";import axios from"axios";import{Message,MessageBox,Notification}from"element-ui";import Cookies from"js-cookie";function getAesString(data,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let encrypted=CryptoJS.encrypt(data,key,{iv:iv,padding:PAD});return encrypted.toString()}function getDAesString(encrypted,key,iv){key=UTF8.parse(key);iv=UTF8.parse(iv);let decrypted=CryptoJS.decrypt(encrypted,key,{iv:iv,padding:PAD});return decrypted.toString(UTF8)}function encrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){data=JSON.stringify(data);var encrypted=getAesString(data,key,iv);return encrypted}function decrypt(data,key="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",iv=1){try{var decryptedStr=getDAesString(data,key,iv);if(!decryptedStr)return null;return JSON.parse(decryptedStr)}catch(error){console.trace("解密密码错误",error);return null}}var Crypto=Object.freeze({__proto__:null,encrypt:encrypt,decrypt:decrypt});const APPLICATION_DETAIL="applicaton_current";function getApplicaton(){let detail=localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));if(detail){return JSON.parse(detail)}return""}function setApplication(detail=""){if(detail){localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL),JSON.stringify(detail))}}var CCApplication=Object.freeze({__proto__:null,getApplicaton:getApplicaton,setApplication:setApplication});function $emit(event,...args){window.ccBus.$emit(event,...args)}function $on(event,callback){window.ccBus.$on(event,callback)}function $off(event){window.ccBus.$off(event)}var CCBus=Object.freeze({__proto__:null,$emit:$emit,$on:$on,$off:$off});let ccCall=new Map;let currentCall;function init(id,callClient){if(id&&callClient){ccCall.set(id,callClient);currentCall=callClient;return currentCall}}function call(id,options){let call;if(id){call=ccCall.get(id)}else{call=currentCall}if(call){call.call(options)}return call}function openCallPanel(id,options){let call;if(id){call=ccCall.get(id)}else{call=currentCall}if(call){call.openCallPanel(options)}return call}var CCCall=Object.freeze({__proto__:null,init:init,call:call,openCallPanel:openCallPanel});function getBaseUrl(){return window.gw.BASE_URL}function getGw(){return window.gw}function getSvc(){return window.Glod}var CCConfig=Object.freeze({__proto__:null,getBaseUrl:getBaseUrl,getGw:getGw,getSvc:getSvc});const service=axios.create({timeout:6e4,headers:{"Content-Type":"application/json; charset=utf-8"}});service.interceptors.request.use(config=>{config.headers["accessToken"]=$CCDK.CCToken.getToken();return config},error=>{Promise.reject(error)});service.interceptors.response.use(response=>{const code=response.data.code||200;if(code!==200){return Promise.reject(null==response.data.msg?"未知异常":response.data.msg)}else{return response.data}},error=>{return Promise.reject(error)});function get(url,data={},responseType=""){return service({url:url,method:"get",params:data,responseType:responseType})}function post(url,data={},responseType=""){return service({url:url,method:"post",data:data,responseType:responseType})}function put(url,data={}){return service({url:url,method:"put",data:data})}function postParams(url,data={}){return service({url:url,method:"post",params:data})}function patch(url,data={}){return service({url:url,method:"patch",data:data})}var CCHttp=Object.freeze({__proto__:null,get:get,post:post,put:put,patch:patch,postParams:postParams});function addMenu1(options){$CCDK.CCBus.$emit("addMenu1",options)}function addMenu2(options){$CCDK.CCBus.$emit("addMenu2",options)}function deleteMenu1(options){$CCDK.CCBus.$emit("deleteMenu1",options)}function deleteMenu2(options){$CCDK.CCBus.$emit("deleteMenu2",options)}function refreshMenu1(options){$CCDK.CCBus.$emit("refreshMenu1",options)}function refreshMenu2(options){$CCDK.CCBus.$emit("refreshMenu2",options)}var CCMenu=Object.freeze({__proto__:null,addMenu1:addMenu1,addMenu2:addMenu2,deleteMenu1:deleteMenu1,deleteMenu2:deleteMenu2,refreshMenu1:refreshMenu1,refreshMenu2:refreshMenu2});function showMessage(text,type="info",duration=3e3,showClose=false,center=false){Message({message:text,type:type,duration:duration,showClose:showClose,center:center})}function showConfirm(text,title,options={},confirm=()=>{},reject=()=>{}){MessageBox.confirm(text,title,options).then(()=>{confirm()}).catch(()=>{reject()})}function showNotification(options={}){Notification(options)}var CCMessage=Object.freeze({__proto__:null,showMessage:showMessage,showConfirm:showConfirm,showNotification:showNotification});const OBJECT_DETAIL="cc_object_detail";const OBJECT="cc_object";function getObject(){let detail=localStorage.getItem(Crypto.encrypt(OBJECT));if(detail){return JSON.parse(detail)}return""}function setObject(detail=""){if(detail){localStorage.setItem(Crypto.encrypt(OBJECT),JSON.stringify(detail))}}function getObjectDetail(){let detail=localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));if(detail){return JSON.parse(detail)}return""}function setObjectDetail(detail=""){if(detail){localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL),JSON.stringify(detail))}}var CCObject=Object.freeze({__proto__:null,getObject:getObject,setObject:setObject,getObjectDetail:getObjectDetail,setObjectDetail:setObjectDetail});let pageList=new Map;function openListPage(objectType,options={}){let pageId=Math.random().toString(16).slice(2);$CCDK.CCBus.$emit("openListPage",pageId,objectType,id,options);return pageId}function openDetailPage(objectType,id,options={}){let pageId=Math.random().toString(16).slice(2);$CCDK.CCBus.$emit("openCreatePage",pageId,objectType,id,options);return pageId}function openCreatePage(objectType,options={}){let pageId=Math.random().toString(16).slice(2);$CCDK.CCBus.$emit("openCreatePage",pageId,objectType,options);return pageId}function openEditPage(objectType,id,options={}){let pageId=Math.random().toString(16).slice(2);$CCDK.CCBus.$emit("openEditPage",pageId,objectType,id,options);return pageId}function openCustomPage(pageApi,options={}){let pageId=Math.random().toString(16).slice(2);$CCDK.CCBus.$emit("openCustomPage",pageId,pageApi,options);return pageId}function addPage(id,page){if(id&&page){pageList.set(id,page)}}function close(pageId=""){let page;if(pageId){page=pageList.get(pageId)}if(page){page.close()}}function refresh(pageId=""){let page;if(pageId){page=pageList.get(pageId)}if(page){page.refresh()}}var CCPage=Object.freeze({__proto__:null,openListPage:openListPage,openDetailPage:openDetailPage,openCreatePage:openCreatePage,openEditPage:openEditPage,openCustomPage:openCustomPage,addPage:addPage,close:close,refresh:refresh});function getDomain(){let lastTow=document.domain.split(".").slice(-2,-1)[0];if(lastTow=="com"||lastTow=="org"||lastTow=="net"){return"."+document.domain.split(".").slice(-3).join(".")}else{return"."+document.domain.split(".").slice(-2).join(".")}}var CCUtils=Object.freeze({__proto__:null,getDomain:getDomain});const TOKEN="cc_token";function getUrlQuery(name){var reg=new RegExp(name+"=([^&]*)(&|$)");var r=window.location.href.match(reg);let res=null;if(r!=null)res=r[1].trim();return res}function getToken(urlName="binding"){let token=getUrlQuery(urlName)||Cookies.get(Crypto.encrypt(TOKEN))||Cookies.get(urlName);if(token){setToken(token)}return token}function setToken(token,domain=getDomain()){Cookies.set(Crypto.encrypt(TOKEN),token,{domain:domain,expires:1/12});Cookies.set(Crypto.encrypt(TOKEN),token,{expires:1/12})}function clearToken(domain=getDomain()){Cookies.remove(Crypto.encrypt(TOKEN),{domain:domain});Cookies.remove(Crypto.encrypt(TOKEN))}var CCToken=Object.freeze({__proto__:null,setToken:setToken,getToken:getToken,clearToken:clearToken});const USER_INFO="cc_user_info";function setUserInfo(userInfo,domain=getDomain()){Cookies.set(Crypto.encrypt(USER_INFO),Crypto.encrypt(userInfo),{domain:domain,expires:1/12});Cookies.set(Crypto.encrypt(USER_INFO),Crypto.encrypt(userInfo),{expires:1/12})}function getUserInfo(){let encryptUserInfo=Cookies.get(Crypto.encrypt(USER_INFO));if(encryptUserInfo){return Crypto.decrypt(encryptUserInfo)}else{return""}}var CCUser=Object.freeze({__proto__:null,setUserInfo:setUserInfo,getUserInfo:getUserInfo});export{CCApplication,CCBus,CCCall,CCConfig,Crypto as CCCrypto,CCHttp,CCMenu,CCMessage,CCObject,CCPage,CCToken,CCUser,CCUtils};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudcc-ccdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/ccdk-min.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"cc-pull": "git fetch --tags -f && git pull",
|
|
7
8
|
"libs:build": "rollup -c && uglifyjs lib/ccdk.js -o lib/ccdk.min.js",
|
|
8
9
|
"libs:publish": "npm run libs:build && npm publish --registry https://registry.npmjs.org"
|
|
9
10
|
},
|