cloudcc-ccdk 0.9.19 → 0.9.21
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 +717 -699
- package/lib/ccdk.js +1995 -1950
- package/lib/ccdk.min.js +1 -1
- package/package.json +35 -35
package/lib/ccdk.js
CHANGED
|
@@ -7,71 +7,71 @@ import Jwt from 'jsonwebtoken';
|
|
|
7
7
|
import { Message, MessageBox, Notification } from 'element-ui';
|
|
8
8
|
import CryptoJS from 'crypto-js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* 数据库操作
|
|
12
|
-
*/
|
|
13
|
-
const db = new Dexie("cloudcc-ltn-main-web");
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 初始化表,默认使用id自增长
|
|
17
|
-
* @param {string} tablename 表名
|
|
18
|
-
* @param {number} version 版本号
|
|
19
|
-
* @param {...any} fields 字段集合
|
|
20
|
-
*/
|
|
21
|
-
function init$2(tablename, version = 1, ...fields) {
|
|
22
|
-
return db.version(version).stores({
|
|
23
|
-
[tablename]: `++id, ${fields}`,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 新建数据,如果设置了ID,那么是更新,否则新建
|
|
29
|
-
* @param {string} tableName 表名
|
|
30
|
-
* @param {array} data 存储的数据集合
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
async function create(tableName, data = []) {
|
|
34
|
-
return await db[tableName].bulkPut(data);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 根据ID删除数据
|
|
39
|
-
* @param {string} tableName 表名
|
|
40
|
-
* @param {array} ids 数据id集合
|
|
41
|
-
* @returns 删除数据的id集合
|
|
42
|
-
*/
|
|
43
|
-
async function deleteCC(tableName, ids = []) {
|
|
44
|
-
return await db[tableName].bulkDelete(ids);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 根据过滤条件查询数据集合
|
|
50
|
-
* @param {string} tableName 表名
|
|
51
|
-
* @param {object} condition 查询条件
|
|
52
|
-
* @returns 集合
|
|
53
|
-
*/
|
|
54
|
-
async function list(tableName, condition) {
|
|
55
|
-
return await db[tableName].where(condition).toArray();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 根据ID精确查找某条数据
|
|
60
|
-
* @param {string} tableName 表名
|
|
61
|
-
* @param {string} id
|
|
62
|
-
* @returns 详情
|
|
63
|
-
*/
|
|
64
|
-
async function detail(tableName, id) {
|
|
65
|
-
return await db[tableName].get(id);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 事务
|
|
69
|
-
* @param {string} tableName 表名
|
|
70
|
-
* @param {function} id 事务方法
|
|
71
|
-
* @returns 详情
|
|
72
|
-
*/
|
|
73
|
-
async function transaction(tableName, transaction) {
|
|
74
|
-
await db.transaction('rw', [db[tableName]], transaction);
|
|
10
|
+
/**
|
|
11
|
+
* 数据库操作
|
|
12
|
+
*/
|
|
13
|
+
const db = new Dexie("cloudcc-ltn-main-web");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 初始化表,默认使用id自增长
|
|
17
|
+
* @param {string} tablename 表名
|
|
18
|
+
* @param {number} version 版本号
|
|
19
|
+
* @param {...any} fields 字段集合
|
|
20
|
+
*/
|
|
21
|
+
function init$2(tablename, version = 1, ...fields) {
|
|
22
|
+
return db.version(version).stores({
|
|
23
|
+
[tablename]: `++id, ${fields}`,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 新建数据,如果设置了ID,那么是更新,否则新建
|
|
29
|
+
* @param {string} tableName 表名
|
|
30
|
+
* @param {array} data 存储的数据集合
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
async function create(tableName, data = []) {
|
|
34
|
+
return await db[tableName].bulkPut(data);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 根据ID删除数据
|
|
39
|
+
* @param {string} tableName 表名
|
|
40
|
+
* @param {array} ids 数据id集合
|
|
41
|
+
* @returns 删除数据的id集合
|
|
42
|
+
*/
|
|
43
|
+
async function deleteCC(tableName, ids = []) {
|
|
44
|
+
return await db[tableName].bulkDelete(ids);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 根据过滤条件查询数据集合
|
|
50
|
+
* @param {string} tableName 表名
|
|
51
|
+
* @param {object} condition 查询条件
|
|
52
|
+
* @returns 集合
|
|
53
|
+
*/
|
|
54
|
+
async function list(tableName, condition) {
|
|
55
|
+
return await db[tableName].where(condition).toArray();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 根据ID精确查找某条数据
|
|
60
|
+
* @param {string} tableName 表名
|
|
61
|
+
* @param {string} id
|
|
62
|
+
* @returns 详情
|
|
63
|
+
*/
|
|
64
|
+
async function detail(tableName, id) {
|
|
65
|
+
return await db[tableName].get(id);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 事务
|
|
69
|
+
* @param {string} tableName 表名
|
|
70
|
+
* @param {function} id 事务方法
|
|
71
|
+
* @returns 详情
|
|
72
|
+
*/
|
|
73
|
+
async function transaction(tableName, transaction) {
|
|
74
|
+
await db.transaction('rw', [db[tableName]], transaction);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
var CCDB = /*#__PURE__*/Object.freeze({
|
|
@@ -85,31 +85,31 @@ var CCDB = /*#__PURE__*/Object.freeze({
|
|
|
85
85
|
transaction: transaction
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
// 当前应用存储标识
|
|
89
|
-
// const APPLICATION_DETAIL = 'applicaton_current'
|
|
90
|
-
|
|
91
|
-
const APPLICATION_DETAIL = () => {
|
|
92
|
-
return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* 获得当前访问的应用对象
|
|
96
|
-
*/
|
|
97
|
-
function getApplicaton() {
|
|
98
|
-
let detail = localStorage.getItem(APPLICATION_DETAIL());
|
|
99
|
-
if (detail) {
|
|
100
|
-
return JSON.parse(detail)
|
|
101
|
-
}
|
|
102
|
-
return ''
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 设置应用对象信息
|
|
107
|
-
* @param {object} detail 应用对象
|
|
108
|
-
*/
|
|
109
|
-
function setApplication(detail = '') {
|
|
110
|
-
if (detail) {
|
|
111
|
-
localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
|
|
112
|
-
}
|
|
88
|
+
// 当前应用存储标识
|
|
89
|
+
// const APPLICATION_DETAIL = 'applicaton_current'
|
|
90
|
+
|
|
91
|
+
const APPLICATION_DETAIL = () => {
|
|
92
|
+
return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 获得当前访问的应用对象
|
|
96
|
+
*/
|
|
97
|
+
function getApplicaton() {
|
|
98
|
+
let detail = localStorage.getItem(APPLICATION_DETAIL());
|
|
99
|
+
if (detail) {
|
|
100
|
+
return JSON.parse(detail)
|
|
101
|
+
}
|
|
102
|
+
return ''
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 设置应用对象信息
|
|
107
|
+
* @param {object} detail 应用对象
|
|
108
|
+
*/
|
|
109
|
+
function setApplication(detail = '') {
|
|
110
|
+
if (detail) {
|
|
111
|
+
localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
|
|
112
|
+
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
var CCApplication = /*#__PURE__*/Object.freeze({
|
|
@@ -118,104 +118,124 @@ var CCApplication = /*#__PURE__*/Object.freeze({
|
|
|
118
118
|
setApplication: setApplication
|
|
119
119
|
});
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* 获得一级域名
|
|
123
|
-
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
124
|
-
*/
|
|
125
|
-
function getDomain() {
|
|
126
|
-
let domain = document.domain;
|
|
127
|
-
if (isValidIP(domain)) {
|
|
128
|
-
return domain
|
|
129
|
-
} else {
|
|
130
|
-
// 倒数第二位域名
|
|
131
|
-
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
132
|
-
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
133
|
-
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
134
|
-
return "." + document.domain.split('.').slice(-3).join('.')
|
|
135
|
-
} else {
|
|
136
|
-
return "." + document.domain.split('.').slice(-2).join('.')
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* 检测是否为有效IP
|
|
142
|
-
* @param {string} ip ip地址
|
|
143
|
-
* @returns 是否为ip地址
|
|
144
|
-
*/
|
|
145
|
-
function isValidIP(ip) {
|
|
146
|
-
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
147
|
-
return reg.test(ip);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* 校验token是否有效
|
|
151
|
-
* {
|
|
152
|
-
"versionType": "Unlimited",
|
|
153
|
-
"loginName": "admin@cloudcc.com",
|
|
154
|
-
"binding": "1eaabe2e24844904b443308f48fb0dee",
|
|
155
|
-
"userId": "0052017BE8702F1PIi4j",
|
|
156
|
-
"orgId": "exorg20235419690prod"
|
|
157
|
-
}
|
|
158
|
-
* @param {string} token 认证信息
|
|
159
|
-
*/
|
|
160
|
-
function verifyToken(token) {
|
|
161
|
-
let j = Jwt.decode(token);
|
|
162
|
-
return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 格式化时间:yyyy-MM-dd HH:mm:ss
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
function getNowFormatDate() {
|
|
170
|
-
var myDate = new Date;
|
|
171
|
-
var year = myDate.getFullYear(); //获取当前年
|
|
172
|
-
var mon = myDate.getMonth() + 1; //获取当前月
|
|
173
|
-
if (mon < 10) {
|
|
174
|
-
mon = "0" + mon;
|
|
175
|
-
}
|
|
176
|
-
var date = myDate.getDate(); //获取当前日
|
|
177
|
-
if (date < 10) {
|
|
178
|
-
date = "0" + date;
|
|
179
|
-
}
|
|
180
|
-
var hours = myDate.getHours(); //获取当前小时
|
|
181
|
-
if (hours < 10) {
|
|
182
|
-
hours = "0" + hours;
|
|
183
|
-
}
|
|
184
|
-
var minutes = myDate.getMinutes(); //获取当前分钟
|
|
185
|
-
if (minutes < 10) {
|
|
186
|
-
minutes = "0" + minutes;
|
|
187
|
-
}
|
|
188
|
-
var seconds = myDate.getSeconds(); //获取当前秒
|
|
189
|
-
if (seconds < 10) {
|
|
190
|
-
seconds = "0" + seconds;
|
|
191
|
-
}
|
|
192
|
-
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
|
|
193
|
-
return now;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* 获得16位标识
|
|
198
|
-
* @returns 16位标识
|
|
199
|
-
*/
|
|
200
|
-
function getUuid() {
|
|
201
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
202
|
-
var r = (Math.random() * 16) | 0,
|
|
203
|
-
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
204
|
-
return v.toString(16);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function getBinding() {
|
|
209
|
-
let binding = window.$CCDK.CCToken.getToken();
|
|
210
|
-
if (!binding) {
|
|
211
|
-
window.open(window.Glod.LOGIN_URL, '_self');
|
|
212
|
-
// this.reLogin();
|
|
213
|
-
} else {
|
|
214
|
-
// 刷新有效期,而且有的老功能,依赖这个binding了
|
|
215
|
-
Cookies.set('binding', binding, { expires: 1 / 12 });
|
|
216
|
-
Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
|
|
217
|
-
}
|
|
218
|
-
return binding
|
|
121
|
+
/**
|
|
122
|
+
* 获得一级域名
|
|
123
|
+
* 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
|
|
124
|
+
*/
|
|
125
|
+
function getDomain() {
|
|
126
|
+
let domain = document.domain;
|
|
127
|
+
if (isValidIP(domain)) {
|
|
128
|
+
return domain
|
|
129
|
+
} else {
|
|
130
|
+
// 倒数第二位域名
|
|
131
|
+
let lastTow = document.domain.split('.').slice(-2, -1)[0];
|
|
132
|
+
// 如果倒数第二位是这些关键字,那么需要取倒数三位域名
|
|
133
|
+
if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
|
|
134
|
+
return "." + document.domain.split('.').slice(-3).join('.')
|
|
135
|
+
} else {
|
|
136
|
+
return "." + document.domain.split('.').slice(-2).join('.')
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 检测是否为有效IP
|
|
142
|
+
* @param {string} ip ip地址
|
|
143
|
+
* @returns 是否为ip地址
|
|
144
|
+
*/
|
|
145
|
+
function isValidIP(ip) {
|
|
146
|
+
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
147
|
+
return reg.test(ip);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 校验token是否有效
|
|
151
|
+
* {
|
|
152
|
+
"versionType": "Unlimited",
|
|
153
|
+
"loginName": "admin@cloudcc.com",
|
|
154
|
+
"binding": "1eaabe2e24844904b443308f48fb0dee",
|
|
155
|
+
"userId": "0052017BE8702F1PIi4j",
|
|
156
|
+
"orgId": "exorg20235419690prod"
|
|
157
|
+
}
|
|
158
|
+
* @param {string} token 认证信息
|
|
159
|
+
*/
|
|
160
|
+
function verifyToken(token) {
|
|
161
|
+
let j = Jwt.decode(token);
|
|
162
|
+
return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 格式化时间:yyyy-MM-dd HH:mm:ss
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
function getNowFormatDate() {
|
|
170
|
+
var myDate = new Date;
|
|
171
|
+
var year = myDate.getFullYear(); //获取当前年
|
|
172
|
+
var mon = myDate.getMonth() + 1; //获取当前月
|
|
173
|
+
if (mon < 10) {
|
|
174
|
+
mon = "0" + mon;
|
|
175
|
+
}
|
|
176
|
+
var date = myDate.getDate(); //获取当前日
|
|
177
|
+
if (date < 10) {
|
|
178
|
+
date = "0" + date;
|
|
179
|
+
}
|
|
180
|
+
var hours = myDate.getHours(); //获取当前小时
|
|
181
|
+
if (hours < 10) {
|
|
182
|
+
hours = "0" + hours;
|
|
183
|
+
}
|
|
184
|
+
var minutes = myDate.getMinutes(); //获取当前分钟
|
|
185
|
+
if (minutes < 10) {
|
|
186
|
+
minutes = "0" + minutes;
|
|
187
|
+
}
|
|
188
|
+
var seconds = myDate.getSeconds(); //获取当前秒
|
|
189
|
+
if (seconds < 10) {
|
|
190
|
+
seconds = "0" + seconds;
|
|
191
|
+
}
|
|
192
|
+
var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
|
|
193
|
+
return now;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 获得16位标识
|
|
198
|
+
* @returns 16位标识
|
|
199
|
+
*/
|
|
200
|
+
function getUuid() {
|
|
201
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
202
|
+
var r = (Math.random() * 16) | 0,
|
|
203
|
+
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
|
204
|
+
return v.toString(16);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function getBinding() {
|
|
209
|
+
let binding = window.$CCDK.CCToken.getToken();
|
|
210
|
+
if (!binding) {
|
|
211
|
+
window.open(window.Glod.LOGIN_URL, '_self');
|
|
212
|
+
// this.reLogin();
|
|
213
|
+
} else {
|
|
214
|
+
// 刷新有效期,而且有的老功能,依赖这个binding了
|
|
215
|
+
Cookies.set('binding', binding, { expires: 1 / 12 });
|
|
216
|
+
Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
|
|
217
|
+
}
|
|
218
|
+
return binding
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 用于获取当前页位置,暂时仅支持视图和详情页说明
|
|
222
|
+
* view:视图页
|
|
223
|
+
* detail:详情页
|
|
224
|
+
* @returns {string} 返回值:当前页位置
|
|
225
|
+
*/
|
|
226
|
+
function getCurrentPageType() {
|
|
227
|
+
let currentPage;
|
|
228
|
+
let currentHref = window.location?.hash || '';
|
|
229
|
+
currentHref = currentHref.split('?')[0] || '';
|
|
230
|
+
const lastHref = currentHref.split('/').pop();
|
|
231
|
+
if(currentHref.includes('#/commonObjects/views/table')){
|
|
232
|
+
// 当前是视图页
|
|
233
|
+
currentPage = 'view';
|
|
234
|
+
}else if(lastHref === 'DETAIL'){
|
|
235
|
+
// 当前是视图页
|
|
236
|
+
currentPage = 'detail';
|
|
237
|
+
}
|
|
238
|
+
return currentPage
|
|
219
239
|
}
|
|
220
240
|
|
|
221
241
|
var CCUtils = /*#__PURE__*/Object.freeze({
|
|
@@ -224,456 +244,457 @@ var CCUtils = /*#__PURE__*/Object.freeze({
|
|
|
224
244
|
getUuid: getUuid,
|
|
225
245
|
getBinding: getBinding,
|
|
226
246
|
getNowFormatDate: getNowFormatDate,
|
|
227
|
-
verifyToken: verifyToken
|
|
247
|
+
verifyToken: verifyToken,
|
|
248
|
+
getCurrentPageType: getCurrentPageType
|
|
228
249
|
});
|
|
229
250
|
|
|
230
|
-
const toStr = Object.prototype.toString;
|
|
231
|
-
|
|
232
|
-
const TypeEnum = {
|
|
233
|
-
'FUNCTION': '[object Function]',
|
|
234
|
-
'ARRAY': '[object Array]',
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
// 是否是一个函数
|
|
238
|
-
const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
|
|
239
|
-
|
|
240
|
-
// 是否是生产环境
|
|
241
|
-
const isProduction = () => true ;
|
|
242
|
-
|
|
243
|
-
// 延时
|
|
244
|
-
const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
|
|
245
|
-
|
|
246
|
-
// 是否是超时请求
|
|
247
|
-
const isTimeout = (error = {
|
|
248
|
-
code: '',
|
|
249
|
-
message: ''
|
|
250
|
-
}) => {
|
|
251
|
-
return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
// 格式换请求体
|
|
255
|
-
const formateData = data => {
|
|
256
|
-
return {
|
|
257
|
-
head: {
|
|
258
|
-
appType: "lightning-main",
|
|
259
|
-
appVersion: "1.1.1",
|
|
260
|
-
accessToken: getBinding(),
|
|
261
|
-
source: "lightning-main"
|
|
262
|
-
},
|
|
263
|
-
body: {
|
|
264
|
-
...data
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* 深度合并
|
|
270
|
-
* @param {object} source 合并的基础对象
|
|
271
|
-
* @param {object} target 新的数据
|
|
272
|
-
*/
|
|
273
|
-
const deepMerge = (source, target) => {
|
|
274
|
-
const res = cloneDeep(source);
|
|
275
|
-
for (let key in target) {
|
|
276
|
-
if (target.hasOwnProperty(key)) {
|
|
277
|
-
res[key] = isObject(target[key])
|
|
278
|
-
? deepMerge(res[key], target[key])
|
|
279
|
-
: target[key];
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return res
|
|
251
|
+
const toStr = Object.prototype.toString;
|
|
252
|
+
|
|
253
|
+
const TypeEnum = {
|
|
254
|
+
'FUNCTION': '[object Function]',
|
|
255
|
+
'ARRAY': '[object Array]',
|
|
283
256
|
};
|
|
284
257
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
258
|
+
// 是否是一个函数
|
|
259
|
+
const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
|
|
260
|
+
|
|
261
|
+
// 是否是生产环境
|
|
262
|
+
const isProduction = () => true ;
|
|
263
|
+
|
|
264
|
+
// 延时
|
|
265
|
+
const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
|
|
266
|
+
|
|
267
|
+
// 是否是超时请求
|
|
268
|
+
const isTimeout = (error = {
|
|
269
|
+
code: '',
|
|
270
|
+
message: ''
|
|
271
|
+
}) => {
|
|
272
|
+
return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// 格式换请求体
|
|
276
|
+
const formateData = data => {
|
|
277
|
+
return {
|
|
278
|
+
head: {
|
|
279
|
+
appType: "lightning-main",
|
|
280
|
+
appVersion: "1.1.1",
|
|
281
|
+
accessToken: getBinding(),
|
|
282
|
+
source: "lightning-main"
|
|
283
|
+
},
|
|
284
|
+
body: {
|
|
285
|
+
...data
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* 深度合并
|
|
291
|
+
* @param {object} source 合并的基础对象
|
|
292
|
+
* @param {object} target 新的数据
|
|
293
|
+
*/
|
|
294
|
+
const deepMerge = (source, target) => {
|
|
295
|
+
const res = cloneDeep(source);
|
|
296
|
+
for (let key in target) {
|
|
297
|
+
if (target.hasOwnProperty(key)) {
|
|
298
|
+
res[key] = isObject(target[key])
|
|
299
|
+
? deepMerge(res[key], target[key])
|
|
300
|
+
: target[key];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return res
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* LRU算法
|
|
308
|
+
* @param {number} capacity 最大缓存容量
|
|
309
|
+
*/
|
|
310
|
+
const LRUCache = function (capacity) {
|
|
311
|
+
this.capacity = capacity;
|
|
312
|
+
this.cache = new Map();
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 获取指定key的缓存
|
|
317
|
+
* @param {string} key 缓存的key
|
|
318
|
+
*/
|
|
319
|
+
LRUCache.prototype.get = function (key) {
|
|
320
|
+
var cacheTemp = this.cache,
|
|
321
|
+
curTemp = cacheTemp.get(key);
|
|
322
|
+
if (curTemp || curTemp === 0) {
|
|
323
|
+
cacheTemp.delete(key);
|
|
324
|
+
cacheTemp.set(key, curTemp);
|
|
325
|
+
return curTemp
|
|
326
|
+
}
|
|
327
|
+
return null
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 指定key添加缓存
|
|
332
|
+
* @param {string} key 缓存的key
|
|
333
|
+
* @param {object} value 缓存的值
|
|
334
|
+
*/
|
|
335
|
+
LRUCache.prototype.put = function (key, value) {
|
|
336
|
+
var cacheTemp = this.cache;
|
|
337
|
+
if (cacheTemp.get(key)) {
|
|
338
|
+
cacheTemp.delete(key);
|
|
339
|
+
} else if (cacheTemp.size >= this.capacity) {
|
|
340
|
+
cacheTemp.delete(cacheTemp.keys().next().value);
|
|
341
|
+
}
|
|
342
|
+
cacheTemp.set(key, value);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
class CCAxios {
|
|
346
|
+
constructor(opt) {
|
|
347
|
+
this.options = opt;
|
|
348
|
+
this.axiosInstance = axios.create(opt);
|
|
349
|
+
this.setupInterceptors();
|
|
350
|
+
this.cachePool = new LRUCache(20);
|
|
351
|
+
// FIXME:区分构造函数参数和接口级别的参数
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
//获取拦截器
|
|
355
|
+
getTransform() {
|
|
356
|
+
const { transform } = this.options;
|
|
357
|
+
return transform;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
//准备拦截器
|
|
361
|
+
setupInterceptors() {
|
|
362
|
+
const transform = this.getTransform();
|
|
363
|
+
if (!transform) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const {
|
|
367
|
+
requestInterceptors,
|
|
368
|
+
requestInterceptorsCatch,
|
|
369
|
+
responseInterceptors,
|
|
370
|
+
responseInterceptorsCatch,
|
|
371
|
+
} = transform;
|
|
372
|
+
// 请求拦截器
|
|
373
|
+
this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
|
|
374
|
+
// 请求拦截器错误处理
|
|
375
|
+
requestInterceptorsCatch
|
|
376
|
+
&& isFn(requestInterceptorsCatch)
|
|
377
|
+
&& this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
|
|
378
|
+
|
|
379
|
+
// 响应拦截器
|
|
380
|
+
this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
|
|
381
|
+
// 响应拦截器错误处理
|
|
382
|
+
responseInterceptorsCatch
|
|
383
|
+
&& isFn(responseInterceptorsCatch)
|
|
384
|
+
&& this.axiosInstance.interceptors.response.use(undefined, (error) => {
|
|
385
|
+
return responseInterceptorsCatch(this.axiosInstance, error)
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
get(config, options = {}) {
|
|
389
|
+
return this.request({ ...config, method: 'GET', }, options)
|
|
390
|
+
}
|
|
391
|
+
post(config, options = {}) {
|
|
392
|
+
const { envType } = options;
|
|
393
|
+
// 公有云专用接口,在私有云不请求
|
|
394
|
+
if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
|
|
395
|
+
return new Promise(() => { })
|
|
396
|
+
}
|
|
397
|
+
// 私有云专用接口,在公有云不请求
|
|
398
|
+
if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
|
|
399
|
+
return new Promise(() => { })
|
|
400
|
+
}
|
|
401
|
+
return this.request({ ...config, method: 'POST', }, options)
|
|
402
|
+
}
|
|
403
|
+
postFormat(config, options = {}) {
|
|
404
|
+
return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
|
|
405
|
+
}
|
|
406
|
+
postParams(config, options = {}) {
|
|
407
|
+
return this.request({ ...config, method: 'POST', params: config.data }, options)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// FIXME:如果初始化时配置了重试那么所有get接口都重试了
|
|
411
|
+
// options是接口级定义的参数
|
|
412
|
+
request(config, options) {
|
|
413
|
+
const transform = this.getTransform();
|
|
414
|
+
const conf = config,
|
|
415
|
+
{ requestOptions } = this.options;
|
|
416
|
+
requestOptions.cache = false;
|
|
417
|
+
requestOptions.cacheKey = '';
|
|
418
|
+
requestOptions.retryRequest = {
|
|
419
|
+
isOpenRetry: false,
|
|
420
|
+
count: 5,
|
|
421
|
+
waitTime: 1000
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const opt = Object.assign({}, requestOptions, options);
|
|
425
|
+
conf.requestOptions = opt;
|
|
426
|
+
|
|
427
|
+
const retPromise = new Promise((resolve, reject) => {
|
|
428
|
+
this.axiosInstance(conf)
|
|
429
|
+
.then(res => {
|
|
430
|
+
const { transformResponseHook } = transform;
|
|
431
|
+
if (transformResponseHook && isFn(transformResponseHook)) {
|
|
432
|
+
try {
|
|
433
|
+
const ret = transformResponseHook(res, opt, this.cachePool);
|
|
434
|
+
resolve(ret);
|
|
435
|
+
} catch (err) {
|
|
436
|
+
reject(err || new Error('request error!'));
|
|
437
|
+
}
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
resolve(res);
|
|
441
|
+
})
|
|
442
|
+
.catch(err => {
|
|
443
|
+
reject(err);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
// 缓存
|
|
447
|
+
retPromise.cache = (callback) => {
|
|
448
|
+
const { cache, cacheKey } = opt;
|
|
449
|
+
const cacheData = (cache && this.cachePool.get([cacheKey]));
|
|
450
|
+
callback(cacheData ? cacheData : null);
|
|
451
|
+
return retPromise
|
|
452
|
+
};
|
|
453
|
+
return retPromise
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// 使用全局弹窗进行提示
|
|
458
|
+
const createErrorModal = (response, options) => {
|
|
459
|
+
const { message } = options;
|
|
460
|
+
let temp;
|
|
461
|
+
if (response.name === 'AxiosError') {
|
|
462
|
+
temp = response.response;
|
|
463
|
+
temp.data.returnInfo = response.returnInfo || message || temp.error || '';
|
|
464
|
+
temp.data.returnCode = response.code || temp.status;
|
|
465
|
+
temp.data.requestId = response.config.headers.requestId;
|
|
466
|
+
} else {
|
|
467
|
+
temp = response;
|
|
468
|
+
temp.data.requestId = response.config.headers.requestId;
|
|
469
|
+
}
|
|
470
|
+
// 存在全局错误弹窗时才调用
|
|
471
|
+
isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
|
|
472
|
+
response: temp
|
|
473
|
+
});
|
|
322
474
|
};
|
|
323
475
|
|
|
324
|
-
class CCAxios {
|
|
325
|
-
constructor(opt) {
|
|
326
|
-
this.options = opt;
|
|
327
|
-
this.axiosInstance = axios.create(opt);
|
|
328
|
-
this.setupInterceptors();
|
|
329
|
-
this.cachePool = new LRUCache(20);
|
|
330
|
-
// FIXME:区分构造函数参数和接口级别的参数
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
//获取拦截器
|
|
334
|
-
getTransform() {
|
|
335
|
-
const { transform } = this.options;
|
|
336
|
-
return transform;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
//准备拦截器
|
|
340
|
-
setupInterceptors() {
|
|
341
|
-
const transform = this.getTransform();
|
|
342
|
-
if (!transform) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const {
|
|
346
|
-
requestInterceptors,
|
|
347
|
-
requestInterceptorsCatch,
|
|
348
|
-
responseInterceptors,
|
|
349
|
-
responseInterceptorsCatch,
|
|
350
|
-
} = transform;
|
|
351
|
-
// 请求拦截器
|
|
352
|
-
this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
|
|
353
|
-
// 请求拦截器错误处理
|
|
354
|
-
requestInterceptorsCatch
|
|
355
|
-
&& isFn(requestInterceptorsCatch)
|
|
356
|
-
&& this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
|
|
357
|
-
|
|
358
|
-
// 响应拦截器
|
|
359
|
-
this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
|
|
360
|
-
// 响应拦截器错误处理
|
|
361
|
-
responseInterceptorsCatch
|
|
362
|
-
&& isFn(responseInterceptorsCatch)
|
|
363
|
-
&& this.axiosInstance.interceptors.response.use(undefined, (error) => {
|
|
364
|
-
return responseInterceptorsCatch(this.axiosInstance, error)
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
get(config, options = {}) {
|
|
368
|
-
return this.request({ ...config, method: 'GET', }, options)
|
|
369
|
-
}
|
|
370
|
-
post(config, options = {}) {
|
|
371
|
-
const { envType } = options;
|
|
372
|
-
// 公有云专用接口,在私有云不请求
|
|
373
|
-
if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
|
|
374
|
-
return new Promise(() => { })
|
|
375
|
-
}
|
|
376
|
-
// 私有云专用接口,在公有云不请求
|
|
377
|
-
if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
|
|
378
|
-
return new Promise(() => { })
|
|
379
|
-
}
|
|
380
|
-
return this.request({ ...config, method: 'POST', }, options)
|
|
381
|
-
}
|
|
382
|
-
postFormat(config, options = {}) {
|
|
383
|
-
return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
|
|
384
|
-
}
|
|
385
|
-
postParams(config, options = {}) {
|
|
386
|
-
return this.request({ ...config, method: 'POST', params: config.data }, options)
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// FIXME:如果初始化时配置了重试那么所有get接口都重试了
|
|
390
|
-
// options是接口级定义的参数
|
|
391
|
-
request(config, options) {
|
|
392
|
-
const transform = this.getTransform();
|
|
393
|
-
const conf = config,
|
|
394
|
-
{ requestOptions } = this.options;
|
|
395
|
-
requestOptions.cache = false;
|
|
396
|
-
requestOptions.cacheKey = '';
|
|
397
|
-
requestOptions.retryRequest = {
|
|
398
|
-
isOpenRetry: false,
|
|
399
|
-
count: 5,
|
|
400
|
-
waitTime: 1000
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
const opt = Object.assign({}, requestOptions, options);
|
|
404
|
-
conf.requestOptions = opt;
|
|
405
|
-
|
|
406
|
-
const retPromise = new Promise((resolve, reject) => {
|
|
407
|
-
this.axiosInstance(conf)
|
|
408
|
-
.then(res => {
|
|
409
|
-
const { transformResponseHook } = transform;
|
|
410
|
-
if (transformResponseHook && isFn(transformResponseHook)) {
|
|
411
|
-
try {
|
|
412
|
-
const ret = transformResponseHook(res, opt, this.cachePool);
|
|
413
|
-
resolve(ret);
|
|
414
|
-
} catch (err) {
|
|
415
|
-
reject(err || new Error('request error!'));
|
|
416
|
-
}
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
resolve(res);
|
|
420
|
-
})
|
|
421
|
-
.catch(err => {
|
|
422
|
-
reject(err);
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
// 缓存
|
|
426
|
-
retPromise.cache = (callback) => {
|
|
427
|
-
const { cache, cacheKey } = opt;
|
|
428
|
-
const cacheData = (cache && this.cachePool.get([cacheKey]));
|
|
429
|
-
callback(cacheData ? cacheData : null);
|
|
430
|
-
return retPromise
|
|
431
|
-
};
|
|
432
|
-
return retPromise
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// 使用全局弹窗进行提示
|
|
437
|
-
const createErrorModal = (response, options) => {
|
|
438
|
-
const { message } = options;
|
|
439
|
-
let temp;
|
|
440
|
-
if (response.name === 'AxiosError') {
|
|
441
|
-
temp = response.response;
|
|
442
|
-
temp.data.returnInfo = response.returnInfo || message || temp.error || '';
|
|
443
|
-
temp.data.returnCode = response.code || temp.status;
|
|
444
|
-
temp.data.requestId = response.config.headers.requestId;
|
|
445
|
-
} else {
|
|
446
|
-
temp = response;
|
|
447
|
-
temp.data.requestId = response.config.headers.requestId;
|
|
448
|
-
}
|
|
449
|
-
// 存在全局错误弹窗时才调用
|
|
450
|
-
isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
|
|
451
|
-
response: temp
|
|
452
|
-
});
|
|
453
|
-
};
|
|
454
|
-
|
|
455
476
|
const createMessage = Message;
|
|
456
477
|
|
|
457
|
-
// 需要上报的errorType
|
|
478
|
+
// 需要上报的errorType
|
|
458
479
|
const needReportErrorType = ['901', '999'];
|
|
459
480
|
|
|
460
|
-
function checkStatus(error, status, msg, errorMessageMode = 'modal') {
|
|
461
|
-
// const errorMsg = errorMsgMap[status] || {
|
|
462
|
-
// label: "message.error.object.contactadministrators"
|
|
463
|
-
// }
|
|
464
|
-
// let errMessage = '',
|
|
465
|
-
// label = '';
|
|
466
|
-
|
|
467
|
-
// label = errorMsg.label;
|
|
468
|
-
// [400, 401].includes(status) && msg && (label = msg)
|
|
469
|
-
let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
|
|
470
|
-
|
|
471
|
-
if (status === 401) {
|
|
472
|
-
//重新登录相关逻辑
|
|
473
|
-
window.open(window.Glod.LOGIN_URL, '_self');
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
{
|
|
477
|
-
if (errorMessageMode === 'modal') {
|
|
478
|
-
createErrorModal(error, { message: errMessage });
|
|
479
|
-
} else if (errorMessageMode === 'message') {
|
|
480
|
-
createMessage.error(errMessage);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* 接口请求重试
|
|
487
|
-
* @param {object} AxiosInstance实例
|
|
488
|
-
* @param {error} AxiosError对象
|
|
489
|
-
*/
|
|
490
|
-
const retry = async (instance, error) => {
|
|
491
|
-
const { config } = error,
|
|
492
|
-
{ waitTime, count = 5} = config.requestOptions || {};
|
|
493
|
-
config.__retryCount = config.__retryCount || 0;
|
|
494
|
-
if(count <= config.__retryCount ) {
|
|
495
|
-
return Promise.reject(error)
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
config.__retryCount++;
|
|
499
|
-
|
|
500
|
-
await delay(waitTime);
|
|
501
|
-
//请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
|
|
502
|
-
delete config.headers;
|
|
503
|
-
return instance(config)
|
|
481
|
+
function checkStatus(error, status, msg, errorMessageMode = 'modal') {
|
|
482
|
+
// const errorMsg = errorMsgMap[status] || {
|
|
483
|
+
// label: "message.error.object.contactadministrators"
|
|
484
|
+
// }
|
|
485
|
+
// let errMessage = '',
|
|
486
|
+
// label = '';
|
|
487
|
+
|
|
488
|
+
// label = errorMsg.label;
|
|
489
|
+
// [400, 401].includes(status) && msg && (label = msg)
|
|
490
|
+
let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
|
|
491
|
+
|
|
492
|
+
if (status === 401) {
|
|
493
|
+
//重新登录相关逻辑
|
|
494
|
+
window.open(window.Glod.LOGIN_URL, '_self');
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
{
|
|
498
|
+
if (errorMessageMode === 'modal') {
|
|
499
|
+
createErrorModal(error, { message: errMessage });
|
|
500
|
+
} else if (errorMessageMode === 'message') {
|
|
501
|
+
createMessage.error(errMessage);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* 接口请求重试
|
|
508
|
+
* @param {object} AxiosInstance实例
|
|
509
|
+
* @param {error} AxiosError对象
|
|
510
|
+
*/
|
|
511
|
+
const retry = async (instance, error) => {
|
|
512
|
+
const { config } = error,
|
|
513
|
+
{ waitTime, count = 5} = config.requestOptions || {};
|
|
514
|
+
config.__retryCount = config.__retryCount || 0;
|
|
515
|
+
if(count <= config.__retryCount ) {
|
|
516
|
+
return Promise.reject(error)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
config.__retryCount++;
|
|
520
|
+
|
|
521
|
+
await delay(waitTime);
|
|
522
|
+
//请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
|
|
523
|
+
delete config.headers;
|
|
524
|
+
return instance(config)
|
|
504
525
|
};
|
|
505
526
|
|
|
506
|
-
const transform = {
|
|
507
|
-
// 请求拦截器
|
|
508
|
-
requestInterceptors(config) {
|
|
509
|
-
// 设置日志请求头信息
|
|
510
|
-
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
511
|
-
config.headers.requestIdProducer = "browser";
|
|
512
|
-
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
513
|
-
return config
|
|
514
|
-
},
|
|
515
|
-
// 响应拦截器
|
|
516
|
-
responseInterceptors(response) {
|
|
517
|
-
const { data, config } = response,
|
|
518
|
-
{ errorType, result } = data;
|
|
519
|
-
//失败
|
|
520
|
-
if (!result) {
|
|
521
|
-
if (needReportErrorType.includes(errorType) && isProduction()) {
|
|
522
|
-
const { errorReporter } = config.requestOptions;
|
|
523
|
-
//如果存在错误上报对象,则上报错误
|
|
524
|
-
if (errorReporter && isFn(errorReporter)) {
|
|
525
|
-
errorReporter(response);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
return response
|
|
529
|
-
}
|
|
530
|
-
// 成功
|
|
531
|
-
// 生产环境上报日志
|
|
532
|
-
const { infoReporter } = config.requestOptions;
|
|
533
|
-
//如果存在日志上报对象,则上报日志
|
|
534
|
-
if (infoReporter && isFn(infoReporter)) {
|
|
535
|
-
infoReporter(response);
|
|
536
|
-
}
|
|
537
|
-
// 返回数据 外面处理
|
|
538
|
-
return response
|
|
539
|
-
},
|
|
540
|
-
// 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
|
|
541
|
-
async responseInterceptorsCatch(axiosInstance, error) {
|
|
542
|
-
const { response, config } = error || {};
|
|
543
|
-
|
|
544
|
-
let err = "",
|
|
545
|
-
msg = "",
|
|
546
|
-
mode = "modal";
|
|
547
|
-
try {
|
|
548
|
-
err = error.toString(),
|
|
549
|
-
msg = response.data.error,
|
|
550
|
-
mode = config.requestOptions.errorMessageMode;
|
|
551
|
-
} catch (e) { }
|
|
552
|
-
|
|
553
|
-
let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
|
|
554
|
-
errMessage = '';
|
|
555
|
-
|
|
556
|
-
// 是否是取消的请求
|
|
557
|
-
if (axios.isCancel(error)) {
|
|
558
|
-
return Promise.reject(error)
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
try {
|
|
562
|
-
//如果存在错误上报对象,则上报错误
|
|
563
|
-
if (isProduction()) {
|
|
564
|
-
// 接口级的错误上报方式会覆盖实例初始化时的错误上报
|
|
565
|
-
const { errorReporter } = config.requestOptions;
|
|
566
|
-
if (errorReporter && isFn(errorReporter)) {
|
|
567
|
-
errorReporter(error);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
// 处理超时
|
|
571
|
-
if (isTimeout(error)) {
|
|
572
|
-
errMessage = 'c2487';
|
|
573
|
-
}
|
|
574
|
-
// 处理网络错误
|
|
575
|
-
if (err && err.includes('Network Error')) {
|
|
576
|
-
errMessage = 'c929';
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
if (errMessage) {
|
|
580
|
-
if (errorMessageMode === 'modal') {
|
|
581
|
-
createErrorModal({
|
|
582
|
-
...error,
|
|
583
|
-
response: {
|
|
584
|
-
data: {
|
|
585
|
-
returnInfo: error.message,
|
|
586
|
-
returnCode: error.code,
|
|
587
|
-
requestId: error.config.headers.requestId
|
|
588
|
-
},
|
|
589
|
-
config: error.config
|
|
590
|
-
}
|
|
591
|
-
}, { message: errMessage });
|
|
592
|
-
} else if (errorMessageMode === 'message') {
|
|
593
|
-
createMessage.error(errMessage);
|
|
594
|
-
}
|
|
595
|
-
return Promise.reject(error)
|
|
596
|
-
}
|
|
597
|
-
} catch (error) {
|
|
598
|
-
throw new Error(error);
|
|
599
|
-
}
|
|
600
|
-
// 根据status处理其他类型错误
|
|
601
|
-
checkStatus(error, error && error.response.status, msg, errorMessageMode);
|
|
602
|
-
|
|
603
|
-
// 接口重试操作
|
|
604
|
-
const { isOpenRetry } = config;
|
|
605
|
-
isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
|
|
606
|
-
|
|
607
|
-
return Promise.reject(error);
|
|
608
|
-
},
|
|
609
|
-
// 响应数据处理,包含解密和数据返回结构设置
|
|
610
|
-
transformResponseHook(response, options, cachePool) {
|
|
611
|
-
const { data } = response;
|
|
612
|
-
const { errorType, result } = data;
|
|
613
|
-
// 失败
|
|
614
|
-
// 501异常处理
|
|
615
|
-
const businessLogicError = (response) => {
|
|
616
|
-
const { errorMessageMode, silent } = response.config.requestOptions;
|
|
617
|
-
// 接口如果设置了出现异常不提醒,则不提醒
|
|
618
|
-
if (silent) return;
|
|
619
|
-
// 根据errorMessageMode来判断显示错误弹窗的ui
|
|
620
|
-
if (errorMessageMode === 'modal') {
|
|
621
|
-
createErrorModal(response, { message: '业务出错' });
|
|
622
|
-
} else if (errorMessageMode === 'message') {
|
|
623
|
-
createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
|
|
624
|
-
}
|
|
625
|
-
};
|
|
626
|
-
if (!result) {
|
|
627
|
-
switch (errorType) {
|
|
628
|
-
case '901':
|
|
629
|
-
createErrorModal(response, { message: '系统错误' });
|
|
630
|
-
break;
|
|
631
|
-
case '999':
|
|
632
|
-
break;
|
|
633
|
-
case '501':
|
|
634
|
-
default:
|
|
635
|
-
businessLogicError(response);
|
|
636
|
-
break;
|
|
637
|
-
}
|
|
638
|
-
return Promise.reject(response)
|
|
639
|
-
}
|
|
640
|
-
// 成功
|
|
641
|
-
const { isReturnNativeResponse, cache, cacheKey } = options;
|
|
642
|
-
// 直接返回
|
|
643
|
-
if (isReturnNativeResponse) {
|
|
644
|
-
cache && cacheKey && (cachePool.put(cacheKey, response));
|
|
645
|
-
return response
|
|
646
|
-
}
|
|
647
|
-
cache && cacheKey && (cachePool.put(cacheKey, data));
|
|
648
|
-
return data
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
function createAxios(opt) {
|
|
654
|
-
return new CCAxios(deepMerge({
|
|
655
|
-
timeout: 60 * 1000,
|
|
656
|
-
headers: {
|
|
657
|
-
'Content-Type': 'application/json;charset=UTF-8',
|
|
658
|
-
},
|
|
659
|
-
transform: cloneDeep(transform),
|
|
660
|
-
requestOptions: {
|
|
661
|
-
envType: '',
|
|
662
|
-
errorMessageMode: 'modal',
|
|
663
|
-
//是否静默错误提示
|
|
664
|
-
silent: false,
|
|
665
|
-
// 接口是否需要缓存
|
|
666
|
-
cache: false,
|
|
667
|
-
// 接口重试相关
|
|
668
|
-
retryRequest: {
|
|
669
|
-
isOpenRetry: false,
|
|
670
|
-
count: 5,
|
|
671
|
-
waitTime: 100,
|
|
672
|
-
},
|
|
673
|
-
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
674
|
-
isReturnNativeResponse: false,
|
|
675
|
-
}
|
|
676
|
-
}, opt || {}))
|
|
527
|
+
const transform = {
|
|
528
|
+
// 请求拦截器
|
|
529
|
+
requestInterceptors(config) {
|
|
530
|
+
// 设置日志请求头信息
|
|
531
|
+
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
532
|
+
config.headers.requestIdProducer = "browser";
|
|
533
|
+
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
534
|
+
return config
|
|
535
|
+
},
|
|
536
|
+
// 响应拦截器
|
|
537
|
+
responseInterceptors(response) {
|
|
538
|
+
const { data, config } = response,
|
|
539
|
+
{ errorType, result } = data;
|
|
540
|
+
//失败
|
|
541
|
+
if (!result) {
|
|
542
|
+
if (needReportErrorType.includes(errorType) && isProduction()) {
|
|
543
|
+
const { errorReporter } = config.requestOptions;
|
|
544
|
+
//如果存在错误上报对象,则上报错误
|
|
545
|
+
if (errorReporter && isFn(errorReporter)) {
|
|
546
|
+
errorReporter(response);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return response
|
|
550
|
+
}
|
|
551
|
+
// 成功
|
|
552
|
+
// 生产环境上报日志
|
|
553
|
+
const { infoReporter } = config.requestOptions;
|
|
554
|
+
//如果存在日志上报对象,则上报日志
|
|
555
|
+
if (infoReporter && isFn(infoReporter)) {
|
|
556
|
+
infoReporter(response);
|
|
557
|
+
}
|
|
558
|
+
// 返回数据 外面处理
|
|
559
|
+
return response
|
|
560
|
+
},
|
|
561
|
+
// 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
|
|
562
|
+
async responseInterceptorsCatch(axiosInstance, error) {
|
|
563
|
+
const { response, config } = error || {};
|
|
564
|
+
|
|
565
|
+
let err = "",
|
|
566
|
+
msg = "",
|
|
567
|
+
mode = "modal";
|
|
568
|
+
try {
|
|
569
|
+
err = error.toString(),
|
|
570
|
+
msg = response.data.error,
|
|
571
|
+
mode = config.requestOptions.errorMessageMode;
|
|
572
|
+
} catch (e) { }
|
|
573
|
+
|
|
574
|
+
let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
|
|
575
|
+
errMessage = '';
|
|
576
|
+
|
|
577
|
+
// 是否是取消的请求
|
|
578
|
+
if (axios.isCancel(error)) {
|
|
579
|
+
return Promise.reject(error)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
try {
|
|
583
|
+
//如果存在错误上报对象,则上报错误
|
|
584
|
+
if (isProduction()) {
|
|
585
|
+
// 接口级的错误上报方式会覆盖实例初始化时的错误上报
|
|
586
|
+
const { errorReporter } = config.requestOptions;
|
|
587
|
+
if (errorReporter && isFn(errorReporter)) {
|
|
588
|
+
errorReporter(error);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// 处理超时
|
|
592
|
+
if (isTimeout(error)) {
|
|
593
|
+
errMessage = 'c2487';
|
|
594
|
+
}
|
|
595
|
+
// 处理网络错误
|
|
596
|
+
if (err && err.includes('Network Error')) {
|
|
597
|
+
errMessage = 'c929';
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (errMessage) {
|
|
601
|
+
if (errorMessageMode === 'modal') {
|
|
602
|
+
createErrorModal({
|
|
603
|
+
...error,
|
|
604
|
+
response: {
|
|
605
|
+
data: {
|
|
606
|
+
returnInfo: error.message,
|
|
607
|
+
returnCode: error.code,
|
|
608
|
+
requestId: error.config.headers.requestId
|
|
609
|
+
},
|
|
610
|
+
config: error.config
|
|
611
|
+
}
|
|
612
|
+
}, { message: errMessage });
|
|
613
|
+
} else if (errorMessageMode === 'message') {
|
|
614
|
+
createMessage.error(errMessage);
|
|
615
|
+
}
|
|
616
|
+
return Promise.reject(error)
|
|
617
|
+
}
|
|
618
|
+
} catch (error) {
|
|
619
|
+
throw new Error(error);
|
|
620
|
+
}
|
|
621
|
+
// 根据status处理其他类型错误
|
|
622
|
+
checkStatus(error, error && error.response.status, msg, errorMessageMode);
|
|
623
|
+
|
|
624
|
+
// 接口重试操作
|
|
625
|
+
const { isOpenRetry } = config;
|
|
626
|
+
isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
|
|
627
|
+
|
|
628
|
+
return Promise.reject(error);
|
|
629
|
+
},
|
|
630
|
+
// 响应数据处理,包含解密和数据返回结构设置
|
|
631
|
+
transformResponseHook(response, options, cachePool) {
|
|
632
|
+
const { data } = response;
|
|
633
|
+
const { errorType, result } = data;
|
|
634
|
+
// 失败
|
|
635
|
+
// 501异常处理
|
|
636
|
+
const businessLogicError = (response) => {
|
|
637
|
+
const { errorMessageMode, silent } = response.config.requestOptions;
|
|
638
|
+
// 接口如果设置了出现异常不提醒,则不提醒
|
|
639
|
+
if (silent) return;
|
|
640
|
+
// 根据errorMessageMode来判断显示错误弹窗的ui
|
|
641
|
+
if (errorMessageMode === 'modal') {
|
|
642
|
+
createErrorModal(response, { message: '业务出错' });
|
|
643
|
+
} else if (errorMessageMode === 'message') {
|
|
644
|
+
createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
if (!result) {
|
|
648
|
+
switch (errorType) {
|
|
649
|
+
case '901':
|
|
650
|
+
createErrorModal(response, { message: '系统错误' });
|
|
651
|
+
break;
|
|
652
|
+
case '999':
|
|
653
|
+
break;
|
|
654
|
+
case '501':
|
|
655
|
+
default:
|
|
656
|
+
businessLogicError(response);
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
return Promise.reject(response)
|
|
660
|
+
}
|
|
661
|
+
// 成功
|
|
662
|
+
const { isReturnNativeResponse, cache, cacheKey } = options;
|
|
663
|
+
// 直接返回
|
|
664
|
+
if (isReturnNativeResponse) {
|
|
665
|
+
cache && cacheKey && (cachePool.put(cacheKey, response));
|
|
666
|
+
return response
|
|
667
|
+
}
|
|
668
|
+
cache && cacheKey && (cachePool.put(cacheKey, data));
|
|
669
|
+
return data
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
function createAxios(opt) {
|
|
675
|
+
return new CCAxios(deepMerge({
|
|
676
|
+
timeout: 60 * 1000,
|
|
677
|
+
headers: {
|
|
678
|
+
'Content-Type': 'application/json;charset=UTF-8',
|
|
679
|
+
},
|
|
680
|
+
transform: cloneDeep(transform),
|
|
681
|
+
requestOptions: {
|
|
682
|
+
envType: '',
|
|
683
|
+
errorMessageMode: 'modal',
|
|
684
|
+
//是否静默错误提示
|
|
685
|
+
silent: false,
|
|
686
|
+
// 接口是否需要缓存
|
|
687
|
+
cache: false,
|
|
688
|
+
// 接口重试相关
|
|
689
|
+
retryRequest: {
|
|
690
|
+
isOpenRetry: false,
|
|
691
|
+
count: 5,
|
|
692
|
+
waitTime: 100,
|
|
693
|
+
},
|
|
694
|
+
// 是否返回原生响应头 比如:需要获取响应头时使用该属性
|
|
695
|
+
isReturnNativeResponse: false,
|
|
696
|
+
}
|
|
697
|
+
}, opt || {}))
|
|
677
698
|
}
|
|
678
699
|
|
|
679
700
|
var CCHttp$1 = /*#__PURE__*/Object.freeze({
|
|
@@ -681,30 +702,30 @@ var CCHttp$1 = /*#__PURE__*/Object.freeze({
|
|
|
681
702
|
createAxios: createAxios
|
|
682
703
|
});
|
|
683
704
|
|
|
684
|
-
window.ccBus = new Vue;
|
|
685
|
-
/**
|
|
686
|
-
* 发布信息
|
|
687
|
-
* @param {string} event 事件名称
|
|
688
|
-
* @param {...any} args 参数列表
|
|
689
|
-
*/
|
|
690
|
-
function $emit( ...args) {
|
|
691
|
-
window.ccBus.$emit( ...args);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* 订阅消息
|
|
695
|
-
* @param {string} event 事件名称
|
|
696
|
-
* @param {function} callback 回调方法
|
|
697
|
-
*/
|
|
698
|
-
function $on(...args) {
|
|
699
|
-
window.ccBus.$on(...args);
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* 取消订阅
|
|
703
|
-
* @param {string} event 事件名称
|
|
704
|
-
* @param { function | function[] | undefined } callbacks 需要解除监听的事件
|
|
705
|
-
*/
|
|
706
|
-
function $off(...args) {
|
|
707
|
-
window.ccBus.$off(...args);
|
|
705
|
+
window.ccBus = new Vue;
|
|
706
|
+
/**
|
|
707
|
+
* 发布信息
|
|
708
|
+
* @param {string} event 事件名称
|
|
709
|
+
* @param {...any} args 参数列表
|
|
710
|
+
*/
|
|
711
|
+
function $emit( ...args) {
|
|
712
|
+
window.ccBus.$emit( ...args);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* 订阅消息
|
|
716
|
+
* @param {string} event 事件名称
|
|
717
|
+
* @param {function} callback 回调方法
|
|
718
|
+
*/
|
|
719
|
+
function $on(...args) {
|
|
720
|
+
window.ccBus.$on(...args);
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* 取消订阅
|
|
724
|
+
* @param {string} event 事件名称
|
|
725
|
+
* @param { function | function[] | undefined } callbacks 需要解除监听的事件
|
|
726
|
+
*/
|
|
727
|
+
function $off(...args) {
|
|
728
|
+
window.ccBus.$off(...args);
|
|
708
729
|
}
|
|
709
730
|
|
|
710
731
|
var CCBus = /*#__PURE__*/Object.freeze({
|
|
@@ -714,57 +735,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
|
|
|
714
735
|
$off: $off
|
|
715
736
|
});
|
|
716
737
|
|
|
717
|
-
// 电话对象
|
|
718
|
-
let ccCall = new Map();
|
|
719
|
-
// 电话服务商当前对象
|
|
720
|
-
let currentCall;
|
|
721
|
-
/**
|
|
722
|
-
* 初始化电话条
|
|
723
|
-
* @param {string} id 电话服务商唯一标识
|
|
724
|
-
* @param {object} callClient 电话对象
|
|
725
|
-
*/
|
|
726
|
-
function init$1(id, callClient) {
|
|
727
|
-
if (id && callClient) {
|
|
728
|
-
ccCall.set(id, callClient);
|
|
729
|
-
currentCall = callClient;
|
|
730
|
-
return currentCall
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* 拨打电话
|
|
737
|
-
* @param {string} id 电话服务商唯一标识
|
|
738
|
-
* @param {object} options 配置信息
|
|
739
|
-
*/
|
|
740
|
-
function call(id, options) {
|
|
741
|
-
let call;
|
|
742
|
-
if (id) {
|
|
743
|
-
call = ccCall.get(id);
|
|
744
|
-
} else {
|
|
745
|
-
call = currentCall;
|
|
746
|
-
}
|
|
747
|
-
if (call) {
|
|
748
|
-
call.call(options);
|
|
749
|
-
}
|
|
750
|
-
return call
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* 打开通话面板
|
|
754
|
-
* @param {string} id 电话服务商唯一标识
|
|
755
|
-
* @param {object} options 配置信息
|
|
756
|
-
*/
|
|
757
|
-
function openCallPanel(id, options) {
|
|
758
|
-
let call;
|
|
759
|
-
if (id) {
|
|
760
|
-
call = ccCall.get(id);
|
|
761
|
-
} else {
|
|
762
|
-
call = currentCall;
|
|
763
|
-
}
|
|
764
|
-
if (call) {
|
|
765
|
-
call.openCallPanel(options);
|
|
766
|
-
}
|
|
767
|
-
return call
|
|
738
|
+
// 电话对象
|
|
739
|
+
let ccCall = new Map();
|
|
740
|
+
// 电话服务商当前对象
|
|
741
|
+
let currentCall;
|
|
742
|
+
/**
|
|
743
|
+
* 初始化电话条
|
|
744
|
+
* @param {string} id 电话服务商唯一标识
|
|
745
|
+
* @param {object} callClient 电话对象
|
|
746
|
+
*/
|
|
747
|
+
function init$1(id, callClient) {
|
|
748
|
+
if (id && callClient) {
|
|
749
|
+
ccCall.set(id, callClient);
|
|
750
|
+
currentCall = callClient;
|
|
751
|
+
return currentCall
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* 拨打电话
|
|
758
|
+
* @param {string} id 电话服务商唯一标识
|
|
759
|
+
* @param {object} options 配置信息
|
|
760
|
+
*/
|
|
761
|
+
function call(id, options) {
|
|
762
|
+
let call;
|
|
763
|
+
if (id) {
|
|
764
|
+
call = ccCall.get(id);
|
|
765
|
+
} else {
|
|
766
|
+
call = currentCall;
|
|
767
|
+
}
|
|
768
|
+
if (call) {
|
|
769
|
+
call.call(options);
|
|
770
|
+
}
|
|
771
|
+
return call
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* 打开通话面板
|
|
775
|
+
* @param {string} id 电话服务商唯一标识
|
|
776
|
+
* @param {object} options 配置信息
|
|
777
|
+
*/
|
|
778
|
+
function openCallPanel(id, options) {
|
|
779
|
+
let call;
|
|
780
|
+
if (id) {
|
|
781
|
+
call = ccCall.get(id);
|
|
782
|
+
} else {
|
|
783
|
+
call = currentCall;
|
|
784
|
+
}
|
|
785
|
+
if (call) {
|
|
786
|
+
call.openCallPanel(options);
|
|
787
|
+
}
|
|
788
|
+
return call
|
|
768
789
|
}
|
|
769
790
|
|
|
770
791
|
var CCCall = /*#__PURE__*/Object.freeze({
|
|
@@ -774,96 +795,96 @@ var CCCall = /*#__PURE__*/Object.freeze({
|
|
|
774
795
|
openCallPanel: openCallPanel
|
|
775
796
|
});
|
|
776
797
|
|
|
777
|
-
/**
|
|
778
|
-
* 错误日志上报
|
|
779
|
-
* @param {object} response 响应体
|
|
780
|
-
*/
|
|
781
|
-
function reportError(response) {
|
|
782
|
-
if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
783
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
/**
|
|
787
|
-
* 常规日志上报
|
|
788
|
-
* @param {object} response 响应体
|
|
789
|
-
*/
|
|
790
|
-
function reportInfo(response) {
|
|
791
|
-
if ("2" === window.Glod['CC_LOG_LEVEL']) {
|
|
792
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
|
|
793
|
-
serviceName: "lightning-custom-page"
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
const service$1 = axios.create({
|
|
799
|
-
timeout: 60 * 1000,
|
|
800
|
-
headers: {
|
|
801
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
802
|
-
},
|
|
803
|
-
});
|
|
804
|
-
|
|
805
|
-
service$1.interceptors.request.use(
|
|
806
|
-
config => {
|
|
807
|
-
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
808
|
-
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
809
|
-
config.headers.requestIdProducer = "browser";
|
|
810
|
-
return config
|
|
811
|
-
},
|
|
812
|
-
error => {
|
|
813
|
-
Promise.reject(error);
|
|
814
|
-
}
|
|
815
|
-
);
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
service$1.interceptors.response.use(
|
|
819
|
-
response => {
|
|
820
|
-
if (response.data.result) {
|
|
821
|
-
// 上报日志
|
|
822
|
-
reportInfo(response);
|
|
823
|
-
return response.data
|
|
824
|
-
} else {
|
|
825
|
-
reportError(response);
|
|
826
|
-
return Promise.reject(response)
|
|
827
|
-
}
|
|
828
|
-
},
|
|
829
|
-
error => {
|
|
830
|
-
// 上报错误日志
|
|
831
|
-
if (error) {
|
|
832
|
-
reportError(error.response);
|
|
833
|
-
}
|
|
834
|
-
return Promise.reject(error)
|
|
835
|
-
}
|
|
836
|
-
);
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
var http = {
|
|
840
|
-
get: (url, data = {}, responseType = '') => {
|
|
841
|
-
return service$1({
|
|
842
|
-
url: url,
|
|
843
|
-
method: 'get',
|
|
844
|
-
params: data,
|
|
845
|
-
responseType: responseType
|
|
846
|
-
})
|
|
847
|
-
},
|
|
848
|
-
post: (url, data = {}, responseType = '') => {
|
|
849
|
-
return service$1({
|
|
850
|
-
url: url,
|
|
851
|
-
method: 'post',
|
|
852
|
-
data: data,
|
|
853
|
-
responseType: responseType
|
|
854
|
-
})
|
|
855
|
-
},
|
|
798
|
+
/**
|
|
799
|
+
* 错误日志上报
|
|
800
|
+
* @param {object} response 响应体
|
|
801
|
+
*/
|
|
802
|
+
function reportError(response) {
|
|
803
|
+
if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
804
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* 常规日志上报
|
|
809
|
+
* @param {object} response 响应体
|
|
810
|
+
*/
|
|
811
|
+
function reportInfo(response) {
|
|
812
|
+
if ("2" === window.Glod['CC_LOG_LEVEL']) {
|
|
813
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
|
|
814
|
+
serviceName: "lightning-custom-page"
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const service$1 = axios.create({
|
|
820
|
+
timeout: 60 * 1000,
|
|
821
|
+
headers: {
|
|
822
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
823
|
+
},
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
service$1.interceptors.request.use(
|
|
827
|
+
config => {
|
|
828
|
+
config.headers.accessToken = window.$CCDK.CCToken.getToken();
|
|
829
|
+
config.headers.requestId = window.$CCDK.CCUtils.getUuid();
|
|
830
|
+
config.headers.requestIdProducer = "browser";
|
|
831
|
+
return config
|
|
832
|
+
},
|
|
833
|
+
error => {
|
|
834
|
+
Promise.reject(error);
|
|
835
|
+
}
|
|
836
|
+
);
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
service$1.interceptors.response.use(
|
|
840
|
+
response => {
|
|
841
|
+
if (response.data.result) {
|
|
842
|
+
// 上报日志
|
|
843
|
+
reportInfo(response);
|
|
844
|
+
return response.data
|
|
845
|
+
} else {
|
|
846
|
+
reportError(response);
|
|
847
|
+
return Promise.reject(response)
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
error => {
|
|
851
|
+
// 上报错误日志
|
|
852
|
+
if (error) {
|
|
853
|
+
reportError(error.response);
|
|
854
|
+
}
|
|
855
|
+
return Promise.reject(error)
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
var http = {
|
|
861
|
+
get: (url, data = {}, responseType = '') => {
|
|
862
|
+
return service$1({
|
|
863
|
+
url: url,
|
|
864
|
+
method: 'get',
|
|
865
|
+
params: data,
|
|
866
|
+
responseType: responseType
|
|
867
|
+
})
|
|
868
|
+
},
|
|
869
|
+
post: (url, data = {}, responseType = '') => {
|
|
870
|
+
return service$1({
|
|
871
|
+
url: url,
|
|
872
|
+
method: 'post',
|
|
873
|
+
data: data,
|
|
874
|
+
responseType: responseType
|
|
875
|
+
})
|
|
876
|
+
},
|
|
856
877
|
};
|
|
857
878
|
|
|
858
|
-
/**
|
|
859
|
-
* 请求common接口
|
|
860
|
-
* @param {string} className 类名
|
|
861
|
-
* @param {string} methodName 方法名
|
|
862
|
-
* @param {Array} params 参数集合
|
|
863
|
-
* @returns {Promise}
|
|
864
|
-
*/
|
|
865
|
-
function post$1(className, methodName, params) {
|
|
866
|
-
return http.post(window
|
|
879
|
+
/**
|
|
880
|
+
* 请求common接口
|
|
881
|
+
* @param {string} className 类名
|
|
882
|
+
* @param {string} methodName 方法名
|
|
883
|
+
* @param {Array} params 参数集合
|
|
884
|
+
* @returns {Promise}
|
|
885
|
+
*/
|
|
886
|
+
function post$1(className, methodName, params) {
|
|
887
|
+
return http.post(window.Glod['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
|
|
867
888
|
}
|
|
868
889
|
|
|
869
890
|
var CCCommon = /*#__PURE__*/Object.freeze({
|
|
@@ -871,33 +892,33 @@ var CCCommon = /*#__PURE__*/Object.freeze({
|
|
|
871
892
|
post: post$1
|
|
872
893
|
});
|
|
873
894
|
|
|
874
|
-
/**
|
|
875
|
-
* 获取基础url
|
|
876
|
-
* @returns 基础地址
|
|
877
|
-
*/
|
|
878
|
-
function getBaseUrl() {
|
|
879
|
-
return window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
|
|
880
|
-
}
|
|
881
|
-
/**
|
|
882
|
-
* 获取网关对象
|
|
883
|
-
* @returns 网关对象
|
|
884
|
-
*/
|
|
885
|
-
function getGw() {
|
|
886
|
-
return window.Glod;
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* 获取服务对象
|
|
890
|
-
* @returns 服务对象
|
|
891
|
-
*/
|
|
892
|
-
function getSvc() {
|
|
893
|
-
return window.Glod;
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* 获取静态资源的访问地址
|
|
897
|
-
* @returns 静态资源访问地址
|
|
898
|
-
*/
|
|
899
|
-
function getCDNUrl() {
|
|
900
|
-
return window.Glod.CDN_URL;
|
|
895
|
+
/**
|
|
896
|
+
* 获取基础url
|
|
897
|
+
* @returns 基础地址
|
|
898
|
+
*/
|
|
899
|
+
function getBaseUrl() {
|
|
900
|
+
return window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* 获取网关对象
|
|
904
|
+
* @returns 网关对象
|
|
905
|
+
*/
|
|
906
|
+
function getGw() {
|
|
907
|
+
return window.Glod;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* 获取服务对象
|
|
911
|
+
* @returns 服务对象
|
|
912
|
+
*/
|
|
913
|
+
function getSvc() {
|
|
914
|
+
return window.Glod;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* 获取静态资源的访问地址
|
|
918
|
+
* @returns 静态资源访问地址
|
|
919
|
+
*/
|
|
920
|
+
function getCDNUrl() {
|
|
921
|
+
return window.Glod.CDN_URL;
|
|
901
922
|
}
|
|
902
923
|
|
|
903
924
|
var CCConfig = /*#__PURE__*/Object.freeze({
|
|
@@ -908,69 +929,69 @@ var CCConfig = /*#__PURE__*/Object.freeze({
|
|
|
908
929
|
getCDNUrl: getCDNUrl
|
|
909
930
|
});
|
|
910
931
|
|
|
911
|
-
/**
|
|
912
|
-
* 加密
|
|
913
|
-
* @param {String} data 数据
|
|
914
|
-
* @param {String} key 密钥
|
|
915
|
-
* @param {String} iv 偏移量
|
|
916
|
-
* @returns
|
|
917
|
-
*/
|
|
918
|
-
function getAesString(data, key, iv) {
|
|
919
|
-
key = CryptoJS.enc.Utf8.parse(key);
|
|
920
|
-
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
921
|
-
let encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
922
|
-
iv: iv,
|
|
923
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
924
|
-
});
|
|
925
|
-
return encrypted.toString(); //返回的是base64格式的密文
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/**
|
|
929
|
-
* 解密
|
|
930
|
-
* @param {String} encrypted 密文
|
|
931
|
-
* @param {String} key 密钥
|
|
932
|
-
* @param {String} iv 偏移量
|
|
933
|
-
* @returns
|
|
934
|
-
*/
|
|
935
|
-
function getDAesString(encrypted, key, iv) {
|
|
936
|
-
key = CryptoJS.enc.Utf8.parse(key);
|
|
937
|
-
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
938
|
-
let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
|
|
939
|
-
iv: iv,
|
|
940
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
941
|
-
});
|
|
942
|
-
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* CryptoJS加密
|
|
947
|
-
* @param {String} data 数据
|
|
948
|
-
* @param {String} key 密钥
|
|
949
|
-
* @param {String} iv 偏移量
|
|
950
|
-
* @returns 加密的数据
|
|
951
|
-
*/
|
|
952
|
-
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
953
|
-
data = JSON.stringify(data);
|
|
954
|
-
var encrypted = getAesString(data, key, iv); //密文
|
|
955
|
-
return encrypted;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
/**
|
|
959
|
-
* CryptoJS解密
|
|
960
|
-
* @param {String} data 加密的数据
|
|
961
|
-
* @param {String} key 密钥
|
|
962
|
-
* @param {String} iv 偏移量
|
|
963
|
-
* @returns 解密的数据
|
|
964
|
-
*/
|
|
965
|
-
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
966
|
-
try {
|
|
967
|
-
var decryptedStr = getDAesString(data, key, iv);
|
|
968
|
-
if (!decryptedStr) return null
|
|
969
|
-
return JSON.parse(decryptedStr);
|
|
970
|
-
} catch (error) {
|
|
971
|
-
console.trace("解密密码错误", error);
|
|
972
|
-
return null;
|
|
973
|
-
}
|
|
932
|
+
/**
|
|
933
|
+
* 加密
|
|
934
|
+
* @param {String} data 数据
|
|
935
|
+
* @param {String} key 密钥
|
|
936
|
+
* @param {String} iv 偏移量
|
|
937
|
+
* @returns
|
|
938
|
+
*/
|
|
939
|
+
function getAesString(data, key, iv) {
|
|
940
|
+
key = CryptoJS.enc.Utf8.parse(key);
|
|
941
|
+
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
942
|
+
let encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
943
|
+
iv: iv,
|
|
944
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
945
|
+
});
|
|
946
|
+
return encrypted.toString(); //返回的是base64格式的密文
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* 解密
|
|
951
|
+
* @param {String} encrypted 密文
|
|
952
|
+
* @param {String} key 密钥
|
|
953
|
+
* @param {String} iv 偏移量
|
|
954
|
+
* @returns
|
|
955
|
+
*/
|
|
956
|
+
function getDAesString(encrypted, key, iv) {
|
|
957
|
+
key = CryptoJS.enc.Utf8.parse(key);
|
|
958
|
+
iv = CryptoJS.enc.Utf8.parse(iv);
|
|
959
|
+
let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
|
|
960
|
+
iv: iv,
|
|
961
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
962
|
+
});
|
|
963
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* CryptoJS加密
|
|
968
|
+
* @param {String} data 数据
|
|
969
|
+
* @param {String} key 密钥
|
|
970
|
+
* @param {String} iv 偏移量
|
|
971
|
+
* @returns 加密的数据
|
|
972
|
+
*/
|
|
973
|
+
function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
974
|
+
data = JSON.stringify(data);
|
|
975
|
+
var encrypted = getAesString(data, key, iv); //密文
|
|
976
|
+
return encrypted;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* CryptoJS解密
|
|
981
|
+
* @param {String} data 加密的数据
|
|
982
|
+
* @param {String} key 密钥
|
|
983
|
+
* @param {String} iv 偏移量
|
|
984
|
+
* @returns 解密的数据
|
|
985
|
+
*/
|
|
986
|
+
function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
|
|
987
|
+
try {
|
|
988
|
+
var decryptedStr = getDAesString(data, key, iv);
|
|
989
|
+
if (!decryptedStr) return null
|
|
990
|
+
return JSON.parse(decryptedStr);
|
|
991
|
+
} catch (error) {
|
|
992
|
+
console.trace("解密密码错误", error);
|
|
993
|
+
return null;
|
|
994
|
+
}
|
|
974
995
|
}
|
|
975
996
|
|
|
976
997
|
var Crypto = /*#__PURE__*/Object.freeze({
|
|
@@ -979,76 +1000,76 @@ var Crypto = /*#__PURE__*/Object.freeze({
|
|
|
979
1000
|
decrypt: decrypt
|
|
980
1001
|
});
|
|
981
1002
|
|
|
982
|
-
const service = axios.create({
|
|
983
|
-
timeout: 60000,
|
|
984
|
-
headers: {
|
|
985
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
986
|
-
},
|
|
987
|
-
});
|
|
988
|
-
|
|
989
|
-
service.interceptors.request.use(
|
|
990
|
-
config => {
|
|
991
|
-
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
992
|
-
return config
|
|
993
|
-
},
|
|
994
|
-
error => {
|
|
995
|
-
Promise.reject(error);
|
|
996
|
-
}
|
|
997
|
-
);
|
|
998
|
-
|
|
999
|
-
service.interceptors.response.use(
|
|
1000
|
-
response => {
|
|
1001
|
-
const code = response.data.code || 200;
|
|
1002
|
-
if (code !== 200) {
|
|
1003
|
-
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
1004
|
-
} else {
|
|
1005
|
-
return response.data
|
|
1006
|
-
}
|
|
1007
|
-
},
|
|
1008
|
-
error => {
|
|
1009
|
-
return Promise.reject(error)
|
|
1010
|
-
}
|
|
1011
|
-
);
|
|
1012
|
-
function get(url, data = {}, responseType = '') {
|
|
1013
|
-
return service({
|
|
1014
|
-
url: url,
|
|
1015
|
-
method: 'get',
|
|
1016
|
-
params: data,
|
|
1017
|
-
responseType: responseType
|
|
1018
|
-
})
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
function post(url, data = {}, responseType = '') {
|
|
1022
|
-
return service({
|
|
1023
|
-
url: url,
|
|
1024
|
-
method: 'post',
|
|
1025
|
-
data: data,
|
|
1026
|
-
responseType: responseType
|
|
1027
|
-
})
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
function put(url, data = {}) {
|
|
1031
|
-
return service({
|
|
1032
|
-
url: url,
|
|
1033
|
-
method: 'put',
|
|
1034
|
-
data: data
|
|
1035
|
-
})
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
function postParams(url, data = {}) {
|
|
1039
|
-
return service({
|
|
1040
|
-
url: url,
|
|
1041
|
-
method: 'post',
|
|
1042
|
-
params: data
|
|
1043
|
-
})
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
function patch(url, data = {}) {
|
|
1047
|
-
return service({
|
|
1048
|
-
url: url,
|
|
1049
|
-
method: 'patch',
|
|
1050
|
-
data: data
|
|
1051
|
-
})
|
|
1003
|
+
const service = axios.create({
|
|
1004
|
+
timeout: 60000,
|
|
1005
|
+
headers: {
|
|
1006
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
1007
|
+
},
|
|
1008
|
+
});
|
|
1009
|
+
|
|
1010
|
+
service.interceptors.request.use(
|
|
1011
|
+
config => {
|
|
1012
|
+
config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
|
|
1013
|
+
return config
|
|
1014
|
+
},
|
|
1015
|
+
error => {
|
|
1016
|
+
Promise.reject(error);
|
|
1017
|
+
}
|
|
1018
|
+
);
|
|
1019
|
+
|
|
1020
|
+
service.interceptors.response.use(
|
|
1021
|
+
response => {
|
|
1022
|
+
const code = response.data.code || 200;
|
|
1023
|
+
if (code !== 200) {
|
|
1024
|
+
return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
|
|
1025
|
+
} else {
|
|
1026
|
+
return response.data
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
error => {
|
|
1030
|
+
return Promise.reject(error)
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1033
|
+
function get(url, data = {}, responseType = '') {
|
|
1034
|
+
return service({
|
|
1035
|
+
url: url,
|
|
1036
|
+
method: 'get',
|
|
1037
|
+
params: data,
|
|
1038
|
+
responseType: responseType
|
|
1039
|
+
})
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
function post(url, data = {}, responseType = '') {
|
|
1043
|
+
return service({
|
|
1044
|
+
url: url,
|
|
1045
|
+
method: 'post',
|
|
1046
|
+
data: data,
|
|
1047
|
+
responseType: responseType
|
|
1048
|
+
})
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
function put(url, data = {}) {
|
|
1052
|
+
return service({
|
|
1053
|
+
url: url,
|
|
1054
|
+
method: 'put',
|
|
1055
|
+
data: data
|
|
1056
|
+
})
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
function postParams(url, data = {}) {
|
|
1060
|
+
return service({
|
|
1061
|
+
url: url,
|
|
1062
|
+
method: 'post',
|
|
1063
|
+
params: data
|
|
1064
|
+
})
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function patch(url, data = {}) {
|
|
1068
|
+
return service({
|
|
1069
|
+
url: url,
|
|
1070
|
+
method: 'patch',
|
|
1071
|
+
data: data
|
|
1072
|
+
})
|
|
1052
1073
|
}
|
|
1053
1074
|
|
|
1054
1075
|
var CCHttp = /*#__PURE__*/Object.freeze({
|
|
@@ -1060,64 +1081,64 @@ var CCHttp = /*#__PURE__*/Object.freeze({
|
|
|
1060
1081
|
postParams: postParams
|
|
1061
1082
|
});
|
|
1062
1083
|
|
|
1063
|
-
/**
|
|
1064
|
-
* 下载js,并挂载到document上
|
|
1065
|
-
* @param {string} src js下载路径
|
|
1066
|
-
* @param {object} scriptOption script配置参数
|
|
1067
|
-
* @returns
|
|
1068
|
-
*/
|
|
1069
|
-
function loadJs(src, scriptOption) {
|
|
1070
|
-
return new Promise((resolve, reject) => {
|
|
1071
|
-
let scriptTemp = document.createElement('script');
|
|
1072
|
-
if (scriptOption) {
|
|
1073
|
-
Object.assign(scriptTemp, scriptOption);
|
|
1074
|
-
}
|
|
1075
|
-
scriptTemp.type = "text/javascript";
|
|
1076
|
-
scriptTemp.src = src;
|
|
1077
|
-
document.body.appendChild(scriptTemp);
|
|
1078
|
-
|
|
1079
|
-
scriptTemp.onload = () => {
|
|
1080
|
-
resolve();
|
|
1081
|
-
};
|
|
1082
|
-
scriptTemp.onerror = () => {
|
|
1083
|
-
reject();
|
|
1084
|
-
};
|
|
1085
|
-
})
|
|
1086
|
-
}
|
|
1087
|
-
/**
|
|
1088
|
-
* 创建加载js组件
|
|
1089
|
-
*/
|
|
1090
|
-
function createLoadJsComponent() {
|
|
1091
|
-
Vue.component('cc-load-script', {
|
|
1092
|
-
render: function (createElement) {
|
|
1093
|
-
var self = this;
|
|
1094
|
-
return createElement('script', {
|
|
1095
|
-
attrs: {
|
|
1096
|
-
type: 'text/javascript',
|
|
1097
|
-
src: this.src
|
|
1098
|
-
},
|
|
1099
|
-
on: {
|
|
1100
|
-
load: function (event) {
|
|
1101
|
-
self.$emit('load', event);
|
|
1102
|
-
},
|
|
1103
|
-
error: function (event) {
|
|
1104
|
-
self.$emit('error', event);
|
|
1105
|
-
},
|
|
1106
|
-
readystatechange: function (event) {
|
|
1107
|
-
if (this.readyState == 'complete') {
|
|
1108
|
-
self.$emit('load', event);
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
});
|
|
1113
|
-
},
|
|
1114
|
-
props: {
|
|
1115
|
-
src: {
|
|
1116
|
-
type: String,
|
|
1117
|
-
required: true
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
});
|
|
1084
|
+
/**
|
|
1085
|
+
* 下载js,并挂载到document上
|
|
1086
|
+
* @param {string} src js下载路径
|
|
1087
|
+
* @param {object} scriptOption script配置参数
|
|
1088
|
+
* @returns
|
|
1089
|
+
*/
|
|
1090
|
+
function loadJs(src, scriptOption) {
|
|
1091
|
+
return new Promise((resolve, reject) => {
|
|
1092
|
+
let scriptTemp = document.createElement('script');
|
|
1093
|
+
if (scriptOption) {
|
|
1094
|
+
Object.assign(scriptTemp, scriptOption);
|
|
1095
|
+
}
|
|
1096
|
+
scriptTemp.type = "text/javascript";
|
|
1097
|
+
scriptTemp.src = src;
|
|
1098
|
+
document.body.appendChild(scriptTemp);
|
|
1099
|
+
|
|
1100
|
+
scriptTemp.onload = () => {
|
|
1101
|
+
resolve();
|
|
1102
|
+
};
|
|
1103
|
+
scriptTemp.onerror = () => {
|
|
1104
|
+
reject();
|
|
1105
|
+
};
|
|
1106
|
+
})
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* 创建加载js组件
|
|
1110
|
+
*/
|
|
1111
|
+
function createLoadJsComponent() {
|
|
1112
|
+
Vue.component('cc-load-script', {
|
|
1113
|
+
render: function (createElement) {
|
|
1114
|
+
var self = this;
|
|
1115
|
+
return createElement('script', {
|
|
1116
|
+
attrs: {
|
|
1117
|
+
type: 'text/javascript',
|
|
1118
|
+
src: this.src
|
|
1119
|
+
},
|
|
1120
|
+
on: {
|
|
1121
|
+
load: function (event) {
|
|
1122
|
+
self.$emit('load', event);
|
|
1123
|
+
},
|
|
1124
|
+
error: function (event) {
|
|
1125
|
+
self.$emit('error', event);
|
|
1126
|
+
},
|
|
1127
|
+
readystatechange: function (event) {
|
|
1128
|
+
if (this.readyState == 'complete') {
|
|
1129
|
+
self.$emit('load', event);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
});
|
|
1134
|
+
},
|
|
1135
|
+
props: {
|
|
1136
|
+
src: {
|
|
1137
|
+
type: String,
|
|
1138
|
+
required: true
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1121
1142
|
}
|
|
1122
1143
|
|
|
1123
1144
|
var CCLoad = /*#__PURE__*/Object.freeze({
|
|
@@ -1126,201 +1147,201 @@ var CCLoad = /*#__PURE__*/Object.freeze({
|
|
|
1126
1147
|
createLoadJsComponent: createLoadJsComponent
|
|
1127
1148
|
});
|
|
1128
1149
|
|
|
1129
|
-
/**
|
|
1130
|
-
* 获取日志基础信息
|
|
1131
|
-
* @returns 日志基础信息
|
|
1132
|
-
*/
|
|
1133
|
-
function getBaseInfo() {
|
|
1134
|
-
let userInfo = window.$CCDK.CCUser.getUserInfo();
|
|
1135
|
-
let old = {
|
|
1136
|
-
// 用户名,使用登录账号
|
|
1137
|
-
"userName": userInfo.loginName || "未知用户",
|
|
1138
|
-
// 用户id
|
|
1139
|
-
"userId": userInfo.userId,
|
|
1140
|
-
// 组织id
|
|
1141
|
-
"orgId": userInfo.orgId,
|
|
1142
|
-
// 组织名称
|
|
1143
|
-
"orgName": userInfo.orgName,
|
|
1144
|
-
// 服务名称
|
|
1145
|
-
"serviceName": "未知应用",
|
|
1146
|
-
// 记录类型:platform平台日志,dev开发者日志
|
|
1147
|
-
"recordType": "platform",
|
|
1148
|
-
// 日志类型
|
|
1149
|
-
"logType": "front",
|
|
1150
|
-
// 发生时间
|
|
1151
|
-
"operateTime": (new Date()).valueOf(),
|
|
1152
|
-
// 发生时间的str格式:yyyy-MM-dd HH:mm:ss
|
|
1153
|
-
"operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
|
|
1154
|
-
// 日志标识码,没有这个标识码,不能上传
|
|
1155
|
-
"cccode": "hidden",
|
|
1156
|
-
// 日志显示级别默认2
|
|
1157
|
-
"displayLevel": "2",
|
|
1158
|
-
};
|
|
1159
|
-
return old
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* 获取网络异常信息
|
|
1163
|
-
* @param {object} response 网络请求响应体
|
|
1164
|
-
* @returns 请求体信息
|
|
1165
|
-
*/
|
|
1166
|
-
function getHttpErrorInfo(error = {}) {
|
|
1167
|
-
let { config = {}, data = {} } = error;
|
|
1168
|
-
if (config) {
|
|
1169
|
-
return {
|
|
1170
|
-
// 请求地址url
|
|
1171
|
-
"requestUrl": config.baseURL + config.url,
|
|
1172
|
-
// 请求id
|
|
1173
|
-
"requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1174
|
-
// 请求id类型
|
|
1175
|
-
"requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
|
|
1176
|
-
// 请求体
|
|
1177
|
-
"requestParameter": config.data,
|
|
1178
|
-
// 错误描述
|
|
1179
|
-
"errorMessage": error.message || data.returnInfo || "未知错误",
|
|
1180
|
-
// 请求结果状态
|
|
1181
|
-
"requestResult": "失败",
|
|
1182
|
-
// 日志级别
|
|
1183
|
-
"errorLevel": "2",
|
|
1184
|
-
// 堆栈信息
|
|
1185
|
-
"printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
|
|
1186
|
-
}
|
|
1187
|
-
} else {
|
|
1188
|
-
return {}
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
/**
|
|
1194
|
-
* 获取网络信息
|
|
1195
|
-
* @param {object} response 网络请求响应体
|
|
1196
|
-
* @returns 请求体信息
|
|
1197
|
-
*/
|
|
1198
|
-
function getHttpInfo(response) {
|
|
1199
|
-
if (response) {
|
|
1200
|
-
if (window.performance) {
|
|
1201
|
-
// 通过性能接口精确测量接口用时
|
|
1202
|
-
let per = performance.getEntriesByName(response.request.responseURL, "resource");
|
|
1203
|
-
if (per.length > 0) {
|
|
1204
|
-
let index = per.length - 1;
|
|
1205
|
-
response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
return {
|
|
1209
|
-
// 接口用时
|
|
1210
|
-
"spendTime": response.spendTime || "0",
|
|
1211
|
-
// 请求地址url
|
|
1212
|
-
"requestUrl": response.request ? response.request.responseURL : "",
|
|
1213
|
-
// 请求id
|
|
1214
|
-
"requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1215
|
-
// 请求id类型
|
|
1216
|
-
"requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
|
|
1217
|
-
// 请求体
|
|
1218
|
-
"requestParameter": response.config.data,
|
|
1219
|
-
// 错误描述
|
|
1220
|
-
"infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
|
|
1221
|
-
// 请求结果状态
|
|
1222
|
-
"requestResult": response.data.result ? "成功" : "失败",
|
|
1223
|
-
// 日志类型:info,debug
|
|
1224
|
-
"infoType": "info",
|
|
1225
|
-
}
|
|
1226
|
-
} else {
|
|
1227
|
-
return {}
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
/**
|
|
1232
|
-
* 上报日志
|
|
1233
|
-
* @param {string} url 请求地址
|
|
1234
|
-
* @param {object} response 响应信息
|
|
1235
|
-
* @param {string} type 日志类型,info,debug,error
|
|
1236
|
-
* @param {object} logInfo 日志信息
|
|
1237
|
-
*/
|
|
1238
|
-
function reportLog(url, response, type = "info", logInfo = {}) {
|
|
1239
|
-
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1240
|
-
let userInfo = getBaseInfo();
|
|
1241
|
-
if ("未知用户" != userInfo.userName && userInfo.userName) {
|
|
1242
|
-
axios.post(url,
|
|
1243
|
-
{
|
|
1244
|
-
...userInfo,
|
|
1245
|
-
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1246
|
-
...logInfo
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
/**
|
|
1254
|
-
* 批量上报日志
|
|
1255
|
-
* @param {string} url 请求地址
|
|
1256
|
-
* @param {object} response 响应信息
|
|
1257
|
-
* @param {string} type 日志类型,info,debug,error
|
|
1258
|
-
* @param {object} logInfo 日志信息
|
|
1259
|
-
*/
|
|
1260
|
-
function batchReportLog(url, response, type = "info", logInfo = []) {
|
|
1261
|
-
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1262
|
-
let userInfo = getBaseInfo();
|
|
1263
|
-
if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
|
|
1264
|
-
let datas = logInfo.map(info => {
|
|
1265
|
-
return {
|
|
1266
|
-
...userInfo,
|
|
1267
|
-
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1268
|
-
...info
|
|
1269
|
-
}
|
|
1270
|
-
});
|
|
1271
|
-
axios.post(url, datas);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
/**
|
|
1277
|
-
* 上报info日志
|
|
1278
|
-
* @param {object} logInfo 日志信息
|
|
1279
|
-
* @param {object} response axios响应信息
|
|
1280
|
-
*/
|
|
1281
|
-
function reportInfoLog(logInfo, response) {
|
|
1282
|
-
logInfo.recordType = "dev";
|
|
1283
|
-
reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
|
|
1284
|
-
}
|
|
1285
|
-
/**
|
|
1286
|
-
* 上报错误信息
|
|
1287
|
-
* @param {object} logInfo 日志信息
|
|
1288
|
-
* @param {object} response axios响应信息
|
|
1289
|
-
*/
|
|
1290
|
-
function reportErrorLog(logInfo, response) {
|
|
1291
|
-
logInfo.recordType = "dev";
|
|
1292
|
-
reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
/**
|
|
1297
|
-
* CC错误日志上报:这个api目前没有使用的场景
|
|
1298
|
-
* @param {object} error 响应体
|
|
1299
|
-
* @param {object} options 配置信息
|
|
1300
|
-
*/
|
|
1301
|
-
function reportCCError(error, options = { serviceName: "lightning-main" }) {
|
|
1302
|
-
if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1303
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
/**
|
|
1307
|
-
* CC常规日志上报:这个api目前没有使用的场景
|
|
1308
|
-
* @param {object} response 响应体
|
|
1309
|
-
* @param {object} options 配置信息
|
|
1310
|
-
*/
|
|
1311
|
-
function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
|
|
1312
|
-
if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1313
|
-
if (response.config.data) {
|
|
1314
|
-
try {
|
|
1315
|
-
let data = JSON.parse(response.config.data);
|
|
1316
|
-
if (data.head && data.head.accessToken) {
|
|
1317
|
-
data.head.accessToken = "******";
|
|
1318
|
-
response.config.data = JSON.stringify(data);
|
|
1319
|
-
}
|
|
1320
|
-
} catch (e) { }
|
|
1321
|
-
}
|
|
1322
|
-
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
|
|
1323
|
-
}
|
|
1150
|
+
/**
|
|
1151
|
+
* 获取日志基础信息
|
|
1152
|
+
* @returns 日志基础信息
|
|
1153
|
+
*/
|
|
1154
|
+
function getBaseInfo() {
|
|
1155
|
+
let userInfo = window.$CCDK.CCUser.getUserInfo();
|
|
1156
|
+
let old = {
|
|
1157
|
+
// 用户名,使用登录账号
|
|
1158
|
+
"userName": userInfo.loginName || "未知用户",
|
|
1159
|
+
// 用户id
|
|
1160
|
+
"userId": userInfo.userId,
|
|
1161
|
+
// 组织id
|
|
1162
|
+
"orgId": userInfo.orgId,
|
|
1163
|
+
// 组织名称
|
|
1164
|
+
"orgName": userInfo.orgName,
|
|
1165
|
+
// 服务名称
|
|
1166
|
+
"serviceName": "未知应用",
|
|
1167
|
+
// 记录类型:platform平台日志,dev开发者日志
|
|
1168
|
+
"recordType": "platform",
|
|
1169
|
+
// 日志类型
|
|
1170
|
+
"logType": "front",
|
|
1171
|
+
// 发生时间
|
|
1172
|
+
"operateTime": (new Date()).valueOf(),
|
|
1173
|
+
// 发生时间的str格式:yyyy-MM-dd HH:mm:ss
|
|
1174
|
+
"operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
|
|
1175
|
+
// 日志标识码,没有这个标识码,不能上传
|
|
1176
|
+
"cccode": "hidden",
|
|
1177
|
+
// 日志显示级别默认2
|
|
1178
|
+
"displayLevel": "2",
|
|
1179
|
+
};
|
|
1180
|
+
return old
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* 获取网络异常信息
|
|
1184
|
+
* @param {object} response 网络请求响应体
|
|
1185
|
+
* @returns 请求体信息
|
|
1186
|
+
*/
|
|
1187
|
+
function getHttpErrorInfo(error = {}) {
|
|
1188
|
+
let { config = {}, data = {} } = error;
|
|
1189
|
+
if (config) {
|
|
1190
|
+
return {
|
|
1191
|
+
// 请求地址url
|
|
1192
|
+
"requestUrl": config.baseURL + config.url,
|
|
1193
|
+
// 请求id
|
|
1194
|
+
"requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1195
|
+
// 请求id类型
|
|
1196
|
+
"requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
|
|
1197
|
+
// 请求体
|
|
1198
|
+
"requestParameter": config.data,
|
|
1199
|
+
// 错误描述
|
|
1200
|
+
"errorMessage": error.message || data.returnInfo || "未知错误",
|
|
1201
|
+
// 请求结果状态
|
|
1202
|
+
"requestResult": "失败",
|
|
1203
|
+
// 日志级别
|
|
1204
|
+
"errorLevel": "2",
|
|
1205
|
+
// 堆栈信息
|
|
1206
|
+
"printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
|
|
1207
|
+
}
|
|
1208
|
+
} else {
|
|
1209
|
+
return {}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* 获取网络信息
|
|
1216
|
+
* @param {object} response 网络请求响应体
|
|
1217
|
+
* @returns 请求体信息
|
|
1218
|
+
*/
|
|
1219
|
+
function getHttpInfo(response) {
|
|
1220
|
+
if (response) {
|
|
1221
|
+
if (window.performance) {
|
|
1222
|
+
// 通过性能接口精确测量接口用时
|
|
1223
|
+
let per = performance.getEntriesByName(response.request.responseURL, "resource");
|
|
1224
|
+
if (per.length > 0) {
|
|
1225
|
+
let index = per.length - 1;
|
|
1226
|
+
response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
return {
|
|
1230
|
+
// 接口用时
|
|
1231
|
+
"spendTime": response.spendTime || "0",
|
|
1232
|
+
// 请求地址url
|
|
1233
|
+
"requestUrl": response.request ? response.request.responseURL : "",
|
|
1234
|
+
// 请求id
|
|
1235
|
+
"requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
|
|
1236
|
+
// 请求id类型
|
|
1237
|
+
"requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
|
|
1238
|
+
// 请求体
|
|
1239
|
+
"requestParameter": response.config.data,
|
|
1240
|
+
// 错误描述
|
|
1241
|
+
"infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
|
|
1242
|
+
// 请求结果状态
|
|
1243
|
+
"requestResult": response.data.result ? "成功" : "失败",
|
|
1244
|
+
// 日志类型:info,debug
|
|
1245
|
+
"infoType": "info",
|
|
1246
|
+
}
|
|
1247
|
+
} else {
|
|
1248
|
+
return {}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* 上报日志
|
|
1254
|
+
* @param {string} url 请求地址
|
|
1255
|
+
* @param {object} response 响应信息
|
|
1256
|
+
* @param {string} type 日志类型,info,debug,error
|
|
1257
|
+
* @param {object} logInfo 日志信息
|
|
1258
|
+
*/
|
|
1259
|
+
function reportLog(url, response, type = "info", logInfo = {}) {
|
|
1260
|
+
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1261
|
+
let userInfo = getBaseInfo();
|
|
1262
|
+
if ("未知用户" != userInfo.userName && userInfo.userName) {
|
|
1263
|
+
axios.post(url,
|
|
1264
|
+
{
|
|
1265
|
+
...userInfo,
|
|
1266
|
+
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1267
|
+
...logInfo
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* 批量上报日志
|
|
1276
|
+
* @param {string} url 请求地址
|
|
1277
|
+
* @param {object} response 响应信息
|
|
1278
|
+
* @param {string} type 日志类型,info,debug,error
|
|
1279
|
+
* @param {object} logInfo 日志信息
|
|
1280
|
+
*/
|
|
1281
|
+
function batchReportLog(url, response, type = "info", logInfo = []) {
|
|
1282
|
+
// 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
|
|
1283
|
+
let userInfo = getBaseInfo();
|
|
1284
|
+
if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
|
|
1285
|
+
let datas = logInfo.map(info => {
|
|
1286
|
+
return {
|
|
1287
|
+
...userInfo,
|
|
1288
|
+
...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
|
|
1289
|
+
...info
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
axios.post(url, datas);
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* 上报info日志
|
|
1299
|
+
* @param {object} logInfo 日志信息
|
|
1300
|
+
* @param {object} response axios响应信息
|
|
1301
|
+
*/
|
|
1302
|
+
function reportInfoLog(logInfo, response) {
|
|
1303
|
+
logInfo.recordType = "dev";
|
|
1304
|
+
reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
|
|
1305
|
+
}
|
|
1306
|
+
/**
|
|
1307
|
+
* 上报错误信息
|
|
1308
|
+
* @param {object} logInfo 日志信息
|
|
1309
|
+
* @param {object} response axios响应信息
|
|
1310
|
+
*/
|
|
1311
|
+
function reportErrorLog(logInfo, response) {
|
|
1312
|
+
logInfo.recordType = "dev";
|
|
1313
|
+
reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* CC错误日志上报:这个api目前没有使用的场景
|
|
1319
|
+
* @param {object} error 响应体
|
|
1320
|
+
* @param {object} options 配置信息
|
|
1321
|
+
*/
|
|
1322
|
+
function reportCCError(error, options = { serviceName: "lightning-main" }) {
|
|
1323
|
+
if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1324
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* CC常规日志上报:这个api目前没有使用的场景
|
|
1329
|
+
* @param {object} response 响应体
|
|
1330
|
+
* @param {object} options 配置信息
|
|
1331
|
+
*/
|
|
1332
|
+
function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
|
|
1333
|
+
if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
|
|
1334
|
+
if (response.config.data) {
|
|
1335
|
+
try {
|
|
1336
|
+
let data = JSON.parse(response.config.data);
|
|
1337
|
+
if (data.head && data.head.accessToken) {
|
|
1338
|
+
data.head.accessToken = "******";
|
|
1339
|
+
response.config.data = JSON.stringify(data);
|
|
1340
|
+
}
|
|
1341
|
+
} catch (e) { }
|
|
1342
|
+
}
|
|
1343
|
+
window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
|
|
1344
|
+
}
|
|
1324
1345
|
}
|
|
1325
1346
|
|
|
1326
1347
|
var CCLog = /*#__PURE__*/Object.freeze({
|
|
@@ -1333,123 +1354,123 @@ var CCLog = /*#__PURE__*/Object.freeze({
|
|
|
1333
1354
|
batchReportLog: batchReportLog
|
|
1334
1355
|
});
|
|
1335
1356
|
|
|
1336
|
-
// 存储所有菜单标识
|
|
1337
|
-
const ALL_MENU_LIST = 'all_menu_list';
|
|
1338
|
-
// 存储当前选中的菜单
|
|
1339
|
-
const CURRENT_MENU = 'current_menu';
|
|
1340
|
-
|
|
1341
|
-
/**
|
|
1342
|
-
* 获取全部菜单
|
|
1343
|
-
*/
|
|
1344
|
-
function getAllMenu() {
|
|
1345
|
-
let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
|
|
1346
|
-
if (data) {
|
|
1347
|
-
return JSON.parse(data)
|
|
1348
|
-
}
|
|
1349
|
-
return []
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
/**
|
|
1353
|
-
* 设置全部菜单
|
|
1354
|
-
* @param {object} data 菜单集合
|
|
1355
|
-
*/
|
|
1356
|
-
function setAllMenu(data = []) {
|
|
1357
|
-
if (data) {
|
|
1358
|
-
localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
/**
|
|
1363
|
-
* 缓存当前选中菜单对象
|
|
1364
|
-
* @param {object} data 菜单对象
|
|
1365
|
-
*/
|
|
1366
|
-
function setCurrentMenu(data = {}) {
|
|
1367
|
-
if (data) {
|
|
1368
|
-
localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
/**
|
|
1373
|
-
* 获取当前选中菜单对象
|
|
1374
|
-
* @param {object} data 菜单对象
|
|
1375
|
-
*/
|
|
1376
|
-
function getCurrentMenu() {
|
|
1377
|
-
let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
|
|
1378
|
-
if (data) {
|
|
1379
|
-
return JSON.parse(data)
|
|
1380
|
-
}
|
|
1381
|
-
return {}
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
* 添加一个一级菜单
|
|
1386
|
-
* @param {object} options 菜单配置
|
|
1387
|
-
*/
|
|
1388
|
-
function addMenu1(options) {
|
|
1389
|
-
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
1390
|
-
}
|
|
1391
|
-
/**
|
|
1392
|
-
* 添加一个二级菜单
|
|
1393
|
-
* @param {object} options 菜单配置
|
|
1394
|
-
*/
|
|
1395
|
-
function addMenu2(options) {
|
|
1396
|
-
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
1397
|
-
}
|
|
1398
|
-
/**
|
|
1399
|
-
* 删除一个一级菜单
|
|
1400
|
-
* @param {object} options 菜单配置
|
|
1401
|
-
*/
|
|
1402
|
-
function deleteMenu1(options) {
|
|
1403
|
-
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
|
-
* 删除一个二级菜单
|
|
1407
|
-
* @param {object} options 菜单配置
|
|
1408
|
-
*/
|
|
1409
|
-
function deleteMenu2(options) {
|
|
1410
|
-
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* 刷新一个一级菜单
|
|
1414
|
-
* @param {object} options 菜单配置
|
|
1415
|
-
*/
|
|
1416
|
-
function refreshMenu1(options) {
|
|
1417
|
-
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* 刷新一个二级菜单
|
|
1421
|
-
* @param {object} options 菜单配置
|
|
1422
|
-
*/
|
|
1423
|
-
function refreshMenu2(options) {
|
|
1424
|
-
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* 替换一个一级菜单
|
|
1428
|
-
* @param {object} options 菜单配置
|
|
1429
|
-
*/
|
|
1430
|
-
function replaceMenu1(options) {
|
|
1431
|
-
window.$CCDK.CCBus.$emit('replaceMenu1', options);
|
|
1432
|
-
}
|
|
1433
|
-
/**
|
|
1434
|
-
* 替换一个二级菜单
|
|
1435
|
-
* @param {object} options 菜单配置
|
|
1436
|
-
*/
|
|
1437
|
-
function replaceMenu2(options) {
|
|
1438
|
-
window.$CCDK.CCBus.$emit('replaceMenu2', options);
|
|
1439
|
-
}
|
|
1440
|
-
/**
|
|
1441
|
-
* 定位到已经打开的一级菜单
|
|
1442
|
-
* @param {object} options 菜单配置
|
|
1443
|
-
*/
|
|
1444
|
-
function reOpenMenu1(options) {
|
|
1445
|
-
window.$CCDK.CCBus.$emit('reOpenMenu1', options);
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
|
|
1449
|
-
* @param {object} options 菜单配置
|
|
1450
|
-
*/
|
|
1451
|
-
function reOpenMenu2(options) {
|
|
1452
|
-
window.$CCDK.CCBus.$emit('reOpenMenu2', options);
|
|
1357
|
+
// 存储所有菜单标识
|
|
1358
|
+
const ALL_MENU_LIST = 'all_menu_list';
|
|
1359
|
+
// 存储当前选中的菜单
|
|
1360
|
+
const CURRENT_MENU = 'current_menu';
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* 获取全部菜单
|
|
1364
|
+
*/
|
|
1365
|
+
function getAllMenu() {
|
|
1366
|
+
let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
|
|
1367
|
+
if (data) {
|
|
1368
|
+
return JSON.parse(data)
|
|
1369
|
+
}
|
|
1370
|
+
return []
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
/**
|
|
1374
|
+
* 设置全部菜单
|
|
1375
|
+
* @param {object} data 菜单集合
|
|
1376
|
+
*/
|
|
1377
|
+
function setAllMenu(data = []) {
|
|
1378
|
+
if (data) {
|
|
1379
|
+
localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* 缓存当前选中菜单对象
|
|
1385
|
+
* @param {object} data 菜单对象
|
|
1386
|
+
*/
|
|
1387
|
+
function setCurrentMenu(data = {}) {
|
|
1388
|
+
if (data) {
|
|
1389
|
+
localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* 获取当前选中菜单对象
|
|
1395
|
+
* @param {object} data 菜单对象
|
|
1396
|
+
*/
|
|
1397
|
+
function getCurrentMenu() {
|
|
1398
|
+
let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
|
|
1399
|
+
if (data) {
|
|
1400
|
+
return JSON.parse(data)
|
|
1401
|
+
}
|
|
1402
|
+
return {}
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* 添加一个一级菜单
|
|
1407
|
+
* @param {object} options 菜单配置
|
|
1408
|
+
*/
|
|
1409
|
+
function addMenu1(options) {
|
|
1410
|
+
window.$CCDK.CCBus.$emit('addMenu1', options);
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* 添加一个二级菜单
|
|
1414
|
+
* @param {object} options 菜单配置
|
|
1415
|
+
*/
|
|
1416
|
+
function addMenu2(options) {
|
|
1417
|
+
window.$CCDK.CCBus.$emit('addMenu2', options);
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* 删除一个一级菜单
|
|
1421
|
+
* @param {object} options 菜单配置
|
|
1422
|
+
*/
|
|
1423
|
+
function deleteMenu1(options) {
|
|
1424
|
+
window.$CCDK.CCBus.$emit('deleteMenu1', options);
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* 删除一个二级菜单
|
|
1428
|
+
* @param {object} options 菜单配置
|
|
1429
|
+
*/
|
|
1430
|
+
function deleteMenu2(options) {
|
|
1431
|
+
window.$CCDK.CCBus.$emit('deleteMenu2', options);
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* 刷新一个一级菜单
|
|
1435
|
+
* @param {object} options 菜单配置
|
|
1436
|
+
*/
|
|
1437
|
+
function refreshMenu1(options) {
|
|
1438
|
+
window.$CCDK.CCBus.$emit('refreshMenu1', options);
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* 刷新一个二级菜单
|
|
1442
|
+
* @param {object} options 菜单配置
|
|
1443
|
+
*/
|
|
1444
|
+
function refreshMenu2(options) {
|
|
1445
|
+
window.$CCDK.CCBus.$emit('refreshMenu2', options);
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* 替换一个一级菜单
|
|
1449
|
+
* @param {object} options 菜单配置
|
|
1450
|
+
*/
|
|
1451
|
+
function replaceMenu1(options) {
|
|
1452
|
+
window.$CCDK.CCBus.$emit('replaceMenu1', options);
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* 替换一个二级菜单
|
|
1456
|
+
* @param {object} options 菜单配置
|
|
1457
|
+
*/
|
|
1458
|
+
function replaceMenu2(options) {
|
|
1459
|
+
window.$CCDK.CCBus.$emit('replaceMenu2', options);
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* 定位到已经打开的一级菜单
|
|
1463
|
+
* @param {object} options 菜单配置
|
|
1464
|
+
*/
|
|
1465
|
+
function reOpenMenu1(options) {
|
|
1466
|
+
window.$CCDK.CCBus.$emit('reOpenMenu1', options);
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
|
|
1470
|
+
* @param {object} options 菜单配置
|
|
1471
|
+
*/
|
|
1472
|
+
function reOpenMenu2(options) {
|
|
1473
|
+
window.$CCDK.CCBus.$emit('reOpenMenu2', options);
|
|
1453
1474
|
}
|
|
1454
1475
|
|
|
1455
1476
|
var CCMenu = /*#__PURE__*/Object.freeze({
|
|
@@ -1470,43 +1491,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
|
|
|
1470
1491
|
getCurrentMenu: getCurrentMenu
|
|
1471
1492
|
});
|
|
1472
1493
|
|
|
1473
|
-
/**
|
|
1474
|
-
* 消息提示框
|
|
1475
|
-
* @param {string} text 提示文字,支持vhtml渲染
|
|
1476
|
-
* @param {string} type 消息类别
|
|
1477
|
-
* @param {number} duration 持续时间
|
|
1478
|
-
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
1479
|
-
* @param {boolean} center 文字是否剧中
|
|
1480
|
-
*/
|
|
1481
|
-
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
1482
|
-
Message({
|
|
1483
|
-
message: text,
|
|
1484
|
-
type,
|
|
1485
|
-
duration,
|
|
1486
|
-
showClose,
|
|
1487
|
-
center
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
/**
|
|
1491
|
-
* 提示确认框
|
|
1492
|
-
* @param {string} text 提示信息
|
|
1493
|
-
* @param {string} title 标题
|
|
1494
|
-
* @param {object} options 配置信息
|
|
1495
|
-
*/
|
|
1496
|
-
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
1497
|
-
MessageBox.confirm(text, title, options).then(() => {
|
|
1498
|
-
confirm();
|
|
1499
|
-
}).catch(() => {
|
|
1500
|
-
reject();
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
/**
|
|
1505
|
-
* 提示消息框
|
|
1506
|
-
* @param {object} options 配置信息
|
|
1507
|
-
*/
|
|
1508
|
-
function showNotification(options = {}) {
|
|
1509
|
-
Notification(options);
|
|
1494
|
+
/**
|
|
1495
|
+
* 消息提示框
|
|
1496
|
+
* @param {string} text 提示文字,支持vhtml渲染
|
|
1497
|
+
* @param {string} type 消息类别
|
|
1498
|
+
* @param {number} duration 持续时间
|
|
1499
|
+
* @param {boolean} showClose 是否显示消息关闭按钮
|
|
1500
|
+
* @param {boolean} center 文字是否剧中
|
|
1501
|
+
*/
|
|
1502
|
+
function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
|
|
1503
|
+
Message({
|
|
1504
|
+
message: text,
|
|
1505
|
+
type,
|
|
1506
|
+
duration,
|
|
1507
|
+
showClose,
|
|
1508
|
+
center
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* 提示确认框
|
|
1513
|
+
* @param {string} text 提示信息
|
|
1514
|
+
* @param {string} title 标题
|
|
1515
|
+
* @param {object} options 配置信息
|
|
1516
|
+
*/
|
|
1517
|
+
function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
|
|
1518
|
+
MessageBox.confirm(text, title, options).then(() => {
|
|
1519
|
+
confirm();
|
|
1520
|
+
}).catch(() => {
|
|
1521
|
+
reject();
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* 提示消息框
|
|
1527
|
+
* @param {object} options 配置信息
|
|
1528
|
+
*/
|
|
1529
|
+
function showNotification(options = {}) {
|
|
1530
|
+
Notification(options);
|
|
1510
1531
|
}
|
|
1511
1532
|
|
|
1512
1533
|
var CCMessage = /*#__PURE__*/Object.freeze({
|
|
@@ -1516,133 +1537,133 @@ var CCMessage = /*#__PURE__*/Object.freeze({
|
|
|
1516
1537
|
showNotification: showNotification
|
|
1517
1538
|
});
|
|
1518
1539
|
|
|
1519
|
-
// 对象详情存储标识
|
|
1520
|
-
const OBJECT_DETAIL = 'cc_object_detail';
|
|
1521
|
-
// 对象详情id存储标识
|
|
1522
|
-
const OBJECT_DETAIL_ID = 'cc_object_detail_id';
|
|
1523
|
-
// 对象存储标识
|
|
1524
|
-
const OBJECT = 'cc_object';
|
|
1525
|
-
// 列表视图存储标识
|
|
1526
|
-
const OBJECT_LIST = 'cc_object_list';
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
* 获得当前标准对象信息
|
|
1530
|
-
*/
|
|
1531
|
-
function getObject() {
|
|
1532
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
1533
|
-
if (detail) {
|
|
1534
|
-
return JSON.parse(detail)
|
|
1535
|
-
}
|
|
1536
|
-
return ''
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
/**
|
|
1540
|
-
* 设置当前标准对象信息
|
|
1541
|
-
* @param {object} detail 对象数据
|
|
1542
|
-
*/
|
|
1543
|
-
function setObject(detail = '') {
|
|
1544
|
-
if (detail) {
|
|
1545
|
-
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
/**
|
|
1550
|
-
* 获得当前标准对象的详细信息
|
|
1551
|
-
* @param {String} apiname: 查找字段的apiname
|
|
1552
|
-
* @param {String} detailId: 详情页数据id
|
|
1553
|
-
*/
|
|
1554
|
-
function getObjectDetail(apiname, detailId) {
|
|
1555
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
1556
|
-
if (detail) {
|
|
1557
|
-
// 转为对象
|
|
1558
|
-
detail = JSON.parse(detail);
|
|
1559
|
-
// 没有指定详情页id,获取最后一次的id
|
|
1560
|
-
if (!detailId) {
|
|
1561
|
-
detailId = detail.id;
|
|
1562
|
-
} else {
|
|
1563
|
-
detail.id = detailId;
|
|
1564
|
-
}
|
|
1565
|
-
// 通过详情页id获取对应的详情页数据
|
|
1566
|
-
let detailList = JSON.parse(sessionStorage.getItem(detailId));
|
|
1567
|
-
if (apiname) {
|
|
1568
|
-
let targetField = undefined;
|
|
1569
|
-
if (Array.isArray(detailList)) {
|
|
1570
|
-
targetField = detailList.find(item => item.apiname === apiname);
|
|
1571
|
-
}
|
|
1572
|
-
return targetField
|
|
1573
|
-
} else {
|
|
1574
|
-
detail.detail = detailList;
|
|
1575
|
-
return detail
|
|
1576
|
-
}
|
|
1577
|
-
} else {
|
|
1578
|
-
return ''
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
/**
|
|
1584
|
-
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1585
|
-
* @param {object} detail 对象详细数据
|
|
1586
|
-
*/
|
|
1587
|
-
function setObjectDetail(detail = '') {
|
|
1588
|
-
if (detail && detail.id) {
|
|
1589
|
-
// 减少detail.detail层级
|
|
1590
|
-
if (Array.isArray(detail.detail) && detail.detail.length > 0) {
|
|
1591
|
-
let data = [];
|
|
1592
|
-
detail.detail.forEach(item => {
|
|
1593
|
-
if (item && Array.isArray(item.data)) {
|
|
1594
|
-
item.data.forEach(itemData => {
|
|
1595
|
-
if (itemData.left && !Array.isArray(itemData.left)) {
|
|
1596
|
-
data.push(itemData.left);
|
|
1597
|
-
}
|
|
1598
|
-
if (itemData.right && !Array.isArray(itemData.right)) {
|
|
1599
|
-
data.push(itemData.right);
|
|
1600
|
-
}
|
|
1601
|
-
});
|
|
1602
|
-
}
|
|
1603
|
-
});
|
|
1604
|
-
if (data.length > 0) {
|
|
1605
|
-
detail.detail = data;
|
|
1606
|
-
// 根据详情页id,记录详情页信息
|
|
1607
|
-
sessionStorage.setItem(detail.id, JSON.stringify(data));
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
/**
|
|
1614
|
-
* 设置当前标准对象列表选中的信息
|
|
1615
|
-
* @param {object} detail 选中数据
|
|
1616
|
-
*/
|
|
1617
|
-
function setObjectList(detail = {}) {
|
|
1618
|
-
if (detail
|
|
1619
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
/**
|
|
1623
|
-
* 获得当前标准对象列表选中的信息
|
|
1624
|
-
*/
|
|
1625
|
-
function getObjectList() {
|
|
1626
|
-
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
|
|
1627
|
-
if (detail) {
|
|
1628
|
-
return JSON.parse(detail)
|
|
1629
|
-
}
|
|
1630
|
-
return { ids: [] }
|
|
1631
|
-
}
|
|
1632
|
-
/**
|
|
1633
|
-
* 设置当前标准对象的详情页id
|
|
1634
|
-
* @param {object} id 对象详情页id
|
|
1635
|
-
*/
|
|
1636
|
-
function setObjectDetailId(id = '') {
|
|
1637
|
-
if (id) {
|
|
1638
|
-
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
/**
|
|
1642
|
-
* 获取最后访问标准对象的详情页id
|
|
1643
|
-
*/
|
|
1644
|
-
function getObjectDetailId() {
|
|
1645
|
-
return localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
|
|
1540
|
+
// 对象详情存储标识
|
|
1541
|
+
const OBJECT_DETAIL = 'cc_object_detail';
|
|
1542
|
+
// 对象详情id存储标识
|
|
1543
|
+
const OBJECT_DETAIL_ID = 'cc_object_detail_id';
|
|
1544
|
+
// 对象存储标识
|
|
1545
|
+
const OBJECT = 'cc_object';
|
|
1546
|
+
// 列表视图存储标识
|
|
1547
|
+
const OBJECT_LIST = 'cc_object_list';
|
|
1548
|
+
|
|
1549
|
+
/**
|
|
1550
|
+
* 获得当前标准对象信息
|
|
1551
|
+
*/
|
|
1552
|
+
function getObject() {
|
|
1553
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
|
|
1554
|
+
if (detail) {
|
|
1555
|
+
return JSON.parse(detail)
|
|
1556
|
+
}
|
|
1557
|
+
return ''
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* 设置当前标准对象信息
|
|
1562
|
+
* @param {object} detail 对象数据
|
|
1563
|
+
*/
|
|
1564
|
+
function setObject(detail = '') {
|
|
1565
|
+
if (detail) {
|
|
1566
|
+
localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* 获得当前标准对象的详细信息
|
|
1572
|
+
* @param {String} apiname: 查找字段的apiname
|
|
1573
|
+
* @param {String} detailId: 详情页数据id
|
|
1574
|
+
*/
|
|
1575
|
+
function getObjectDetail(apiname, detailId) {
|
|
1576
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL));
|
|
1577
|
+
if (detail) {
|
|
1578
|
+
// 转为对象
|
|
1579
|
+
detail = JSON.parse(detail);
|
|
1580
|
+
// 没有指定详情页id,获取最后一次的id
|
|
1581
|
+
if (!detailId) {
|
|
1582
|
+
detailId = detail.id;
|
|
1583
|
+
} else {
|
|
1584
|
+
detail.id = detailId;
|
|
1585
|
+
}
|
|
1586
|
+
// 通过详情页id获取对应的详情页数据
|
|
1587
|
+
let detailList = JSON.parse(sessionStorage.getItem(detailId));
|
|
1588
|
+
if (apiname) {
|
|
1589
|
+
let targetField = undefined;
|
|
1590
|
+
if (Array.isArray(detailList)) {
|
|
1591
|
+
targetField = detailList.find(item => item.apiname === apiname);
|
|
1592
|
+
}
|
|
1593
|
+
return targetField
|
|
1594
|
+
} else {
|
|
1595
|
+
detail.detail = detailList;
|
|
1596
|
+
return detail
|
|
1597
|
+
}
|
|
1598
|
+
} else {
|
|
1599
|
+
return ''
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1606
|
+
* @param {object} detail 对象详细数据
|
|
1607
|
+
*/
|
|
1608
|
+
function setObjectDetail(detail = '') {
|
|
1609
|
+
if (detail && detail.id) {
|
|
1610
|
+
// 减少detail.detail层级
|
|
1611
|
+
if (Array.isArray(detail.detail) && detail.detail.length > 0) {
|
|
1612
|
+
let data = [];
|
|
1613
|
+
detail.detail.forEach(item => {
|
|
1614
|
+
if (item && Array.isArray(item.data)) {
|
|
1615
|
+
item.data.forEach(itemData => {
|
|
1616
|
+
if (itemData.left && !Array.isArray(itemData.left)) {
|
|
1617
|
+
data.push(itemData.left);
|
|
1618
|
+
}
|
|
1619
|
+
if (itemData.right && !Array.isArray(itemData.right)) {
|
|
1620
|
+
data.push(itemData.right);
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
});
|
|
1625
|
+
if (data.length > 0) {
|
|
1626
|
+
detail.detail = data;
|
|
1627
|
+
// 根据详情页id,记录详情页信息
|
|
1628
|
+
sessionStorage.setItem(detail.id, JSON.stringify(data));
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL), JSON.stringify(detail));
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* 设置当前标准对象列表选中的信息
|
|
1636
|
+
* @param {object} detail 选中数据
|
|
1637
|
+
*/
|
|
1638
|
+
function setObjectList(detail = {}) {
|
|
1639
|
+
if (detail) {
|
|
1640
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* 获得当前标准对象列表选中的信息
|
|
1645
|
+
*/
|
|
1646
|
+
function getObjectList() {
|
|
1647
|
+
let detail = localStorage.getItem(Crypto.encrypt(OBJECT_LIST));
|
|
1648
|
+
if (detail) {
|
|
1649
|
+
return JSON.parse(detail)
|
|
1650
|
+
}
|
|
1651
|
+
return { ids: [] }
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* 设置当前标准对象的详情页id
|
|
1655
|
+
* @param {object} id 对象详情页id
|
|
1656
|
+
*/
|
|
1657
|
+
function setObjectDetailId(id = '') {
|
|
1658
|
+
if (id) {
|
|
1659
|
+
localStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* 获取最后访问标准对象的详情页id
|
|
1664
|
+
*/
|
|
1665
|
+
function getObjectDetailId() {
|
|
1666
|
+
return localStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
|
|
1646
1667
|
}
|
|
1647
1668
|
|
|
1648
1669
|
var CCObject = /*#__PURE__*/Object.freeze({
|
|
@@ -1657,64 +1678,64 @@ var CCObject = /*#__PURE__*/Object.freeze({
|
|
|
1657
1678
|
getObjectDetailId: getObjectDetailId
|
|
1658
1679
|
});
|
|
1659
1680
|
|
|
1660
|
-
/**
|
|
1661
|
-
* 详情页的一些操作
|
|
1662
|
-
*/
|
|
1663
|
-
// 表名
|
|
1664
|
-
const TABLE_NAME$1 = "ccdetail";
|
|
1665
|
-
/**
|
|
1666
|
-
* 获得详情页数据
|
|
1667
|
-
* @param {String} apiname: 查找字段的apiname
|
|
1668
|
-
* @param {String} detailId: 详情页数据id
|
|
1669
|
-
*/
|
|
1670
|
-
function getDetail(apiname, detailId) {
|
|
1671
|
-
return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1676
|
-
* @param {object} detail 对象详细数据
|
|
1677
|
-
*/
|
|
1678
|
-
function setDetail(detail = '') {
|
|
1679
|
-
window.$CCDK.CCObject.setObjectDetail(detail);
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* 设置当前标准对象的详情页id
|
|
1683
|
-
* @param {object} id 对象详情页id
|
|
1684
|
-
*/
|
|
1685
|
-
function setDetailId(id = '') {
|
|
1686
|
-
window.$CCDK.CCObject.setObjectDetailId(id);
|
|
1687
|
-
}
|
|
1688
|
-
/**
|
|
1689
|
-
* 获取最后访问标准对象的详情页id
|
|
1690
|
-
*/
|
|
1691
|
-
function getDetailId() {
|
|
1692
|
-
return window.$CCDK.CCObject.getObjectDetailId()
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
/**
|
|
1696
|
-
* 刷新相关列表
|
|
1697
|
-
* @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
|
|
1698
|
-
*/
|
|
1699
|
-
function refreshRelatedList(ids) {
|
|
1700
|
-
window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
/**
|
|
1704
|
-
* 存储数据
|
|
1705
|
-
* @param {object} object 数据对象
|
|
1706
|
-
* @returns
|
|
1707
|
-
*/
|
|
1708
|
-
async function setRelatedFieldWidth(object) {
|
|
1709
|
-
return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* 获取数据
|
|
1713
|
-
* @param {object} object 过滤条件
|
|
1714
|
-
* @returns
|
|
1715
|
-
*/
|
|
1716
|
-
async function getRelatedFieldWidth(object) {
|
|
1717
|
-
return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
|
|
1681
|
+
/**
|
|
1682
|
+
* 详情页的一些操作
|
|
1683
|
+
*/
|
|
1684
|
+
// 表名
|
|
1685
|
+
const TABLE_NAME$1 = "ccdetail";
|
|
1686
|
+
/**
|
|
1687
|
+
* 获得详情页数据
|
|
1688
|
+
* @param {String} apiname: 查找字段的apiname
|
|
1689
|
+
* @param {String} detailId: 详情页数据id
|
|
1690
|
+
*/
|
|
1691
|
+
function getDetail(apiname, detailId) {
|
|
1692
|
+
return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* 设置当前标准对象的详细信息,默认两个小时有效期
|
|
1697
|
+
* @param {object} detail 对象详细数据
|
|
1698
|
+
*/
|
|
1699
|
+
function setDetail(detail = '') {
|
|
1700
|
+
window.$CCDK.CCObject.setObjectDetail(detail);
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* 设置当前标准对象的详情页id
|
|
1704
|
+
* @param {object} id 对象详情页id
|
|
1705
|
+
*/
|
|
1706
|
+
function setDetailId(id = '') {
|
|
1707
|
+
window.$CCDK.CCObject.setObjectDetailId(id);
|
|
1708
|
+
}
|
|
1709
|
+
/**
|
|
1710
|
+
* 获取最后访问标准对象的详情页id
|
|
1711
|
+
*/
|
|
1712
|
+
function getDetailId() {
|
|
1713
|
+
return window.$CCDK.CCObject.getObjectDetailId()
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* 刷新相关列表
|
|
1718
|
+
* @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
|
|
1719
|
+
*/
|
|
1720
|
+
function refreshRelatedList(ids) {
|
|
1721
|
+
window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* 存储数据
|
|
1726
|
+
* @param {object} object 数据对象
|
|
1727
|
+
* @returns
|
|
1728
|
+
*/
|
|
1729
|
+
async function setRelatedFieldWidth(object) {
|
|
1730
|
+
return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* 获取数据
|
|
1734
|
+
* @param {object} object 过滤条件
|
|
1735
|
+
* @returns
|
|
1736
|
+
*/
|
|
1737
|
+
async function getRelatedFieldWidth(object) {
|
|
1738
|
+
return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
|
|
1718
1739
|
}
|
|
1719
1740
|
|
|
1720
1741
|
var CCDetail = /*#__PURE__*/Object.freeze({
|
|
@@ -1728,64 +1749,86 @@ var CCDetail = /*#__PURE__*/Object.freeze({
|
|
|
1728
1749
|
getRelatedFieldWidth: getRelatedFieldWidth
|
|
1729
1750
|
});
|
|
1730
1751
|
|
|
1731
|
-
// 表名
|
|
1732
|
-
const TABLE_NAME = "cclist";
|
|
1733
|
-
/**
|
|
1734
|
-
* 对象视图页一些操作
|
|
1735
|
-
*/
|
|
1736
|
-
/**
|
|
1737
|
-
*
|
|
1738
|
-
* @param {object} detail 选中数据
|
|
1739
|
-
*/
|
|
1740
|
-
function setSelected(detail = {}) {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
/**
|
|
1751
|
-
*
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
*/
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
*
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1752
|
+
// 表名
|
|
1753
|
+
const TABLE_NAME = "cclist";
|
|
1754
|
+
/**
|
|
1755
|
+
* 对象视图页一些操作
|
|
1756
|
+
*/
|
|
1757
|
+
/**
|
|
1758
|
+
* 设置当前标准对象列表选中的信息,仅更新ids
|
|
1759
|
+
* @param {object} detail 选中数据
|
|
1760
|
+
*/
|
|
1761
|
+
function setSelected(detail = {}) {
|
|
1762
|
+
const ids = detail?.ids;
|
|
1763
|
+
if(ids){
|
|
1764
|
+
let info = window.$CCDK.CCObject.getObjectList() || {};
|
|
1765
|
+
info.ids = ids;
|
|
1766
|
+
window.$CCDK.CCObject.setObjectList(info);
|
|
1767
|
+
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
}
|
|
1771
|
+
/**
|
|
1772
|
+
* 获得当前标准对象列表选中的信息
|
|
1773
|
+
*/
|
|
1774
|
+
function getSelected() {
|
|
1775
|
+
let {ids} = window.$CCDK.CCObject.getObjectList();
|
|
1776
|
+
return { ids: ids }
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* 获得当前视图列表页选中的视图id
|
|
1780
|
+
*/
|
|
1781
|
+
function getViewId() {
|
|
1782
|
+
let {viewId} = window.$CCDK.CCObject.getObjectList();
|
|
1783
|
+
return viewId || ''
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* 设置过滤条件
|
|
1788
|
+
* @param {object} object 过滤条件
|
|
1789
|
+
* {
|
|
1790
|
+
objprefix: "003",
|
|
1791
|
+
viewid: "aec20238DB5F47AciNyO",
|
|
1792
|
+
filtercondition: '{"data":[{"fieldId":"ffe100000001260MztUa","type":"S","val":"11222","objid":"account","op":"c"},{"fieldId":"ffe2017082200ad001fa","type":"AD","val":"中国","objid":"account","op":"c"}]}',
|
|
1793
|
+
filterdetail:
|
|
1794
|
+
}
|
|
1795
|
+
*/
|
|
1796
|
+
async function setFilter(object) {
|
|
1797
|
+
await window.$CCDK.CCDB.create(TABLE_NAME, [object]);
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* 获取过滤条件
|
|
1801
|
+
* @param {object} object 过滤条件
|
|
1802
|
+
* {
|
|
1803
|
+
objprefix: "003",
|
|
1804
|
+
viewid: "aec20238DB5F47AciNyO",
|
|
1805
|
+
}
|
|
1806
|
+
*/
|
|
1807
|
+
async function getFilter(object) {
|
|
1808
|
+
return await window.$CCDK.CCDB.list(TABLE_NAME, object);
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* 删除某对象下某视图列表的筛选条件
|
|
1812
|
+
* */
|
|
1813
|
+
async function deleteFilter(id) {
|
|
1814
|
+
return await window.$CCDK.CCDB.deleteCC(TABLE_NAME, id)
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
/**
|
|
1818
|
+
* 清空所有数据
|
|
1819
|
+
*/
|
|
1820
|
+
async function clearFilterAll() {
|
|
1821
|
+
await window.$CCDK.CCDB.db[TABLE_NAME].toCollection().modify(item => {
|
|
1822
|
+
item.filtercondition = "";
|
|
1823
|
+
item.filterdetail = "";
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* 获取当前对象视图页数据
|
|
1828
|
+
* @return {object} 当前视图对象信息
|
|
1829
|
+
*/
|
|
1830
|
+
function getViewInfo(){
|
|
1831
|
+
return window.$CCDK.CCObject.getObjectList() || {}
|
|
1789
1832
|
}
|
|
1790
1833
|
|
|
1791
1834
|
var CCList = /*#__PURE__*/Object.freeze({
|
|
@@ -1795,180 +1838,182 @@ var CCList = /*#__PURE__*/Object.freeze({
|
|
|
1795
1838
|
setFilter: setFilter,
|
|
1796
1839
|
getFilter: getFilter,
|
|
1797
1840
|
deleteFilter: deleteFilter,
|
|
1798
|
-
clearFilterAll: clearFilterAll
|
|
1841
|
+
clearFilterAll: clearFilterAll,
|
|
1842
|
+
getViewId: getViewId,
|
|
1843
|
+
getViewInfo: getViewInfo
|
|
1799
1844
|
});
|
|
1800
1845
|
|
|
1801
|
-
/**
|
|
1802
|
-
* 用于保存打开的页面集合
|
|
1803
|
-
*/
|
|
1804
|
-
let pageList = new Map();
|
|
1805
|
-
/**
|
|
1806
|
-
* 打开对象视图页面
|
|
1807
|
-
* @param {object} obj 对象信息
|
|
1808
|
-
* @param {object} options 配置信息
|
|
1809
|
-
*/
|
|
1810
|
-
function openListPage(obj, options = {}) {
|
|
1811
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1812
|
-
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
1813
|
-
return pageId;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
/**
|
|
1817
|
-
* 打开数据详情页
|
|
1818
|
-
* @param {object} obj 对象体
|
|
1819
|
-
* @param {string} id 数据id
|
|
1820
|
-
* @param {object} options 配置信息
|
|
1821
|
-
*/
|
|
1822
|
-
function openDetailPage(obj, id, options = {}) {
|
|
1823
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1824
|
-
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
1825
|
-
return pageId;
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
/**
|
|
1829
|
-
* 打开创建页面
|
|
1830
|
-
* @param {object} obj 对象体
|
|
1831
|
-
* @param {object} options 配置信息
|
|
1832
|
-
*/
|
|
1833
|
-
function openCreatePage(obj, options = {}) {
|
|
1834
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1835
|
-
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
1836
|
-
return pageId;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
/**
|
|
1840
|
-
* 打开修改页面
|
|
1841
|
-
* @param {object} obj 对象体
|
|
1842
|
-
* @param {string} id 数据id
|
|
1843
|
-
* @param {object} options 配置信息
|
|
1844
|
-
*/
|
|
1845
|
-
function openEditPage(obj, id, options = {}) {
|
|
1846
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1847
|
-
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
1848
|
-
return pageId;
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* 打开自定义页面
|
|
1852
|
-
* @param {object} obj 自定义页面参数
|
|
1853
|
-
* @param {object} options 配置信息
|
|
1854
|
-
*/
|
|
1855
|
-
function openCustomPage(obj, options = {}) {
|
|
1856
|
-
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1857
|
-
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
1858
|
-
return pageId;
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
/**
|
|
1862
|
-
* 通过页面id,重新打开某个页面
|
|
1863
|
-
* @param {string} pageId 页面id
|
|
1864
|
-
* @param {object} options 配置信息
|
|
1865
|
-
*/
|
|
1866
|
-
function reOpenPage(pageId, options) {
|
|
1867
|
-
let page;
|
|
1868
|
-
if (pageId) {
|
|
1869
|
-
page = pageList.get(pageId);
|
|
1870
|
-
}
|
|
1871
|
-
if (page) {
|
|
1872
|
-
page.reOpenPage();
|
|
1873
|
-
if (options.refresh) {
|
|
1874
|
-
page.refresh();
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
/**
|
|
1880
|
-
* 将打开的页面添加到集合中
|
|
1881
|
-
* @param {string} id 唯一ID
|
|
1882
|
-
* @param {object} page 页面对象
|
|
1883
|
-
*/
|
|
1884
|
-
function addPage(id, page) {
|
|
1885
|
-
if (id && page) {
|
|
1886
|
-
pageList.set(id, page);
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1890
|
-
/**
|
|
1891
|
-
* 删除某个页面
|
|
1892
|
-
* @param {string} pageId 唯一ID
|
|
1893
|
-
*/
|
|
1894
|
-
function deletePage(pageId) {
|
|
1895
|
-
if (pageId) {
|
|
1896
|
-
pageList.delete(pageId);
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
* 更改页面数据
|
|
1901
|
-
* @param {string} id 唯一ID
|
|
1902
|
-
* @param {object} page 页面对象
|
|
1903
|
-
*/
|
|
1904
|
-
function updatePage(id, page) {
|
|
1905
|
-
if (id && page) {
|
|
1906
|
-
pageList.set(id, page);
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
/**
|
|
1911
|
-
* 通过页面id查询页面
|
|
1912
|
-
* @param {string} pageId 唯一ID
|
|
1913
|
-
*/
|
|
1914
|
-
function searchPage(pageId) {
|
|
1915
|
-
return pageList.get(pageId)
|
|
1916
|
-
}
|
|
1917
|
-
/**
|
|
1918
|
-
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
1919
|
-
* 如果pageId为all,关闭所有一级菜单
|
|
1920
|
-
* @param {string} pageId 页面id
|
|
1921
|
-
*/
|
|
1922
|
-
function close$1(pageId = '') {
|
|
1923
|
-
let page;
|
|
1924
|
-
if(pageId === 'all'){
|
|
1925
|
-
page = [...pageList.values()];
|
|
1926
|
-
page.forEach(item => {
|
|
1927
|
-
if(item){
|
|
1928
|
-
item.close();
|
|
1929
|
-
}
|
|
1930
|
-
});
|
|
1931
|
-
}else if (pageId) {
|
|
1932
|
-
page = pageList.get(pageId);
|
|
1933
|
-
} else {
|
|
1934
|
-
// 不传pageId 默认关闭当前选中的
|
|
1935
|
-
// 当前选中菜单的树形结构
|
|
1936
|
-
let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
|
|
1937
|
-
if (currentMenuTree) {
|
|
1938
|
-
// 说明当前选中的是二级菜单
|
|
1939
|
-
if (currentMenuTree.level2Id) {
|
|
1940
|
-
page = pageList.get(currentMenuTree.level2Id);
|
|
1941
|
-
} else {
|
|
1942
|
-
// 说明当前选中的是一级菜单
|
|
1943
|
-
page = pageList.get(currentMenuTree.id);
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
// if (pageList.size > 0) {
|
|
1947
|
-
// page = [...pageList.values()][pageList.size - 1]
|
|
1948
|
-
// }
|
|
1949
|
-
}
|
|
1950
|
-
if (page) {
|
|
1951
|
-
page.close();
|
|
1952
|
-
}
|
|
1953
|
-
}
|
|
1954
|
-
/**
|
|
1955
|
-
* 刷新当前页面
|
|
1956
|
-
*/
|
|
1957
|
-
function refresh() {
|
|
1958
|
-
window.$CCDK.CCBus.$emit('refresh');
|
|
1959
|
-
}
|
|
1960
|
-
/**
|
|
1961
|
-
* 获取当前一二级选中菜单的树形结构
|
|
1962
|
-
* @param {object} obj 自定义页面参数
|
|
1963
|
-
* @param {object} options 配置信息
|
|
1964
|
-
*/
|
|
1965
|
-
function getCurrentPage() {
|
|
1966
|
-
// 当前选中菜单的树形结构
|
|
1967
|
-
let currentMenuTree = localStorage.getItem('current_page');
|
|
1968
|
-
if (currentMenuTree) {
|
|
1969
|
-
return JSON.parse(currentMenuTree)
|
|
1970
|
-
}
|
|
1971
|
-
return ''
|
|
1846
|
+
/**
|
|
1847
|
+
* 用于保存打开的页面集合
|
|
1848
|
+
*/
|
|
1849
|
+
let pageList = new Map();
|
|
1850
|
+
/**
|
|
1851
|
+
* 打开对象视图页面
|
|
1852
|
+
* @param {object} obj 对象信息
|
|
1853
|
+
* @param {object} options 配置信息
|
|
1854
|
+
*/
|
|
1855
|
+
function openListPage(obj, options = {}) {
|
|
1856
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1857
|
+
window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
|
|
1858
|
+
return pageId;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* 打开数据详情页
|
|
1863
|
+
* @param {object} obj 对象体
|
|
1864
|
+
* @param {string} id 数据id
|
|
1865
|
+
* @param {object} options 配置信息
|
|
1866
|
+
*/
|
|
1867
|
+
function openDetailPage(obj, id, options = {}) {
|
|
1868
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1869
|
+
window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
|
|
1870
|
+
return pageId;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* 打开创建页面
|
|
1875
|
+
* @param {object} obj 对象体
|
|
1876
|
+
* @param {object} options 配置信息
|
|
1877
|
+
*/
|
|
1878
|
+
function openCreatePage(obj, options = {}) {
|
|
1879
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1880
|
+
window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
|
|
1881
|
+
return pageId;
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* 打开修改页面
|
|
1886
|
+
* @param {object} obj 对象体
|
|
1887
|
+
* @param {string} id 数据id
|
|
1888
|
+
* @param {object} options 配置信息
|
|
1889
|
+
*/
|
|
1890
|
+
function openEditPage(obj, id, options = {}) {
|
|
1891
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1892
|
+
window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
|
|
1893
|
+
return pageId;
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* 打开自定义页面
|
|
1897
|
+
* @param {object} obj 自定义页面参数
|
|
1898
|
+
* @param {object} options 配置信息
|
|
1899
|
+
*/
|
|
1900
|
+
function openCustomPage(obj, options = {}) {
|
|
1901
|
+
let pageId = options.pageId||Math.random().toString(16).slice(2);
|
|
1902
|
+
window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
|
|
1903
|
+
return pageId;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
/**
|
|
1907
|
+
* 通过页面id,重新打开某个页面
|
|
1908
|
+
* @param {string} pageId 页面id
|
|
1909
|
+
* @param {object} options 配置信息
|
|
1910
|
+
*/
|
|
1911
|
+
function reOpenPage(pageId, options) {
|
|
1912
|
+
let page;
|
|
1913
|
+
if (pageId) {
|
|
1914
|
+
page = pageList.get(pageId);
|
|
1915
|
+
}
|
|
1916
|
+
if (page) {
|
|
1917
|
+
page.reOpenPage();
|
|
1918
|
+
if (options.refresh) {
|
|
1919
|
+
page.refresh();
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* 将打开的页面添加到集合中
|
|
1926
|
+
* @param {string} id 唯一ID
|
|
1927
|
+
* @param {object} page 页面对象
|
|
1928
|
+
*/
|
|
1929
|
+
function addPage(id, page) {
|
|
1930
|
+
if (id && page) {
|
|
1931
|
+
pageList.set(id, page);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* 删除某个页面
|
|
1937
|
+
* @param {string} pageId 唯一ID
|
|
1938
|
+
*/
|
|
1939
|
+
function deletePage(pageId) {
|
|
1940
|
+
if (pageId) {
|
|
1941
|
+
pageList.delete(pageId);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* 更改页面数据
|
|
1946
|
+
* @param {string} id 唯一ID
|
|
1947
|
+
* @param {object} page 页面对象
|
|
1948
|
+
*/
|
|
1949
|
+
function updatePage(id, page) {
|
|
1950
|
+
if (id && page) {
|
|
1951
|
+
pageList.set(id, page);
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
/**
|
|
1956
|
+
* 通过页面id查询页面
|
|
1957
|
+
* @param {string} pageId 唯一ID
|
|
1958
|
+
*/
|
|
1959
|
+
function searchPage(pageId) {
|
|
1960
|
+
return pageList.get(pageId)
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* 关闭页面,如果pageId为null,那么关闭当前页面
|
|
1964
|
+
* 如果pageId为all,关闭所有一级菜单
|
|
1965
|
+
* @param {string} pageId 页面id
|
|
1966
|
+
*/
|
|
1967
|
+
function close$1(pageId = '') {
|
|
1968
|
+
let page;
|
|
1969
|
+
if(pageId === 'all'){
|
|
1970
|
+
page = [...pageList.values()];
|
|
1971
|
+
page.forEach(item => {
|
|
1972
|
+
if(item){
|
|
1973
|
+
item.close();
|
|
1974
|
+
}
|
|
1975
|
+
});
|
|
1976
|
+
}else if (pageId) {
|
|
1977
|
+
page = pageList.get(pageId);
|
|
1978
|
+
} else {
|
|
1979
|
+
// 不传pageId 默认关闭当前选中的
|
|
1980
|
+
// 当前选中菜单的树形结构
|
|
1981
|
+
let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
|
|
1982
|
+
if (currentMenuTree) {
|
|
1983
|
+
// 说明当前选中的是二级菜单
|
|
1984
|
+
if (currentMenuTree.level2Id) {
|
|
1985
|
+
page = pageList.get(currentMenuTree.level2Id);
|
|
1986
|
+
} else {
|
|
1987
|
+
// 说明当前选中的是一级菜单
|
|
1988
|
+
page = pageList.get(currentMenuTree.id);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
// if (pageList.size > 0) {
|
|
1992
|
+
// page = [...pageList.values()][pageList.size - 1]
|
|
1993
|
+
// }
|
|
1994
|
+
}
|
|
1995
|
+
if (page) {
|
|
1996
|
+
page.close();
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* 刷新当前页面
|
|
2001
|
+
*/
|
|
2002
|
+
function refresh() {
|
|
2003
|
+
window.$CCDK.CCBus.$emit('refresh');
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* 获取当前一二级选中菜单的树形结构
|
|
2007
|
+
* @param {object} obj 自定义页面参数
|
|
2008
|
+
* @param {object} options 配置信息
|
|
2009
|
+
*/
|
|
2010
|
+
function getCurrentPage() {
|
|
2011
|
+
// 当前选中菜单的树形结构
|
|
2012
|
+
let currentMenuTree = localStorage.getItem('current_page');
|
|
2013
|
+
if (currentMenuTree) {
|
|
2014
|
+
return JSON.parse(currentMenuTree)
|
|
2015
|
+
}
|
|
2016
|
+
return ''
|
|
1972
2017
|
}
|
|
1973
2018
|
|
|
1974
2019
|
var CCPage = /*#__PURE__*/Object.freeze({
|
|
@@ -1988,62 +2033,62 @@ var CCPage = /*#__PURE__*/Object.freeze({
|
|
|
1988
2033
|
getCurrentPage: getCurrentPage
|
|
1989
2034
|
});
|
|
1990
2035
|
|
|
1991
|
-
/**
|
|
1992
|
-
* 设置用户信息
|
|
1993
|
-
* @param {object} sentry
|
|
1994
|
-
* @param {object} ccUser 用户信息
|
|
1995
|
-
*/
|
|
1996
|
-
function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
|
|
1997
|
-
if (ccUser && ccUser != "") {
|
|
1998
|
-
// 添加日志监控标签:组织id
|
|
1999
|
-
sentry.setTag("orgId", ccUser.orgId);
|
|
2000
|
-
// 添加日志监控标签:组织名称
|
|
2001
|
-
sentry.setTag("orgName", ccUser.orgName);
|
|
2002
|
-
// 添加日志监控标签:用户id和用户名称
|
|
2003
|
-
sentry.setUser({
|
|
2004
|
-
username: ccUser.userName,
|
|
2005
|
-
id: ccUser.userId,
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
}
|
|
2009
|
-
/**
|
|
2010
|
-
* 内存上报
|
|
2011
|
-
* @param {object} sentry
|
|
2012
|
-
*/
|
|
2013
|
-
function reportMemory(sentry, ccUser) {
|
|
2014
|
-
if (performance.memory) {
|
|
2015
|
-
let memeryMsg =
|
|
2016
|
-
"内存监控:jsHeapSizeLimit=" +
|
|
2017
|
-
(performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
|
|
2018
|
-
"mb、" +
|
|
2019
|
-
"totalJSHeapSize=" +
|
|
2020
|
-
(performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
2021
|
-
"mb、" +
|
|
2022
|
-
"usedJSHeapSize=" +
|
|
2023
|
-
(performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
2024
|
-
"mb";
|
|
2025
|
-
initUserInfo(sentry, ccUser);
|
|
2026
|
-
sentry.withScope(function (scope) {
|
|
2027
|
-
// 使用内存
|
|
2028
|
-
sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
|
|
2029
|
-
// 添加日志监控标签:组织id
|
|
2030
|
-
scope.setFingerprint(["内存监控"]);
|
|
2031
|
-
sentry.captureMessage(memeryMsg);
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
/**
|
|
2037
|
-
* 网络异常上报
|
|
2038
|
-
* @param {object} sentry
|
|
2039
|
-
* @param {error} error
|
|
2040
|
-
*/
|
|
2041
|
-
function reportHttpException(sentry, error, ccUser) {
|
|
2042
|
-
initUserInfo(sentry, ccUser);
|
|
2043
|
-
sentry.withScope(function (scope) {
|
|
2044
|
-
scope.setFingerprint(["接口未捕获异常response"]);
|
|
2045
|
-
sentry.captureException(error);
|
|
2046
|
-
});
|
|
2036
|
+
/**
|
|
2037
|
+
* 设置用户信息
|
|
2038
|
+
* @param {object} sentry
|
|
2039
|
+
* @param {object} ccUser 用户信息
|
|
2040
|
+
*/
|
|
2041
|
+
function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
|
|
2042
|
+
if (ccUser && ccUser != "") {
|
|
2043
|
+
// 添加日志监控标签:组织id
|
|
2044
|
+
sentry.setTag("orgId", ccUser.orgId);
|
|
2045
|
+
// 添加日志监控标签:组织名称
|
|
2046
|
+
sentry.setTag("orgName", ccUser.orgName);
|
|
2047
|
+
// 添加日志监控标签:用户id和用户名称
|
|
2048
|
+
sentry.setUser({
|
|
2049
|
+
username: ccUser.userName,
|
|
2050
|
+
id: ccUser.userId,
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* 内存上报
|
|
2056
|
+
* @param {object} sentry
|
|
2057
|
+
*/
|
|
2058
|
+
function reportMemory(sentry, ccUser) {
|
|
2059
|
+
if (performance.memory) {
|
|
2060
|
+
let memeryMsg =
|
|
2061
|
+
"内存监控:jsHeapSizeLimit=" +
|
|
2062
|
+
(performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
|
|
2063
|
+
"mb、" +
|
|
2064
|
+
"totalJSHeapSize=" +
|
|
2065
|
+
(performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
2066
|
+
"mb、" +
|
|
2067
|
+
"usedJSHeapSize=" +
|
|
2068
|
+
(performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
|
|
2069
|
+
"mb";
|
|
2070
|
+
initUserInfo(sentry, ccUser);
|
|
2071
|
+
sentry.withScope(function (scope) {
|
|
2072
|
+
// 使用内存
|
|
2073
|
+
sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
|
|
2074
|
+
// 添加日志监控标签:组织id
|
|
2075
|
+
scope.setFingerprint(["内存监控"]);
|
|
2076
|
+
sentry.captureMessage(memeryMsg);
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* 网络异常上报
|
|
2083
|
+
* @param {object} sentry
|
|
2084
|
+
* @param {error} error
|
|
2085
|
+
*/
|
|
2086
|
+
function reportHttpException(sentry, error, ccUser) {
|
|
2087
|
+
initUserInfo(sentry, ccUser);
|
|
2088
|
+
sentry.withScope(function (scope) {
|
|
2089
|
+
scope.setFingerprint(["接口未捕获异常response"]);
|
|
2090
|
+
sentry.captureException(error);
|
|
2091
|
+
});
|
|
2047
2092
|
}
|
|
2048
2093
|
|
|
2049
2094
|
var CCSentry = /*#__PURE__*/Object.freeze({
|
|
@@ -2053,24 +2098,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
|
|
|
2053
2098
|
reportHttpException: reportHttpException
|
|
2054
2099
|
});
|
|
2055
2100
|
|
|
2056
|
-
/**
|
|
2057
|
-
* 初始化侧边区域
|
|
2058
|
-
* @param {object} options 自定义页面配置
|
|
2059
|
-
*/
|
|
2060
|
-
function init(options) {
|
|
2061
|
-
window.$CCDK.CCBus.$emit('initSide', options);
|
|
2062
|
-
}
|
|
2063
|
-
/**
|
|
2064
|
-
* 打开侧边区域
|
|
2065
|
-
*/
|
|
2066
|
-
function open() {
|
|
2067
|
-
window.$CCDK.CCBus.$emit('openSide');
|
|
2068
|
-
}
|
|
2069
|
-
/**
|
|
2070
|
-
* 关闭侧边区域
|
|
2071
|
-
*/
|
|
2072
|
-
function close() {
|
|
2073
|
-
window.$CCDK.CCBus.$emit('closeSide');
|
|
2101
|
+
/**
|
|
2102
|
+
* 初始化侧边区域
|
|
2103
|
+
* @param {object} options 自定义页面配置
|
|
2104
|
+
*/
|
|
2105
|
+
function init(options) {
|
|
2106
|
+
window.$CCDK.CCBus.$emit('initSide', options);
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* 打开侧边区域
|
|
2110
|
+
*/
|
|
2111
|
+
function open() {
|
|
2112
|
+
window.$CCDK.CCBus.$emit('openSide');
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* 关闭侧边区域
|
|
2116
|
+
*/
|
|
2117
|
+
function close() {
|
|
2118
|
+
window.$CCDK.CCBus.$emit('closeSide');
|
|
2074
2119
|
}
|
|
2075
2120
|
|
|
2076
2121
|
var CCSide = /*#__PURE__*/Object.freeze({
|
|
@@ -2080,60 +2125,60 @@ var CCSide = /*#__PURE__*/Object.freeze({
|
|
|
2080
2125
|
close: close
|
|
2081
2126
|
});
|
|
2082
2127
|
|
|
2083
|
-
// cookie存储标识
|
|
2084
|
-
const TOKEN = "cc_token";
|
|
2085
|
-
/**
|
|
2086
|
-
* 获取URL中参数的数据
|
|
2087
|
-
* @param {name} 参数名
|
|
2088
|
-
*/
|
|
2089
|
-
function getUrlQuery(name) {
|
|
2090
|
-
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
2091
|
-
var r = window.location.href.match(reg);
|
|
2092
|
-
let res = null;
|
|
2093
|
-
if (r != null) res = r[1].trim();
|
|
2094
|
-
return res;
|
|
2095
|
-
}
|
|
2096
|
-
/**
|
|
2097
|
-
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
|
|
2098
|
-
* @param {String} urlName 获取token的url名称
|
|
2099
|
-
* @param {String} cookieName 获取token的cookie名称
|
|
2100
|
-
* @returns
|
|
2101
|
-
*/
|
|
2102
|
-
function getToken(urlName = "binding", cookieName = TOKEN) {
|
|
2103
|
-
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
|
|
2104
|
-
if (token) {
|
|
2105
|
-
token = setToken(token, cookieName);
|
|
2106
|
-
}
|
|
2107
|
-
return token
|
|
2108
|
-
}
|
|
2109
|
-
/**
|
|
2110
|
-
* 存储token
|
|
2111
|
-
* @param {String} token token
|
|
2112
|
-
* @param {String} cookieName 获取token的cookie名称
|
|
2113
|
-
* @param {String} domain 域名
|
|
2114
|
-
*/
|
|
2115
|
-
function setToken(token, cookieName = TOKEN, domain = getDomain()) {
|
|
2116
|
-
// let { result } = verifyToken(token);
|
|
2117
|
-
// if (result) {
|
|
2118
|
-
Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
|
|
2119
|
-
Cookies.set("JSESSIONID", token, { expires: 1 / 12 });
|
|
2120
|
-
// localStorage.setItem(Crypto.encrypt(cookieName), token);
|
|
2121
|
-
return token
|
|
2122
|
-
// } else {
|
|
2123
|
-
// return null
|
|
2124
|
-
// }
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
/**
|
|
2128
|
-
* 清除Token数据
|
|
2129
|
-
* @param {String} domain 域名
|
|
2130
|
-
* @param {String} cookieName 获取token的cookie名称
|
|
2131
|
-
*/
|
|
2132
|
-
function clearToken(cookieName = TOKEN, domain = getDomain()) {
|
|
2133
|
-
Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
|
|
2134
|
-
Cookies.remove(Crypto.encrypt(cookieName));
|
|
2135
|
-
Cookies.remove("JSESSIONID");
|
|
2136
|
-
localStorage.removeItem(Crypto.encrypt(cookieName));
|
|
2128
|
+
// cookie存储标识
|
|
2129
|
+
const TOKEN = "cc_token";
|
|
2130
|
+
/**
|
|
2131
|
+
* 获取URL中参数的数据
|
|
2132
|
+
* @param {name} 参数名
|
|
2133
|
+
*/
|
|
2134
|
+
function getUrlQuery(name) {
|
|
2135
|
+
var reg = new RegExp(name + "=([^&]*)(&|$)");
|
|
2136
|
+
var r = window.location.href.match(reg);
|
|
2137
|
+
let res = null;
|
|
2138
|
+
if (r != null) res = r[1].trim();
|
|
2139
|
+
return res;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
|
|
2143
|
+
* @param {String} urlName 获取token的url名称
|
|
2144
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
2145
|
+
* @returns
|
|
2146
|
+
*/
|
|
2147
|
+
function getToken(urlName = "binding", cookieName = TOKEN) {
|
|
2148
|
+
let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
|
|
2149
|
+
if (token) {
|
|
2150
|
+
token = setToken(token, cookieName);
|
|
2151
|
+
}
|
|
2152
|
+
return token
|
|
2153
|
+
}
|
|
2154
|
+
/**
|
|
2155
|
+
* 存储token
|
|
2156
|
+
* @param {String} token token
|
|
2157
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
2158
|
+
* @param {String} domain 域名
|
|
2159
|
+
*/
|
|
2160
|
+
function setToken(token, cookieName = TOKEN, domain = getDomain()) {
|
|
2161
|
+
// let { result } = verifyToken(token);
|
|
2162
|
+
// if (result) {
|
|
2163
|
+
Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
|
|
2164
|
+
Cookies.set("JSESSIONID", token, { expires: 1 / 12 });
|
|
2165
|
+
// localStorage.setItem(Crypto.encrypt(cookieName), token);
|
|
2166
|
+
return token
|
|
2167
|
+
// } else {
|
|
2168
|
+
// return null
|
|
2169
|
+
// }
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* 清除Token数据
|
|
2174
|
+
* @param {String} domain 域名
|
|
2175
|
+
* @param {String} cookieName 获取token的cookie名称
|
|
2176
|
+
*/
|
|
2177
|
+
function clearToken(cookieName = TOKEN, domain = getDomain()) {
|
|
2178
|
+
Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
|
|
2179
|
+
Cookies.remove(Crypto.encrypt(cookieName));
|
|
2180
|
+
Cookies.remove("JSESSIONID");
|
|
2181
|
+
localStorage.removeItem(Crypto.encrypt(cookieName));
|
|
2137
2182
|
}
|
|
2138
2183
|
|
|
2139
2184
|
var CCToken = /*#__PURE__*/Object.freeze({
|
|
@@ -2144,55 +2189,55 @@ var CCToken = /*#__PURE__*/Object.freeze({
|
|
|
2144
2189
|
getUrlQuery: getUrlQuery
|
|
2145
2190
|
});
|
|
2146
2191
|
|
|
2147
|
-
// 用户cookie存储标识
|
|
2148
|
-
const USER_INFO = "cc_user_info";
|
|
2149
|
-
// JWT的cookie存储标识
|
|
2150
|
-
const USER_JWT_INFO = "cc_user_jwt_info";
|
|
2151
|
-
|
|
2152
|
-
/**
|
|
2153
|
-
* 存储用户信息
|
|
2154
|
-
* @param {String} userInfo 用户信息
|
|
2155
|
-
* @param {String} domain 域名
|
|
2156
|
-
*/
|
|
2157
|
-
function setUserInfo(userInfo, domain = getDomain()) {
|
|
2158
|
-
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
/**
|
|
2162
|
-
* 获取用户信息
|
|
2163
|
-
* @returns {String} 用户信息
|
|
2164
|
-
*/
|
|
2165
|
-
function getUserInfo() {
|
|
2166
|
-
// 加密的用户信息
|
|
2167
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
2168
|
-
if (encryptUserInfo) {
|
|
2169
|
-
return Crypto.decrypt(encryptUserInfo)
|
|
2170
|
-
} else {
|
|
2171
|
-
return ""
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
/**
|
|
2176
|
-
* 存储用户jwt信息
|
|
2177
|
-
* @param {String} jwtInfo 用户信息
|
|
2178
|
-
* @param {String} domain 域名
|
|
2179
|
-
*/
|
|
2180
|
-
function setUserJwtInfo(jwtInfo, domain = getDomain()) {
|
|
2181
|
-
Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 });
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
/**
|
|
2185
|
-
* 获取用户jwt信息
|
|
2186
|
-
* @returns {Object} 用户信息
|
|
2187
|
-
*/
|
|
2188
|
-
function getUserJwtInfo() {
|
|
2189
|
-
// 加密的用户信息
|
|
2190
|
-
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
|
|
2191
|
-
if (encryptUserInfo) {
|
|
2192
|
-
return JSON.parse(Crypto.decrypt(encryptUserInfo))
|
|
2193
|
-
} else {
|
|
2194
|
-
return {}
|
|
2195
|
-
}
|
|
2192
|
+
// 用户cookie存储标识
|
|
2193
|
+
const USER_INFO = "cc_user_info";
|
|
2194
|
+
// JWT的cookie存储标识
|
|
2195
|
+
const USER_JWT_INFO = "cc_user_jwt_info";
|
|
2196
|
+
|
|
2197
|
+
/**
|
|
2198
|
+
* 存储用户信息
|
|
2199
|
+
* @param {String} userInfo 用户信息
|
|
2200
|
+
* @param {String} domain 域名
|
|
2201
|
+
*/
|
|
2202
|
+
function setUserInfo(userInfo, domain = getDomain()) {
|
|
2203
|
+
Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
/**
|
|
2207
|
+
* 获取用户信息
|
|
2208
|
+
* @returns {String} 用户信息
|
|
2209
|
+
*/
|
|
2210
|
+
function getUserInfo() {
|
|
2211
|
+
// 加密的用户信息
|
|
2212
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
|
|
2213
|
+
if (encryptUserInfo) {
|
|
2214
|
+
return Crypto.decrypt(encryptUserInfo)
|
|
2215
|
+
} else {
|
|
2216
|
+
return ""
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
/**
|
|
2221
|
+
* 存储用户jwt信息
|
|
2222
|
+
* @param {String} jwtInfo 用户信息
|
|
2223
|
+
* @param {String} domain 域名
|
|
2224
|
+
*/
|
|
2225
|
+
function setUserJwtInfo(jwtInfo, domain = getDomain()) {
|
|
2226
|
+
Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 });
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
/**
|
|
2230
|
+
* 获取用户jwt信息
|
|
2231
|
+
* @returns {Object} 用户信息
|
|
2232
|
+
*/
|
|
2233
|
+
function getUserJwtInfo() {
|
|
2234
|
+
// 加密的用户信息
|
|
2235
|
+
let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
|
|
2236
|
+
if (encryptUserInfo) {
|
|
2237
|
+
return JSON.parse(Crypto.decrypt(encryptUserInfo))
|
|
2238
|
+
} else {
|
|
2239
|
+
return {}
|
|
2240
|
+
}
|
|
2196
2241
|
}
|
|
2197
2242
|
|
|
2198
2243
|
var CCUser = /*#__PURE__*/Object.freeze({
|
|
@@ -2203,8 +2248,8 @@ var CCUser = /*#__PURE__*/Object.freeze({
|
|
|
2203
2248
|
getUserJwtInfo: getUserJwtInfo
|
|
2204
2249
|
});
|
|
2205
2250
|
|
|
2206
|
-
let CCDK = { CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
|
|
2207
|
-
Vue.prototype.$CCDK = CCDK;
|
|
2251
|
+
let CCDK = { CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
|
|
2252
|
+
Vue.prototype.$CCDK = CCDK;
|
|
2208
2253
|
window.$CCDK = CCDK;
|
|
2209
2254
|
|
|
2210
2255
|
export { CCDK as default };
|