cloudcc-ccdk 0.1.9 → 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 +17 -0
- package/lib/ccdk.js +269 -187
- package/lib/ccdk.min.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
#### 发布版本:0.2.1
|
|
2
|
+
#### 更新日期:2022/11/2
|
|
3
|
+
#### 更新内容:
|
|
4
|
+
* 修复
|
|
5
|
+
* 迭代
|
|
6
|
+
* 添加CCMenu
|
|
7
|
+
* 添加CCApplication
|
|
8
|
+
* 优化
|
|
9
|
+
|
|
10
|
+
#### 发布版本:0.2.0
|
|
11
|
+
#### 更新日期:2022/11/2
|
|
12
|
+
#### 更新内容:
|
|
13
|
+
* 修复
|
|
14
|
+
* 迭代
|
|
15
|
+
* 优化
|
|
16
|
+
* 调整ccdk名称顺序
|
|
17
|
+
|
|
1
18
|
#### 发布版本:0.1.9
|
|
2
19
|
#### 更新日期:2022/11/2
|
|
3
20
|
#### 更新内容:
|
package/lib/ccdk.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Cookies from 'js-cookie';
|
|
2
1
|
import CryptoJS from 'crypto-js/aes';
|
|
3
2
|
import UTF8 from 'crypto-js/enc-utf8';
|
|
4
3
|
import PAD from 'crypto-js/pad-pkcs7';
|
|
5
|
-
import { Message, MessageBox, Notification } from 'element-ui';
|
|
6
4
|
import axios from 'axios';
|
|
5
|
+
import { Message, MessageBox, Notification } from 'element-ui';
|
|
6
|
+
import Cookies from 'js-cookie';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 加密
|
|
@@ -76,109 +76,124 @@ var Crypto = /*#__PURE__*/Object.freeze({
|
|
|
76
76
|
decrypt: decrypt
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
// 当前应用存储标识
|
|
80
|
+
const APPLICATION_DETAIL = 'applicaton_current';
|
|
79
81
|
/**
|
|
80
|
-
*
|
|
81
|
-
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
82
|
+
* 获得当前访问的应用对象
|
|
82
83
|
*/
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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));
|
|
91
99
|
}
|
|
92
100
|
}
|
|
93
101
|
|
|
94
|
-
var
|
|
102
|
+
var CCApplication = /*#__PURE__*/Object.freeze({
|
|
95
103
|
__proto__: null,
|
|
96
|
-
|
|
104
|
+
getApplicaton: getApplicaton,
|
|
105
|
+
setApplication: setApplication
|
|
97
106
|
});
|
|
98
107
|
|
|
99
|
-
// cookie存储标识
|
|
100
|
-
const USER_INFO = "cc_user_info";
|
|
101
|
-
|
|
102
108
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {
|
|
105
|
-
* @param
|
|
109
|
+
* 发布信息
|
|
110
|
+
* @param {string} event 事件名称
|
|
111
|
+
* @param {...any} args 参数列表
|
|
106
112
|
*/
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
113
|
+
function $emit(event, ...args) {
|
|
114
|
+
window.ccBus.$emit(event, ...args);
|
|
110
115
|
}
|
|
111
|
-
|
|
112
116
|
/**
|
|
113
|
-
*
|
|
114
|
-
* @
|
|
117
|
+
* 订阅消息
|
|
118
|
+
* @param {string} event 事件名称
|
|
119
|
+
* @param {function} callback 回调方法
|
|
115
120
|
*/
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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);
|
|
124
130
|
}
|
|
125
131
|
|
|
126
|
-
var
|
|
132
|
+
var CCBus = /*#__PURE__*/Object.freeze({
|
|
127
133
|
__proto__: null,
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
$emit: $emit,
|
|
135
|
+
$on: $on,
|
|
136
|
+
$off: $off
|
|
130
137
|
});
|
|
131
138
|
|
|
132
|
-
//
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
* @param {name} 参数名
|
|
137
|
-
*/
|
|
138
|
-
function getUrlQuery(name) {
|
|
139
|
-
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
140
|
-
var r = window.location.href.match(reg);
|
|
141
|
-
let res = null;
|
|
142
|
-
if (r != null) res = r[1].trim();
|
|
143
|
-
return res;
|
|
144
|
-
}
|
|
139
|
+
// 电话对象
|
|
140
|
+
let ccCall = new Map();
|
|
141
|
+
// 电话服务商当前对象
|
|
142
|
+
let currentCall;
|
|
145
143
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {
|
|
148
|
-
* @
|
|
144
|
+
* 初始化电话条
|
|
145
|
+
* @param {string} id 电话服务商唯一标识
|
|
146
|
+
* @param {object} callClient 电话对象
|
|
149
147
|
*/
|
|
150
|
-
function
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
function init(id, callClient) {
|
|
149
|
+
if (id && callClient) {
|
|
150
|
+
ccCall.set(id, callClient);
|
|
151
|
+
currentCall = callClient;
|
|
152
|
+
return currentCall
|
|
155
153
|
}
|
|
156
|
-
return token
|
|
157
154
|
}
|
|
155
|
+
|
|
156
|
+
|
|
158
157
|
/**
|
|
159
|
-
*
|
|
160
|
-
* @param {
|
|
161
|
-
* @param {
|
|
158
|
+
* 拨打电话
|
|
159
|
+
* @param {string} id 电话服务商唯一标识
|
|
160
|
+
* @param {object} options 配置信息
|
|
162
161
|
*/
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
166
173
|
}
|
|
167
|
-
|
|
168
174
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @param {
|
|
175
|
+
* 打开通话面板
|
|
176
|
+
* @param {string} id 电话服务商唯一标识
|
|
177
|
+
* @param {object} options 配置信息
|
|
171
178
|
*/
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
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
|
|
175
190
|
}
|
|
176
191
|
|
|
177
|
-
var
|
|
192
|
+
var CCCall = /*#__PURE__*/Object.freeze({
|
|
178
193
|
__proto__: null,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
194
|
+
init: init,
|
|
195
|
+
call: call,
|
|
196
|
+
openCallPanel: openCallPanel
|
|
182
197
|
});
|
|
183
198
|
|
|
184
199
|
/**
|
|
@@ -210,52 +225,6 @@ var CCConfig = /*#__PURE__*/Object.freeze({
|
|
|
210
225
|
getSvc: getSvc
|
|
211
226
|
});
|
|
212
227
|
|
|
213
|
-
/**
|
|
214
|
-
* 消息提示框
|
|
215
|
-
* @param {string} text 提示文字,支持vhtml渲染
|
|
216
|
-
* @param {string} type 消息类别
|
|
217
|
-
* @param {number} duration 持续时间
|
|
218
|
-
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
219
|
-
* @param {boolean} center 文字是否剧中
|
|
220
|
-
*/
|
|
221
|
-
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
222
|
-
Message({
|
|
223
|
-
message: text,
|
|
224
|
-
type,
|
|
225
|
-
duration,
|
|
226
|
-
showClose,
|
|
227
|
-
center
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* 提示确认框
|
|
232
|
-
* @param {string} text 提示信息
|
|
233
|
-
* @param {string} title 标题
|
|
234
|
-
* @param {object} options 配置信息
|
|
235
|
-
*/
|
|
236
|
-
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
237
|
-
MessageBox.confirm(text, title, options).then(() => {
|
|
238
|
-
confirm();
|
|
239
|
-
}).catch(() => {
|
|
240
|
-
reject();
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* 提示消息框
|
|
246
|
-
* @param {object} options 配置信息
|
|
247
|
-
*/
|
|
248
|
-
function showNotification(options = {}) {
|
|
249
|
-
Notification(options);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
253
|
-
__proto__: null,
|
|
254
|
-
showMessage: showMessage,
|
|
255
|
-
showConfirm: showConfirm,
|
|
256
|
-
showNotification: showNotification
|
|
257
|
-
});
|
|
258
|
-
|
|
259
228
|
const service = axios.create({
|
|
260
229
|
timeout: 60000,
|
|
261
230
|
headers: {
|
|
@@ -337,6 +306,105 @@ var CCHttp = /*#__PURE__*/Object.freeze({
|
|
|
337
306
|
postParams: postParams
|
|
338
307
|
});
|
|
339
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
|
|
360
|
+
});
|
|
361
|
+
|
|
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);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
402
|
+
__proto__: null,
|
|
403
|
+
showMessage: showMessage,
|
|
404
|
+
showConfirm: showConfirm,
|
|
405
|
+
showNotification: showNotification
|
|
406
|
+
});
|
|
407
|
+
|
|
340
408
|
// 对象详情存储标识
|
|
341
409
|
const OBJECT_DETAIL = 'cc_object_detail';
|
|
342
410
|
// 对象存储标识
|
|
@@ -456,94 +524,108 @@ var CCPage = /*#__PURE__*/Object.freeze({
|
|
|
456
524
|
});
|
|
457
525
|
|
|
458
526
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* @param {...any} args 参数列表
|
|
527
|
+
* 获得一级域名
|
|
528
|
+
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
462
529
|
*/
|
|
463
|
-
function
|
|
464
|
-
|
|
530
|
+
function getDomain() {
|
|
531
|
+
// 倒数第二位域名
|
|
532
|
+
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
533
|
+
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
534
|
+
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
535
|
+
return "." + document.domain.split('.').slice(-3).join('.')
|
|
536
|
+
} else {
|
|
537
|
+
return "." + document.domain.split('.').slice(-2).join('.')
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
542
|
+
__proto__: null,
|
|
543
|
+
getDomain: getDomain
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// cookie存储标识
|
|
547
|
+
const TOKEN = "cc_token";
|
|
548
|
+
/**
|
|
549
|
+
* 获取URL中参数的数据
|
|
550
|
+
* @param {name} 参数名
|
|
551
|
+
*/
|
|
552
|
+
function getUrlQuery(name) {
|
|
553
|
+
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
554
|
+
var r = window.location.href.match(reg);
|
|
555
|
+
let res = null;
|
|
556
|
+
if (r != null) res = r[1].trim();
|
|
557
|
+
return res;
|
|
465
558
|
}
|
|
466
559
|
/**
|
|
467
|
-
*
|
|
468
|
-
* @param {
|
|
469
|
-
* @
|
|
560
|
+
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
|
|
561
|
+
* @param {String} urlName 获取token的url名称
|
|
562
|
+
* @returns
|
|
470
563
|
*/
|
|
471
|
-
function
|
|
472
|
-
|
|
564
|
+
function getToken(urlName = "binding") {
|
|
565
|
+
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
|
|
566
|
+
// 如果存在token,那么存储到cookies中,刷新有效期
|
|
567
|
+
if (token) {
|
|
568
|
+
setToken(token);
|
|
569
|
+
}
|
|
570
|
+
return token
|
|
473
571
|
}
|
|
474
572
|
/**
|
|
475
|
-
*
|
|
476
|
-
* @param {
|
|
573
|
+
* 存储token
|
|
574
|
+
* @param {String} token token
|
|
575
|
+
* @param {String} domain 域名
|
|
477
576
|
*/
|
|
478
|
-
function
|
|
479
|
-
|
|
577
|
+
function setToken(token, domain = getDomain()) {
|
|
578
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
579
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* 清除Token数据
|
|
584
|
+
* @param {String} domain 域名
|
|
585
|
+
*/
|
|
586
|
+
function clearToken(domain = getDomain()) {
|
|
587
|
+
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
588
|
+
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
480
589
|
}
|
|
481
590
|
|
|
482
|
-
var
|
|
591
|
+
var CCToken = /*#__PURE__*/Object.freeze({
|
|
483
592
|
__proto__: null,
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
593
|
+
setToken: setToken,
|
|
594
|
+
getToken: getToken,
|
|
595
|
+
clearToken: clearToken
|
|
487
596
|
});
|
|
488
597
|
|
|
489
|
-
//
|
|
490
|
-
|
|
491
|
-
// 电话服务商当前对象
|
|
492
|
-
let currentCall;
|
|
493
|
-
/**
|
|
494
|
-
* 初始化电话条
|
|
495
|
-
* @param {string} id 电话服务商唯一标识
|
|
496
|
-
* @param {object} callClient 电话对象
|
|
497
|
-
*/
|
|
498
|
-
function init(id, callClient) {
|
|
499
|
-
if (id && callClient) {
|
|
500
|
-
ccCall.set(id, callClient);
|
|
501
|
-
currentCall = callClient;
|
|
502
|
-
return currentCall
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
598
|
+
// cookie存储标识
|
|
599
|
+
const USER_INFO = "cc_user_info";
|
|
506
600
|
|
|
507
601
|
/**
|
|
508
|
-
*
|
|
509
|
-
* @param {
|
|
510
|
-
* @param {
|
|
602
|
+
* 存储用户信息
|
|
603
|
+
* @param {String} userInfo 用户信息
|
|
604
|
+
* @param {String} domain 域名
|
|
511
605
|
*/
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
call = ccCall.get(id);
|
|
516
|
-
} else {
|
|
517
|
-
call = currentCall;
|
|
518
|
-
}
|
|
519
|
-
if (call) {
|
|
520
|
-
call.call(options);
|
|
521
|
-
}
|
|
522
|
-
return call
|
|
606
|
+
function setUserInfo(userInfo, domain = getDomain()) {
|
|
607
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
608
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
523
609
|
}
|
|
610
|
+
|
|
524
611
|
/**
|
|
525
|
-
*
|
|
526
|
-
* @
|
|
527
|
-
* @param {object} options 配置信息
|
|
612
|
+
* 获取用户信息
|
|
613
|
+
* @returns {String} 用户信息
|
|
528
614
|
*/
|
|
529
|
-
function
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
615
|
+
function getUserInfo() {
|
|
616
|
+
// 加密的用户信息
|
|
617
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
618
|
+
if (encryptUserInfo) {
|
|
619
|
+
return Crypto.decrypt(encryptUserInfo)
|
|
533
620
|
} else {
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
if (call) {
|
|
537
|
-
call.openCallPanel(options);
|
|
621
|
+
return ""
|
|
538
622
|
}
|
|
539
|
-
return call
|
|
540
623
|
}
|
|
541
624
|
|
|
542
|
-
var
|
|
625
|
+
var CCUser = /*#__PURE__*/Object.freeze({
|
|
543
626
|
__proto__: null,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
openCallPanel: openCallPanel
|
|
627
|
+
setUserInfo: setUserInfo,
|
|
628
|
+
getUserInfo: getUserInfo
|
|
547
629
|
});
|
|
548
630
|
|
|
549
|
-
export { CCBus, CCCall,
|
|
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
|
|
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.1
|
|
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
|
},
|