cloudcc-ccdk 0.1.3 → 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 +94 -86
- package/lib/ccdk.js +414 -364
- package/lib/ccdk.min.js +1 -1
- package/package.json +27 -25
package/README.md
CHANGED
|
@@ -1,87 +1,95 @@
|
|
|
1
|
-
#### 发布版本:0.1.
|
|
2
|
-
#### 更新日期:2022/10/20
|
|
3
|
-
#### 更新内容:
|
|
4
|
-
* 修复
|
|
5
|
-
* 迭代
|
|
6
|
-
*
|
|
7
|
-
* 优化
|
|
8
|
-
|
|
9
|
-
#### 发布版本:0.1.
|
|
10
|
-
#### 更新日期:2022/10/
|
|
11
|
-
#### 更新内容:
|
|
12
|
-
* 修复
|
|
13
|
-
* 迭代
|
|
14
|
-
*
|
|
15
|
-
* 优化
|
|
16
|
-
|
|
17
|
-
#### 发布版本:0.1.
|
|
18
|
-
#### 更新日期:2022/10/
|
|
19
|
-
#### 更新内容:
|
|
20
|
-
* 修复
|
|
21
|
-
* 迭代
|
|
22
|
-
* 添加
|
|
23
|
-
* 优化
|
|
24
|
-
|
|
25
|
-
#### 发布版本:0.1.
|
|
26
|
-
#### 更新日期:2022/10/
|
|
27
|
-
#### 更新内容:
|
|
28
|
-
* 修复
|
|
29
|
-
* 迭代
|
|
30
|
-
* 添加
|
|
31
|
-
* 优化
|
|
32
|
-
|
|
33
|
-
#### 发布版本:0.0
|
|
34
|
-
#### 更新日期:2022/
|
|
35
|
-
#### 更新内容:
|
|
36
|
-
* 修复
|
|
37
|
-
* 迭代
|
|
38
|
-
*
|
|
39
|
-
* 优化
|
|
40
|
-
|
|
41
|
-
#### 发布版本:0.0.
|
|
42
|
-
#### 更新日期:2022/8/12
|
|
43
|
-
#### 更新内容:
|
|
44
|
-
* 修复
|
|
45
|
-
* 迭代
|
|
46
|
-
* cookies
|
|
47
|
-
* 优化
|
|
48
|
-
|
|
49
|
-
#### 发布版本:0.0.
|
|
50
|
-
#### 更新日期:2022/8/
|
|
51
|
-
#### 更新内容:
|
|
52
|
-
* 修复
|
|
53
|
-
* 迭代
|
|
54
|
-
*
|
|
55
|
-
* 优化
|
|
56
|
-
|
|
57
|
-
#### 发布版本:0.0.
|
|
58
|
-
#### 更新日期:2022/8/
|
|
59
|
-
#### 更新内容:
|
|
60
|
-
* 修复
|
|
61
|
-
* 迭代
|
|
62
|
-
*
|
|
63
|
-
* 优化
|
|
64
|
-
|
|
65
|
-
#### 发布版本:0.0.
|
|
66
|
-
#### 更新日期:2022/8/8
|
|
67
|
-
#### 更新内容:
|
|
68
|
-
* 修复
|
|
69
|
-
* 迭代
|
|
70
|
-
* 优化加密库依赖导入
|
|
71
|
-
* 优化
|
|
72
|
-
|
|
73
|
-
#### 发布版本:0.0.
|
|
74
|
-
#### 更新日期:2022/8/8
|
|
75
|
-
#### 更新内容:
|
|
76
|
-
* 修复
|
|
77
|
-
* 迭代
|
|
78
|
-
* 优化加密库依赖导入
|
|
79
|
-
* 优化
|
|
80
|
-
|
|
81
|
-
#### 发布版本:0.0.
|
|
82
|
-
#### 更新日期:2022/
|
|
83
|
-
#### 更新内容:
|
|
84
|
-
* 修复
|
|
85
|
-
* 迭代
|
|
86
|
-
*
|
|
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
|
+
|
|
33
|
+
#### 发布版本:0.1.0
|
|
34
|
+
#### 更新日期:2022/10/10
|
|
35
|
+
#### 更新内容:
|
|
36
|
+
* 修复
|
|
37
|
+
* 迭代
|
|
38
|
+
* 添加CCConfig
|
|
39
|
+
* 优化
|
|
40
|
+
|
|
41
|
+
#### 发布版本:0.0.9
|
|
42
|
+
#### 更新日期:2022/8/12
|
|
43
|
+
#### 更新内容:
|
|
44
|
+
* 修复
|
|
45
|
+
* 迭代
|
|
46
|
+
* cookies存储到域名中一份
|
|
47
|
+
* 优化
|
|
48
|
+
|
|
49
|
+
#### 发布版本:0.0.8
|
|
50
|
+
#### 更新日期:2022/8/12
|
|
51
|
+
#### 更新内容:
|
|
52
|
+
* 修复
|
|
53
|
+
* 迭代
|
|
54
|
+
* cookies有效期修改为2个小时
|
|
55
|
+
* 优化
|
|
56
|
+
|
|
57
|
+
#### 发布版本:0.0.7
|
|
58
|
+
#### 更新日期:2022/8/11
|
|
59
|
+
#### 更新内容:
|
|
60
|
+
* 修复
|
|
61
|
+
* 迭代
|
|
62
|
+
* token存储到cookes的二级域名兼容com.cn/org.cn/net.cn
|
|
63
|
+
* 优化
|
|
64
|
+
|
|
65
|
+
#### 发布版本:0.0.6
|
|
66
|
+
#### 更新日期:2022/8/8
|
|
67
|
+
#### 更新内容:
|
|
68
|
+
* 修复
|
|
69
|
+
* 迭代
|
|
70
|
+
* 优化加密库依赖导入
|
|
71
|
+
* 优化
|
|
72
|
+
|
|
73
|
+
#### 发布版本:0.0.5
|
|
74
|
+
#### 更新日期:2022/8/8
|
|
75
|
+
#### 更新内容:
|
|
76
|
+
* 修复
|
|
77
|
+
* 迭代
|
|
78
|
+
* 优化加密库依赖导入
|
|
79
|
+
* 优化
|
|
80
|
+
|
|
81
|
+
#### 发布版本:0.0.4
|
|
82
|
+
#### 更新日期:2022/8/8
|
|
83
|
+
#### 更新内容:
|
|
84
|
+
* 修复
|
|
85
|
+
* 迭代
|
|
86
|
+
* 优化加密库依赖导入
|
|
87
|
+
* 优化
|
|
88
|
+
|
|
89
|
+
#### 发布版本:0.0.3
|
|
90
|
+
#### 更新日期:2022/7/28
|
|
91
|
+
#### 更新内容:
|
|
92
|
+
* 修复
|
|
93
|
+
* 迭代
|
|
94
|
+
* 添加注解
|
|
87
95
|
* 优化
|
package/lib/ccdk.js
CHANGED
|
@@ -5,69 +5,69 @@ import PAD from 'crypto-js/pad-pkcs7';
|
|
|
5
5
|
import { Message, MessageBox, Notification } from 'element-ui';
|
|
6
6
|
import axios from 'axios';
|
|
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
|
-
}
|
|
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
71
|
}
|
|
72
72
|
|
|
73
73
|
var Crypto = /*#__PURE__*/Object.freeze({
|
|
@@ -76,19 +76,19 @@ var Crypto = /*#__PURE__*/Object.freeze({
|
|
|
76
76
|
decrypt: decrypt
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* 获得一级域名
|
|
81
|
-
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
82
|
-
*/
|
|
83
|
-
function getDomain() {
|
|
84
|
-
// 倒数第二位域名
|
|
85
|
-
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
86
|
-
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
87
|
-
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
88
|
-
return "." + document.domain.split('.').slice(-3).join('.')
|
|
89
|
-
} else {
|
|
90
|
-
return "." + document.domain.split('.').slice(-2).join('.')
|
|
91
|
-
}
|
|
79
|
+
/**
|
|
80
|
+
* 获得一级域名
|
|
81
|
+
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
82
|
+
*/
|
|
83
|
+
function getDomain() {
|
|
84
|
+
// 倒数第二位域名
|
|
85
|
+
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
86
|
+
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
87
|
+
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
88
|
+
return "." + document.domain.split('.').slice(-3).join('.')
|
|
89
|
+
} else {
|
|
90
|
+
return "." + document.domain.split('.').slice(-2).join('.')
|
|
91
|
+
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -96,31 +96,31 @@ var CCUtils = /*#__PURE__*/Object.freeze({
|
|
|
96
96
|
getDomain: getDomain
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
// cookie存储标识
|
|
100
|
-
const USER_INFO = "cc_user_info";
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 存储用户信息
|
|
104
|
-
* @param {String} userInfo 用户信息
|
|
105
|
-
* @param {String} domain 域名
|
|
106
|
-
*/
|
|
107
|
-
function setUserInfo(userInfo, domain = getDomain()) {
|
|
108
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
109
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 获取用户信息
|
|
114
|
-
* @returns {String} 用户信息
|
|
115
|
-
*/
|
|
116
|
-
function getUserInfo() {
|
|
117
|
-
// 加密的用户信息
|
|
118
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
119
|
-
if (encryptUserInfo) {
|
|
120
|
-
return Crypto.decrypt(encryptUserInfo)
|
|
121
|
-
} else {
|
|
122
|
-
return ""
|
|
123
|
-
}
|
|
99
|
+
// cookie存储标识
|
|
100
|
+
const USER_INFO = "cc_user_info";
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 存储用户信息
|
|
104
|
+
* @param {String} userInfo 用户信息
|
|
105
|
+
* @param {String} domain 域名
|
|
106
|
+
*/
|
|
107
|
+
function setUserInfo(userInfo, domain = getDomain()) {
|
|
108
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
109
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 获取用户信息
|
|
114
|
+
* @returns {String} 用户信息
|
|
115
|
+
*/
|
|
116
|
+
function getUserInfo() {
|
|
117
|
+
// 加密的用户信息
|
|
118
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
119
|
+
if (encryptUserInfo) {
|
|
120
|
+
return Crypto.decrypt(encryptUserInfo)
|
|
121
|
+
} else {
|
|
122
|
+
return ""
|
|
123
|
+
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
var CCUser = /*#__PURE__*/Object.freeze({
|
|
@@ -129,49 +129,49 @@ var CCUser = /*#__PURE__*/Object.freeze({
|
|
|
129
129
|
getUserInfo: getUserInfo
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
// cookie存储标识
|
|
133
|
-
const TOKEN = "cc_token";
|
|
134
|
-
/**
|
|
135
|
-
* 获取URL中参数的数据
|
|
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
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
|
|
147
|
-
* @param {String} urlName 获取token的url名称
|
|
148
|
-
* @returns
|
|
149
|
-
*/
|
|
150
|
-
function getToken(urlName = "binding") {
|
|
151
|
-
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
|
|
152
|
-
// 如果存在token,那么存储到cookies中,刷新有效期
|
|
153
|
-
if (token) {
|
|
154
|
-
setToken(token);
|
|
155
|
-
}
|
|
156
|
-
return token
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* 存储token
|
|
160
|
-
* @param {String} token token
|
|
161
|
-
* @param {String} domain 域名
|
|
162
|
-
*/
|
|
163
|
-
function setToken(token, domain = getDomain()) {
|
|
164
|
-
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
165
|
-
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 清除Token数据
|
|
170
|
-
* @param {String} domain 域名
|
|
171
|
-
*/
|
|
172
|
-
function clearToken(domain = getDomain()) {
|
|
173
|
-
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
174
|
-
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
132
|
+
// cookie存储标识
|
|
133
|
+
const TOKEN = "cc_token";
|
|
134
|
+
/**
|
|
135
|
+
* 获取URL中参数的数据
|
|
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
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
|
|
147
|
+
* @param {String} urlName 获取token的url名称
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
function getToken(urlName = "binding") {
|
|
151
|
+
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
|
|
152
|
+
// 如果存在token,那么存储到cookies中,刷新有效期
|
|
153
|
+
if (token) {
|
|
154
|
+
setToken(token);
|
|
155
|
+
}
|
|
156
|
+
return token
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 存储token
|
|
160
|
+
* @param {String} token token
|
|
161
|
+
* @param {String} domain 域名
|
|
162
|
+
*/
|
|
163
|
+
function setToken(token, domain = getDomain()) {
|
|
164
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
165
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 清除Token数据
|
|
170
|
+
* @param {String} domain 域名
|
|
171
|
+
*/
|
|
172
|
+
function clearToken(domain = getDomain()) {
|
|
173
|
+
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
174
|
+
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
@@ -181,26 +181,26 @@ var CCToken = /*#__PURE__*/Object.freeze({
|
|
|
181
181
|
clearToken: clearToken
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
/**
|
|
185
|
-
* 获取基础url
|
|
186
|
-
* @returns 基础地址
|
|
187
|
-
*/
|
|
188
|
-
function getBaseUrl() {
|
|
189
|
-
return window.gw.BASE_URL
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* 获取网关对象
|
|
193
|
-
* @returns 网关对象
|
|
194
|
-
*/
|
|
195
|
-
function getGw() {
|
|
196
|
-
return window.gw;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* 获取服务对象
|
|
200
|
-
* @returns 服务对象
|
|
201
|
-
*/
|
|
202
|
-
function getSvc() {
|
|
203
|
-
return window.Glod;
|
|
184
|
+
/**
|
|
185
|
+
* 获取基础url
|
|
186
|
+
* @returns 基础地址
|
|
187
|
+
*/
|
|
188
|
+
function getBaseUrl() {
|
|
189
|
+
return window.gw.BASE_URL
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 获取网关对象
|
|
193
|
+
* @returns 网关对象
|
|
194
|
+
*/
|
|
195
|
+
function getGw() {
|
|
196
|
+
return window.gw;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* 获取服务对象
|
|
200
|
+
* @returns 服务对象
|
|
201
|
+
*/
|
|
202
|
+
function getSvc() {
|
|
203
|
+
return window.Glod;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
var CCConfig = /*#__PURE__*/Object.freeze({
|
|
@@ -210,43 +210,43 @@ var CCConfig = /*#__PURE__*/Object.freeze({
|
|
|
210
210
|
getSvc: getSvc
|
|
211
211
|
});
|
|
212
212
|
|
|
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);
|
|
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
250
|
}
|
|
251
251
|
|
|
252
252
|
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
@@ -256,76 +256,76 @@ var CCMessage = /*#__PURE__*/Object.freeze({
|
|
|
256
256
|
showNotification: showNotification
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
const service = axios.create({
|
|
260
|
-
timeout: 60000,
|
|
261
|
-
headers: {
|
|
262
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
service.interceptors.request.use(
|
|
267
|
-
config => {
|
|
268
|
-
config.headers['accessToken'] = $CCDK.CCToken.getToken();
|
|
269
|
-
return config
|
|
270
|
-
},
|
|
271
|
-
error => {
|
|
272
|
-
Promise.reject(error);
|
|
273
|
-
}
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
service.interceptors.response.use(
|
|
277
|
-
response => {
|
|
278
|
-
const code = response.data.code || 200;
|
|
279
|
-
if (code !== 200) {
|
|
280
|
-
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
281
|
-
} else {
|
|
282
|
-
return response.data
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
error => {
|
|
286
|
-
return Promise.reject(error)
|
|
287
|
-
}
|
|
288
|
-
);
|
|
289
|
-
function get(url, data = {}, responseType = '') {
|
|
290
|
-
return service({
|
|
291
|
-
url: url,
|
|
292
|
-
method: 'get',
|
|
293
|
-
params: data,
|
|
294
|
-
responseType: responseType
|
|
295
|
-
})
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function post(url, data = {}, responseType = '') {
|
|
299
|
-
return service({
|
|
300
|
-
url: url,
|
|
301
|
-
method: 'post',
|
|
302
|
-
data: data,
|
|
303
|
-
responseType: responseType
|
|
304
|
-
})
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function put(url, data = {}) {
|
|
308
|
-
return service({
|
|
309
|
-
url: url,
|
|
310
|
-
method: 'put',
|
|
311
|
-
data: data
|
|
312
|
-
})
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function postParams(url, data = {}) {
|
|
316
|
-
return service({
|
|
317
|
-
url: url,
|
|
318
|
-
method: 'post',
|
|
319
|
-
params: data
|
|
320
|
-
})
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function patch(url, data = {}) {
|
|
324
|
-
return service({
|
|
325
|
-
url: url,
|
|
326
|
-
method: 'patch',
|
|
327
|
-
data: data
|
|
328
|
-
})
|
|
259
|
+
const service = axios.create({
|
|
260
|
+
timeout: 60000,
|
|
261
|
+
headers: {
|
|
262
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
service.interceptors.request.use(
|
|
267
|
+
config => {
|
|
268
|
+
config.headers['accessToken'] = $CCDK.CCToken.getToken();
|
|
269
|
+
return config
|
|
270
|
+
},
|
|
271
|
+
error => {
|
|
272
|
+
Promise.reject(error);
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
service.interceptors.response.use(
|
|
277
|
+
response => {
|
|
278
|
+
const code = response.data.code || 200;
|
|
279
|
+
if (code !== 200) {
|
|
280
|
+
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
281
|
+
} else {
|
|
282
|
+
return response.data
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
error => {
|
|
286
|
+
return Promise.reject(error)
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
function get(url, data = {}, responseType = '') {
|
|
290
|
+
return service({
|
|
291
|
+
url: url,
|
|
292
|
+
method: 'get',
|
|
293
|
+
params: data,
|
|
294
|
+
responseType: responseType
|
|
295
|
+
})
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function post(url, data = {}, responseType = '') {
|
|
299
|
+
return service({
|
|
300
|
+
url: url,
|
|
301
|
+
method: 'post',
|
|
302
|
+
data: data,
|
|
303
|
+
responseType: responseType
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function put(url, data = {}) {
|
|
308
|
+
return service({
|
|
309
|
+
url: url,
|
|
310
|
+
method: 'put',
|
|
311
|
+
data: data
|
|
312
|
+
})
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function postParams(url, data = {}) {
|
|
316
|
+
return service({
|
|
317
|
+
url: url,
|
|
318
|
+
method: 'post',
|
|
319
|
+
params: data
|
|
320
|
+
})
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function patch(url, data = {}) {
|
|
324
|
+
return service({
|
|
325
|
+
url: url,
|
|
326
|
+
method: 'patch',
|
|
327
|
+
data: data
|
|
328
|
+
})
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
var CCHttp = /*#__PURE__*/Object.freeze({
|
|
@@ -337,25 +337,25 @@ var CCHttp = /*#__PURE__*/Object.freeze({
|
|
|
337
337
|
postParams: postParams
|
|
338
338
|
});
|
|
339
339
|
|
|
340
|
-
/**
|
|
341
|
-
* 获得当前访问的标准对象
|
|
342
|
-
*/
|
|
343
|
-
function getObject() {
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* 获得当前标准对象的详细信息
|
|
349
|
-
*/
|
|
350
|
-
function getObjectDetail() {
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* 修改当前标准对象的详细信息
|
|
356
|
-
*/
|
|
357
|
-
function setObjectDetail() {
|
|
358
|
-
|
|
340
|
+
/**
|
|
341
|
+
* 获得当前访问的标准对象
|
|
342
|
+
*/
|
|
343
|
+
function getObject() {
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 获得当前标准对象的详细信息
|
|
349
|
+
*/
|
|
350
|
+
function getObjectDetail() {
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 修改当前标准对象的详细信息
|
|
356
|
+
*/
|
|
357
|
+
function setObjectDetail() {
|
|
358
|
+
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
var CCObject = /*#__PURE__*/Object.freeze({
|
|
@@ -365,57 +365,57 @@ var CCObject = /*#__PURE__*/Object.freeze({
|
|
|
365
365
|
setObjectDetail: setObjectDetail
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
/**
|
|
369
|
-
* 打开对象视图页面
|
|
370
|
-
* @param {string} objectType 对象类型
|
|
371
|
-
* @param {object} options 配置信息
|
|
372
|
-
*/
|
|
373
|
-
function openListPage(objectType, options = {}) {
|
|
374
|
-
$CCDK.CCBus.$emit('openListPage', objectType, id, options);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* 打开数据详情页
|
|
379
|
-
* @param {string} objectType 对象类型
|
|
380
|
-
* @param {string} id 数据id
|
|
381
|
-
* @param {object} options 配置信息
|
|
382
|
-
*/
|
|
383
|
-
function openDetailPage(objectType, id, options = {}) {
|
|
384
|
-
$CCDK.CCBus.$emit('openCreatePage', objectType, id, options);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* 打开创建页面
|
|
389
|
-
* @param {string} objectType 对象类型
|
|
390
|
-
* @param {object} options 配置信息
|
|
391
|
-
*/
|
|
392
|
-
function openCreatePage(objectType, options = {}) {
|
|
393
|
-
$CCDK.CCBus.$emit('openCreatePage', objectType, options);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* 打开修改页面
|
|
398
|
-
* @param {string} objectType 对象类型
|
|
399
|
-
* @param {string} id 数据id
|
|
400
|
-
* @param {object} options 配置信息
|
|
401
|
-
*/
|
|
402
|
-
function openEditPage(objectType, id, options = {}) {
|
|
403
|
-
$CCDK.CCBus.$emit('openEditPage', objectType, id, options);
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* 打开自定义页面
|
|
407
|
-
* @param {string} pageId 自定义页面id
|
|
408
|
-
* @param {object} options 配置信息
|
|
409
|
-
*/
|
|
410
|
-
function openCustomPage(pageId, options = {}) {
|
|
411
|
-
$CCDK.CCBus.$emit('openCustomPage', pageId, options);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* 关闭本页面
|
|
416
|
-
*/
|
|
417
|
-
function close() {
|
|
418
|
-
|
|
368
|
+
/**
|
|
369
|
+
* 打开对象视图页面
|
|
370
|
+
* @param {string} objectType 对象类型
|
|
371
|
+
* @param {object} options 配置信息
|
|
372
|
+
*/
|
|
373
|
+
function openListPage(objectType, options = {}) {
|
|
374
|
+
$CCDK.CCBus.$emit('openListPage', objectType, id, options);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 打开数据详情页
|
|
379
|
+
* @param {string} objectType 对象类型
|
|
380
|
+
* @param {string} id 数据id
|
|
381
|
+
* @param {object} options 配置信息
|
|
382
|
+
*/
|
|
383
|
+
function openDetailPage(objectType, id, options = {}) {
|
|
384
|
+
$CCDK.CCBus.$emit('openCreatePage', objectType, id, options);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* 打开创建页面
|
|
389
|
+
* @param {string} objectType 对象类型
|
|
390
|
+
* @param {object} options 配置信息
|
|
391
|
+
*/
|
|
392
|
+
function openCreatePage(objectType, options = {}) {
|
|
393
|
+
$CCDK.CCBus.$emit('openCreatePage', objectType, options);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 打开修改页面
|
|
398
|
+
* @param {string} objectType 对象类型
|
|
399
|
+
* @param {string} id 数据id
|
|
400
|
+
* @param {object} options 配置信息
|
|
401
|
+
*/
|
|
402
|
+
function openEditPage(objectType, id, options = {}) {
|
|
403
|
+
$CCDK.CCBus.$emit('openEditPage', objectType, id, options);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* 打开自定义页面
|
|
407
|
+
* @param {string} pageId 自定义页面id
|
|
408
|
+
* @param {object} options 配置信息
|
|
409
|
+
*/
|
|
410
|
+
function openCustomPage(pageId, options = {}) {
|
|
411
|
+
$CCDK.CCBus.$emit('openCustomPage', pageId, options);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* 关闭本页面
|
|
416
|
+
*/
|
|
417
|
+
function close() {
|
|
418
|
+
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
@@ -428,28 +428,28 @@ var CCPage = /*#__PURE__*/Object.freeze({
|
|
|
428
428
|
close: close
|
|
429
429
|
});
|
|
430
430
|
|
|
431
|
-
/**
|
|
432
|
-
* 发布信息
|
|
433
|
-
* @param {string} event 事件名称
|
|
434
|
-
* @param {...any} args 参数列表
|
|
435
|
-
*/
|
|
436
|
-
function $emit(event, ...args) {
|
|
437
|
-
window.ccBus.$emit(event, ...args);
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* 订阅消息
|
|
441
|
-
* @param {string} event 事件名称
|
|
442
|
-
* @param {function} callback 回调方法
|
|
443
|
-
*/
|
|
444
|
-
function $on(event, callback) {
|
|
445
|
-
window.ccBus.$on(event, callback);
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* 取消订阅
|
|
449
|
-
* @param {string} event 事件名称
|
|
450
|
-
*/
|
|
451
|
-
function $off(event) {
|
|
452
|
-
window.ccBus.$off(event);
|
|
431
|
+
/**
|
|
432
|
+
* 发布信息
|
|
433
|
+
* @param {string} event 事件名称
|
|
434
|
+
* @param {...any} args 参数列表
|
|
435
|
+
*/
|
|
436
|
+
function $emit(event, ...args) {
|
|
437
|
+
window.ccBus.$emit(event, ...args);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* 订阅消息
|
|
441
|
+
* @param {string} event 事件名称
|
|
442
|
+
* @param {function} callback 回调方法
|
|
443
|
+
*/
|
|
444
|
+
function $on(event, callback) {
|
|
445
|
+
window.ccBus.$on(event, callback);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* 取消订阅
|
|
449
|
+
* @param {string} event 事件名称
|
|
450
|
+
*/
|
|
451
|
+
function $off(event) {
|
|
452
|
+
window.ccBus.$off(event);
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
var CCBus = /*#__PURE__*/Object.freeze({
|
|
@@ -459,4 +459,54 @@ var CCBus = /*#__PURE__*/Object.freeze({
|
|
|
459
459
|
$off: $off
|
|
460
460
|
});
|
|
461
461
|
|
|
462
|
-
|
|
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"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});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,26 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cloudcc-ccdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "lib/ccdk-min.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"libs:build": "rollup -c && uglifyjs lib/ccdk.js -o lib/ccdk.min.js",
|
|
8
|
-
"libs:publish": "npm run libs:build && npm publish --registry https://registry.npmjs.org"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"cloudcc-ccdk",
|
|
12
|
-
"cloudcc"
|
|
13
|
-
],
|
|
14
|
-
"files": [
|
|
15
|
-
"lib"
|
|
16
|
-
],
|
|
17
|
-
"author": "294985925@qq.com",
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"rollup": "^2.77.0",
|
|
20
|
-
"uglify-js": "^3.17.3"
|
|
21
|
-
},
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"js
|
|
25
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "cloudcc-ccdk",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/ccdk-min.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"libs:build": "rollup -c && uglifyjs lib/ccdk.js -o lib/ccdk.min.js",
|
|
8
|
+
"libs:publish": "npm run libs:build && npm publish --registry https://registry.npmjs.org"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"cloudcc-ccdk",
|
|
12
|
+
"cloudcc"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"author": "294985925@qq.com",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"rollup": "^2.77.0",
|
|
20
|
+
"uglify-js": "^3.17.3"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"axios": "^1.1.3",
|
|
24
|
+
"crypto-js": "^4.1.1",
|
|
25
|
+
"element-ui": "^2.15.10",
|
|
26
|
+
"js-cookie": "^3.0.1"
|
|
27
|
+
}
|
|
26
28
|
}
|