cloudcc-ccdk 0.1.2 → 0.1.4

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 CHANGED
@@ -1,3 +1,35 @@
1
+ #### 发布版本:0.1.4
2
+ #### 更新日期:2022/10/20
3
+ #### 更新内容:
4
+ * 修复
5
+ * 迭代
6
+ * 添加CCCall方法
7
+ * 优化
8
+
9
+ #### 发布版本:0.1.3
10
+ #### 更新日期:2022/10/20
11
+ #### 更新内容:
12
+ * 修复
13
+ * 迭代
14
+ * 将cloudcc-ui改为element-ui
15
+ * 优化
16
+
17
+ #### 发布版本:0.1.2
18
+ #### 更新日期:2022/10/18
19
+ #### 更新内容:
20
+ * 修复
21
+ * 迭代
22
+ * 添加CCBus
23
+ * 优化
24
+
25
+ #### 发布版本:0.1.1
26
+ #### 更新日期:2022/10/14
27
+ #### 更新内容:
28
+ * 修复
29
+ * 迭代
30
+ * 添加CCCpage
31
+ * 优化
32
+
1
33
  #### 发布版本:0.1.0
2
34
  #### 更新日期:2022/10/10
3
35
  #### 更新内容:
package/lib/ccdk.js CHANGED
@@ -2,7 +2,7 @@ import Cookies from 'js-cookie';
2
2
  import CryptoJS from 'crypto-js/aes';
3
3
  import UTF8 from 'crypto-js/enc-utf8';
4
4
  import PAD from 'crypto-js/pad-pkcs7';
5
- import { Message, MessageBox, Notification } from 'cloudcc-ui';
5
+ import { Message, MessageBox, Notification } from 'element-ui';
6
6
  import axios from 'axios';
7
7
 
8
8
  /**
@@ -428,14 +428,26 @@ var CCPage = /*#__PURE__*/Object.freeze({
428
428
  close: close
429
429
  });
430
430
 
431
+ /**
432
+ * 发布信息
433
+ * @param {string} event 事件名称
434
+ * @param {...any} args 参数列表
435
+ */
431
436
  function $emit(event, ...args) {
432
437
  window.ccBus.$emit(event, ...args);
433
438
  }
434
-
439
+ /**
440
+ * 订阅消息
441
+ * @param {string} event 事件名称
442
+ * @param {function} callback 回调方法
443
+ */
435
444
  function $on(event, callback) {
436
445
  window.ccBus.$on(event, callback);
437
446
  }
438
-
447
+ /**
448
+ * 取消订阅
449
+ * @param {string} event 事件名称
450
+ */
439
451
  function $off(event) {
440
452
  window.ccBus.$off(event);
441
453
  }
@@ -447,4 +459,54 @@ var CCBus = /*#__PURE__*/Object.freeze({
447
459
  $off: $off
448
460
  });
449
461
 
450
- export { CCBus, CCMessage as CCClient, CCConfig, Crypto as CCCrypto, CCHttp, CCObject, CCPage, CCToken, CCUser, CCUtils };
462
+ // 电话对象
463
+ let ccCall = new Map();
464
+ /**
465
+ * 初始化电话条
466
+ * @param {string} id 电话服务商唯一标识
467
+ * @param {object} callClient 电话对象
468
+ */
469
+ function init(id, callClient) {
470
+ if (id && callClient) {
471
+ ccCall.set(id, callClient);
472
+ return callClient
473
+ }
474
+ }
475
+
476
+ /**
477
+ * 拨打电话
478
+ * @param {string} id 电话服务商唯一标识
479
+ * @param {object} options 配置信息
480
+ */
481
+ function call(id, options) {
482
+ if (id) {
483
+ let call = ccCall.get(id);
484
+ if (call) {
485
+ call.call(options);
486
+ }
487
+ return call
488
+ }
489
+ }
490
+ /**
491
+ * 打开通话面板
492
+ * @param {string} id 电话服务商唯一标识
493
+ * @param {object} options 配置信息
494
+ */
495
+ function openCallPanel(id, options) {
496
+ if (id) {
497
+ let call = ccCall.get(id);
498
+ if (call) {
499
+ call.openCallPanel(options);
500
+ }
501
+ return call
502
+ }
503
+ }
504
+
505
+ var CCCall = /*#__PURE__*/Object.freeze({
506
+ __proto__: null,
507
+ init: init,
508
+ call: call,
509
+ openCallPanel: openCallPanel
510
+ });
511
+
512
+ export { CCBus, CCCall, CCMessage as CCClient, CCConfig, Crypto as CCCrypto, CCHttp, CCObject, CCPage, CCToken, CCUser, CCUtils };
package/lib/ccdk.min.js CHANGED
@@ -1 +1 @@
1
- import Cookies from"js-cookie";import CryptoJS from"crypto-js/aes";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";import{Message,MessageBox,Notification}from"cloudcc-ui";import axios from"axios";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});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 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});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});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});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 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 getObject(){}function getObjectDetail(){}function setObjectDetail(){}var CCObject=Object.freeze({__proto__:null,getObject:getObject,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 $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});export{CCBus,CCMessage as CCClient,CCConfig,Crypto as CCCrypto,CCHttp,CCObject,CCPage,CCToken,CCUser,CCUtils};
1
+ import Cookies from"js-cookie";import CryptoJS from"crypto-js/aes";import UTF8 from"crypto-js/enc-utf8";import PAD from"crypto-js/pad-pkcs7";import{Message,MessageBox,Notification}from"element-ui";import axios from"axios";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});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 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});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});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});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 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 getObject(){}function getObjectDetail(){}function setObjectDetail(){}var CCObject=Object.freeze({__proto__:null,getObject:getObject,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 $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;function init(id,callClient){if(id&&callClient){ccCall.set(id,callClient);return callClient}}function call(id,options){if(id){let call=ccCall.get(id);if(call){call.call(options)}return call}}function openCallPanel(id,options){if(id){let call=ccCall.get(id);if(call){call.openCallPanel(options)}return call}}var CCCall=Object.freeze({__proto__:null,init:init,call:call,openCallPanel:openCallPanel});export{CCBus,CCCall,CCMessage as CCClient,CCConfig,Crypto as CCCrypto,CCHttp,CCObject,CCPage,CCToken,CCUser,CCUtils};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-ccdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "",
5
5
  "main": "lib/ccdk-min.js",
6
6
  "scripts": {
@@ -20,7 +20,9 @@
20
20
  "uglify-js": "^3.17.3"
21
21
  },
22
22
  "dependencies": {
23
+ "axios": "^1.1.3",
23
24
  "crypto-js": "^4.1.1",
25
+ "element-ui": "^2.15.10",
24
26
  "js-cookie": "^3.0.1"
25
27
  }
26
28
  }