cloudcc-ccdk 0.3.6 → 0.3.7
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 +249 -241
- package/lib/ccdk.js +598 -598
- package/lib/ccdk.min.js +1 -1
- package/package.json +29 -29
package/lib/ccdk.js
CHANGED
|
@@ -6,69 +6,69 @@ import axios from 'axios';
|
|
|
6
6
|
import { Message, MessageBox, Notification } from 'element-ui';
|
|
7
7
|
import Cookies from 'js-cookie';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* 加密
|
|
11
|
-
* @param {String} data 数据
|
|
12
|
-
* @param {String} key 密钥
|
|
13
|
-
* @param {String} iv 偏移量
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
function getAesString(data, key, iv) {
|
|
17
|
-
key = UTF8.parse(key);
|
|
18
|
-
iv = UTF8.parse(iv);
|
|
19
|
-
let encrypted = CryptoJS.encrypt(data, key, {
|
|
20
|
-
iv: iv,
|
|
21
|
-
padding: PAD,
|
|
22
|
-
});
|
|
23
|
-
return encrypted.toString(); //返回的是base64格式的密文
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 解密
|
|
28
|
-
* @param {String} encrypted 密文
|
|
29
|
-
* @param {String} key 密钥
|
|
30
|
-
* @param {String} iv 偏移量
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
function getDAesString(encrypted, key, iv) {
|
|
34
|
-
key = UTF8.parse(key);
|
|
35
|
-
iv = UTF8.parse(iv);
|
|
36
|
-
let decrypted = CryptoJS.decrypt(encrypted, key, {
|
|
37
|
-
iv: iv,
|
|
38
|
-
padding: PAD,
|
|
39
|
-
});
|
|
40
|
-
return decrypted.toString(UTF8);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* CryptoJS加密
|
|
45
|
-
* @param {String} data 数据
|
|
46
|
-
* @param {String} key 密钥
|
|
47
|
-
* @param {String} iv 偏移量
|
|
48
|
-
* @returns 加密的数据
|
|
49
|
-
*/
|
|
50
|
-
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
51
|
-
data = JSON.stringify(data);
|
|
52
|
-
var encrypted = getAesString(data, key, iv); //密文
|
|
53
|
-
return encrypted;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* CryptoJS解密
|
|
58
|
-
* @param {String} data 加密的数据
|
|
59
|
-
* @param {String} key 密钥
|
|
60
|
-
* @param {String} iv 偏移量
|
|
61
|
-
* @returns 解密的数据
|
|
62
|
-
*/
|
|
63
|
-
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
64
|
-
try {
|
|
65
|
-
var decryptedStr = getDAesString(data, key, iv);
|
|
66
|
-
if (!decryptedStr) return null
|
|
67
|
-
return JSON.parse(decryptedStr);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.trace("解密密码错误", error);
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* 加密
|
|
11
|
+
* @param {String} data 数据
|
|
12
|
+
* @param {String} key 密钥
|
|
13
|
+
* @param {String} iv 偏移量
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function getAesString(data, key, iv) {
|
|
17
|
+
key = UTF8.parse(key);
|
|
18
|
+
iv = UTF8.parse(iv);
|
|
19
|
+
let encrypted = CryptoJS.encrypt(data, key, {
|
|
20
|
+
iv: iv,
|
|
21
|
+
padding: PAD,
|
|
22
|
+
});
|
|
23
|
+
return encrypted.toString(); //返回的是base64格式的密文
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 解密
|
|
28
|
+
* @param {String} encrypted 密文
|
|
29
|
+
* @param {String} key 密钥
|
|
30
|
+
* @param {String} iv 偏移量
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
function getDAesString(encrypted, key, iv) {
|
|
34
|
+
key = UTF8.parse(key);
|
|
35
|
+
iv = UTF8.parse(iv);
|
|
36
|
+
let decrypted = CryptoJS.decrypt(encrypted, key, {
|
|
37
|
+
iv: iv,
|
|
38
|
+
padding: PAD,
|
|
39
|
+
});
|
|
40
|
+
return decrypted.toString(UTF8);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* CryptoJS加密
|
|
45
|
+
* @param {String} data 数据
|
|
46
|
+
* @param {String} key 密钥
|
|
47
|
+
* @param {String} iv 偏移量
|
|
48
|
+
* @returns 加密的数据
|
|
49
|
+
*/
|
|
50
|
+
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
51
|
+
data = JSON.stringify(data);
|
|
52
|
+
var encrypted = getAesString(data, key, iv); //密文
|
|
53
|
+
return encrypted;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* CryptoJS解密
|
|
58
|
+
* @param {String} data 加密的数据
|
|
59
|
+
* @param {String} key 密钥
|
|
60
|
+
* @param {String} iv 偏移量
|
|
61
|
+
* @returns 解密的数据
|
|
62
|
+
*/
|
|
63
|
+
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
64
|
+
try {
|
|
65
|
+
var decryptedStr = getDAesString(data, key, iv);
|
|
66
|
+
if (!decryptedStr) return null
|
|
67
|
+
return JSON.parse(decryptedStr);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.trace("解密密码错误", error);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
var Crypto = /*#__PURE__*/Object.freeze({
|
|
@@ -77,27 +77,27 @@ var Crypto = /*#__PURE__*/Object.freeze({
|
|
|
77
77
|
decrypt: decrypt
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
-
// 当前应用存储标识
|
|
81
|
-
const APPLICATION_DETAIL = 'applicaton_current';
|
|
82
|
-
/**
|
|
83
|
-
* 获得当前访问的应用对象
|
|
84
|
-
*/
|
|
85
|
-
function getApplicaton() {
|
|
86
|
-
let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
|
|
87
|
-
if (detail) {
|
|
88
|
-
return JSON.parse(detail)
|
|
89
|
-
}
|
|
90
|
-
return ''
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 设置应用对象信息
|
|
95
|
-
* @param {object} detail 应用对象
|
|
96
|
-
*/
|
|
97
|
-
function setApplication(detail = '') {
|
|
98
|
-
if (detail) {
|
|
99
|
-
localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
|
|
100
|
-
}
|
|
80
|
+
// 当前应用存储标识
|
|
81
|
+
const APPLICATION_DETAIL = 'applicaton_current';
|
|
82
|
+
/**
|
|
83
|
+
* 获得当前访问的应用对象
|
|
84
|
+
*/
|
|
85
|
+
function getApplicaton() {
|
|
86
|
+
let detail = localStorage.getItem(Crypto.encrypt(APPLICATION_DETAIL));
|
|
87
|
+
if (detail) {
|
|
88
|
+
return JSON.parse(detail)
|
|
89
|
+
}
|
|
90
|
+
return ''
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 设置应用对象信息
|
|
95
|
+
* @param {object} detail 应用对象
|
|
96
|
+
*/
|
|
97
|
+
function setApplication(detail = '') {
|
|
98
|
+
if (detail) {
|
|
99
|
+
localStorage.setItem(Crypto.encrypt(APPLICATION_DETAIL), JSON.stringify(detail));
|
|
100
|
+
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
var CCApplication = /*#__PURE__*/Object.freeze({
|
|
@@ -106,29 +106,29 @@ var CCApplication = /*#__PURE__*/Object.freeze({
|
|
|
106
106
|
setApplication: setApplication
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
window.ccBus = new Vue;
|
|
110
|
-
/**
|
|
111
|
-
* 发布信息
|
|
112
|
-
* @param {string} event 事件名称
|
|
113
|
-
* @param {...any} args 参数列表
|
|
114
|
-
*/
|
|
115
|
-
function $emit(event, ...args) {
|
|
116
|
-
window.ccBus.$emit(event, ...args);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 订阅消息
|
|
120
|
-
* @param {string} event 事件名称
|
|
121
|
-
* @param {function} callback 回调方法
|
|
122
|
-
*/
|
|
123
|
-
function $on(event, callback) {
|
|
124
|
-
window.ccBus.$on(event, callback);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* 取消订阅
|
|
128
|
-
* @param {string} event 事件名称
|
|
129
|
-
*/
|
|
130
|
-
function $off(event) {
|
|
131
|
-
window.ccBus.$off(event);
|
|
109
|
+
window.ccBus = new Vue;
|
|
110
|
+
/**
|
|
111
|
+
* 发布信息
|
|
112
|
+
* @param {string} event 事件名称
|
|
113
|
+
* @param {...any} args 参数列表
|
|
114
|
+
*/
|
|
115
|
+
function $emit(event, ...args) {
|
|
116
|
+
window.ccBus.$emit(event, ...args);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* 订阅消息
|
|
120
|
+
* @param {string} event 事件名称
|
|
121
|
+
* @param {function} callback 回调方法
|
|
122
|
+
*/
|
|
123
|
+
function $on(event, callback) {
|
|
124
|
+
window.ccBus.$on(event, callback);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 取消订阅
|
|
128
|
+
* @param {string} event 事件名称
|
|
129
|
+
*/
|
|
130
|
+
function $off(event) {
|
|
131
|
+
window.ccBus.$off(event);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
var CCBus = /*#__PURE__*/Object.freeze({
|
|
@@ -138,57 +138,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
|
|
|
138
138
|
$off: $off
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
-
// 电话对象
|
|
142
|
-
let ccCall = new Map();
|
|
143
|
-
// 电话服务商当前对象
|
|
144
|
-
let currentCall;
|
|
145
|
-
/**
|
|
146
|
-
* 初始化电话条
|
|
147
|
-
* @param {string} id 电话服务商唯一标识
|
|
148
|
-
* @param {object} callClient 电话对象
|
|
149
|
-
*/
|
|
150
|
-
function init(id, callClient) {
|
|
151
|
-
if (id && callClient) {
|
|
152
|
-
ccCall.set(id, callClient);
|
|
153
|
-
currentCall = callClient;
|
|
154
|
-
return currentCall
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* 拨打电话
|
|
161
|
-
* @param {string} id 电话服务商唯一标识
|
|
162
|
-
* @param {object} options 配置信息
|
|
163
|
-
*/
|
|
164
|
-
function call(id, options) {
|
|
165
|
-
let call;
|
|
166
|
-
if (id) {
|
|
167
|
-
call = ccCall.get(id);
|
|
168
|
-
} else {
|
|
169
|
-
call = currentCall;
|
|
170
|
-
}
|
|
171
|
-
if (call) {
|
|
172
|
-
call.call(options);
|
|
173
|
-
}
|
|
174
|
-
return call
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* 打开通话面板
|
|
178
|
-
* @param {string} id 电话服务商唯一标识
|
|
179
|
-
* @param {object} options 配置信息
|
|
180
|
-
*/
|
|
181
|
-
function openCallPanel(id, options) {
|
|
182
|
-
let call;
|
|
183
|
-
if (id) {
|
|
184
|
-
call = ccCall.get(id);
|
|
185
|
-
} else {
|
|
186
|
-
call = currentCall;
|
|
187
|
-
}
|
|
188
|
-
if (call) {
|
|
189
|
-
call.openCallPanel(options);
|
|
190
|
-
}
|
|
191
|
-
return call
|
|
141
|
+
// 电话对象
|
|
142
|
+
let ccCall = new Map();
|
|
143
|
+
// 电话服务商当前对象
|
|
144
|
+
let currentCall;
|
|
145
|
+
/**
|
|
146
|
+
* 初始化电话条
|
|
147
|
+
* @param {string} id 电话服务商唯一标识
|
|
148
|
+
* @param {object} callClient 电话对象
|
|
149
|
+
*/
|
|
150
|
+
function init(id, callClient) {
|
|
151
|
+
if (id && callClient) {
|
|
152
|
+
ccCall.set(id, callClient);
|
|
153
|
+
currentCall = callClient;
|
|
154
|
+
return currentCall
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 拨打电话
|
|
161
|
+
* @param {string} id 电话服务商唯一标识
|
|
162
|
+
* @param {object} options 配置信息
|
|
163
|
+
*/
|
|
164
|
+
function call(id, options) {
|
|
165
|
+
let call;
|
|
166
|
+
if (id) {
|
|
167
|
+
call = ccCall.get(id);
|
|
168
|
+
} else {
|
|
169
|
+
call = currentCall;
|
|
170
|
+
}
|
|
171
|
+
if (call) {
|
|
172
|
+
call.call(options);
|
|
173
|
+
}
|
|
174
|
+
return call
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* 打开通话面板
|
|
178
|
+
* @param {string} id 电话服务商唯一标识
|
|
179
|
+
* @param {object} options 配置信息
|
|
180
|
+
*/
|
|
181
|
+
function openCallPanel(id, options) {
|
|
182
|
+
let call;
|
|
183
|
+
if (id) {
|
|
184
|
+
call = ccCall.get(id);
|
|
185
|
+
} else {
|
|
186
|
+
call = currentCall;
|
|
187
|
+
}
|
|
188
|
+
if (call) {
|
|
189
|
+
call.openCallPanel(options);
|
|
190
|
+
}
|
|
191
|
+
return call
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
var CCCall = /*#__PURE__*/Object.freeze({
|
|
@@ -198,26 +198,26 @@ var CCCall = /*#__PURE__*/Object.freeze({
|
|
|
198
198
|
openCallPanel: openCallPanel
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
/**
|
|
202
|
-
* 获取基础url
|
|
203
|
-
* @returns 基础地址
|
|
204
|
-
*/
|
|
205
|
-
function getBaseUrl() {
|
|
206
|
-
return window.gw.BASE_URL
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* 获取网关对象
|
|
210
|
-
* @returns 网关对象
|
|
211
|
-
*/
|
|
212
|
-
function getGw() {
|
|
213
|
-
return window.gw;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* 获取服务对象
|
|
217
|
-
* @returns 服务对象
|
|
218
|
-
*/
|
|
219
|
-
function getSvc() {
|
|
220
|
-
return window.Glod;
|
|
201
|
+
/**
|
|
202
|
+
* 获取基础url
|
|
203
|
+
* @returns 基础地址
|
|
204
|
+
*/
|
|
205
|
+
function getBaseUrl() {
|
|
206
|
+
return window.gw.BASE_URL
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 获取网关对象
|
|
210
|
+
* @returns 网关对象
|
|
211
|
+
*/
|
|
212
|
+
function getGw() {
|
|
213
|
+
return window.gw;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 获取服务对象
|
|
217
|
+
* @returns 服务对象
|
|
218
|
+
*/
|
|
219
|
+
function getSvc() {
|
|
220
|
+
return window.Glod;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
var CCConfig = /*#__PURE__*/Object.freeze({
|
|
@@ -227,76 +227,76 @@ var CCConfig = /*#__PURE__*/Object.freeze({
|
|
|
227
227
|
getSvc: getSvc
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
-
const service = axios.create({
|
|
231
|
-
timeout: 60000,
|
|
232
|
-
headers: {
|
|
233
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
service.interceptors.request.use(
|
|
238
|
-
config => {
|
|
239
|
-
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
240
|
-
return config
|
|
241
|
-
},
|
|
242
|
-
error => {
|
|
243
|
-
Promise.reject(error);
|
|
244
|
-
}
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
service.interceptors.response.use(
|
|
248
|
-
response => {
|
|
249
|
-
const code = response.data.code || 200;
|
|
250
|
-
if (code !== 200) {
|
|
251
|
-
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
252
|
-
} else {
|
|
253
|
-
return response.data
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
error => {
|
|
257
|
-
return Promise.reject(error)
|
|
258
|
-
}
|
|
259
|
-
);
|
|
260
|
-
function get(url, data = {}, responseType = '') {
|
|
261
|
-
return service({
|
|
262
|
-
url: url,
|
|
263
|
-
method: 'get',
|
|
264
|
-
params: data,
|
|
265
|
-
responseType: responseType
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function post(url, data = {}, responseType = '') {
|
|
270
|
-
return service({
|
|
271
|
-
url: url,
|
|
272
|
-
method: 'post',
|
|
273
|
-
data: data,
|
|
274
|
-
responseType: responseType
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function put(url, data = {}) {
|
|
279
|
-
return service({
|
|
280
|
-
url: url,
|
|
281
|
-
method: 'put',
|
|
282
|
-
data: data
|
|
283
|
-
})
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function postParams(url, data = {}) {
|
|
287
|
-
return service({
|
|
288
|
-
url: url,
|
|
289
|
-
method: 'post',
|
|
290
|
-
params: data
|
|
291
|
-
})
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function patch(url, data = {}) {
|
|
295
|
-
return service({
|
|
296
|
-
url: url,
|
|
297
|
-
method: 'patch',
|
|
298
|
-
data: data
|
|
299
|
-
})
|
|
230
|
+
const service = axios.create({
|
|
231
|
+
timeout: 60000,
|
|
232
|
+
headers: {
|
|
233
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
service.interceptors.request.use(
|
|
238
|
+
config => {
|
|
239
|
+
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
240
|
+
return config
|
|
241
|
+
},
|
|
242
|
+
error => {
|
|
243
|
+
Promise.reject(error);
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
service.interceptors.response.use(
|
|
248
|
+
response => {
|
|
249
|
+
const code = response.data.code || 200;
|
|
250
|
+
if (code !== 200) {
|
|
251
|
+
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
252
|
+
} else {
|
|
253
|
+
return response.data
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
error => {
|
|
257
|
+
return Promise.reject(error)
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
function get(url, data = {}, responseType = '') {
|
|
261
|
+
return service({
|
|
262
|
+
url: url,
|
|
263
|
+
method: 'get',
|
|
264
|
+
params: data,
|
|
265
|
+
responseType: responseType
|
|
266
|
+
})
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function post(url, data = {}, responseType = '') {
|
|
270
|
+
return service({
|
|
271
|
+
url: url,
|
|
272
|
+
method: 'post',
|
|
273
|
+
data: data,
|
|
274
|
+
responseType: responseType
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function put(url, data = {}) {
|
|
279
|
+
return service({
|
|
280
|
+
url: url,
|
|
281
|
+
method: 'put',
|
|
282
|
+
data: data
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function postParams(url, data = {}) {
|
|
287
|
+
return service({
|
|
288
|
+
url: url,
|
|
289
|
+
method: 'post',
|
|
290
|
+
params: data
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function patch(url, data = {}) {
|
|
295
|
+
return service({
|
|
296
|
+
url: url,
|
|
297
|
+
method: 'patch',
|
|
298
|
+
data: data
|
|
299
|
+
})
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
var CCHttp = /*#__PURE__*/Object.freeze({
|
|
@@ -308,47 +308,47 @@ var CCHttp = /*#__PURE__*/Object.freeze({
|
|
|
308
308
|
postParams: postParams
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
-
/**
|
|
312
|
-
* 添加一个一级菜单
|
|
313
|
-
* @param {object} options 菜单配置
|
|
314
|
-
*/
|
|
315
|
-
function addMenu1(options) {
|
|
316
|
-
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* 添加一个二级菜单
|
|
320
|
-
* @param {object} options 菜单配置
|
|
321
|
-
*/
|
|
322
|
-
function addMenu2(options) {
|
|
323
|
-
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* 删除一个一级菜单
|
|
327
|
-
* @param {object} options 菜单配置
|
|
328
|
-
*/
|
|
329
|
-
function deleteMenu1(options) {
|
|
330
|
-
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* 删除一个二级菜单
|
|
334
|
-
* @param {object} options 菜单配置
|
|
335
|
-
*/
|
|
336
|
-
function deleteMenu2(options) {
|
|
337
|
-
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* 刷新一个一级菜单
|
|
341
|
-
* @param {object} options 菜单配置
|
|
342
|
-
*/
|
|
343
|
-
function refreshMenu1(options) {
|
|
344
|
-
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* 刷新一个二级菜单
|
|
348
|
-
* @param {object} options 菜单配置
|
|
349
|
-
*/
|
|
350
|
-
function refreshMenu2(options) {
|
|
351
|
-
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
311
|
+
/**
|
|
312
|
+
* 添加一个一级菜单
|
|
313
|
+
* @param {object} options 菜单配置
|
|
314
|
+
*/
|
|
315
|
+
function addMenu1(options) {
|
|
316
|
+
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* 添加一个二级菜单
|
|
320
|
+
* @param {object} options 菜单配置
|
|
321
|
+
*/
|
|
322
|
+
function addMenu2(options) {
|
|
323
|
+
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 删除一个一级菜单
|
|
327
|
+
* @param {object} options 菜单配置
|
|
328
|
+
*/
|
|
329
|
+
function deleteMenu1(options) {
|
|
330
|
+
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 删除一个二级菜单
|
|
334
|
+
* @param {object} options 菜单配置
|
|
335
|
+
*/
|
|
336
|
+
function deleteMenu2(options) {
|
|
337
|
+
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* 刷新一个一级菜单
|
|
341
|
+
* @param {object} options 菜单配置
|
|
342
|
+
*/
|
|
343
|
+
function refreshMenu1(options) {
|
|
344
|
+
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* 刷新一个二级菜单
|
|
348
|
+
* @param {object} options 菜单配置
|
|
349
|
+
*/
|
|
350
|
+
function refreshMenu2(options) {
|
|
351
|
+
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
var CCMenu = /*#__PURE__*/Object.freeze({
|
|
@@ -361,43 +361,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
|
|
|
361
361
|
refreshMenu2: refreshMenu2
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
-
/**
|
|
365
|
-
* 消息提示框
|
|
366
|
-
* @param {string} text 提示文字,支持vhtml渲染
|
|
367
|
-
* @param {string} type 消息类别
|
|
368
|
-
* @param {number} duration 持续时间
|
|
369
|
-
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
370
|
-
* @param {boolean} center 文字是否剧中
|
|
371
|
-
*/
|
|
372
|
-
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
373
|
-
Message({
|
|
374
|
-
message: text,
|
|
375
|
-
type,
|
|
376
|
-
duration,
|
|
377
|
-
showClose,
|
|
378
|
-
center
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* 提示确认框
|
|
383
|
-
* @param {string} text 提示信息
|
|
384
|
-
* @param {string} title 标题
|
|
385
|
-
* @param {object} options 配置信息
|
|
386
|
-
*/
|
|
387
|
-
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
388
|
-
MessageBox.confirm(text, title, options).then(() => {
|
|
389
|
-
confirm();
|
|
390
|
-
}).catch(() => {
|
|
391
|
-
reject();
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* 提示消息框
|
|
397
|
-
* @param {object} options 配置信息
|
|
398
|
-
*/
|
|
399
|
-
function showNotification(options = {}) {
|
|
400
|
-
Notification(options);
|
|
364
|
+
/**
|
|
365
|
+
* 消息提示框
|
|
366
|
+
* @param {string} text 提示文字,支持vhtml渲染
|
|
367
|
+
* @param {string} type 消息类别
|
|
368
|
+
* @param {number} duration 持续时间
|
|
369
|
+
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
370
|
+
* @param {boolean} center 文字是否剧中
|
|
371
|
+
*/
|
|
372
|
+
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
373
|
+
Message({
|
|
374
|
+
message: text,
|
|
375
|
+
type,
|
|
376
|
+
duration,
|
|
377
|
+
showClose,
|
|
378
|
+
center
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* 提示确认框
|
|
383
|
+
* @param {string} text 提示信息
|
|
384
|
+
* @param {string} title 标题
|
|
385
|
+
* @param {object} options 配置信息
|
|
386
|
+
*/
|
|
387
|
+
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
388
|
+
MessageBox.confirm(text, title, options).then(() => {
|
|
389
|
+
confirm();
|
|
390
|
+
}).catch(() => {
|
|
391
|
+
reject();
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* 提示消息框
|
|
397
|
+
* @param {object} options 配置信息
|
|
398
|
+
*/
|
|
399
|
+
function showNotification(options = {}) {
|
|
400
|
+
Notification(options);
|
|
401
401
|
}
|
|
402
402
|
|
|
403
403
|
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
@@ -407,78 +407,78 @@ var CCMessage = /*#__PURE__*/Object.freeze({
|
|
|
407
407
|
showNotification: showNotification
|
|
408
408
|
});
|
|
409
409
|
|
|
410
|
-
// 对象详情存储标识
|
|
411
|
-
const OBJECT_DETAIL = 'cc_object_detail';
|
|
412
|
-
// 对象存储标识
|
|
413
|
-
const OBJECT = 'cc_object';
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* 获得当前标准对象信息
|
|
417
|
-
*/
|
|
418
|
-
function getObject( ) {
|
|
419
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
420
|
-
if (detail) {
|
|
421
|
-
return JSON.parse(detail)
|
|
422
|
-
}
|
|
423
|
-
return ''
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* 设置当前标准对象信息
|
|
428
|
-
* @param {object} detail 对象数据
|
|
429
|
-
*/
|
|
430
|
-
function setObject(detail = '') {
|
|
431
|
-
if (detail) {
|
|
432
|
-
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* 获得当前标准对象的详细信息
|
|
438
|
-
* @param {String} apiname: 查找字段的apiname
|
|
439
|
-
*/
|
|
440
|
-
function getObjectDetail(apiname) {
|
|
441
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
442
|
-
if (detail) {
|
|
443
|
-
if(apiname){
|
|
444
|
-
let
|
|
445
|
-
let targetField = undefined;
|
|
446
|
-
if(Array.isArray(
|
|
447
|
-
targetField =
|
|
448
|
-
}
|
|
449
|
-
return targetField
|
|
450
|
-
}else {
|
|
451
|
-
return JSON.parse(detail)
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
return ''
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
459
|
-
* @param {object} detail 对象详细数据
|
|
460
|
-
*/
|
|
461
|
-
function setObjectDetail(detail = '') {
|
|
462
|
-
if (detail) {
|
|
463
|
-
// 减少detail.detail层级
|
|
464
|
-
if(Array.isArray(detail.detail)){
|
|
465
|
-
let data = [];
|
|
466
|
-
detail.detail.forEach(item=>{
|
|
467
|
-
if(item && Array.isArray(item.data)){
|
|
468
|
-
item.data.forEach(itemData=>{
|
|
469
|
-
if(itemData.left && !Array.isArray(itemData.left)){
|
|
470
|
-
data.push(itemData.left);
|
|
471
|
-
}
|
|
472
|
-
if(itemData.right && !Array.isArray(itemData.right)){
|
|
473
|
-
data.push(itemData.right);
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
if(data.length > 0){detail.detail = data;}
|
|
479
|
-
}
|
|
480
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
481
|
-
}
|
|
410
|
+
// 对象详情存储标识
|
|
411
|
+
const OBJECT_DETAIL = 'cc_object_detail';
|
|
412
|
+
// 对象存储标识
|
|
413
|
+
const OBJECT = 'cc_object';
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* 获得当前标准对象信息
|
|
417
|
+
*/
|
|
418
|
+
function getObject( ) {
|
|
419
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
420
|
+
if (detail) {
|
|
421
|
+
return JSON.parse(detail)
|
|
422
|
+
}
|
|
423
|
+
return ''
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 设置当前标准对象信息
|
|
428
|
+
* @param {object} detail 对象数据
|
|
429
|
+
*/
|
|
430
|
+
function setObject(detail = '') {
|
|
431
|
+
if (detail) {
|
|
432
|
+
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 获得当前标准对象的详细信息
|
|
438
|
+
* @param {String} apiname: 查找字段的apiname
|
|
439
|
+
*/
|
|
440
|
+
function getObjectDetail(apiname) {
|
|
441
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
442
|
+
if (detail) {
|
|
443
|
+
if(apiname){
|
|
444
|
+
let detailObj = JSON.parse(detail).detail;
|
|
445
|
+
let targetField = undefined;
|
|
446
|
+
if(Array.isArray(detailObj)){
|
|
447
|
+
targetField = detailObj.find(item=>item.apiname===apiname);
|
|
448
|
+
}
|
|
449
|
+
return targetField
|
|
450
|
+
}else {
|
|
451
|
+
return JSON.parse(detail)
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return ''
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
459
|
+
* @param {object} detail 对象详细数据
|
|
460
|
+
*/
|
|
461
|
+
function setObjectDetail(detail = '') {
|
|
462
|
+
if (detail) {
|
|
463
|
+
// 减少detail.detail层级
|
|
464
|
+
if(Array.isArray(detail.detail)){
|
|
465
|
+
let data = [];
|
|
466
|
+
detail.detail.forEach(item=>{
|
|
467
|
+
if(item && Array.isArray(item.data)){
|
|
468
|
+
item.data.forEach(itemData=>{
|
|
469
|
+
if(itemData.left && !Array.isArray(itemData.left)){
|
|
470
|
+
data.push(itemData.left);
|
|
471
|
+
}
|
|
472
|
+
if(itemData.right && !Array.isArray(itemData.right)){
|
|
473
|
+
data.push(itemData.right);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
if(data.length > 0){detail.detail = data;}
|
|
479
|
+
}
|
|
480
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
481
|
+
}
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
var CCObject = /*#__PURE__*/Object.freeze({
|
|
@@ -489,125 +489,125 @@ var CCObject = /*#__PURE__*/Object.freeze({
|
|
|
489
489
|
setObjectDetail: setObjectDetail
|
|
490
490
|
});
|
|
491
491
|
|
|
492
|
-
/**
|
|
493
|
-
* 用于保存打开的页面集合
|
|
494
|
-
*/
|
|
495
|
-
let pageList = new Map();
|
|
496
|
-
/**
|
|
497
|
-
* 打开对象视图页面
|
|
498
|
-
* @param {object} obj 对象信息
|
|
499
|
-
* @param {object} options 配置信息
|
|
500
|
-
*/
|
|
501
|
-
function openListPage(obj, options = {}) {
|
|
502
|
-
let pageId = Math.random().toString(16).slice(2);
|
|
503
|
-
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
504
|
-
return pageId;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* 打开数据详情页
|
|
509
|
-
* @param {object} obj 对象体
|
|
510
|
-
* @param {string} id 数据id
|
|
511
|
-
* @param {object} options 配置信息
|
|
512
|
-
*/
|
|
513
|
-
function openDetailPage(obj, id, options = {}) {
|
|
514
|
-
let pageId = Math.random().toString(16).slice(2);
|
|
515
|
-
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
516
|
-
return pageId;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* 打开创建页面
|
|
521
|
-
* @param {object} obj 对象体
|
|
522
|
-
* @param {object} options 配置信息
|
|
523
|
-
*/
|
|
524
|
-
function openCreatePage(obj, options = {}) {
|
|
525
|
-
let pageId = Math.random().toString(16).slice(2);
|
|
526
|
-
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
527
|
-
return pageId;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* 打开修改页面
|
|
532
|
-
* @param {object} obj 对象体
|
|
533
|
-
* @param {string} id 数据id
|
|
534
|
-
* @param {object} options 配置信息
|
|
535
|
-
*/
|
|
536
|
-
function openEditPage(obj, id, options = {}) {
|
|
537
|
-
let pageId = Math.random().toString(16).slice(2);
|
|
538
|
-
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
539
|
-
return pageId;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* 打开自定义页面
|
|
543
|
-
* @param {object} obj 自定义页面参数
|
|
544
|
-
* @param {object} options 配置信息
|
|
545
|
-
*/
|
|
546
|
-
function openCustomPage(obj, options = {}) {
|
|
547
|
-
let pageId = Math.random().toString(16).slice(2);
|
|
548
|
-
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
549
|
-
return pageId;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* 通过页面id,重新打开某个页面
|
|
554
|
-
* @param {string} pageId 页面id
|
|
555
|
-
* @param {object} options 配置信息
|
|
556
|
-
*/
|
|
557
|
-
function reOpenPage(pageId, options) {
|
|
558
|
-
let page;
|
|
559
|
-
if (pageId) {
|
|
560
|
-
page = pageList.get(pageId);
|
|
561
|
-
}
|
|
562
|
-
if (page) {
|
|
563
|
-
page.reOpenPage();
|
|
564
|
-
if (options.refresh) {
|
|
565
|
-
page.refresh();
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* 将打开的页面添加到集合中
|
|
572
|
-
* @param {string} id 唯一ID
|
|
573
|
-
* @param {object} page 页面对象
|
|
574
|
-
*/
|
|
575
|
-
function addPage(id, page) {
|
|
576
|
-
if (id && page) {
|
|
577
|
-
pageList.set(id, page);
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
584
|
-
* @param {string} pageId 页面id
|
|
585
|
-
*/
|
|
586
|
-
function close(pageId = '') {
|
|
587
|
-
let page;
|
|
588
|
-
if (pageId) {
|
|
589
|
-
page = pageList.get(pageId);
|
|
590
|
-
} else {
|
|
591
|
-
if (pageList.size > 0) {
|
|
592
|
-
page = [...pageList.values()][pageList.size - 1];
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if (page) {
|
|
596
|
-
page.close();
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* 刷新页面
|
|
601
|
-
* @param {string} pageId 页面id
|
|
602
|
-
*/
|
|
603
|
-
function refresh(pageId = '') {
|
|
604
|
-
let page;
|
|
605
|
-
if (pageId) {
|
|
606
|
-
page = pageList.get(pageId);
|
|
607
|
-
}
|
|
608
|
-
if (page) {
|
|
609
|
-
page.refresh();
|
|
610
|
-
}
|
|
492
|
+
/**
|
|
493
|
+
* 用于保存打开的页面集合
|
|
494
|
+
*/
|
|
495
|
+
let pageList = new Map();
|
|
496
|
+
/**
|
|
497
|
+
* 打开对象视图页面
|
|
498
|
+
* @param {object} obj 对象信息
|
|
499
|
+
* @param {object} options 配置信息
|
|
500
|
+
*/
|
|
501
|
+
function openListPage(obj, options = {}) {
|
|
502
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
503
|
+
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
504
|
+
return pageId;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* 打开数据详情页
|
|
509
|
+
* @param {object} obj 对象体
|
|
510
|
+
* @param {string} id 数据id
|
|
511
|
+
* @param {object} options 配置信息
|
|
512
|
+
*/
|
|
513
|
+
function openDetailPage(obj, id, options = {}) {
|
|
514
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
515
|
+
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
516
|
+
return pageId;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* 打开创建页面
|
|
521
|
+
* @param {object} obj 对象体
|
|
522
|
+
* @param {object} options 配置信息
|
|
523
|
+
*/
|
|
524
|
+
function openCreatePage(obj, options = {}) {
|
|
525
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
526
|
+
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
527
|
+
return pageId;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* 打开修改页面
|
|
532
|
+
* @param {object} obj 对象体
|
|
533
|
+
* @param {string} id 数据id
|
|
534
|
+
* @param {object} options 配置信息
|
|
535
|
+
*/
|
|
536
|
+
function openEditPage(obj, id, options = {}) {
|
|
537
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
538
|
+
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
539
|
+
return pageId;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* 打开自定义页面
|
|
543
|
+
* @param {object} obj 自定义页面参数
|
|
544
|
+
* @param {object} options 配置信息
|
|
545
|
+
*/
|
|
546
|
+
function openCustomPage(obj, options = {}) {
|
|
547
|
+
let pageId = Math.random().toString(16).slice(2);
|
|
548
|
+
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
549
|
+
return pageId;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* 通过页面id,重新打开某个页面
|
|
554
|
+
* @param {string} pageId 页面id
|
|
555
|
+
* @param {object} options 配置信息
|
|
556
|
+
*/
|
|
557
|
+
function reOpenPage(pageId, options) {
|
|
558
|
+
let page;
|
|
559
|
+
if (pageId) {
|
|
560
|
+
page = pageList.get(pageId);
|
|
561
|
+
}
|
|
562
|
+
if (page) {
|
|
563
|
+
page.reOpenPage();
|
|
564
|
+
if (options.refresh) {
|
|
565
|
+
page.refresh();
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* 将打开的页面添加到集合中
|
|
572
|
+
* @param {string} id 唯一ID
|
|
573
|
+
* @param {object} page 页面对象
|
|
574
|
+
*/
|
|
575
|
+
function addPage(id, page) {
|
|
576
|
+
if (id && page) {
|
|
577
|
+
pageList.set(id, page);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
584
|
+
* @param {string} pageId 页面id
|
|
585
|
+
*/
|
|
586
|
+
function close(pageId = '') {
|
|
587
|
+
let page;
|
|
588
|
+
if (pageId) {
|
|
589
|
+
page = pageList.get(pageId);
|
|
590
|
+
} else {
|
|
591
|
+
if (pageList.size > 0) {
|
|
592
|
+
page = [...pageList.values()][pageList.size - 1];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (page) {
|
|
596
|
+
page.close();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* 刷新页面
|
|
601
|
+
* @param {string} pageId 页面id
|
|
602
|
+
*/
|
|
603
|
+
function refresh(pageId = '') {
|
|
604
|
+
let page;
|
|
605
|
+
if (pageId) {
|
|
606
|
+
page = pageList.get(pageId);
|
|
607
|
+
}
|
|
608
|
+
if (page) {
|
|
609
|
+
page.refresh();
|
|
610
|
+
}
|
|
611
611
|
}
|
|
612
612
|
|
|
613
613
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
@@ -623,19 +623,19 @@ var CCPage = /*#__PURE__*/Object.freeze({
|
|
|
623
623
|
refresh: refresh
|
|
624
624
|
});
|
|
625
625
|
|
|
626
|
-
/**
|
|
627
|
-
* 获得一级域名
|
|
628
|
-
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
629
|
-
*/
|
|
630
|
-
function getDomain() {
|
|
631
|
-
// 倒数第二位域名
|
|
632
|
-
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
633
|
-
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
634
|
-
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
635
|
-
return "." + document.domain.split('.').slice(-3).join('.')
|
|
636
|
-
} else {
|
|
637
|
-
return "." + document.domain.split('.').slice(-2).join('.')
|
|
638
|
-
}
|
|
626
|
+
/**
|
|
627
|
+
* 获得一级域名
|
|
628
|
+
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
629
|
+
*/
|
|
630
|
+
function getDomain() {
|
|
631
|
+
// 倒数第二位域名
|
|
632
|
+
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
633
|
+
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
634
|
+
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
635
|
+
return "." + document.domain.split('.').slice(-3).join('.')
|
|
636
|
+
} else {
|
|
637
|
+
return "." + document.domain.split('.').slice(-2).join('.')
|
|
638
|
+
}
|
|
639
639
|
}
|
|
640
640
|
|
|
641
641
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -643,49 +643,49 @@ var CCUtils = /*#__PURE__*/Object.freeze({
|
|
|
643
643
|
getDomain: getDomain
|
|
644
644
|
});
|
|
645
645
|
|
|
646
|
-
// cookie存储标识
|
|
647
|
-
const TOKEN = "cc_token";
|
|
648
|
-
/**
|
|
649
|
-
* 获取URL中参数的数据
|
|
650
|
-
* @param {name} 参数名
|
|
651
|
-
*/
|
|
652
|
-
function getUrlQuery(name) {
|
|
653
|
-
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
654
|
-
var r = window.location.href.match(reg);
|
|
655
|
-
let res = null;
|
|
656
|
-
if (r != null) res = r[1].trim();
|
|
657
|
-
return res;
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
|
|
661
|
-
* @param {String} urlName 获取token的url名称
|
|
662
|
-
* @returns
|
|
663
|
-
*/
|
|
664
|
-
function getToken(urlName = "binding") {
|
|
665
|
-
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
|
|
666
|
-
// 如果存在token,那么存储到cookies中,刷新有效期
|
|
667
|
-
if (token) {
|
|
668
|
-
setToken(token);
|
|
669
|
-
}
|
|
670
|
-
return token
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* 存储token
|
|
674
|
-
* @param {String} token token
|
|
675
|
-
* @param {String} domain 域名
|
|
676
|
-
*/
|
|
677
|
-
function setToken(token, domain = getDomain()) {
|
|
678
|
-
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
679
|
-
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* 清除Token数据
|
|
684
|
-
* @param {String} domain 域名
|
|
685
|
-
*/
|
|
686
|
-
function clearToken(domain = getDomain()) {
|
|
687
|
-
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
688
|
-
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
646
|
+
// cookie存储标识
|
|
647
|
+
const TOKEN = "cc_token";
|
|
648
|
+
/**
|
|
649
|
+
* 获取URL中参数的数据
|
|
650
|
+
* @param {name} 参数名
|
|
651
|
+
*/
|
|
652
|
+
function getUrlQuery(name) {
|
|
653
|
+
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
654
|
+
var r = window.location.href.match(reg);
|
|
655
|
+
let res = null;
|
|
656
|
+
if (r != null) res = r[1].trim();
|
|
657
|
+
return res;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三
|
|
661
|
+
* @param {String} urlName 获取token的url名称
|
|
662
|
+
* @returns
|
|
663
|
+
*/
|
|
664
|
+
function getToken(urlName = "binding") {
|
|
665
|
+
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(TOKEN)) || Cookies.get(urlName);
|
|
666
|
+
// 如果存在token,那么存储到cookies中,刷新有效期
|
|
667
|
+
if (token) {
|
|
668
|
+
setToken(token);
|
|
669
|
+
}
|
|
670
|
+
return token
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* 存储token
|
|
674
|
+
* @param {String} token token
|
|
675
|
+
* @param {String} domain 域名
|
|
676
|
+
*/
|
|
677
|
+
function setToken(token, domain = getDomain()) {
|
|
678
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { domain: domain, expires: 1 / 12 });
|
|
679
|
+
Cookies.set(Crypto.encrypt(TOKEN), token, { expires: 1 / 12 });
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* 清除Token数据
|
|
684
|
+
* @param {String} domain 域名
|
|
685
|
+
*/
|
|
686
|
+
function clearToken(domain = getDomain()) {
|
|
687
|
+
Cookies.remove(Crypto.encrypt(TOKEN), { domain: domain });
|
|
688
|
+
Cookies.remove(Crypto.encrypt(TOKEN));
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
@@ -695,31 +695,31 @@ var CCToken = /*#__PURE__*/Object.freeze({
|
|
|
695
695
|
clearToken: clearToken
|
|
696
696
|
});
|
|
697
697
|
|
|
698
|
-
// cookie存储标识
|
|
699
|
-
const USER_INFO = "cc_user_info";
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* 存储用户信息
|
|
703
|
-
* @param {String} userInfo 用户信息
|
|
704
|
-
* @param {String} domain 域名
|
|
705
|
-
*/
|
|
706
|
-
function setUserInfo(userInfo, domain = getDomain()) {
|
|
707
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
708
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* 获取用户信息
|
|
713
|
-
* @returns {String} 用户信息
|
|
714
|
-
*/
|
|
715
|
-
function getUserInfo() {
|
|
716
|
-
// 加密的用户信息
|
|
717
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
718
|
-
if (encryptUserInfo) {
|
|
719
|
-
return Crypto.decrypt(encryptUserInfo)
|
|
720
|
-
} else {
|
|
721
|
-
return ""
|
|
722
|
-
}
|
|
698
|
+
// cookie存储标识
|
|
699
|
+
const USER_INFO = "cc_user_info";
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* 存储用户信息
|
|
703
|
+
* @param {String} userInfo 用户信息
|
|
704
|
+
* @param {String} domain 域名
|
|
705
|
+
*/
|
|
706
|
+
function setUserInfo(userInfo, domain = getDomain()) {
|
|
707
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
708
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { expires: 1 / 12 });
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* 获取用户信息
|
|
713
|
+
* @returns {String} 用户信息
|
|
714
|
+
*/
|
|
715
|
+
function getUserInfo() {
|
|
716
|
+
// 加密的用户信息
|
|
717
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
718
|
+
if (encryptUserInfo) {
|
|
719
|
+
return Crypto.decrypt(encryptUserInfo)
|
|
720
|
+
} else {
|
|
721
|
+
return ""
|
|
722
|
+
}
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
var CCUser = /*#__PURE__*/Object.freeze({
|