cloudcc-ccdk 0.2.0 → 0.2.1
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 +9 -0
- package/lib/ccdk.js +197 -115
- package/lib/ccdk.min.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
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,11 +453,11 @@ 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
|
|
|
381
463
|
/**
|
|
@@ -432,13 +514,13 @@ function close() {
|
|
|
432
514
|
}
|
|
433
515
|
|
|
434
516
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
517
|
+
__proto__: null,
|
|
518
|
+
openListPage: openListPage,
|
|
519
|
+
openDetailPage: openDetailPage,
|
|
520
|
+
openCreatePage: openCreatePage,
|
|
521
|
+
openEditPage: openEditPage,
|
|
522
|
+
openCustomPage: openCustomPage,
|
|
523
|
+
close: close
|
|
442
524
|
});
|
|
443
525
|
|
|
444
526
|
/**
|
|
@@ -457,8 +539,8 @@ function getDomain() {
|
|
|
457
539
|
}
|
|
458
540
|
|
|
459
541
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
460
|
-
|
|
461
|
-
|
|
542
|
+
__proto__: null,
|
|
543
|
+
getDomain: getDomain
|
|
462
544
|
});
|
|
463
545
|
|
|
464
546
|
// cookie存储标识
|
|
@@ -507,10 +589,10 @@ function clearToken(domain = getDomain()) {
|
|
|
507
589
|
}
|
|
508
590
|
|
|
509
591
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
592
|
+
__proto__: null,
|
|
593
|
+
setToken: setToken,
|
|
594
|
+
getToken: getToken,
|
|
595
|
+
clearToken: clearToken
|
|
514
596
|
});
|
|
515
597
|
|
|
516
598
|
// cookie存储标识
|
|
@@ -541,9 +623,9 @@ function getUserInfo() {
|
|
|
541
623
|
}
|
|
542
624
|
|
|
543
625
|
var CCUser = /*#__PURE__*/Object.freeze({
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
626
|
+
__proto__: null,
|
|
627
|
+
setUserInfo: setUserInfo,
|
|
628
|
+
getUserInfo: getUserInfo
|
|
547
629
|
});
|
|
548
630
|
|
|
549
|
-
export { CCBus, CCCall, CCConfig, Crypto as CCCrypto, CCHttp, CCMessage, CCObject, CCPage, CCToken, CCUser, CCUtils };
|
|
631
|
+
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});function openListPage(objectType,options={}){$CCDK.CCBus.$emit("openListPage",objectType,id,options)}function openDetailPage(objectType,id,options={}){$CCDK.CCBus.$emit("openCreatePage",objectType,id,options)}function openCreatePage(objectType,options={}){$CCDK.CCBus.$emit("openCreatePage",objectType,options)}function openEditPage(objectType,id,options={}){$CCDK.CCBus.$emit("openEditPage",objectType,id,options)}function openCustomPage(pageId,options={}){$CCDK.CCBus.$emit("openCustomPage",pageId,options)}function close(){}var CCPage=Object.freeze({__proto__:null,openListPage:openListPage,openDetailPage:openDetailPage,openCreatePage:openCreatePage,openEditPage:openEditPage,openCustomPage:openCustomPage,close:close});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.1",
|
|
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
|
},
|